summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2026-03-11 02:48:17 +0300
committerSean Christopherson <seanjc@google.com>2026-04-09 02:04:25 +0300
commit56906910ea3084cbe82b9078a561130a6203f978 (patch)
tree61c05c78f790e70b32fa40e3cad7517349f3604a
parent138e5f6a3e1172fee8665bc8b1bbe695ba6b2adf (diff)
downloadlinux-56906910ea3084cbe82b9078a561130a6203f978.tar.xz
KVM: SEV: Document the SEV-ES check when querying SMM support as "safe"
Use the "unsafe" API to check for an SEV-ES+ guest when determining whether or not SMBASE is a supported MSR, i.e. whether or not emulated SMM is supported. This will eventually allow adding lockdep assertings to the APIs for detecting SEV+ VMs without triggering "real" false positives. While svm_has_emulated_msr() doesn't hold kvm->lock, i.e. can get both false positives *and* false negatives, both are completely fine, as the only time the result isn't stable is when userspace is the sole consumer of the result. I.e. userspace can confuse itself, but that's it. No functional change intended. Link: https://patch.msgid.link/20260310234829.2608037-10-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--arch/x86/kvm/svm/svm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index d874af3d520a..69a3efc14368 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -4517,9 +4517,17 @@ static bool svm_has_emulated_msr(struct kvm *kvm, u32 index)
case MSR_IA32_SMBASE:
if (!IS_ENABLED(CONFIG_KVM_SMM))
return false;
- /* SEV-ES guests do not support SMM, so report false */
- if (kvm && sev_es_guest(kvm))
+
+#ifdef CONFIG_KVM_AMD_SEV
+ /*
+ * KVM can't access register state to emulate SMM for SEV-ES
+ * guests. Conusming stale data here is "fine", as KVM only
+ * checks for MSR_IA32_SMBASE support without a vCPU when
+ * userspace is querying KVM_CAP_X86_SMM.
+ */
+ if (kvm && ____sev_es_guest(kvm))
return false;
+#endif
break;
default:
break;