[PATCH 2/6] x86/mm/kaiser: Fix inconsistency in SAVE_AND_SWITCH_TO_KERNEL_CR3

From: Peter Zijlstra
Date: Wed Nov 29 2017 - 05:36:22 EST


For some obscure reason \scratch_reg is not including the %r while
\save_reg is.

Also-Reported-by: Borislav Petkov <bp@xxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/entry/calling.h | 10 +++++-----
arch/x86/entry/entry_64.S | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)

--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -227,8 +227,8 @@ For 32-bit we have the following convent

.macro SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg:req save_reg:req
STATIC_JUMP_IF_FALSE .Ldone_\@, kaiser_enabled_key, def=1
- movq %cr3, %r\scratch_reg
- movq %r\scratch_reg, \save_reg
+ movq %cr3, \scratch_reg
+ movq \scratch_reg, \save_reg
/*
* Is the "switch mask" all zero? That means that both of
* these are zero:
@@ -239,11 +239,11 @@ For 32-bit we have the following convent
*
* That indicates a kernel CR3 value, not user/shadow.
*/
- testq $(KAISER_SWITCH_MASK), %r\scratch_reg
+ testq $(KAISER_SWITCH_MASK), \scratch_reg
jz .Ldone_\@

- ADJUST_KERNEL_CR3 %r\scratch_reg
- movq %r\scratch_reg, %cr3
+ ADJUST_KERNEL_CR3 \scratch_reg
+ movq \scratch_reg, %cr3

.Ldone_\@:
.endm
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1254,7 +1254,7 @@ ENTRY(paranoid_entry)
xorl %ebx, %ebx

1:
- SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg=ax save_reg=%r14
+ SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg=%rax save_reg=%r14

ret
END(paranoid_entry)