lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition
Date
Move page table configuration macros like `P4D_SHIFT` out of
`#ifndef __ASSEMBLY__` condition, so that they can be used by assembly
code or linker scripts. For example, the `TEXT_CFI_JT` macro in
`include/asm-generic/vmlinux.lds.h` needs `PMD_SIZE` when Clang CFI is
enabled.

Signed-off-by: Wende Tan <twd2.me@gmail.com>
---
include/asm-generic/pgtable-nop4d.h | 10 ++++++----
include/asm-generic/pgtable-nopmd.h | 19 ++++++++++---------
include/asm-generic/pgtable-nopud.h | 15 ++++++++-------
3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h
index 03b7dae47dd4..a3de2e358ebc 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -2,17 +2,19 @@
#ifndef _PGTABLE_NOP4D_H
#define _PGTABLE_NOP4D_H

-#ifndef __ASSEMBLY__
+#include <linux/const.h>

#define __PAGETABLE_P4D_FOLDED 1

-typedef struct { pgd_t pgd; } p4d_t;
-
#define P4D_SHIFT PGDIR_SHIFT
#define PTRS_PER_P4D 1
-#define P4D_SIZE (1UL << P4D_SHIFT)
+#define P4D_SIZE (_UL(1) << P4D_SHIFT)
#define P4D_MASK (~(P4D_SIZE-1))

+#ifndef __ASSEMBLY__
+
+typedef struct { pgd_t pgd; } p4d_t;
+
/*
* The "pgd_xxx()" functions here are trivial for a folded two-level
* setup: the p4d is never bad, and a p4d always exists (as it's folded
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 10789cf51d16..cacaa454f97b 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -2,14 +2,20 @@
#ifndef _PGTABLE_NOPMD_H
#define _PGTABLE_NOPMD_H

-#ifndef __ASSEMBLY__
-
#include <asm-generic/pgtable-nopud.h>
-
-struct mm_struct;
+#include <linux/const.h>

#define __PAGETABLE_PMD_FOLDED 1

+#define PMD_SHIFT PUD_SHIFT
+#define PTRS_PER_PMD 1
+#define PMD_SIZE (_UL(1) << PMD_SHIFT)
+#define PMD_MASK (~(PMD_SIZE-1))
+
+#ifndef __ASSEMBLY__
+
+struct mm_struct;
+
/*
* Having the pmd type consist of a pud gets the size right, and allows
* us to conceptually access the pud entry that this pmd is folded into
@@ -17,11 +23,6 @@ struct mm_struct;
*/
typedef struct { pud_t pud; } pmd_t;

-#define PMD_SHIFT PUD_SHIFT
-#define PTRS_PER_PMD 1
-#define PMD_SIZE (1UL << PMD_SHIFT)
-#define PMD_MASK (~(PMD_SIZE-1))
-
/*
* The "pud_xxx()" functions here are trivial for a folded two-level
* setup: the pmd is never bad, and a pmd always exists (as it's folded
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index eb70c6d7ceff..dd9239073a86 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -2,12 +2,18 @@
#ifndef _PGTABLE_NOPUD_H
#define _PGTABLE_NOPUD_H

-#ifndef __ASSEMBLY__
-
#include <asm-generic/pgtable-nop4d.h>
+#include <linux/const.h>

#define __PAGETABLE_PUD_FOLDED 1

+#define PUD_SHIFT P4D_SHIFT
+#define PTRS_PER_PUD 1
+#define PUD_SIZE (_UL(1) << PUD_SHIFT)
+#define PUD_MASK (~(PUD_SIZE-1))
+
+#ifndef __ASSEMBLY__
+
/*
* Having the pud type consist of a p4d gets the size right, and allows
* us to conceptually access the p4d entry that this pud is folded into
@@ -15,11 +21,6 @@
*/
typedef struct { p4d_t p4d; } pud_t;

-#define PUD_SHIFT P4D_SHIFT
-#define PTRS_PER_PUD 1
-#define PUD_SIZE (1UL << PUD_SHIFT)
-#define PUD_MASK (~(PUD_SIZE-1))
-
/*
* The "p4d_xxx()" functions here are trivial for a folded two-level
* setup: the pud is never bad, and a pud always exists (as it's folded
--
2.25.1
\
 
 \ /
  Last update: 2021-07-19 23:11    [W:0.068 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site