Skip to content

Commit bff903e

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: 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> Message-Id: <20230322011440.2195485-4-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 9a4c485 commit bff903e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,6 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
29552955
break;
29562956

29572957
wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB);
2958-
set_msr_interception(vcpu, svm->msrpm, MSR_IA32_PRED_CMD, 0, 1);
29592958
break;
29602959
case MSR_AMD64_VIRT_SPEC_CTRL:
29612960
if (!msr->host_initiated &&
@@ -4151,6 +4150,10 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
41514150

41524151
svm_recalc_instruction_intercepts(vcpu, svm);
41534152

4153+
if (boot_cpu_has(X86_FEATURE_IBPB))
4154+
set_msr_interception(vcpu, svm->msrpm, MSR_IA32_PRED_CMD, 0,
4155+
!!guest_has_pred_cmd_msr(vcpu));
4156+
41544157
/* For sev guests, the memory encryption bit is not reserved in CR3. */
41554158
if (sev_guest(vcpu->kvm)) {
41564159
best = kvm_find_cpuid_entry(vcpu, 0x8000001F);

0 commit comments

Comments
 (0)