Re: [PATCH] UIO: Implement a UIO interface for the SMX Cryptengine

From: Ben Nizette
Date: Wed Mar 12 2008 - 06:35:46 EST



On Wed, 2008-03-12 at 19:08 +0900, Paul Mundt wrote:
> On Tue, Mar 11, 2008 at 03:57:10PM +1100, Ben Nizette wrote:
> > +
> > + info->mem[0].size = regs->end - regs->start;
> > + info->mem[0].memtype = UIO_MEM_PHYS;
> > +
> You have an off-by-1 in the resource size. ioremap and struct resource
> are not equal in their expectations. You probably want to do something
> like:
>
> info->mem[0].size = regs->end - regs->start + 1;
> info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size);
> ...
>
You're right, thanks. I hadn't noticed since we don't actually access
all the way to the end of the region in normal use.

> and make sure that your resource end doesn't overlap with a start address
> of an unrelated resource in your definition. /proc/iomem tends to be
> useful for this.

Yup. In our case this is fairly easy as the engine just takes up a
whole Chip Select's worth of address space on an AVR32 AT32AP7000.

--Ben.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/