KVM: arm/arm64: Only clean the dcache on translation fault

"Linux Kernel Mailing List" <[email protected]> Sat, 10 Feb 2018 22:00:23 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/a9c0e12ebee56ef06b7eccdbc73bab71d0018df8
Commit:     a9c0e12ebee56ef06b7eccdbc73bab71d0018df8
Parent:     d0e22b4ac3ba23c611739f554392bf5e217df49f
Refname:    refs/heads/master
Author:     Marc Zyngier <[email protected]>
AuthorDate: Mon Oct 23 17:11:20 2017 +0100
Committer:  Christoffer Dall <[email protected]>
CommitDate: Mon Jan 8 15:20:45 2018 +0100

    KVM: arm/arm64: Only clean the dcache on translation fault
    
    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 <[email protected]>
    Signed-off-by: Marc Zyngier <[email protected]>
    Signed-off-by: Christoffer Dall <[email protected]>
---
 virt/kvm/arm/mmu.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 0417c8e2a81c..f956efbd933d 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -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);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html