KVM: SVM: Refuse to attempt VRMUN if an SEV-ES+ guest has an invalid VMSA
authorSean Christopherson <seanjc@google.com>
Thu, 27 Feb 2025 01:25:34 +0000 (17:25 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 3 Mar 2025 15:33:43 +0000 (07:33 -0800)
commit72d12715edcd06cf1ef581c36633c44d43558f32
tree6528bc1da9e44b79dc40b36c5b9f35b2995c29f0
parentd4b69c3d1471a7fa48111b3bb6489e7c5a5bcb2a
KVM: SVM: Refuse to attempt VRMUN if an SEV-ES+ guest has an invalid VMSA

Explicitly reject KVM_RUN with KVM_EXIT_FAIL_ENTRY if userspace "coerces"
KVM into running an SEV-ES+ guest with an invalid VMSA, e.g. by modifying
a vCPU's mp_state to be RUNNABLE after an SNP vCPU has undergone a Destroy
event.  On Destroy or failed Create, KVM marks the vCPU HALTED so that
*KVM* doesn't run the vCPU, but nothing prevents a misbehaving VMM from
manually making the vCPU RUNNABLE via KVM_SET_MP_STATE.

Attempting VMRUN with an invalid VMSA should be harmless, but knowingly
executing VMRUN with bad control state is at best dodgy.

Fixes: e366f92ea99e ("KVM: SEV: Support SEV-SNP AP Creation NAE event")
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Link: https://lore.kernel.org/r/20250227012541.3234589-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h