svm_recalc_instruction_intercepts(vcpu, svm);
/*
- * If the host supports V_SPEC_CTRL then disable the interception
- * of MSR_IA32_SPEC_CTRL.
+ * If the CPU virtualizes MSR_IA32_SPEC_CTRL, i.e. KVM doesn't need to
+ * manually context switch the MSR, immediately configure interception
+ * of SPEC_CTRL, without waiting for the guest to access the MSR.
*/
if (boot_cpu_has(X86_FEATURE_V_SPEC_CTRL))
- set_msr_interception(vcpu, svm->msrpm, MSR_IA32_SPEC_CTRL, 1, 1);
+ set_msr_interception(vcpu, svm->msrpm, MSR_IA32_SPEC_CTRL,
+ guest_has_spec_ctrl_msr(vcpu),
+ guest_has_spec_ctrl_msr(vcpu));
if (kvm_vcpu_apicv_active(vcpu))
avic_init_vmcb(svm, vmcb);