lkml.org 
[lkml]   [2008]   [Sep]   [26]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateFri, 26 Sep 2008 09:39:02 +0200
FromIngo Molnar <>
SubjectRe: [patch] ioremap sanity check to catch mapping requests exceeding the BAR sizes
* 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);
> +		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.

	Ingo


\
 
 \ /
  Last update: 2008-09-26 09:41    [from the cache]
©2003-2008