All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <k.shutemov@velesys.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Do not export PAGE_SIZE to userspace.
Date: Tue, 23 Oct 2007 13:33:04 +0300	[thread overview]
Message-ID: <20071023103304.GA10209@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 5041 bytes --]


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@gmail.com>
---
 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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2007-10-23 10:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-23 10:33 Kirill A. Shutemov [this message]
2007-10-23 16:22 ` [PATCH] Do not export PAGE_SIZE to userspace Mike Frysinger
2007-10-23 16:59   ` Kirill A. Shutemov
2007-10-23 17:35     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071023103304.GA10209@localhost.localdomain \
    --to=k.shutemov@velesys.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.