linux/include/asm-avr32
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
..
arch-at32ap Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx 2008-07-23 12:03:18 -07:00
mach [PATCH] atmel_serial: Rename at91_register_uart_fns 2006-10-04 10:25:05 -07:00
a.out.h aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
addrspace.h
asm.h avr32: Use constants from sysreg.h in asm.h 2008-04-19 20:40:07 -04:00
atmel-mci.h atmel-mci: Driver for Atmel on-chip MMC controllers 2008-07-15 14:14:49 +02:00
atomic.h [AVR32] Fix atomic_add_unless() and atomic_sub_unless() 2007-07-18 20:47:04 +02:00
auxvec.h
bitops.h forbid asm/bitops.h direct inclusion 2007-10-19 11:53:41 -07:00
bug.h Fix WARN_ON() on bitfield ops for all other archs 2007-08-01 20:45:38 -07:00
bugs.h
byteorder.h avr32: Work around byteswap bug in gcc < 4.2 2008-03-10 13:32:33 +01:00
cache.h [AVR32] Define ARCH_KMALLOC_MINALIGN to L1_CACHE_BYTES 2007-06-14 18:30:50 +02:00
cachectl.h
cacheflush.h [AVR32] Fix copy_to_user_page() breakage 2007-12-07 14:54:47 +01:00
checksum.h Remove a couple final references to obsolete verify_area(). 2007-02-09 15:01:56 +01:00
cputime.h
current.h
delay.h Fix __const_udelay declaration and definition mismatches 2008-02-06 10:41:06 -08:00
device.h Driver core: add dev_archdata to struct device 2006-12-01 14:52:01 -08:00
div64.h
dma-mapping.h AVR32: Fix sg_page breakage 2007-10-24 10:16:02 +02:00
dma.h
elf.h Cleanup asm/{elf,page,user}.h: #ifdef __KERNEL__ is no longer needed 2008-02-07 08:42:30 -08:00
emergency-restart.h
errno.h
fb.h fbdev: detect primary display device 2007-07-17 10:23:11 -07:00
fcntl.h
futex.h
gpio.h [AVR32] GPIO API implementation 2007-02-09 15:01:58 +01:00
hardirq.h
hw_irq.h
io.h Remove dma_cache_(wback|inv|wback_inv) functions 2007-10-17 08:42:57 -07:00
ioctl.h
ioctls.h termios: Termios defines for other platforms 2008-07-20 17:12:38 -07:00
ipcbuf.h
irq_regs.h [PATCH] IRQ: Fix AVR32 breakage 2006-10-11 11:14:14 -07:00
irq.h avr32: Delete mostly unused header asm/intc.h 2008-04-19 20:40:07 -04:00
irqflags.h
Kbuild [AVR32] Fix typo in include/asm-avr32/Kbuild 2007-03-07 10:50:27 +01:00
kdebug.h [AVR32] NMI debugging 2008-01-25 08:31:43 +01:00
kmap_types.h
kprobes.h kprobes: support kretprobe blacklist 2007-10-16 09:43:10 -07:00
kvm.h kvm: provide kvm.h for all architecture: fixes headers_install 2008-04-02 15:28:18 -07:00
linkage.h
local.h
mman.h
mmu_context.h avr32: Kill unneeded #include <asm/pgalloc.h> from asm/mmu_context.h 2008-06-27 17:48:05 +02:00
mmu.h
module.h
msgbuf.h
mutex.h
namei.h
numnodes.h
ocd.h [AVR32] Enable debugging only when needed 2008-01-25 08:31:39 +01:00
page.h PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
param.h
pci.h avr32: Provide PCI DMA mapping API 2008-06-27 15:07:01 +02:00
percpu.h
pgalloc.h avr32: Use a quicklist for PTE allocation as well 2008-07-02 11:01:29 +02:00
pgtable-2level.h
pgtable.h avr32: Store virtual addresses in the PGD 2008-07-02 11:01:28 +02:00
poll.h Consolidate asm/poll.h 2007-05-11 08:29:34 -07:00
posix_types.h asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
processor.h aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
ptrace.h [AVR32] Enable debugging only when needed 2008-01-25 08:31:39 +01:00
resource.h
scatterlist.h Add CONFIG_DEBUG_SG sg validation 2007-10-22 21:20:03 +02:00
sections.h
semaphore.h Generic semaphore implementation 2008-04-17 10:42:34 -04:00
sembuf.h
serial.h avr32: add include/asm-avr32/serial.h 2008-04-19 20:40:10 -04:00
setup.h Fix name of Russell King in various comments 2008-07-10 18:04:43 -07:00
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
socket.h [NET]: Introducing socket mark socket option. 2008-01-31 19:27:19 -08:00
sockios.h [NET]: Introduce SIOCGSTAMPNS ioctl to get timestamps with nanosec resolution 2007-04-25 22:24:04 -07:00
stat.h
statfs.h
string.h
sysreg.h [AVR32] Implement irqflags trace and lockdep support 2007-12-07 14:52:37 +01:00
system.h Add cmpxchg_local to avr32 2008-02-07 08:42:31 -08:00
termbits.h lots-of-architectures: enable arbitary speed tty support 2007-07-10 17:51:13 -07:00
termios.h [PATCH] consolidate line discipline number definitions 2007-02-11 10:51:26 -08:00
thread_info.h avr32: Power Management support ("standby" and "mem" modes) 2008-07-02 11:05:01 +02:00
timex.h read_current_timer() cleanups 2008-02-06 10:41:02 -08:00
tlb.h
tlbflush.h avr32: Clean up and optimize the TLB operations 2008-07-02 11:01:28 +02:00
topology.h
traps.h
types.h avr32: types: use <asm-generic/int-*.h> for the avr32 architecture 2008-05-02 16:18:20 -07:00
uaccess.h [AVR32] Fix compile error with gcc 4.1 2007-04-27 14:21:47 +02:00
ucontext.h
unaligned.h kernel: Move arches to use common unaligned access 2008-04-29 08:06:27 -07:00
unistd.h Fix timerfd breakage on avr32 2008-02-05 14:37:15 -08:00
user.h Sanitize the type of struct user.u_ar0 2008-02-07 08:42:30 -08:00
xor.h add include/asm-avr32/xor.h 2008-04-19 20:40:09 -04:00