Skip to content

Commit ea4654e

Browse files
leitaoingomolnar
authored andcommitted
x86/bugs: Rename CONFIG_PAGE_TABLE_ISOLATION => CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
Step 4/10 of the namespace unification of CPU mitigations related Kconfig options. [ mingo: Converted new uses that got added since the series was posted. ] Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20231121160740.1249350-5-leitao@debian.org
1 parent 5fa31af commit ea4654e

23 files changed

Lines changed: 51 additions & 50 deletions

File tree

Documentation/arch/x86/pti.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ comments in pti.c).
2626

2727
This approach helps to ensure that side-channel attacks leveraging
2828
the paging structures do not function when PTI is enabled. It can be
29-
enabled by setting CONFIG_PAGE_TABLE_ISOLATION=y at compile time.
30-
Once enabled at compile-time, it can be disabled at boot with the
31-
'nopti' or 'pti=' kernel parameters (see kernel-parameters.txt).
29+
enabled by setting CONFIG_MITIGATION_PAGE_TABLE_ISOLATION=y at compile
30+
time. Once enabled at compile-time, it can be disabled at boot with
31+
the 'nopti' or 'pti=' kernel parameters (see kernel-parameters.txt).
3232

3333
Page Table Management
3434
=====================

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,7 @@ menuconfig SPECULATION_MITIGATIONS
24842484

24852485
if SPECULATION_MITIGATIONS
24862486

2487-
config PAGE_TABLE_ISOLATION
2487+
config MITIGATION_PAGE_TABLE_ISOLATION
24882488
bool "Remove the kernel mapping in user mode"
24892489
default y
24902490
depends on (X86_64 || X86_PAE)

arch/x86/boot/compressed/ident_map_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* Copyright (C) 2016 Kees Cook
99
*/
1010

11-
/* No PAGE_TABLE_ISOLATION support needed either: */
12-
#undef CONFIG_PAGE_TABLE_ISOLATION
11+
/* No MITIGATION_PAGE_TABLE_ISOLATION support needed either: */
12+
#undef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
1313

1414
#include "error.h"
1515
#include "misc.h"

arch/x86/entry/calling.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ For 32-bit we have the following conventions - kernel is built with
142142
.endif
143143
.endm
144144

145-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
145+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
146146

147147
/*
148-
* PAGE_TABLE_ISOLATION PGDs are 8k. Flip bit 12 to switch between the two
148+
* MITIGATION_PAGE_TABLE_ISOLATION PGDs are 8k. Flip bit 12 to switch between the two
149149
* halves:
150150
*/
151151
#define PTI_USER_PGTABLE_BIT PAGE_SHIFT
@@ -160,7 +160,7 @@ For 32-bit we have the following conventions - kernel is built with
160160

161161
.macro ADJUST_KERNEL_CR3 reg:req
162162
ALTERNATIVE "", "SET_NOFLUSH_BIT \reg", X86_FEATURE_PCID
163-
/* Clear PCID and "PAGE_TABLE_ISOLATION bit", point CR3 at kernel pagetables: */
163+
/* Clear PCID and "MITIGATION_PAGE_TABLE_ISOLATION bit", point CR3 at kernel pagetables: */
164164
andq $(~PTI_USER_PGTABLE_AND_PCID_MASK), \reg
165165
.endm
166166

@@ -275,7 +275,7 @@ For 32-bit we have the following conventions - kernel is built with
275275
.Lend_\@:
276276
.endm
277277

278-
#else /* CONFIG_PAGE_TABLE_ISOLATION=n: */
278+
#else /* CONFIG_MITIGATION_PAGE_TABLE_ISOLATION=n: */
279279

280280
.macro SWITCH_TO_KERNEL_CR3 scratch_reg:req
281281
.endm

arch/x86/entry/entry_64.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_usermode, SYM_L_GLOBAL)
562562
#ifdef CONFIG_XEN_PV
563563
ALTERNATIVE "", "jmp xenpv_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV
564564
#endif
565-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
565+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
566566
ALTERNATIVE "", "jmp .Lpti_restore_regs_and_return_to_usermode", X86_FEATURE_PTI
567567
#endif
568568

@@ -578,7 +578,7 @@ SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_usermode, SYM_L_GLOBAL)
578578
jnz .Lnative_iret
579579
ud2
580580

581-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
581+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
582582
.Lpti_restore_regs_and_return_to_usermode:
583583
POP_REGS pop_rdi=0
584584

@@ -1096,7 +1096,7 @@ SYM_CODE_END(error_return)
10961096
*
10971097
* Registers:
10981098
* %r14: Used to save/restore the CR3 of the interrupted context
1099-
* when PAGE_TABLE_ISOLATION is in use. Do not clobber.
1099+
* when MITIGATION_PAGE_TABLE_ISOLATION is in use. Do not clobber.
11001100
*/
11011101
SYM_CODE_START(asm_exc_nmi)
11021102
UNWIND_HINT_IRET_ENTRY

