linux/arch/mips/sgi-ip27
Andrea Righi 27ac792ca0 PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures
On 32-bit architectures PAGE_ALIGN() truncates 64-bit values to the 32-bit
boundary. For example:

	u64 val = PAGE_ALIGN(size);

always returns a value < 4GB even if size is greater than 4GB.

The problem resides in PAGE_MASK definition (from include/asm-x86/page.h for
example):

#define PAGE_SHIFT      12
#define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
#define PAGE_MASK       (~(PAGE_SIZE-1))
...
#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)

The "~" is performed on a 32-bit value, so everything in "and" with
PAGE_MASK greater than 4GB will be truncated to the 32-bit boundary.
Using the ALIGN() macro seems to be the right way, because it uses
typeof(addr) for the mask.

Also move the PAGE_ALIGN() definitions out of include/asm-*/page.h in
include/linux/mm.h.

See also lkml discussion: http://lkml.org/lkml/2008/6/11/237

[akpm@linux-foundation.org: fix drivers/media/video/uvc/uvc_queue.c]
[akpm@linux-foundation.org: fix v850]
[akpm@linux-foundation.org: fix powerpc]
[akpm@linux-foundation.org: fix arm]
[akpm@linux-foundation.org: fix mips]
[akpm@linux-foundation.org: fix drivers/media/video/pvrusb2/pvrusb2-dvb.c]
[akpm@linux-foundation.org: fix drivers/mtd/maps/uclinux.c]
[akpm@linux-foundation.org: fix powerpc]
Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 10:47:21 -07:00
..
Kconfig [MIPS] Fix build error: don't offer SMP on systems that don't have SMP. 2006-06-29 21:10:51 +01:00
Makefile [MIPS] Use -Werror on subdirectories which build cleanly. 2007-07-31 21:35:33 +01:00
TODO [MIPS] Rewrite all the assembler interrupt handlers to C. 2006-04-19 04:14:21 +02:00
ip27-berr.c [MIPS] IP27: remove duplicate extern dump_tlb_all() prototype 2007-10-11 23:46:00 +01:00
ip27-console.c arch: Remove unnecessary inclusions of asm/semaphore.h 2008-04-18 22:14:49 -04:00
ip27-dbgio.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ip27-hubio.c arch/mips/: Spelling fixes 2008-02-03 16:54:53 +02:00
ip27-init.c [MIPS] IP27: misc fixes 2008-06-05 18:13:15 +01:00
ip27-irq.c [MIPS] IP27: Convert to clock_event_device. 2007-10-18 18:11:47 +01:00
ip27-klconfig.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ip27-klnuma.c PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
ip27-memory.c mm: move bootmem descriptors definition to a single place 2008-07-24 10:47:14 -07:00
ip27-nmi.c [MIPS] Replace use of print_symbol with new %sP pointer format. 2008-07-15 18:44:33 +01:00
ip27-reset.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ip27-smp.c [MIPS] IP27: Fix clockevent setup 2008-06-05 18:13:14 +01:00
ip27-timer.c [MIPS] IP27: Fix clockevent setup 2008-06-05 18:13:14 +01:00
ip27-xtalk.c [MIPS] Fix loads of section missmatches 2008-03-12 14:14:41 +00:00