]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures
authorAndrea Righi <righi.andrea@gmail.com>
Thu, 24 Jul 2008 04:28:13 +0000 (21:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Jul 2008 17:47:21 +0000 (10:47 -0700)
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>
57 files changed:
arch/arm/kernel/module.c
arch/arm/plat-omap/fb.c
arch/avr32/mm/ioremap.c
arch/h8300/kernel/setup.c
arch/m68k/amiga/chipram.c
arch/m68knommu/kernel/setup.c
arch/mips/kernel/module.c
arch/mips/sgi-ip27/ip27-klnuma.c
arch/powerpc/kernel/suspend.c
arch/powerpc/lib/code-patching.c
arch/sparc64/kernel/iommu_common.h
arch/x86/kernel/module_64.c
arch/xtensa/kernel/setup.c
drivers/char/random.c
drivers/ieee1394/iso.c
drivers/media/video/pvrusb2/pvrusb2-dvb.c
drivers/media/video/pvrusb2/pvrusb2-ioread.c
drivers/media/video/uvc/uvc_queue.c
drivers/media/video/videobuf-core.c
drivers/mtd/maps/uclinux.c
drivers/net/mlx4/eq.c
drivers/pcmcia/electra_cf.c
drivers/scsi/sun_esp.c
drivers/video/acornfb.c
drivers/video/imxfb.c
drivers/video/omap/dispc.c
drivers/video/omap/omapfb_main.c
drivers/video/pxafb.c
drivers/video/sa1100fb.c
include/asm-alpha/page.h
include/asm-arm/page-nommu.h
include/asm-arm/page.h
include/asm-avr32/page.h
include/asm-blackfin/page.h
include/asm-cris/page.h
include/asm-frv/page.h
include/asm-h8300/page.h
include/asm-ia64/page.h
include/asm-m32r/page.h
include/asm-m68k/dvma.h
include/asm-m68k/page.h
include/asm-m68knommu/page.h
include/asm-mips/page.h
include/asm-mips/processor.h
include/asm-mn10300/page.h
include/asm-parisc/page.h
include/asm-powerpc/page.h
include/asm-s390/page.h
include/asm-sh/page.h
include/asm-sparc/page_32.h
include/asm-sparc/page_64.h
include/asm-um/page.h
include/asm-v850/page.h
include/asm-x86/page.h
include/asm-xtensa/page.h
include/linux/mm.h
sound/core/info.c

index 79b7e5cf5416cff90059fd145ca6a2c76d253011..a68259a0cccdb54ac3dd06cb3e5248b9b0904cd8 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/moduleloader.h>
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
index 96d6f061973329eed696b3ad370f15e86ae95630..5d107520e6b90348a5d168c25da557613d41d04f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/bootmem.h>
index 3437c82434ac9ec189742862d1ce996223feabf4..f03b79f0e0ab0a75f631e7886ad41a7a855c518d 100644 (file)
@@ -6,6 +6,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/vmalloc.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/io.h>
 
index b1f25c20a5dbdb8f6c1a2c4a29e61546499ce3e7..7fda657110eb3d7a7cab104dd3d81f1693506526 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/fb.h>
 #include <linux/console.h>
index cbe36538af47be5cd2914fe7172ad2ea0f96c026..61df1d33c0500c514cb520cb3cbef58f5f3622d9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
index 03f4fe6a2fc0e20e6e28f233cb8718a4799dd9b6..5985f198902113d6ce971e975983fa09019db051 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/fb.h>
 #include <linux/module.h>
+#include <linux/mm.h>
 #include <linux/console.h>
 #include <linux/errno.h>
 #include <linux/string.h>
index e7ed0ac485375744bf8b78be07d2ef595357d644..1f60e27523d9e65ad43289462ee269e4c696ba30 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/moduleloader.h>
 #include <linux/elf.h>
+#include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
index 48932ce1d7302bc7972a29be1d620273e83f3136..d9c79d8be81d1b65745e2454b12e56db05ea75c5 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright 2000 - 2001 Kanoj Sarcar (kanoj@sgi.com)
  */
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/kernel.h>
 #include <linux/nodemask.h>
index 8cee571075417fadd755e168ba4b0471bf58846f..6fc6328dc626c0809d1fe3e6f85814e26f4dce8c 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
  */
 
+#include <linux/mm.h>
 #include <asm/page.h>
 
 /* References to section boundaries */
index 0559fe086eb4a020d2b2434def7e4ab9f4ae8395..7c975d43e3f388d50152bbdcb42a72adfcb50a13 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <asm/page.h>
 #include <asm/code-patching.h>
 
index f3575a614fa2e643dbcc5f93e3e2e03f26e77e2e..53b19c8231a931ee1ab2f1a863e62053026ac748 100644 (file)
@@ -23,7 +23,7 @@
 #define IO_PAGE_SHIFT                  13
 #define IO_PAGE_SIZE                   (1UL << IO_PAGE_SHIFT)
 #define IO_PAGE_MASK                   (~(IO_PAGE_SIZE-1))
-#define IO_PAGE_ALIGN(addr)            (((addr)+IO_PAGE_SIZE-1)&IO_PAGE_MASK)
+#define IO_PAGE_ALIGN(addr)            ALIGN(addr, IO_PAGE_SIZE)
 
 #define IO_TSB_ENTRIES                 (128*1024)
 #define IO_TSB_SIZE                    (IO_TSB_ENTRIES * 8)
index 0e867676b5a57ebd14b063bf71cdac852e2b4089..6ba87830d4b130e6aac27eef6aa5442c2e1d1e40 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/bug.h>
 
index 5e6d75c9f92b33c9a7a210c12333852710350e70..a00359e8f7a8f06c14bfbff198e34d4bc5d5d5ea 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/screen_info.h>
 #include <linux/bootmem.h>
index 0cf98bd4f2d2438351357890a2cee00062b6c6da..e0d0e371909cd2f1c00d4e2f63fe8c8ae2c81bcc 100644 (file)
 #include <linux/fs.h>
 #include <linux/genhd.h>
 #include <linux/interrupt.h>
+#include <linux/mm.h>
 #include <linux/spinlock.h>
 #include <linux/percpu.h>
 #include <linux/cryptohash.h>
index 07ca35c98f96f8557b222db17763b03083f2e849..1cf6487b65ba8ce9c2b042d0dc5bcbcf03369f50 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/mm.h>
 #include <linux/slab.h>
 
 #include "hosts.h"
index 6ec4bf81fc7f3e0d65c2f3308e0ae93fdff0aa82..77b3c338506624992f9023eff7adc2a123dd3550 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/mm.h>
 #include "dvbdev.h"
 #include "pvrusb2-debug.h"
 #include "pvrusb2-hdw-internal.h"
index 05a1376405e794d85ddfbcf9d569314519e8c925..b4824782d858c9c8626c791405c822ba363e64af 100644 (file)
@@ -22,6 +22,7 @@
 #include "pvrusb2-debug.h"
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <asm/uaccess.h>
index 7388d0cee3d4745c2b9aa415c355a47a49b4df2e..5646a6a329393ca9b2573c6de21f29f92805ba44 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/version.h>
+#include <linux/mm.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/usb.h>
index 0a88c44ace00b20199e8606cef813234d39e5c74..b7b05842cf281bda10b27572df02ff9301fb823d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 
index c42f4b83f686dc0235f699b75a2dd457f4f53218..3fcf92130aa4cb3fda410a51ba1602667b096147 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#include <linux/mm.h>
 #include <linux/major.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index e141a1513f079427e6e7e881b587c3cf317ab500..ea3a09aaa8440ac87a3ea98d85bc6ce1f0bc7fd1 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/mm.h>
 #include <linux/dma-mapping.h>
 
 #include <linux/mlx4/cmd.h>
index c21f9a9c3e3f45d04b034d0e291652039c032918..a34284b1482a52ab5f2282fe3c7263049f6e3a4c 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/of_platform.h>
 
index 2c87db98cdfb81f8abc48dc50defb5b35b494b92..f9cf7015136648380aa6bc86f18809ed3eacd2c5 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/mm.h>
 #include <linux/init.h>
 
 #include <asm/irq.h>
index eedb8285e32fa389930152148d32224db3ac947a..017233d0c48131d67bc635eb6309cc84c27b245f 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/platform_device.h>
index 94e4d3ac1a05b3a265b9d86aecdf3d94025b96b6..0c5a475c1caecfe4545218b985932bfb35997e4b 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/fb.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index ab32ceb061781fdb1a2c155991ec1b879dc53133..ab77c51fe9d620bc4f41f0816fb4999d7e1bddaf 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/dma-mapping.h>
+#include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index 14d0f7a1114587fd3496918a8495b636d9152059..f85af5c4fa688a2c6d9be356fa6bd974c89a74f7 100644 (file)
@@ -25,6 +25,7 @@
  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 #include <linux/platform_device.h>
+#include <linux/mm.h>
 #include <linux/uaccess.h>
 
 #include <asm/mach-types.h>
index bb2514369507aa9171c361472b3ed0add14eff16..5e8a140399fc962cb5c6416ef16a880ec96c10c8 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/fb.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index ab2b2110478bc212a2f274f02bd24358ce371188..4a9f7e121807e391bdea2d496059d12001b1f076 100644 (file)
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/fb.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index 22ff9762d17b63b8379abea371cb816d37dcaae2..0995f9d13417241e283cad83bd4f0729af014c66 100644 (file)
@@ -80,9 +80,6 @@ typedef struct page *pgtable_t;
 
 #endif /* !__ASSEMBLY__ */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #define __pa(x)                        ((unsigned long) (x) - PAGE_OFFSET)
 #define __va(x)                        ((void *)((unsigned long) (x) + PAGE_OFFSET))
 #ifndef CONFIG_DISCONTIGMEM
index a1bcad0604805bc3fbc736bc14c31f80039b6987..ea1cde84f500d96e5dd552b63fc8e0736f593ef2 100644 (file)
@@ -7,6 +7,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #ifndef _ASMARM_PAGE_NOMMU_H
 #define _ASMARM_PAGE_NOMMU_H
 
@@ -42,9 +43,6 @@ typedef unsigned long pgprot_t;
 #define __pmd(x)        (x)
 #define __pgprot(x)     (x)
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
index 8e05bdb5f12f555f94c66b8ff1c008c3a3a5cb86..7c5fc5582e5dde1cdadbc9d3758a205f7aa5cd61 100644 (file)
@@ -15,9 +15,6 @@
 #define PAGE_SIZE              (1UL << PAGE_SHIFT)
 #define PAGE_MASK              (~(PAGE_SIZE-1))
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #ifndef __ASSEMBLY__
 
 #ifndef CONFIG_MMU
index cbbc5ca9728bb94558513df79d18904633b84ca9..f805d1cb11bc199b86055552900630371ee9f562 100644 (file)
@@ -57,9 +57,6 @@ static inline int get_order(unsigned long size)
 
 #endif /* !__ASSEMBLY__ */
 
-/* Align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
 /*
  * The hardware maps the virtual addresses 0x80000000 -> 0x9fffffff
  * permanently to the physical addresses 0x00000000 -> 0x1fffffff when
index c7db0220fbd6dd74d7a8b97a4bae4fe801fdfc25..344f6a8c1f22a9cebe0a86f38c3955e30c0032a5 100644 (file)
@@ -51,9 +51,6 @@ typedef struct page *pgtable_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
index c45bb1ef397cb3466c2d836f8fc1679ba69d4a9d..d19272ba6b696d659c1e14643e86445c135aeb92 100644 (file)
@@ -60,9 +60,6 @@ typedef struct page *pgtable_t;
 
 #define page_to_phys(page)     __pa((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #ifndef __ASSEMBLY__
 
 #endif /* __ASSEMBLY__ */
index c2c1e89e747d248d78c0a7535fe2b4f11740edb7..bd9c220094c74b288a03dc958f91e1b977dcb57c 100644 (file)
@@ -40,9 +40,6 @@ typedef struct page *pgtable_t;
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 #define PTE_MASK       PAGE_MASK
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
 #define devmem_is_allowed(pfn) 1
 
 #define __pa(vaddr)            virt_to_phys((void *) (unsigned long) (vaddr))
index d6a3eaf3b27eebfb53395cbeb9ac50cf492124a1..0b6acf0b03aa823a884cd8a861666ef9b1a75ecd 100644 (file)
@@ -43,9 +43,6 @@ typedef struct page *pgtable_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
index 36f39321b7681a305da85b7be173a4c5c171e0b1..5f271bc712ee92675ab0a04b255aa13ec0daa439 100644 (file)
@@ -40,7 +40,6 @@
 
 #define PAGE_SIZE              (__IA64_UL_CONST(1) << PAGE_SHIFT)
 #define PAGE_MASK              (~(PAGE_SIZE - 1))
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
 #define PERCPU_PAGE_SHIFT      16      /* log2() of max. size of per-CPU area */
 #define PERCPU_PAGE_SIZE       (__IA64_UL_CONST(1) << PERCPU_PAGE_SHIFT)
index 8a677f3fca683d658dc41c6306ff6828f9df6390..c9333089fe111e5b0e4878bb4c6cd063d6b9271f 100644 (file)
@@ -41,9 +41,6 @@ typedef struct page *pgtable_t;
 
 #endif /* !__ASSEMBLY__ */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
 /*
  * This handles the memory map.. We could make this a config
  * option, but too many people screw it up, and too few need
index 4fff408d0150879e8acd517e6ce4aa9743e6ee5d..890bbf7e7758b1f3613479d562b084c99ae19442 100644 (file)
@@ -13,7 +13,7 @@
 #define DVMA_PAGE_SHIFT        13
 #define DVMA_PAGE_SIZE (1UL << DVMA_PAGE_SHIFT)
 #define DVMA_PAGE_MASK (~(DVMA_PAGE_SIZE-1))
-#define DVMA_PAGE_ALIGN(addr)  (((addr)+DVMA_PAGE_SIZE-1)&DVMA_PAGE_MASK)
+#define DVMA_PAGE_ALIGN(addr)  ALIGN(addr, DVMA_PAGE_SIZE)
 
 extern void dvma_init(void);
 extern int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
index 880c2cbff8a681cc8619ef50f5b26cd5fd202433..a34b8bad784703b1597c5e15e5f655e3a05a7a3e 100644 (file)
@@ -103,9 +103,6 @@ typedef struct page *pgtable_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #endif /* !__ASSEMBLY__ */
 
 #include <asm/page_offset.h>
index 1e82ebb7d6442d755266ac2b452f04964ab52b61..3a1ede4544cba4815e357a23daafbb07189f59f1 100644 (file)
@@ -43,9 +43,6 @@ typedef struct page *pgtable_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 extern unsigned long memory_start;
 extern unsigned long memory_end;
 
index 494f00ba9541f6b3cefb4a43e97d990b244182ef..fe7a88ea066e6a655fc4d9a14408d0e54f8bf1d4 100644 (file)
@@ -137,9 +137,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 
 #endif /* !__ASSEMBLY__ */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
 /*
  * __pa()/__va() should be used only during mem init.
  */
index 58cbac5a64e4472dd45e17c3cef7426b86dbf243..a1e4453469f9af2e09ed52cd3f2b428b46b0c5da 100644 (file)
@@ -45,7 +45,7 @@ extern unsigned int vced_count, vcei_count;
  * This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
-#define TASK_UNMAPPED_BASE     (PAGE_ALIGN(TASK_SIZE / 3))
+#define TASK_UNMAPPED_BASE     ((TASK_SIZE / 3) & ~(PAGE_SIZE))
 #endif
 
 #ifdef CONFIG_64BIT
index 124971b9fb9bfc91ca464637406a71e3d4651449..8288e124165b50fbd83f73bec88dd391227a9941 100644 (file)
@@ -61,9 +61,6 @@ typedef struct page *pgtable_t;
 
 #endif /* !__ASSEMBLY__ */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
 /*
  * This handles the memory map.. We could make this a config
  * option, but too many people screw it up, and too few need
index 27d50b85954109d123a8e9118a8799a4eadc5221..c3941f09a87891e79c52f05f182ed84e0f0fc0c9 100644 (file)
@@ -119,10 +119,6 @@ extern int npmem_ranges;
 #define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY)
 #define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY)
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-
 #define LINUX_GATEWAY_SPACE     0
 
 /* This governs the relationship between virtual and physical addresses.
index cffdf0eb0df68068fb0720a8ba9adff870be5fbe..e088545cb3f5ea67b2065f962f89c34f4798ae1a 100644 (file)
@@ -119,9 +119,6 @@ extern phys_addr_t kernstart_addr;
 /* align addr on a size boundary - adjust address up if needed */
 #define _ALIGN(addr,size)     _ALIGN_UP(addr,size)
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       _ALIGN(addr, PAGE_SIZE)
-
 /*
  * Don't compare things with KERNELBASE or PAGE_OFFSET to test for
  * "kernelness", use is_kernel_addr() - it should do what you want.
index 12fd9c4f0f154fe86baaed66c71103d24b15f65a..991ba939408c5f9c6b1f9bcdfbc159e715f13554 100644 (file)
@@ -138,9 +138,6 @@ void arch_alloc_page(struct page *page, int order);
 
 #endif /* !__ASSEMBLY__ */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #define __PAGE_OFFSET           0x0UL
 #define PAGE_OFFSET             0x0UL
 #define __pa(x)                 (unsigned long)(x)
index 304c30b5d9472b0eee5b1d167d5c5d4cd485e881..5dc01d2fcc4cd5a7a2e1f9666b4b07a005703941 100644 (file)
@@ -22,9 +22,6 @@
 #define PAGE_MASK      (~(PAGE_SIZE-1))
 #define PTE_MASK       PAGE_MASK
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
 #define HPAGE_SHIFT    16
 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
index 14de518cc38ffddb1bf7786d3ba5722ae4902a78..cf5fb70ca1c1c3f562bdeae825db12fda8f90963 100644 (file)
@@ -134,9 +134,6 @@ BTFIXUPDEF_SETHI(sparc_unmapped_base)
 
 #endif /* !(__ASSEMBLY__) */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)  (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #define PAGE_OFFSET    0xf0000000
 #ifndef __ASSEMBLY__
 extern unsigned long phys_base;
index a8a2bba032c1a158704279383b0d59cfac0877fb..b579b910ef5123b24c1fc02fc92c1d4520e6ea9e 100644 (file)
@@ -106,9 +106,6 @@ typedef struct page *pgtable_t;
 
 #endif /* !(__ASSEMBLY__) */
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 /* We used to stick this into a hard-coded global register (%g4)
  * but that does not make sense anymore.
  */
index 916e1a61999f4b414b94e31db9b928c09ef69aff..335c57383c021d65cd0d5459dc4ffa64a8fcfd21 100644 (file)
@@ -92,9 +92,6 @@ typedef struct page *pgtable_t;
 #define __pgd(x) ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 extern unsigned long uml_physmem;
 
 #define PAGE_OFFSET (uml_physmem)
index 74a539a9bd5952b246e4450cbb6136b22e59bb3c..f9de35d873fa501871f9740c02ca4a06c0a92440 100644 (file)
@@ -94,10 +94,6 @@ typedef unsigned long pgprot_t;
 #endif /* !__ASSEMBLY__ */
 
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
-
 /* No current v850 processor has virtual memory.  */
 #define __virt_to_phys(addr)   (addr)
 #define __phys_to_virt(addr)   (addr)
index 6e02098b160527aa28415520ec4590ff3cab7898..49982110e4d94e4025896a6c05d7fddecca382ae 100644 (file)
@@ -34,9 +34,6 @@
 
 #define HUGE_MAX_HSTATE 2
 
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 #ifndef __ASSEMBLY__
 #include <linux/types.h>
 #endif
index 80a6ae0dd25957e548d53b4c3e125f32df042ba9..11f7dc2dbec769f4ed5dd4233a6bc787d983556e 100644 (file)
 
 /*
  * PAGE_SHIFT determines the page size
- * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
  */
 
 #define PAGE_SHIFT             12
 #define PAGE_SIZE              (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
 #define PAGE_MASK              (~(PAGE_SIZE-1))
-#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
 
 #define PAGE_OFFSET            XCHAL_KSEG_CACHED_VADDR
 #define MAX_MEM_PFN            XCHAL_KSEG_SIZE
index df322fb4df31f1a7cd507ea0f2c4993a59a23da3..d87a5a5fe87ddc48d8a205a7f3b17627ed0874f7 100644 (file)
@@ -41,6 +41,9 @@ extern unsigned long mmap_min_addr;
 
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+
 /*
  * Linux kernel virtual memory manager primitives.
  * The idea being to have a "virtual" mm in the same way
index cb5ead3e202df5512317aeba7e5c281d993f8fae..c67773ad9298076e701ea161b5f7c9ce3560da1e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/time.h>
+#include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <sound/core.h>