arch/x86/include/asm/disabled-features.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# define DISABLE_LA57 (1<<(X86_FEATURE_LA57 & 31))
4545
#endif
4646

47-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
47+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
4848
# define DISABLE_PTI 0
4949
#else
5050
# define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31))

arch/x86/include/asm/pgalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline void paravirt_release_p4d(unsigned long pfn) {}
3434
*/
3535
extern gfp_t __userpte_alloc_gfp;
3636

37-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
37+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
3838
/*
3939
* Instead of one PGD, we acquire two PGDs. Being order-1, it is
4040
* both 8k in size and 8k-aligned. That lets us just flip bit 12

arch/x86/include/asm/pgtable-3level.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
5252

5353
static inline void native_set_pud(pud_t *pudp, pud_t pud)
5454
{
55-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
55+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
5656
pud.p4d.pgd = pti_set_user_pgtbl(&pudp->p4d.pgd, pud.p4d.pgd);
5757
#endif
5858
pxx_xchg64(pud, pudp, native_pud_val(pud));

arch/x86/include/asm/pgtable.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
909909
pmd_t *populate_extra_pmd(unsigned long vaddr);
910910
pte_t *populate_extra_pte(unsigned long vaddr);
911911

912-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
912+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
913913
pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd);
914914

915915
/*
@@ -923,12 +923,12 @@ static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
923923
return pgd;
924924
return __pti_set_user_pgtbl(pgdp, pgd);
925925
}
926-
#else /* CONFIG_PAGE_TABLE_ISOLATION */
926+
#else /* CONFIG_MITIGATION_PAGE_TABLE_ISOLATION */
927927
static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
928928
{
929929
return pgd;
930930
}
931-
#endif /* CONFIG_PAGE_TABLE_ISOLATION */
931+
#endif /* CONFIG_MITIGATION_PAGE_TABLE_ISOLATION */
932932

933933
#endif /* __ASSEMBLY__ */
934934

@@ -1131,7 +1131,7 @@ static inline int p4d_bad(p4d_t p4d)
11311131
{
11321132
unsigned long ignore_flags = _KERNPG_TABLE | _PAGE_USER;
11331133

1134-
if (IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION))
1134+
if (IS_ENABLED(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION))
11351135
ignore_flags |= _PAGE_NX;
11361136

11371137
return (p4d_flags(p4d) & ~ignore_flags) != 0;
@@ -1177,7 +1177,7 @@ static inline int pgd_bad(pgd_t pgd)
11771177
if (!pgtable_l5_enabled())
11781178
return 0;
11791179

1180-
if (IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION))
1180+
if (IS_ENABLED(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION))
11811181
ignore_flags |= _PAGE_NX;
11821182

11831183
return (pgd_flags(pgd) & ~ignore_flags) != _KERNPG_TABLE;
@@ -1422,9 +1422,9 @@ static inline bool pgdp_maps_userspace(void *__ptr)
14221422
#define pgd_leaf pgd_large
14231423
static inline int pgd_large(pgd_t pgd) { return 0; }
14241424

1425-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
1425+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
14261426
/*
1427-
* All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
1427+
* All top-level MITIGATION_PAGE_TABLE_ISOLATION page tables are order-1 pages
14281428
* (8k-aligned and 8k in size). The kernel one is at the beginning 4k and
14291429
* the user one is in the last 4k. To switch between them, you
14301430
* just need to flip the 12th bit in their addresses.
@@ -1469,7 +1469,7 @@ static inline p4d_t *user_to_kernel_p4dp(p4d_t *p4dp)
14691469
{
14701470
return ptr_clear_bit(p4dp, PTI_PGTABLE_SWITCH_BIT);
14711471
}
1472-
#endif /* CONFIG_PAGE_TABLE_ISOLATION */
1472+
#endif /* CONFIG_MITIGATION_PAGE_TABLE_ISOLATION */
14731473

14741474
/*
14751475
* clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
@@ -1484,7 +1484,7 @@ static inline p4d_t *user_to_kernel_p4dp(p4d_t *p4dp)
14841484
static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14851485
{
14861486
memcpy(dst, src, count * sizeof(pgd_t));
1487-
#ifdef CONFIG_PAGE_TABLE_ISOLATION
1487+
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
14881488
if (!static_cpu_has(X86_FEATURE_PTI))
14891489
return;
14901490
/* Clone the user space pgd as well */

arch/x86/include/asm/pgtable_64.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
143143
{
144144
pgd_t pgd;
145145

146-
if (pgtable_l5_enabled() || !IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION)) {
146+
if (pgtable_l5_enabled() ||
147+
!IS_ENABLED(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION)) {
147148
WRITE_ONCE(*p4dp, p4d);
148149
return;
149150
}

0 commit comments

Comments
 (0)