KVM: arm/arm64: Only clean the dcache on translation fault
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 23 Oct 2017 16:11:20 +0000 (17:11 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Mon, 8 Jan 2018 14:20:45 +0000 (15:20 +0100)
The only case where we actually need to perform a dcache maintenance
is when we map the page for the first time, and subsequent permission
faults do not require cache maintenance. Let's make it conditional
on not being a permission fault (and thus a translation fault).

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
virt/kvm/arm/mmu.c

index 0417c8e2a81cb2f25d32db17f29d2a25e48ac1ba..f956efbd933d2614cc58922c4d7290114d1168e0 100644 (file)
@@ -1400,7 +1400,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                        new_pmd = kvm_s2pmd_mkwrite(new_pmd);
                        kvm_set_pfn_dirty(pfn);
                }
-               clean_dcache_guest_page(vcpu, pfn, PMD_SIZE);
+
+               if (fault_status != FSC_PERM)
+                       clean_dcache_guest_page(vcpu, pfn, PMD_SIZE);
 
                if (exec_fault) {
                        new_pmd = kvm_s2pmd_mkexec(new_pmd);
@@ -1416,7 +1418,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                        kvm_set_pfn_dirty(pfn);
                        mark_page_dirty(kvm, gfn);
                }
-               clean_dcache_guest_page(vcpu, pfn, PAGE_SIZE);
+
+               if (fault_status != FSC_PERM)
+                       clean_dcache_guest_page(vcpu, pfn, PAGE_SIZE);
 
                if (exec_fault) {
                        new_pte = kvm_s2pte_mkexec(new_pte);