[PATCH 4.1 64/65] pti: Rename X86_FEATURE_KAISER to X86_FEATURE_PTI

From: Pavel Tatashin
Date: Mon Mar 05 2018 - 19:27:39 EST


cat /proc/cpuinfo still shows kaiser feature, and want only pti
to be visible to users. Therefore, rename this macro to get
correct user visible output.

Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
Signed-off-by: Brian Maly <brian.maly@xxxxxxxxxx>
---
arch/x86/include/asm/cpufeature.h | 2 +-
arch/x86/include/asm/kaiser.h | 6 +++---
arch/x86/kernel/entry_64.S | 12 ++++++------
arch/x86/mm/kaiser.c | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index a22aa8c5903c..fc790e2f0d4e 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -202,7 +202,7 @@
#define X86_FEATURE_KAISER ( 7*32+31) /* CONFIG_KAISER w/o nokaiser */

/* Because the ALTERNATIVE scheme is for members of the X86_FEATURE club... */
-#define X86_FEATURE_KAISER ( 7*32+31) /* CONFIG_PAGE_TABLE_ISOLATION w/o nokaiser */
+#define X86_FEATURE_PTI ( 7*32+31) /* CONFIG_PAGE_TABLE_ISOLATION w/o nopti */

/* Virtualization flags: Linux defined, word 8 */
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/include/asm/kaiser.h b/arch/x86/include/asm/kaiser.h
index 802bbbdfe143..5d85ddf26166 100644
--- a/arch/x86/include/asm/kaiser.h
+++ b/arch/x86/include/asm/kaiser.h
@@ -47,14 +47,14 @@ movq \reg, %cr3
.endm

.macro SWITCH_KERNEL_CR3
-ALTERNATIVE "jmp 8f", "pushq %rax", X86_FEATURE_KAISER
+ALTERNATIVE "jmp 8f", "pushq %rax", X86_FEATURE_PTI
_SWITCH_TO_KERNEL_CR3 %rax
popq %rax
8:
.endm

.macro SWITCH_USER_CR3
-ALTERNATIVE "jmp 8f", "pushq %rax", X86_FEATURE_KAISER
+ALTERNATIVE "jmp 8f", "pushq %rax", X86_FEATURE_PTI
_SWITCH_TO_USER_CR3 %rax %al
popq %rax
8:
@@ -63,7 +63,7 @@ popq %rax
.macro SWITCH_KERNEL_CR3_NO_STACK
ALTERNATIVE "jmp 8f", \
__stringify(movq %rax, PER_CPU_VAR(unsafe_stack_register_backup)), \
- X86_FEATURE_KAISER
+ X86_FEATURE_PTI
_SWITCH_TO_KERNEL_CR3 %rax
movq PER_CPU_VAR(unsafe_stack_register_backup), %rax
8:
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 95b57f4393b7..204dfb58c9f0 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1327,7 +1327,7 @@ ENTRY(paranoid_entry)
* unconditionally, but we need to find out whether the reverse
* should be done on return (conveyed to paranoid_exit in %ebx).
*/
- ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_KAISER
+ ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_PTI
testl $KAISER_SHADOW_PGD_OFFSET, %eax
jz 2f
orl $2, %ebx
@@ -1361,7 +1361,7 @@ ENTRY(paranoid_exit)
TRACE_IRQS_OFF_DEBUG
TRACE_IRQS_IRETQ_DEBUG
#ifdef CONFIG_PAGE_TABLE_ISOLATION
- /* No ALTERNATIVE for X86_FEATURE_KAISER: paranoid_entry sets %ebx */
+ /* No ALTERNATIVE for X86_FEATURE_PTI: paranoid_entry sets %ebx */
testl $2, %ebx /* SWITCH_USER_CR3 needed? */
jz paranoid_exit_no_switch
SWITCH_USER_CR3
@@ -1567,7 +1567,7 @@ ENTRY(nmi)
#ifdef CONFIG_PAGE_TABLE_ISOLATION
/* Unconditionally use kernel CR3 for do_nmi() */
/* %rax is saved above, so OK to clobber here */
- ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_KAISER
+ ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_PTI
/* If PCID enabled, NOFLUSH now and NOFLUSH on return */
ALTERNATIVE "", "bts $63, %rax", X86_FEATURE_PCID
pushq %rax
@@ -1583,7 +1583,7 @@ ENTRY(nmi)
* kernel code that needs user CR3, but do we ever return
* to "user mode" where we need the kernel CR3?
*/
- ALTERNATIVE "", "popq %rax; movq %rax, %cr3", X86_FEATURE_KAISER
+ ALTERNATIVE "", "popq %rax; movq %rax, %cr3", X86_FEATURE_PTI
#endif
/*
* Return back to user mode. We must *not* do the normal exit
@@ -1806,7 +1806,7 @@ end_repeat_nmi:
#ifdef CONFIG_PAGE_TABLE_ISOLATION
/* Unconditionally use kernel CR3 for do_nmi() */
/* %rax is saved above, so OK to clobber here */
- ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_KAISER
+ ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_PTI
/* If PCID enabled, NOFLUSH now and NOFLUSH on return */
ALTERNATIVE "", "bts $63, %rax", X86_FEATURE_PCID
pushq %rax
@@ -1825,7 +1825,7 @@ end_repeat_nmi:
* kernel code that needs user CR3, like just just before
* a sysret.
*/
- ALTERNATIVE "", "popq %rax; movq %rax, %cr3", X86_FEATURE_KAISER
+ ALTERNATIVE "", "popq %rax; movq %rax, %cr3", X86_FEATURE_PTI
#endif

testl %ebx,%ebx /* swapgs needed? */
diff --git a/arch/x86/mm/kaiser.c b/arch/x86/mm/kaiser.c
index 05fb616c9e2a..e37ac77e6cb6 100644
--- a/arch/x86/mm/kaiser.c
+++ b/arch/x86/mm/kaiser.c
@@ -289,14 +289,14 @@ skip:

enable:
if (enable)
- setup_force_cpu_cap(X86_FEATURE_KAISER);
+ setup_force_cpu_cap(X86_FEATURE_PTI);

return;

disable:
pr_info("Kernel/User page tables isolation: disabled\n");
kaiser_enabled = 0;
- setup_clear_cpu_cap(X86_FEATURE_KAISER);
+ setup_clear_cpu_cap(X86_FEATURE_PTI);
}

/*
--
2.16.2