Skip to content

Commit ea262f8

Browse files
ashkalrabonzini
authored andcommitted
KVM: SEV: Avoid WBINVD for HVA-based MMU notifications for SNP
With SNP/guest_memfd, private/encrypted memory should not be mappable, and MMU notifications for HVA-mapped memory will only be relevant to unencrypted guest memory. Therefore, the rationale behind issuing a wbinvd_on_all_cpus() in sev_guest_memory_reclaimed() should not apply for SNP guests and can be ignored. Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> [mdr: Add some clarifications in commit] Signed-off-by: Michael Roth <michael.roth@amd.com> Message-ID: <20240501085210.2213060-17-michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent b210402 commit ea262f8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3039,7 +3039,13 @@ static void sev_flush_encrypted_page(struct kvm_vcpu *vcpu, void *va)
30393039

30403040
void sev_guest_memory_reclaimed(struct kvm *kvm)
30413041
{
3042-
if (!sev_guest(kvm))
3042+
/*
3043+
* With SNP+gmem, private/encrypted memory is unreachable via the
3044+
* hva-based mmu notifiers, so these events are only actually
3045+
* pertaining to shared pages where there is no need to perform
3046+
* the WBINVD to flush associated caches.
3047+
*/
3048+
if (!sev_guest(kvm) || sev_snp_guest(kvm))
30433049
return;
30443050

30453051
wbinvd_on_all_cpus();

0 commit comments

Comments
 (0)