From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYJMf-00008b-PD for qemu-devel@nongnu.org; Wed, 18 Mar 2015 15:10:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYJMZ-0005Fm-PM for qemu-devel@nongnu.org; Wed, 18 Mar 2015 15:10:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYJMZ-0005FZ-Gg for qemu-devel@nongnu.org; Wed, 18 Mar 2015 15:10:43 -0400 From: Andrew Jones Date: Wed, 18 Mar 2015 15:10:32 -0400 Message-Id: <1426705833-2679-3-git-send-email-drjones@redhat.com> In-Reply-To: <1426705833-2679-1-git-send-email-drjones@redhat.com> References: <1426705700-2564-1-git-send-email-drjones@redhat.com> <1426705833-2679-1-git-send-email-drjones@redhat.com> Subject: [Qemu-devel] [RFC PATCH 2/3] arm/arm64: KVM: decouple READONLY and UNCACHED List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org, ard.biesheuvel@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, peter.maydell@linaro.org, pbonzini@redhat.com Cc: catalin.marinas@arm.com, lersek@redhat.com, agraf@suse.de, m.smarduch@samsung.com 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 --- 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