lkml.org 
[lkml]   [2008]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
On Fri, Sep 26, 2008 at 12:39 AM, Ingo Molnar <mingo@elte.hu> wrote:
>
> * Suresh Siddha <suresh.b.siddha@intel.com> wrote:
>
>> [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
>>
>> Go through the iomem resource tree to check if any of the ioremap() requests
>> span more than any slot in the iomem resource tree and do a WARN_ON() if we hit
>> this check.
>>
>> This will raise a red-flag, if some driver is mapping more than what
>> is needed. And hopefully identify possible corruptions much earlier.
>>
>> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
>
> applied to tip/core/resources, thanks Suresh.
>
> one question:
>
>> + for (p = p->child; p ; p = r_next(NULL, p, &l)) {
>> + /*
>> + * We can probably skip the resources with out
>> + * IORESOURCE_IO attribute?
>> + */
>> + if (p->start >= addr + size)
>> + continue;
>> + if (p->end < addr)
>> + continue;
>> + if (p->start <= addr && (p->end >= addr + size - 1))
>> + continue;
>> + printk(KERN_WARNING "resource map sanity check conflict "
>> + " 0x%llx 0x%llx 0x%llx 0x%llx %s\n",
>> + addr, addr + size - 1, p->start, p->end, p->name);


need cast with (unsigned long long)...


>> + err = -1;
>> + break;
>
> i think all the checks you added are precise to the byte and you allow
> all the sensible ioremaps: which nest fully inside a single resource -
> and you reject all the other partial overlap or multiple overlap
> scenarios.
>
> One potential thing to check for would be whether addr+size overlaps a
> 4GB boundary? That would almost always be a bug, and it could also cause
> problems with the checks above if resource_t is 32 bits. The ioremap
> code should already prevent it though.

in that case, BAR should be disabled already.

YH


\
 
 \ /
  Last update: 2008-09-26 10:13    [W:0.072 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site