Skip to contentSkip to conversation

KVM: VMX: Move VM-exit RSB stuffing out of line

PATCH In review Jim Mattson 2 participants 2 messages Jun 30, 2022 – Jul 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 KVM: VMX: Move VM-exit RSB stuffing out of line

RSB-stuffing after VM-exit is only needed for legacy CPUs without eIBRS. Move the RSB-stuffing code out of line to avoid the JMP on modern CPUs.

Note that CPUs that are subject to SpectreRSB attacks need RSB-stuffing on VM-exit whether or not RETPOLINE is in use as a SpectreBTB mitigation. However, I am leaving the existing mitigation strategy alone.

---
 arch/x86/kvm/vmx/vmenter.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmenter.S +2 -2
index 435c187927c4..ea5986b96004 100644
@@ -76,7 +76,8 @@ SYM_FUNC_END(vmx_vmenter)
  */
 SYM_FUNC_START(vmx_vmexit)
 #ifdef CONFIG_RETPOLINE
-	ALTERNATIVE "jmp .Lvmexit_skip_rsb", "", X86_FEATURE_RETPOLINE
+	ALTERNATIVE "RET", "", X86_FEATURE_RETPOLINE
+
 	/* Preserve guest's RAX, it's used to stuff the RSB. */
 	push %_ASM_AX
 
@@ -87,7 +88,6 @@ SYM_FUNC_START(vmx_vmexit)
 	or $1, %_ASM_AX
 
 	pop %_ASM_AX
-.Lvmexit_skip_rsb:
 #endif
 	RET
 SYM_FUNC_END(vmx_vmexit)
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
#1 lore raw
Quoted 3 lines · Jim Mattson

RSB-stuffing after VM-exit is only needed for legacy CPUs without eIBRS. Move the RSB-stuffing code out of line to avoid the JMP on modern CPUs.

The shortlog and this sentence need to be updated, the stuffing code is still in-line, but the JMP is being dropped.

Quoted 35 lines

Note that CPUs that are subject to SpectreRSB attacks need RSB-stuffing on VM-exit whether or not RETPOLINE is in use as a SpectreBTB mitigation. However, I am leaving the existing mitigation strategy alone.

---
 arch/x86/kvm/vmx/vmenter.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmenter.S +2 -2
index 435c187927c4..ea5986b96004 100644
@@ -76,7 +76,8 @@ SYM_FUNC_END(vmx_vmenter)
  */
 SYM_FUNC_START(vmx_vmexit)
 #ifdef CONFIG_RETPOLINE
-	ALTERNATIVE "jmp .Lvmexit_skip_rsb", "", X86_FEATURE_RETPOLINE
+	ALTERNATIVE "RET", "", X86_FEATURE_RETPOLINE
+
 	/* Preserve guest's RAX, it's used to stuff the RSB. */
 	push %_ASM_AX
 
@@ -87,7 +88,6 @@ SYM_FUNC_START(vmx_vmexit)
 	or $1, %_ASM_AX
 
 	pop %_ASM_AX
-.Lvmexit_skip_rsb:
 #endif
 	RET
 SYM_FUNC_END(vmx_vmexit)
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog