Skip to content

Commit e1ebb2b

Browse files
Krish Sadhukhansuryasaimadhu
authored andcommitted
KVM: SVM: Don't flush cache if hardware enforces cache coherency across encryption domains
In some hardware implementations, coherency between the encrypted and unencrypted mappings of the same physical page in a VM is enforced. In such a system, it is not required for software to flush the VM's page from all CPU caches in the system prior to changing the value of the C-bit for the page. So check that bit before flushing the cache. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lkml.kernel.org/r/20200917212038.5090-4-krish.sadhukhan@oracle.com
1 parent 75d1cc0 commit e1ebb2b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ static void sev_clflush_pages(struct page *pages[], unsigned long npages)
384384
uint8_t *page_virtual;
385385
unsigned long i;
386386

387-
if (npages == 0 || pages == NULL)
387+
if (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 ||
388+
pages == NULL)
388389
return;
389390

390391
for (i = 0; i < npages; i++) {

0 commit comments

Comments
 (0)