1
0
Files
linux/include/asm-x86
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
..
2008-07-18 14:35:14 +02:00
2008-07-22 10:43:44 +02:00
2008-01-30 13:34:07 +01:00
2008-05-23 20:33:28 +02:00
2008-07-21 21:35:38 +02:00
2008-04-17 17:41:33 +02:00
2008-07-09 09:14:12 +02:00
2008-04-19 19:19:54 +02:00
2008-02-04 16:48:04 +01:00
2008-07-16 12:15:17 -07:00
2008-07-08 13:10:58 +02:00
2008-05-25 08:58:35 +02:00
2008-07-09 09:13:59 +02:00
2008-07-14 11:37:46 +02:00
2008-05-01 08:03:58 -07:00
2008-07-18 14:10:27 +02:00
2008-07-11 11:00:54 +02:00
2008-01-30 13:33:35 +01:00
2008-07-08 10:38:19 +02:00
2008-07-09 07:43:25 +02:00
2008-01-30 13:33:14 +01:00
2008-04-18 00:46:35 +02:00
2008-01-30 13:30:28 +01:00
2008-07-16 00:29:07 +02:00
2008-05-12 21:28:05 +02:00
2008-01-30 13:30:16 +01:00
2008-05-24 11:22:12 +02:00
2008-04-17 20:05:37 +02:00
2008-01-30 13:31:55 +01:00
2008-07-08 13:10:31 +02:00
2008-07-08 13:10:31 +02:00
2008-07-08 13:10:31 +02:00
2008-01-30 13:31:43 +01:00
2008-07-08 12:24:13 +02:00
2008-06-10 15:52:07 +02:00
2008-07-08 13:10:24 +02:00
2008-04-17 17:40:58 +02:00
2008-07-13 08:19:45 +02:00
2008-04-19 19:19:55 +02:00
2008-07-08 11:31:25 +02:00
2008-07-22 10:43:45 +02:00
2008-07-22 10:43:45 +02:00
2008-07-16 12:15:17 -07:00
2008-06-02 12:48:23 +02:00
2008-05-25 08:58:30 +02:00
2008-05-25 07:09:47 +02:00
2008-04-19 19:19:57 +02:00
2008-06-18 12:27:03 +02:00
2008-04-17 10:42:34 -04:00
2008-07-18 17:59:13 +02:00
2008-07-16 10:55:07 +02:00
2008-07-08 15:49:08 +02:00
2008-06-18 12:27:03 +02:00
2008-02-06 10:41:02 -08:00
2008-07-18 18:51:57 +02:00
2008-07-09 07:43:27 +02:00
2008-04-26 17:35:46 +02:00
2008-06-02 12:48:23 +02:00
2008-06-18 12:27:03 +02:00
2008-06-18 12:27:03 +02:00