Skip to content

Commit 706a189

Browse files
sean-jchansendc
authored andcommitted
KVM/VMX: Use BT+JNC, i.e. EFLAGS.CF to select VMRESUME vs. VMLAUNCH
Use EFLAGS.CF instead of EFLAGS.ZF to track whether to use VMRESUME versus VMLAUNCH. Freeing up EFLAGS.ZF will allow doing VERW, which clobbers ZF, for MDS mitigations as late as possible without needing to duplicate VERW for both paths. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Link: https://lore.kernel.org/all/20240213-delay-verw-v8-5-a6216d83edb7%40linux.intel.com
1 parent 6613d82 commit 706a189

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

arch/x86/kvm/vmx/run_flags.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#ifndef __KVM_X86_VMX_RUN_FLAGS_H
33
#define __KVM_X86_VMX_RUN_FLAGS_H
44

5-
#define VMX_RUN_VMRESUME (1 << 0)
6-
#define VMX_RUN_SAVE_SPEC_CTRL (1 << 1)
5+
#define VMX_RUN_VMRESUME_SHIFT 0
6+
#define VMX_RUN_SAVE_SPEC_CTRL_SHIFT 1
7+
8+
#define VMX_RUN_VMRESUME BIT(VMX_RUN_VMRESUME_SHIFT)
9+
#define VMX_RUN_SAVE_SPEC_CTRL BIT(VMX_RUN_SAVE_SPEC_CTRL_SHIFT)
710

811
#endif /* __KVM_X86_VMX_RUN_FLAGS_H */

arch/x86/kvm/vmx/vmenter.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ SYM_FUNC_START(__vmx_vcpu_run)
139139
mov (%_ASM_SP), %_ASM_AX
140140

141141
/* Check if vmlaunch or vmresume is needed */
142-
test $VMX_RUN_VMRESUME, %ebx
142+
bt $VMX_RUN_VMRESUME_SHIFT, %ebx
143143

144144
/* Load guest registers. Don't clobber flags. */
145145
mov VCPU_RCX(%_ASM_AX), %_ASM_CX
@@ -161,8 +161,8 @@ SYM_FUNC_START(__vmx_vcpu_run)
161161
/* Load guest RAX. This kills the @regs pointer! */
162162
mov VCPU_RAX(%_ASM_AX), %_ASM_AX
163163

164-
/* Check EFLAGS.ZF from 'test VMX_RUN_VMRESUME' above */
165-
jz .Lvmlaunch
164+
/* Check EFLAGS.CF from the VMX_RUN_VMRESUME bit test above. */
165+
jnc .Lvmlaunch
166166

167167
/*
168168
* After a successful VMRESUME/VMLAUNCH, control flow "magically"

0 commit comments

Comments
 (0)