All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] mmap + wrapping around to 0
@ 2001-11-08 16:56 Dave Ashley
  2001-11-08 18:00 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Ashley @ 2001-11-08 16:56 UTC (permalink / raw)
  To: linux-kernel

I have a fix for this problem. In the file
include/linux/mm.h
in the inline function do_mmap(), change
        if ((offset + PAGE_ALIGN(len)) < offset)
to
        if ((offset + PAGE_ALIGN(len)-1) < offset)

-Dave

On Wed, 7 Nov 2001, Dave Ashley wrote:

> I'm using linux on an embedded system based on the 2.4.2 kernel. There
> is a flash rom at physical address FFE00000 of 2 megabytes size. I have
> a flash utility that uses mmap() on /dev/mem, but I can't call it with
> offset 0xffe00000, size 0x00200000, I must call it with size
> 0x001ff000 (1 page size less than the real size). I figure this is because
> the end address has wrapped around to 0 and this messes up the system.
>
> This should work, the memory is there. But I can't access that last page.
>
> BTW the cpu is a ppc 8260 (603e core).
>
> -Dave

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmap + wrapping around to 0
  2001-11-08 16:56 [PATCH] mmap + wrapping around to 0 Dave Ashley
@ 2001-11-08 18:00 ` Alan Cox
  2001-11-08 18:03   ` Dave Ashley (linux mailing list)
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2001-11-08 18:00 UTC (permalink / raw)
  To: Dave Ashley (linux mailing list); +Cc: linux-kernel

> in the inline function do_mmap(), change
>         if ((offset + PAGE_ALIGN(len)) < offset)
> to
>         if ((offset + PAGE_ALIGN(len)-1) < offset)

Shouldnt that be

	PAGE_ALIGN(len-1)

so you compute the page of the last byte ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmap + wrapping around to 0
  2001-11-08 18:00 ` Alan Cox
@ 2001-11-08 18:03   ` Dave Ashley (linux mailing list)
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Ashley (linux mailing list) @ 2001-11-08 18:03 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

PAGE_ALIGN results in a multiple of PAGE_SIZE always.
If you subtract one inside, the end result will
be the same.

As an example:
map 0x1000 bytes at 0xfffff000
PAGE_ALIGN(0x1000) = 0x1000
PAGE_ALIGN(0x0fff) = 0x1000
PAGE_ALIGN(0x1000)-1 = 0x0fff
The difference is adding 0x1000 or 0xfff to
0xfffff000, and the result wrapping around
to 0, or going to 0xffffffff (the later
result is what we want and the comparison works).

-Dave

On Thu, 8 Nov 2001, Alan Cox wrote:

> > in the inline function do_mmap(), change
> >         if ((offset + PAGE_ALIGN(len)) < offset)
> > to
> >         if ((offset + PAGE_ALIGN(len)-1) < offset)
>
> Shouldnt that be
>
> 	PAGE_ALIGN(len-1)
>
> so you compute the page of the last byte ?
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-08 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-08 16:56 [PATCH] mmap + wrapping around to 0 Dave Ashley
2001-11-08 18:00 ` Alan Cox
2001-11-08 18:03   ` Dave Ashley (linux mailing list)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.