[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251113231420.1695919-6-seanjc@google.com>
Date: Thu, 13 Nov 2025 15:14:20 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] KVM: SVM: Skip OSVW MSR reads if current CPU doesn't
support the feature
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.
Signed-off-by: Sean Christopherson <seanjc@...gle.com>
---
arch/x86/kvm/svm/svm.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 152c56762b26..c971a15453be 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -443,12 +443,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;
--
2.52.0.rc1.455.g30608eb744-goog
Powered by blists - more mailing lists