]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Skip OSVW MSR reads if current CPU doesn't support the feature
authorSean Christopherson <seanjc@google.com>
Thu, 13 Nov 2025 23:14:20 +0000 (15:14 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 3 Mar 2026 20:23:26 +0000 (12:23 -0800)
Skip the OSVW RDMSRs if the current CPU doesn't enumerate support for the
MSRs.  In practice, checking only the boot CPU's capabilities is
sufficient, as the RDMSRs should fault when unsupported, but there's no
downside to being more precise, and checking only the boot CPU _looks_
wrong given the rather odd semantics of the MSRs.  E.g. if a CPU doesn't
support OVSW, then KVM must assume all errata are present.

Link: https://patch.msgid.link/20251113231420.1695919-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c

index 5c4328f426049b3b7492fe74d60128a48fd9b44c..3f3290d5a0a6ef6b8b4acbc2866b9a36ebafb7c2 100644 (file)
@@ -447,12 +447,8 @@ static void svm_init_os_visible_workarounds(void)
        if (!osvw_len)
                return;
 
-       if (!boot_cpu_has(X86_FEATURE_OSVW)) {
-               osvw_status = osvw_len = 0;
-               return;
-       }
-
-       if (native_read_msr_safe(MSR_AMD64_OSVW_ID_LENGTH, &len) ||
+       if (!this_cpu_has(X86_FEATURE_OSVW) ||
+           native_read_msr_safe(MSR_AMD64_OSVW_ID_LENGTH, &len) ||
            native_read_msr_safe(MSR_AMD64_OSVW_STATUS, &status))
                len = status = 0;