]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SVM: Simplify MSR interception logic for IA32_XSS MSR
authorChao Gao <chao.gao@intel.com>
Thu, 12 Jun 2025 08:19:47 +0000 (01:19 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 25 Jun 2025 16:47:28 +0000 (09:47 -0700)
Use svm_set_intercept_for_msr() directly to configure IA32_XSS MSR
interception, ensuring consistency with other cases where MSRs are
intercepted depending on guest caps and CPUIDs.

No functional change intended.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://lore.kernel.org/r/20250612081947.94081-3-chao.gao@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c

index 0251509b55604caeba09cd80a2237eab2707e60d..3f20f6eb1ef64ba392f4cd50fe833197e0e33af7 100644 (file)
@@ -4410,11 +4410,9 @@ void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu)
         * XSAVES being exposed to the guest so that KVM can at least honor
         * guest CPUID for RDMSR and WRMSR.
         */
-       if (guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVES) &&
-           guest_cpuid_has(vcpu, X86_FEATURE_XSAVES))
-               svm_disable_intercept_for_msr(vcpu, MSR_IA32_XSS, MSR_TYPE_RW);
-       else
-               svm_enable_intercept_for_msr(vcpu, MSR_IA32_XSS, MSR_TYPE_RW);
+       svm_set_intercept_for_msr(vcpu, MSR_IA32_XSS, MSR_TYPE_RW,
+                                 !guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVES) ||
+                                 !guest_cpuid_has(vcpu, X86_FEATURE_XSAVES));
 }
 
 void sev_vcpu_after_set_cpuid(struct vcpu_svm *svm)