Skip to content

Commit 4e96f01

Browse files
committed
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 <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20250227012541.3234589-11-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 5279d6f commit 4e96f01

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3880,6 +3880,7 @@ void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu)
38803880
return;
38813881

38823882
gfn = gpa_to_gfn(svm->sev_es.snp_vmsa_gpa);
3883+
svm->sev_es.snp_vmsa_gpa = INVALID_PAGE;
38833884

38843885
slot = gfn_to_memslot(vcpu->kvm, gfn);
38853886
if (!slot)
@@ -3910,8 +3911,6 @@ void sev_snp_init_protected_guest_state(struct kvm_vcpu *vcpu)
39103911
vcpu->arch.pv.pv_unhalted = false;
39113912
vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
39123913

3913-
svm->sev_es.snp_vmsa_gpa = INVALID_PAGE;
3914-
39153914
/*
39163915
* gmem pages aren't currently migratable, but if this ever changes
39173916
* then care should be taken to ensure svm->sev_es.vmsa is pinned

0 commit comments

Comments
 (0)