430 lines
12 KiB
Diff
430 lines
12 KiB
Diff
|
From e2d1ffb13e3909dab142f0f8ec8f934b79930717 Mon Sep 17 00:00:00 2001
|
||
|
From: Vincenzo Frascino <vincenzo.frascino@arm.com>
|
||
|
Date: Mon, 14 Oct 2024 16:13:39 +0100
|
||
|
Subject: vdso: Introduce vdso/page.h
|
||
|
|
||
|
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
|
||
|
---
|
||
|
arch/alpha/include/asm/page.h | 6 +-----
|
||
|
arch/arc/include/uapi/asm/page.h | 7 +++----
|
||
|
arch/arm/include/asm/page.h | 5 +----
|
||
|
arch/arm64/include/asm/page-def.h | 5 +----
|
||
|
arch/csky/include/asm/page.h | 8 ++------
|
||
|
arch/hexagon/include/asm/page.h | 4 +---
|
||
|
arch/loongarch/include/asm/page.h | 7 +------
|
||
|
arch/m68k/include/asm/page.h | 6 ++----
|
||
|
arch/microblaze/include/asm/page.h | 5 +----
|
||
|
arch/mips/include/asm/page.h | 7 +------
|
||
|
arch/nios2/include/asm/page.h | 7 +------
|
||
|
arch/openrisc/include/asm/page.h | 11 +----------
|
||
|
arch/parisc/include/asm/page.h | 4 +---
|
||
|
arch/powerpc/include/asm/page.h | 10 +---------
|
||
|
arch/riscv/include/asm/page.h | 4 +---
|
||
|
arch/s390/include/asm/page.h | 13 +++++--------
|
||
|
arch/sh/include/asm/page.h | 6 ++----
|
||
|
arch/sparc/include/asm/page_32.h | 4 +---
|
||
|
arch/sparc/include/asm/page_64.h | 4 +---
|
||
|
arch/um/include/asm/page.h | 5 +----
|
||
|
arch/x86/include/asm/page_types.h | 5 +----
|
||
|
arch/xtensa/include/asm/page.h | 8 +-------
|
||
|
include/vdso/page.h | 30 ++++++++++++++++++++++++++++++
|
||
|
23 files changed, 61 insertions(+), 110 deletions(-)
|
||
|
create mode 100644 include/vdso/page.h
|
||
|
|
||
|
--- a/arch/alpha/include/asm/page.h
|
||
|
+++ b/arch/alpha/include/asm/page.h
|
||
|
@@ -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__
|
||
|
|
||
|
--- a/arch/arc/include/uapi/asm/page.h
|
||
|
+++ b/arch/arc/include/uapi/asm/page.h
|
||
|
@@ -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
|
||
|
@@ -24,11 +24,10 @@
|
||
|
* 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 */
|
||
|
--- a/arch/arm/include/asm/page.h
|
||
|
+++ b/arch/arm/include/asm/page.h
|
||
|
@@ -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__
|
||
|
|
||
|
--- a/arch/arm64/include/asm/page-def.h
|
||
|
+++ b/arch/arm64/include/asm/page-def.h
|
||
|
@@ -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 */
|
||
|
--- a/arch/csky/include/asm/page.h
|
||
|
+++ b/arch/csky/include/asm/page.h
|
||
|
@@ -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)
|
||
|
--- a/arch/hexagon/include/asm/page.h
|
||
|
+++ b/arch/hexagon/include/asm/page.h
|
||
|
@@ -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__
|
||
|
--- a/arch/loongarch/include/asm/page.h
|
||
|
+++ b/arch/loongarch/include/asm/page.h
|
||
|
@@ -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)
|
||
|
--- a/arch/m68k/include/asm/page.h
|
||
|
+++ b/arch/m68k/include/asm/page.h
|
||
|
@@ -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__
|
||
|
--- a/arch/microblaze/include/asm/page.h
|
||
|
+++ b/arch/microblaze/include/asm/page.h
|
||
|
@@ -19,10 +19,7 @@
|
||
|
|
||
|
#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))
|
||
|
|
||
|
--- a/arch/mips/include/asm/page.h
|
||
|
+++ b/arch/mips/include/asm/page.h
|
||
|
@@ -14,12 +14,7 @@
|
||
|
#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
|
||
|
--- a/arch/nios2/include/asm/page.h
|
||
|
+++ b/arch/nios2/include/asm/page.h
|
||
|
@@ -18,12 +18,7 @@
|
||
|
#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.
|
||
|
--- a/arch/openrisc/include/asm/page.h
|
||
|
+++ b/arch/openrisc/include/asm/page.h
|
||
|
@@ -15,16 +15,7 @@
|
||
|
#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
|
||
|
--- a/arch/parisc/include/asm/page.h
|
||
|
+++ b/arch/parisc/include/asm/page.h
|
||
|
@@ -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
|
||
|
|
||
|
--- a/arch/powerpc/include/asm/page.h
|
||
|
+++ b/arch/powerpc/include/asm/page.h
|
||
|
@@ -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
|
||
|
@@ -42,13 +41,6 @@ extern unsigned int hpage_shift;
|
||
|
#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_.
|
||
|
*
|
||
|
--- a/arch/riscv/include/asm/page.h
|
||
|
+++ b/arch/riscv/include/asm/page.h
|
||
|
@@ -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)
|
||
|
--- a/arch/s390/include/asm/page.h
|
||
|
+++ b/arch/s390/include/asm/page.h
|
||
|
@@ -11,14 +11,11 @@
|
||
|
#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))
|
||
|
+#include <vdso/page.h>
|
||
|
|
||
|
-/* PAGE_SHIFT determines the page size */
|
||
|
-#define PAGE_SHIFT _PAGE_SHIFT
|
||
|
-#define PAGE_SIZE _PAGE_SIZE
|
||
|
-#define PAGE_MASK _PAGE_MASK
|
||
|
+#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
|
||
|
--- a/arch/sh/include/asm/page.h
|
||
|
+++ b/arch/sh/include/asm/page.h
|
||
|
@@ -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)
|
||
|
--- a/arch/sparc/include/asm/page_32.h
|
||
|
+++ b/arch/sparc/include/asm/page_32.h
|
||
|
@@ -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__
|
||
|
|
||
|
--- a/arch/sparc/include/asm/page_64.h
|
||
|
+++ b/arch/sparc/include/asm/page_64.h
|
||
|
@@ -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.
|
||
|
--- a/arch/um/include/asm/page.h
|
||
|
+++ b/arch/um/include/asm/page.h
|
||
|
@@ -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__
|
||
|
|
||
|
--- a/arch/x86/include/asm/page_types.h
|
||
|
+++ b/arch/x86/include/asm/page_types.h
|
||
|
@@ -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)
|
||
|
|
||
|
--- a/arch/xtensa/include/asm/page.h
|
||
|
+++ b/arch/xtensa/include/asm/page.h
|
||
|
@@ -18,13 +18,7 @@
|
||
|
#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
|
||
|
--- /dev/null
|
||
|
+++ b/include/vdso/page.h
|
||
|
@@ -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 */
|