lkml.org 
[lkml]   [2008]   [Sep]   [27]   [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
Suresh Siddha wrote:
> +int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
> +{
> + struct resource *p = &iomem_resource;
> + int err = 0;
> + loff_t l;
> +
> + read_lock(&resource_lock);
> + for (p = p->child; p ; p = r_next(NULL, p, &l)) {
> + /*
> + * We can probably skip the resources with out
> + * IORESOURCE_IO attribute?
>

Any attempt to use ioremap on memory is a bug, so you should warn about
that too.

> + */
> + 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;
> + }
> + read_unlock(&resource_lock);
> +
> + return err;

J


\
 
 \ /
  Last update: 2008-09-27 09:19    [W:2.529 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site