From: Sean Christopherson Date: Thu, 27 Feb 2025 01:25:41 +0000 (-0800) Subject: KVM: SVM: Invalidate "next" SNP VMSA GPA even on failure X-Git-Tag: v6.15-rc1~195^2~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e96f010afb2815e33c9b15a695e0e0b4cb3cea6;p=thirdparty%2Fkernel%2Flinux.git KVM: SVM: Invalidate "next" SNP VMSA GPA even on failure When processing an SNP AP Creation event, invalidate the "next" VMSA GPA even if acquiring the page/pfn for the new VMSA fails. In practice, the next GPA will never be used regardless of whether or not its invalidated, as the entire flow is guarded by snp_ap_waiting_for_reset, and said guard and snp_vmsa_gpa are always written as a pair. But that's really hard to see in the code. Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20250227012541.3234589-11-seanjc@google.com Signed-off-by: Sean Christopherson --- diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index f1139e2251b67..ea50f44a22394 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3880,6 +3880,7 @@ void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu) return; gfn = gpa_to_gfn(svm->sev_es.snp_vmsa_gpa); + svm->sev_es.snp_vmsa_gpa = INVALID_PAGE; slot = gfn_to_memslot(vcpu->kvm, gfn); if (!slot) @@ -3910,8 +3911,6 @@ void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu) vcpu->arch.pv.pv_unhalted = false; vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; - svm->sev_es.snp_vmsa_gpa = INVALID_PAGE; - /* * gmem pages aren't currently migratable, but if this ever changes * then care should be taken to ensure svm->sev_es.vmsa is pinned