Skip to content

Commit fc704b5

Browse files
committed
x86/bugs: KVM: Move VM_CLEAR_CPU_BUFFERS into SVM as SVM_CLEAR_CPU_BUFFERS
Now that VMX encodes its own sequence for clearing CPU buffers, move VM_CLEAR_CPU_BUFFERS into SVM to minimize the chances of KVM botching a mitigation in the future, e.g. using VM_CLEAR_CPU_BUFFERS instead of checking multiple mitigation flags. No functional change intended. Reviewed-by: Brendan Jackman <jackmanb@google.com> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://patch.msgid.link/20251113233746.1703361-7-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent e6ff1d6 commit fc704b5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

arch/x86/include/asm/nospec-branch.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@
329329
#define CLEAR_CPU_BUFFERS \
330330
ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF
331331

332-
#define VM_CLEAR_CPU_BUFFERS \
333-
ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF_VM
334-
335332
#ifdef CONFIG_X86_64
336333
.macro CLEAR_BRANCH_HISTORY
337334
ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_LOOP

arch/x86/kvm/svm/vmenter.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
jmp 901b
9393
.endm
9494

95+
#define SVM_CLEAR_CPU_BUFFERS \
96+
ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF_VM
9597

9698
/**
9799
* __svm_vcpu_run - Run a vCPU via a transition to SVM guest mode
@@ -170,7 +172,7 @@ SYM_FUNC_START(__svm_vcpu_run)
170172
mov VCPU_RDI(%_ASM_DI), %_ASM_DI
171173

172174
/* Clobbers EFLAGS.ZF */
173-
VM_CLEAR_CPU_BUFFERS
175+
SVM_CLEAR_CPU_BUFFERS
174176

175177
/* Enter guest mode */
176178
3: vmrun %_ASM_AX
@@ -339,7 +341,7 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run)
339341
mov KVM_VMCB_pa(%rax), %rax
340342

341343
/* Clobbers EFLAGS.ZF */
342-
VM_CLEAR_CPU_BUFFERS
344+
SVM_CLEAR_CPU_BUFFERS
343345

344346
/* Enter guest mode */
345347
1: vmrun %rax

0 commit comments

Comments
 (0)