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 <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> [mdr: Add some clarifications in commit] Signed-off-by: Michael Roth <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent b210402 commit ea262f8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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)