Skip to content

Commit e268bee

Browse files
committed
KVM: SVM: Mark VMCB dirty before processing incoming snp_vmsa_gpa
Mark the VMCB dirty, i.e. zero control.clean, prior to handling the new VMSA. Nothing in the VALID_PAGE() case touches control.clean, and isolating the VALID_PAGE() code will allow simplifying the overall logic. Note, the VMCB probably doesn't need to be marked dirty when the VMSA is invalid, as KVM will disallow running the vCPU in such a state. But it also doesn't hurt anything. Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20250227012541.3234589-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 4633243 commit e268bee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,6 +3855,12 @@ static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
38553855
/* Clear use of the VMSA */
38563856
svm->vmcb->control.vmsa_pa = INVALID_PAGE;
38573857

3858+
/*
3859+
* When replacing the VMSA during SEV-SNP AP creation,
3860+
* mark the VMCB dirty so that full state is always reloaded.
3861+
*/
3862+
vmcb_mark_all_dirty(svm->vmcb);
3863+
38583864
if (VALID_PAGE(svm->sev_es.snp_vmsa_gpa)) {
38593865
gfn_t gfn = gpa_to_gfn(svm->sev_es.snp_vmsa_gpa);
38603866
struct kvm_memory_slot *slot;
@@ -3901,12 +3907,6 @@ static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
39013907
kvm_release_page_clean(page);
39023908
}
39033909

3904-
/*
3905-
* When replacing the VMSA during SEV-SNP AP creation,
3906-
* mark the VMCB dirty so that full state is always reloaded.
3907-
*/
3908-
vmcb_mark_all_dirty(svm->vmcb);
3909-
39103910
return 0;
39113911
}
39123912

0 commit comments

Comments
 (0)