[PATCH V4 10/50] x86: Replace PTI_PGTABLE_SWITCH_BIT with PTI_USER_PGTABLE_BIT
From: Lai Jiangshan
Date: Tue Oct 26 2021 - 10:22:16 EST
From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
They are the same in meaning and value.
Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
arch/x86/include/asm/pgtable.h | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 65542106464b..c8909457574a 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -5,6 +5,7 @@
#include <linux/mem_encrypt.h>
#include <asm/page.h>
#include <asm/pgtable_types.h>
+#include <asm/processor-flags.h>
/*
* Macro to mark a page protection value as UC-
@@ -1164,14 +1165,6 @@ static inline bool pgdp_maps_userspace(void *__ptr)
static inline int pgd_large(pgd_t pgd) { return 0; }
#ifdef CONFIG_PAGE_TABLE_ISOLATION
-/*
- * All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
- * (8k-aligned and 8k in size). The kernel one is at the beginning 4k and
- * the user one is in the last 4k. To switch between them, you
- * just need to flip the 12th bit in their addresses.
- */
-#define PTI_PGTABLE_SWITCH_BIT PAGE_SHIFT
-
/*
* This generates better code than the inline assembly in
* __set_bit().
@@ -1193,12 +1186,12 @@ static inline void *ptr_clear_bit(void *ptr, int bit)
static inline pgd_t *kernel_to_user_pgdp(pgd_t *pgdp)
{
- return ptr_set_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
+ return ptr_set_bit(pgdp, PTI_USER_PGTABLE_BIT);
}
static inline pgd_t *user_to_kernel_pgdp(pgd_t *pgdp)
{
- return ptr_clear_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
+ return ptr_clear_bit(pgdp, PTI_USER_PGTABLE_BIT);
}
#endif /* CONFIG_PAGE_TABLE_ISOLATION */
--
2.19.1.6.gb485710b