KVM: MIPS/TLB: Handle virtually tagged icaches
authorJames Hogan <james.hogan@imgtec.com>
Tue, 14 Mar 2017 10:25:46 +0000 (10:25 +0000)
committerJames Hogan <james.hogan@imgtec.com>
Tue, 28 Mar 2017 14:36:17 +0000 (15:36 +0100)
When TLB entries are invalidated in the presence of a virtually tagged
icache, such as that found on Octeon CPUs, flush the icache so that we
don't get a reserved instruction exception even though the TLB mapping
is removed.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: David Daney <david.daney@cavium.com>
Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
arch/mips/kvm/tlb.c

index c215470fdcb0c91cd726461f35af1d55f17aa756..fbab2f7477212634f304157b2959b419b9d52d02 100644 (file)
@@ -185,6 +185,13 @@ int kvm_mips_host_tlb_inv(struct kvm_vcpu *vcpu, unsigned long va,
 
        local_irq_restore(flags);
 
+       /*
+        * We don't want to get reserved instruction exceptions for missing tlb
+        * entries.
+        */
+       if (cpu_has_vtag_icache)
+               flush_icache_all();
+
        if (user && idx_user >= 0)
                kvm_debug("%s: Invalidated guest user entryhi %#lx @ idx %d\n",
                          __func__, (va & VPN2_MASK) |
@@ -260,6 +267,13 @@ int kvm_vz_host_tlb_inv(struct kvm_vcpu *vcpu, unsigned long va)
        htw_start();
        local_irq_restore(flags);
 
+       /*
+        * We don't want to get reserved instruction exceptions for missing tlb
+        * entries.
+        */
+       if (cpu_has_vtag_icache)
+               flush_icache_all();
+
        if (idx > 0)
                kvm_debug("%s: Invalidated root entryhi %#lx @ idx %d\n",
                          __func__, (va & VPN2_MASK) |