[PATCH] Do not export PAGE_SIZE to userspace.

From: Kirill A. Shutemov
Date: Tue Oct 23 2007 - 06:58:39 EST



Userspace should use getpagesize() or sysconf(_SC_PAGESIZE) to get memory
page size.

man 2 getpagesize:
... Generally, one uses binaries that are architecture but not machine
model dependent, in order to have a single binary distribution per
architecture. This means that a user program should not find PAGE_SIZE at
compile time from a header file, but use an actual system call, at least
for those architectures (like sun4) where this dependency exists.

Signed-off-by: Kirill A. Shutemov <k.shutemov@xxxxxxxxx>
---
include/asm-blackfin/page.h | 4 ++--
include/asm-m32r/page.h | 3 ++-
include/asm-ppc/page.h | 4 ++--
include/asm-s390/page.h | 2 +-
include/asm-sh64/page.h | 2 +-
include/asm-um/page.h | 4 ++++
include/asm-x86/page_32.h | 3 ++-
include/asm-x86/page_64.h | 3 ++-
8 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/include/asm-blackfin/page.h b/include/asm-blackfin/page.h
index 8bc8671..613d353 100644
--- a/include/asm-blackfin/page.h
+++ b/include/asm-blackfin/page.h
@@ -1,6 +1,8 @@
#ifndef _BLACKFIN_PAGE_H
#define _BLACKFIN_PAGE_H

+#ifdef __KERNEL__
+
/* PAGE_SHIFT determines the page size */

#define PAGE_SHIFT 12
@@ -11,8 +13,6 @@
#endif
#define PAGE_MASK (~(PAGE_SIZE-1))

-#ifdef __KERNEL__
-
#include <asm/setup.h>

#ifndef __ASSEMBLY__
diff --git a/include/asm-m32r/page.h b/include/asm-m32r/page.h
index 04fd183..7246369 100644
--- a/include/asm-m32r/page.h
+++ b/include/asm-m32r/page.h
@@ -1,12 +1,13 @@
#ifndef _ASM_M32R_PAGE_H
#define _ASM_M32R_PAGE_H

+#ifdef __KERNEL__
+
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))

-#ifdef __KERNEL__
#ifndef __ASSEMBLY__

extern void clear_page(void *to);
diff --git a/include/asm-ppc/page.h b/include/asm-ppc/page.h
index ad4c5a1..a1333a0 100644
--- a/include/asm-ppc/page.h
+++ b/include/asm-ppc/page.h
@@ -1,6 +1,8 @@
#ifndef _PPC_PAGE_H
#define _PPC_PAGE_H

+#ifdef __KERNEL__
+
#include <asm/asm-compat.h>

/* PAGE_SHIFT determines the page size */
@@ -13,8 +15,6 @@
*/
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))

-#ifdef __KERNEL__
-
/* This must match what is in arch/ppc/Makefile */
#define PAGE_OFFSET CONFIG_KERNEL_START
#define KERNELBASE PAGE_OFFSET
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h
index 584d0ee..160293c 100644
--- a/include/asm-s390/page.h
+++ b/include/asm-s390/page.h
@@ -9,6 +9,7 @@
#ifndef _S390_PAGE_H
#define _S390_PAGE_H

+#ifdef __KERNEL__
#include <linux/const.h>
#include <asm/types.h>

@@ -19,7 +20,6 @@
#define PAGE_DEFAULT_ACC 0
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)

-#ifdef __KERNEL__
#include <asm/setup.h>
#ifndef __ASSEMBLY__

diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h
index 472089a..d1c3fa2 100644
--- a/include/asm-sh64/page.h
+++ b/include/asm-sh64/page.h
@@ -17,6 +17,7 @@
*
*/

+#ifdef __KERNEL__

/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
@@ -43,7 +44,6 @@
#define ARCH_HAS_SETCLEAR_HUGE_PTE
#endif

-#ifdef __KERNEL__
#ifndef __ASSEMBLY__

extern struct page *mem_map;
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
index 4b424c7..85604ae 100644
--- a/include/asm-um/page.h
+++ b/include/asm-um/page.h
@@ -7,6 +7,8 @@
#ifndef __UM_PAGE_H
#define __UM_PAGE_H

+#ifdef __KERNEL__
+
struct page;

#include <linux/types.h>
@@ -118,4 +120,6 @@ extern struct page *arch_validate(struct page *page, gfp_t mask, int order);
#include <asm-generic/memory_model.h>
#include <asm-generic/page.h>

+#endif /* __KERNEL__ */
+
#endif
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
index 80ecc66..2569e21 100644
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -1,6 +1,8 @@
#ifndef _I386_PAGE_H
#define _I386_PAGE_H

+#ifdef __KERNEL__
+
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
@@ -9,7 +11,6 @@
#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)

-#ifdef __KERNEL__
#ifndef __ASSEMBLY__

#ifdef CONFIG_X86_USE_3DNOW
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index c3b52bc..80ab148 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -1,6 +1,8 @@
#ifndef _X86_64_PAGE_H
#define _X86_64_PAGE_H

+#ifdef __KERNEL__
+
#include <linux/const.h>

/* PAGE_SHIFT determines the page size */
@@ -37,7 +39,6 @@
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)

-#ifdef __KERNEL__
#ifndef __ASSEMBLY__

extern unsigned long end_pfn;
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ Velesys LLC, http://www.velesys.com/
+ ALT Linux Team, http://www.altlinux.com/

Attachment: signature.asc
Description: Digital signature