LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Do not export PAGE_SIZE to userspace.
@ 2007-10-23 10:33 Kirill A. Shutemov
  2007-10-23 16:22 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2007-10-23 10:33 UTC (permalink / raw)
  To: linux-kernel

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Do not export PAGE_SIZE to userspace.
  2007-10-23 10:33 [PATCH] Do not export PAGE_SIZE to userspace Kirill A. Shutemov
@ 2007-10-23 16:22 ` Mike Frysinger
  2007-10-23 16:59   ` Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2007-10-23 16:22 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: linux-kernel

On 10/23/07, Kirill A. Shutemov <k.shutemov@velesys.com> wrote:
> Userspace should use getpagesize() or sysconf(_SC_PAGESIZE) to get memory
> page size.

please go back through the archives and read the history here.  we
should work at dropping page.h completely, not making it an empty
file.
-mike

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Do not export PAGE_SIZE to userspace.
  2007-10-23 16:22 ` Mike Frysinger
@ 2007-10-23 16:59   ` Kirill A. Shutemov
  2007-10-23 17:35     ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2007-10-23 16:59 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel

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

On [Tue, 23.10.2007 12:22], Mike Frysinger wrote:
> On 10/23/07, Kirill A. Shutemov <k.shutemov@velesys.com> wrote:
> > Userspace should use getpagesize() or sysconf(_SC_PAGESIZE) to get memory
> > page size.
> 
> please go back through the archives and read the history here.  we
> should work at dropping page.h completely, not making it an empty
> file.

Do you mean page.h shouldn't be exported to userspace or should be dropped
from kernelspace too?

-- 
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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Do not export PAGE_SIZE to userspace.
  2007-10-23 16:59   ` Kirill A. Shutemov
@ 2007-10-23 17:35     ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2007-10-23 17:35 UTC (permalink / raw)
  To: Kirill A. Shutemov; +Cc: linux-kernel

On 10/23/07, Kirill A. Shutemov <k.shutemov@velesys.com> wrote:
> On [Tue, 23.10.2007 12:22], Mike Frysinger wrote:
> > On 10/23/07, Kirill A. Shutemov <k.shutemov@velesys.com> wrote:
> > > Userspace should use getpagesize() or sysconf(_SC_PAGESIZE) to get memory
> > > page size.
> >
> > please go back through the archives and read the history here.  we
> > should work at dropping page.h completely, not making it an empty
> > file.
>
> Do you mean page.h shouldn't be exported to userspace

yes

> or should be dropped from kernelspace too?

noooooooooooooooooo

;)
-mike

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-23 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-23 10:33 [PATCH] Do not export PAGE_SIZE to userspace Kirill A. Shutemov
2007-10-23 16:22 ` Mike Frysinger
2007-10-23 16:59   ` Kirill A. Shutemov
2007-10-23 17:35     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).