Skip to content

Commit 9a4c485

Browse files
sean-jcbonzini
authored andcommitted
KVM: VMX: Passthrough MSR_IA32_PRED_CMD based purely on host+guest CPUID
Passthrough MSR_IA32_PRED_CMD based purely on whether or not the MSR is supported and enabled, i.e. don't wait until the first write. There's no benefit to deferred passthrough, and the extra logic only adds complexity. Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Message-Id: <20230322011440.2195485-3-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 52887af commit 9a4c485

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,19 +2298,6 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
22982298
break;
22992299

23002300
wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB);
2301-
2302-
/*
2303-
* For non-nested:
2304-
* When it's written (to non-zero) for the first time, pass
2305-
* it through.
2306-
*
2307-
* For nested:
2308-
* The handling of the MSR bitmap for L2 guests is done in
2309-
* nested_vmx_prepare_msr_bitmap. We should not touch the
2310-
* vmcs02.msr_bitmap here since it gets completely overwritten
2311-
* in the merging.
2312-
*/
2313-
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_PRED_CMD, MSR_TYPE_W);
23142301
break;
23152302
case MSR_IA32_CR_PAT:
23162303
if (!kvm_pat_valid(data))
@@ -7743,6 +7730,9 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
77437730
vmx_set_intercept_for_msr(vcpu, MSR_IA32_XFD_ERR, MSR_TYPE_R,
77447731
!guest_cpuid_has(vcpu, X86_FEATURE_XFD));
77457732

7733+
if (boot_cpu_has(X86_FEATURE_IBPB))
7734+
vmx_set_intercept_for_msr(vcpu, MSR_IA32_PRED_CMD, MSR_TYPE_W,
7735+
!guest_has_pred_cmd_msr(vcpu));
77467736

77477737
set_cr4_guest_host_mask(vmx);
77487738

0 commit comments

Comments
 (0)