From: Wende Tan <twd2.me@gmail.com>
To: arnd@arndb.de, linux-arch@vger.kernel.org
Cc: Wende Tan <twd2.me@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition
Date: Mon, 19 Jul 2021 21:03:18 +0000 [thread overview]
Message-ID: <20210719210318.1023754-1-twd2.me@gmail.com> (raw)
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
next reply other threads:[~2021-07-19 23:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 21:03 Wende Tan [this message]
2021-07-20 11:42 ` [PATCH] arch: Move page table config macros out of `#ifndef __ASSEMBLY__` condition kernel test robot
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=20210719210318.1023754-1-twd2.me@gmail.com \
--to=twd2.me@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--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 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).