kernel_optimize_test/drivers/char
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
..
agp Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
hw_random sparc64: Add Niagara2 RNG driver. 2008-07-18 00:46:09 -07:00
ip2 device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
ipmi device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
mwave mwave-mwavedd: BKL pushdown 2008-07-02 15:06:23 -06:00
pcmcia Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2008-07-22 13:13:47 -07:00
rio gs: use tty_port 2008-07-20 17:12:36 -07:00
tpm Merge commit 'v2.6.26' into bkl-removal 2008-07-14 15:29:34 -06:00
xilinx_hwicap device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
.gitignore
amiserial.c tty: rework break handling 2008-07-22 13:03:28 -07:00
apm-emulation.c APM emulation: Notify about all suspend events, not just APM invoked ones (v2) 2008-07-16 23:27:02 +02:00
applicom.c
applicom.h
bfin-otp.c
briq_panel.c briq_panel: BKL pushdown 2008-06-20 14:05:55 -06:00
bsr.c powerpc: Add driver for Barrier Synchronization Register 2008-07-15 12:24:55 +10:00
cd1865.h
ChangeLog
consolemap.c
cp437.uni
cs5535_gpio.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
cyclades.c tty: rework break handling 2008-07-22 13:03:28 -07:00
defkeymap.c_shipped
defkeymap.map
digi1.h
digiFep1.h
digiPCI.h
ds1286.c ds1286: BKL pushdown 2008-06-20 14:05:56 -06:00
ds1302.c
ds1620.c ds1620: BKL pushdown 2008-06-20 14:05:56 -06:00
dsp56k.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
dtlk.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
efirtc.c efirtc: BKL pushdown 2008-06-20 14:05:56 -06:00
epca.c Fix the epca driver to permit epca_setup() to be invoked from the kernel cmdline 2008-07-22 13:03:28 -07:00
epca.h epca: use tty_port 2008-07-20 17:12:36 -07:00
epcaconfig.h
esp.c tty: rework break handling 2008-07-22 13:03:28 -07:00
generic_nvram.c
generic_serial.c gs: use tty_port 2008-07-20 17:12:36 -07:00
genrtc.c genrtc: BKL pushdown 2008-06-20 14:05:57 -06:00
hangcheck-timer.c
hpet.c hpet: BKL pushdown 2008-06-20 14:05:57 -06:00
hvc_beat.c
hvc_console.c
hvc_console.h
hvc_iseries.c
hvc_rtas.c
hvc_vio.c
hvc_xen.c
hvcs.c
hvsi.c
i8k.c
ip27-rtc.c ip27-rtc: BKL pushdown 2008-06-20 14:05:57 -06:00
isicom.c isicom: restore using hardware break support 2008-07-22 13:03:28 -07:00
istallion.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2008-07-22 13:13:47 -07:00
Kconfig specialix: restore driver using new break functionality 2008-07-22 13:03:28 -07:00
keyboard.c Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into next 2008-07-21 00:55:14 -04:00
lcd.c lcd: BKL pushdown 2008-06-20 14:05:58 -06:00
lcd.h
lp.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
Makefile tty: Split ldisc code into its own file 2008-07-22 13:03:27 -07:00
mbcs.c mbcs: cdev lock_kernel() pushdown 2008-06-20 14:05:48 -06:00
mbcs.h
mem.c use generic_access_phys for /dev/mem mappings 2008-07-24 10:47:15 -07:00
misc.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
mmtimer.c mmtimer: Push BKL down into the ioctl handler 2008-07-17 11:34:49 -07:00
moxa.c tty: rework break handling 2008-07-22 13:03:28 -07:00
moxa.h
mspec.c mspec: convert nopfn to fault 2008-07-24 10:47:14 -07:00
mxser.c Char: mxser, add CP-102UF support 2008-07-22 13:03:28 -07:00
mxser.h
n_hdlc.c n_hdlc: honor O_NONBLOCK on write 2008-07-22 13:03:28 -07:00
n_r3964.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
n_tty.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
nozomi.c
nsc_gpio.c
nvram.c drivers/char/nvram.c: Removed duplicated include 2008-07-23 09:36:23 -07:00
nwbutton.c
nwbutton.h
nwflash.c
pc8736x_gpio.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
ppdev.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
ps3flash.c
pty.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
random.c PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
raw.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
riscom8_reg.h
riscom8.c riscom8: Restore driver using new break functionality 2008-07-22 13:03:28 -07:00
riscom8.h tty: add more tty_port fields 2008-07-20 17:12:38 -07:00
rocket_int.h tty: add more tty_port fields 2008-07-20 17:12:38 -07:00
rocket.c tty: rework break handling 2008-07-22 13:03:28 -07:00
rocket.h tty: add more tty_port fields 2008-07-20 17:12:38 -07:00
rtc.c Merge commit 'v2.6.26' into bkl-removal 2008-07-14 15:29:34 -06:00
scc.h
scx200_gpio.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
selection.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
ser_a2232.c
ser_a2232.h
ser_a2232fw.ax
ser_a2232fw.h
serial167.c
snsc_event.c
snsc.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
snsc.h
sonypi.c sonypi: BKL pushdown 2008-07-02 15:06:25 -06:00
specialix_io8.h tty: add more tty_port fields 2008-07-20 17:12:38 -07:00
specialix.c specialix: restore driver using new break functionality 2008-07-22 13:03:28 -07:00
stallion.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2008-07-22 13:13:47 -07:00
sx.c tty: rework break handling 2008-07-22 13:03:28 -07:00
sx.h
sxboards.h
sxwindow.h
synclink_gt.c synclink_gt fix locking in error path of rx enable 2008-07-22 13:03:29 -07:00
synclink.c tty: rework break handling 2008-07-22 13:03:28 -07:00
synclinkmp.c tty: rework break handling 2008-07-22 13:03:28 -07:00
sysrq.c fix: "smp_call_function: get rid of the unused nonatomic/retry argument" 2008-06-27 11:52:45 +02:00
tb0219.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
tlclk.c tlckl: BKL pushdown 2008-06-20 14:05:51 -06:00
toshiba.c
tty_audit.c
tty_io.c remove is_tty() 2008-07-24 10:47:13 -07:00
tty_ioctl.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
tty_ldisc.c tty: Split ldisc code into its own file 2008-07-22 13:03:27 -07:00
vc_screen.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
viocons.c
viotape.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00
virtio_console.c
vme_scc.c tty: rework break handling 2008-07-22 13:03:28 -07:00
vr41xx_giu.c Add a bunch of cycle_kernel_lock() calls 2008-06-20 14:05:53 -06:00
vt_ioctl.c
vt.c device create: char: convert device_create to device_create_drvdata 2008-07-21 21:54:41 -07:00