]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
vdso: Introduce vdso/page.h
authorVincenzo Frascino <vincenzo.frascino@arm.com>
Mon, 14 Oct 2024 15:13:39 +0000 (16:13 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 15 Oct 2024 22:13:04 +0000 (00:13 +0200)
The VDSO implementation includes headers from outside of the
vdso/ namespace.

Introduce vdso/page.h to make sure that the generic library
uses only the allowed namespace.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Link: https://lore.kernel.org/all/20241014151340.1639555-3-vincenzo.frascino@arm.com
23 files changed:
arch/alpha/include/asm/page.h
arch/arc/include/uapi/asm/page.h
arch/arm/include/asm/page.h
arch/arm64/include/asm/page-def.h
arch/csky/include/asm/page.h
arch/hexagon/include/asm/page.h
arch/loongarch/include/asm/page.h
arch/m68k/include/asm/page.h
arch/microblaze/include/asm/page.h
arch/mips/include/asm/page.h
arch/nios2/include/asm/page.h
arch/openrisc/include/asm/page.h
arch/parisc/include/asm/page.h
arch/powerpc/include/asm/page.h
arch/riscv/include/asm/page.h
arch/s390/include/asm/page.h
arch/sh/include/asm/page.h
arch/sparc/include/asm/page_32.h
arch/sparc/include/asm/page_64.h
arch/um/include/asm/page.h
arch/x86/include/asm/page_types.h
arch/xtensa/include/asm/page.h
include/vdso/page.h [new file with mode: 0644]

index 70419e6be1a354b3b846e958dfc2bb899253f5c9..261af54fd601d7b8405746c26aeee314c1f97aa7 100644 (file)
@@ -4,11 +4,7 @@
 
 #include <linux/const.h>
 #include <asm/pal.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #ifndef __ASSEMBLY__
 
index 7fd9e741b5274d505b1cde2eb7fb8d466d635394..4606a326af5c47b11c3e29e3193d67a6c224ff4d 100644 (file)
@@ -14,7 +14,7 @@
 
 /* PAGE_SHIFT determines the page size */
 #ifdef __KERNEL__
-#define PAGE_SHIFT CONFIG_PAGE_SHIFT
+#include <vdso/page.h>
 #else
 /*
  * Default 8k
  * not available
  */
 #define PAGE_SHIFT 13
+#define PAGE_SIZE      _BITUL(PAGE_SHIFT)      /* Default 8K */
+#define PAGE_MASK      (~(PAGE_SIZE-1))
 #endif
 
-#define PAGE_SIZE      _BITUL(PAGE_SHIFT)      /* Default 8K */
 #define PAGE_OFFSET    _AC(0x80000000, UL)     /* Kernel starts at 2G onwrds */
 
-#define PAGE_MASK      (~(PAGE_SIZE-1))
-
 #endif /* _UAPI__ASM_ARC_PAGE_H */
index 62af9f7f9e963ec1810093b2fd38ee4c5a822662..ef11b721230e20ea9b7cb0107be0f3ce756bc2c8 100644 (file)
@@ -7,10 +7,7 @@
 #ifndef _ASMARM_PAGE_H
 #define _ASMARM_PAGE_H
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
-#define PAGE_SIZE              (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK              (~((1 << PAGE_SHIFT) - 1))
+#include <vdso/page.h>
 
 #ifndef __ASSEMBLY__
 
index 792e9fe881dcf51128a15b40cddf55ccd2884dd9..d402e08442ee24685582b49a01bdbc61d2b6da5e 100644 (file)
@@ -10,9 +10,6 @@
 
 #include <linux/const.h>
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
-#define PAGE_SIZE              (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK              (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #endif /* __ASM_PAGE_DEF_H */
index 0ca6c408c07f27ee76398a9dc0ae502813e17408..f8beae295afb07ba9f8e0802919550e06502a6dd 100644 (file)
@@ -7,12 +7,8 @@
 #include <asm/cache.h>
 #include <linux/const.h>
 
-/*
- * PAGE_SHIFT determines the page size: 4KB
- */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE - 1))
+#include <vdso/page.h>
+
 #define THREAD_SIZE    (PAGE_SIZE * 2)
 #define THREAD_MASK    (~(THREAD_SIZE - 1))
 #define THREAD_SHIFT   (PAGE_SHIFT + 1)
index 8a6af57274c2dbc271da1105afa7bf7b5c00f8e3..b01f8df69dd40ac5ffa2bbea7f67b0b15c27fdf0 100644 (file)
@@ -45,9 +45,7 @@
 #define HVM_HUGEPAGE_SIZE 0x5
 #endif
 
