qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 2/3] arm/arm64: KVM: decouple READONLY and UNCAC


From: Andrew Jones
Subject: [Qemu-devel] [RFC PATCH 2/3] arm/arm64: KVM: decouple READONLY and UNCACHED
Date: Wed, 18 Mar 2015 15:10:32 -0400

KVM_MEM_UNCACHED memory will no longer need caches to be flushed
for memory as it's faulted in. Just use READONLY directly, in that
case, now.

Signed-off-by: Andrew Jones <address@hidden>
---
 arch/arm/kvm/mmu.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 719931e83c468..59af5ad779eb6 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1260,7 +1260,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, 
phys_addr_t fault_ipa,
        if (!hugetlb && !force_pte)
                hugetlb = transparent_hugepage_adjust(&pfn, &fault_ipa);
 
-       fault_ipa_uncached = memslot->flags & KVM_MEM_UNCACHED;
+       /*
+        * Readonly memslots are not incoherent with the caches by definition,
+        * but in practice, they are used mostly to emulate ROMs or NOR flashes
+        * that the guest may consider devices and hence map as uncached.
+        * To prevent incoherency issues in these cases, force dcache flushes
+        * for all pages in the region as they're faulted in.
+        */
+       fault_ipa_uncached = (memslot->flags & KVM_MEM_READONLY) &&
+                               !(memslot->flags & KVM_MEM_UNCACHED);
 
        if (hugetlb) {
                pmd_t new_pmd = pfn_pmd(pfn, mem_type);
@@ -1784,15 +1792,6 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct 
kvm_memory_slot *free,
 int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
                            unsigned long npages)
 {
-       /*
-        * Readonly memslots are not incoherent with the caches by definition,
-        * but in practice, they are used mostly to emulate ROMs or NOR flashes
-        * that the guest may consider devices and hence map as uncached.
-        * To prevent incoherency issues in these cases, tag all readonly
-        * regions as incoherent.
-        */
-       if (slot->flags & KVM_MEM_READONLY)
-               slot->flags |= KVM_MEM_UNCACHED;
        return 0;
 }
 
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]