Skip to content

Commit c8c340a

Browse files
masa-kozbonzini
authored andcommitted
KVM: SEV: Flush cache on non-coherent systems before RECEIVE_UPDATE_DATA
Flush the destination page before invoking RECEIVE_UPDATE_DATA, as the PSP encrypts the data with the guest's key when writing to guest memory. If the target memory was not previously encrypted, the cache may contain dirty, unecrypted data that will persist on non-coherent systems. Fixes: 15fb7de ("KVM: SVM: Add KVM_SEV_RECEIVE_UPDATE_DATA command") Cc: [email protected] Cc: Peter Gonda <[email protected]> Cc: Marc Orr <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Brijesh Singh <[email protected]> Signed-off-by: Masahiro Kozuka <[email protected]> [sean: converted bug report to changelog] Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a3ca528 commit c8c340a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,13 @@ static int sev_receive_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
14841484
goto e_free_trans;
14851485
}
14861486

1487+
/*
1488+
* Flush (on non-coherent CPUs) before RECEIVE_UPDATE_DATA, the PSP
1489+
* encrypts the written data with the guest's key, and the cache may
1490+
* contain dirty, unencrypted data.
1491+
*/
1492+
sev_clflush_pages(guest_page, n);
1493+
14871494
/* The RECEIVE_UPDATE_DATA command requires C-bit to be always set. */
14881495
data.guest_address = (page_to_pfn(guest_page[0]) << PAGE_SHIFT) + offset;
14891496
data.guest_address |= sev_me_mask;

0 commit comments

Comments
 (0)