-#define PAGE_SHIFT CONFIG_PAGE_SHIFT
-#define PAGE_SIZE  (1UL << PAGE_SHIFT)
-#define PAGE_MASK  (~((1 << PAGE_SHIFT) - 1))
+#include <vdso/page.h>
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
index e85df33f11c77212c2e8ec8e6b3f1dbb955bc622..83f3533e31a47409cd0749ee6314729b2f58633d 100644 (file)
@@ -8,12 +8,7 @@
 #include <linux/const.h>
 #include <asm/addrspace.h>
 
-/*
- * PAGE_SHIFT determines the page size
- */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE - 1))
+#include <vdso/page.h>
 
 #define HPAGE_SHIFT    (PAGE_SHIFT + PAGE_SHIFT - 3)
 #define HPAGE_SIZE     (_AC(1, UL) << HPAGE_SHIFT)
index 8cfb84b49975146162da5a62d93a4781d1479099..b173ba27d36f14c9c503517021e14114e54f4749 100644 (file)
@@ -6,10 +6,8 @@
 #include <asm/setup.h>
 #include <asm/page_offset.h>
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
+
 #define PAGE_OFFSET    (PAGE_OFFSET_RAW)
 
 #ifndef __ASSEMBLY__
index 8810f4f1c3b02d347592a320a50c14546a2fb360..d1ec3806edab949f3de0cd710c60a13c41497d69 100644 (file)
 
 #ifdef __KERNEL__
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (ASM_CONST(1) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #define LOAD_OFFSET    ASM_CONST((CONFIG_KERNEL_START-CONFIG_KERNEL_BASE_ADDR))
 
index 4609cb0326cf31f18465896d26b23ce0e5fdd553..bc3e3484c1bfa9f7e1cfaecf034099a9b84b7b2b 100644 (file)
 #include <linux/kernel.h>
 #include <asm/mipsregs.h>
 
-/*
- * PAGE_SHIFT determines the page size
- */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~((1 << PAGE_SHIFT) - 1))
+#include <vdso/page.h>
 
 /*
  * This is used for calculating the real page sizes
index 0722f88e63cc7c6dfeee78cf33b8303769d1d17a..2897ec1b74f61857ea5d9e1c7462d3005ad84371 100644 (file)
 #include <linux/pfn.h>
 #include <linux/const.h>
 
-/*
- * PAGE_SHIFT determines the page size
- */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE - 1))
+#include <vdso/page.h>
 
 /*
  * PAGE_OFFSET -- the first address of the first page of memory.
index 1d5913f67c312f8691b697e92290b7d5d7f2b0e8..124a2db4b16030dabc0b7c684836050dc9c062c2 100644 (file)
 #ifndef __ASM_OPENRISC_PAGE_H
 #define __ASM_OPENRISC_PAGE_H
 
-
-/* PAGE_SHIFT determines the page size */
-
-#define PAGE_SHIFT      CONFIG_PAGE_SHIFT
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE       (1 << PAGE_SHIFT)
-#else
-#define PAGE_SIZE       (1UL << PAGE_SHIFT)
-#endif
-#define PAGE_MASK       (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #define PAGE_OFFSET    0xc0000000
 #define KERNELBASE     PAGE_OFFSET
index 4bea2e95798f02f4904d42e3cc6b69bfc60f1c0e..6c4836fb540705fd18b63b123a13638b88c4092a 100644 (file)
@@ -4,9 +4,7 @@
 
 #include <linux/const.h>
 
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
 
index 83d0a4fc5f755a292bfffae0bf448b0127c5ed83..af9a2628d1df05d3205d3d04e775f1a9fda20b4b 100644 (file)
@@ -21,8 +21,7 @@
  * page size. When using 64K pages however, whether we are really supporting
  * 64K pages in HW or not is irrelevant to those definitions.
  */
-#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
-#define PAGE_SIZE              (ASM_CONST(1) << PAGE_SHIFT)
+#include <vdso/page.h>
 
 #ifndef __ASSEMBLY__
 #ifndef CONFIG_HUGETLB_PAGE
@@ -41,13 +40,6 @@ extern unsigned int hpage_shift;
 #define HUGE_MAX_HSTATE                (MMU_PAGE_COUNT-1)
 #endif
 
-/*
- * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
- * assign PAGE_MASK to a larger type it gets extended the way we want
- * (i.e. with 1s in the high bits)
- */
-#define PAGE_MASK      (~((1 << PAGE_SHIFT) - 1))
-
 /*
  * KERNELBASE is the virtual address of the start of the kernel, it's often
  * the same as PAGE_OFFSET, but _might not be_.
index 32d308a3355fd413743bdef7cb74f7d46ce3724b..9875399827c78017fa3c367d3dab92650f1947a8 100644 (file)
@@ -12,9 +12,7 @@
 #include <linux/pfn.h>
 #include <linux/const.h>
 
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE - 1))
+#include <vdso/page.h>
 
 #define HPAGE_SHIFT            PMD_SHIFT
 #define HPAGE_SIZE             (_AC(1, UL) << HPAGE_SHIFT)
index 73e1e03317b433d4a737926706998781a0cc5003..dbc25dc5fa0a321265651c00436d5c7387632eef 100644 (file)
 #include <linux/const.h>
 #include <asm/types.h>
 
-#define _PAGE_SHIFT    CONFIG_PAGE_SHIFT
-#define _PAGE_SIZE     (_AC(1, UL) << _PAGE_SHIFT)
-#define _PAGE_MASK     (~(_PAGE_SIZE - 1))
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     _PAGE_SHIFT
-#define PAGE_SIZE      _PAGE_SIZE
-#define PAGE_MASK      _PAGE_MASK
+#include <vdso/page.h>
+
+#define _PAGE_SHIFT    PAGE_SHIFT
+#define _PAGE_SIZE     PAGE_SIZE
+#define _PAGE_MASK     PAGE_MASK
 #define PAGE_DEFAULT_ACC       _AC(0, UL)
 /* storage-protection override */
 #define PAGE_SPO_ACC           9
index f780b467e75d7c38316baf1a1beb8707f1fc6d91..fc39b8171bfb4f2923262966116ecaa96d48be3e 100644 (file)
@@ -8,10 +8,8 @@
 
 #include <linux/const.h>
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
+
 #define PTE_MASK       PAGE_MASK
 
 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
index 9977c77374cd41ef55a7a3965a672fe6aa58bcc5..9954254ea5698e5d9a991074721b8d1c4f4bdcfc 100644 (file)
@@ -11,9 +11,7 @@
 
 #include <linux/const.h>
 
-#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
-#define PAGE_SIZE    (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK    (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #ifndef __ASSEMBLY__
 
index e9bd24821c93db0f163112b8f4bdbd03b876cf2a..2a68ff5b6eabdf13ebc779446ac84b2d28012fb0 100644 (file)
@@ -4,9 +4,7 @@
 
 #include <linux/const.h>
 
-#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
-#define PAGE_SIZE    (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK    (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 /* Flushing for D-cache alias handling is only needed if
  * the page size is smaller than 16K.
index 9ef9a8aedfa661d9a8ca0e63102736c0c1e259b2..834313ecd3d65e2e4fb8b956e966ccf7f421a099 100644 (file)
@@ -9,10 +9,7 @@
 
 #include <linux/const.h>
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #ifndef __ASSEMBLY__
 
index 52f1b4ff0cc16ccb23cc41defc956e2229d7f8e7..974688973cf6e00d83ae4ca4bc7f351349a8a0c6 100644 (file)
@@ -6,10 +6,7 @@
 #include <linux/types.h>
 #include <linux/mem_encrypt.h>
 
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
-#define PAGE_SIZE              (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK              (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #define __VIRTUAL_MASK         ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
 
index 4db56ef052d2235eb35ea712026615d0cf66859b..595c1037b73889a6c6138007b7491723a1beb6fe 100644 (file)
 #include <asm/cache.h>
 #include <asm/kmem_layout.h>
 
-/*
- * PAGE_SHIFT determines the page size
- */
-
-#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
-#define PAGE_SIZE      (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
+#include <vdso/page.h>
 
 #ifdef CONFIG_MMU
 #define PAGE_OFFSET    XCHAL_KSEG_CACHED_VADDR
diff --git a/include/vdso/page.h b/include/vdso/page.h
new file mode 100644 (file)
index 0000000..4ada1ba
--- /dev/null
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __VDSO_PAGE_H
+#define __VDSO_PAGE_H
+
+#include <uapi/linux/const.h>
+
+/*
+ * PAGE_SHIFT determines the page size.
+ *
+ * Note: This definition is required because PAGE_SHIFT is used
+ * in several places throuout the codebase.
+ */
+#define PAGE_SHIFT      CONFIG_PAGE_SHIFT
+
+#define PAGE_SIZE      (_AC(1,UL) << CONFIG_PAGE_SHIFT)
+
+#if defined(CONFIG_PHYS_ADDR_T_64BIT) && !defined(CONFIG_64BIT)
+/*
+ * Applies only to 32-bit architectures with a 64-bit phys_addr_t.
+ *
+ * Subtle: (1 << CONFIG_PAGE_SHIFT) is an int, not an unsigned long.
+ * So if we assign PAGE_MASK to a larger type it gets extended the
+ * way we want (i.e. with 1s in the high bits)
+ */
+#define PAGE_MASK      (~((1 << CONFIG_PAGE_SHIFT) - 1))
+#else
+#define PAGE_MASK      (~(PAGE_SIZE - 1))
+#endif
+
+#endif /* __VDSO_PAGE_H */