]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: MIPS/T&E: Treat unhandled guest KSeg0 as MMIO
authorJames Hogan <james.hogan@imgtec.com>
Mon, 11 May 2015 22:31:45 +0000 (23:31 +0100)
committerJames Hogan <james.hogan@imgtec.com>
Fri, 3 Feb 2017 15:21:21 +0000 (15:21 +0000)
Treat unhandled accesses to guest KSeg0 as MMIO, rather than only host
KSeg0 addresses. This will allow read only memory regions (such as the
Malta boot flash as emulated by QEMU) to have writes (before reads)
treated as MMIO, and unallocated physical addresses to have all accesses
treated as MMIO.

The MMIO emulation uses the gva_to_gpa callback, so this is also updated
for trap & emulate to handle guest KSeg0 addresses.

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: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
arch/mips/kvm/mmu.c
arch/mips/kvm/trap_emul.c

index 1af65f2e6bb7ffd21319b191f2c27dc7e9194815..934bcc3732dae71eb558364b827de46c2c89d25a 100644 (file)
@@ -350,7 +350,6 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
        pfn = gfn_to_pfn(kvm, gfn);
 
        if (is_error_noslot_pfn(pfn)) {
-               kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn);
                err = -EFAULT;
                goto out;
        }
index ae971ae30e30a7040550f5da073163f96ce13704..77e059068a2987533314c669967b01ab010efe18 100644 (file)
@@ -23,9 +23,12 @@ static gpa_t kvm_trap_emul_gva_to_gpa_cb(gva_t gva)
 {
        gpa_t gpa;
        gva_t kseg = KSEGX(gva);
+       gva_t gkseg = KVM_GUEST_KSEGX(gva);
 
        if ((kseg == CKSEG0) || (kseg == CKSEG1))
                gpa = CPHYSADDR(gva);
+       else if (gkseg == KVM_GUEST_KSEG0)
+               gpa = KVM_GUEST_CPHYSADDR(gva);
        else {
                kvm_err("%s: cannot find GPA for GVA: %#lx\n", __func__, gva);
                kvm_mips_dump_host_tlbs();
@@ -240,11 +243,8 @@ static int kvm_trap_emul_handle_tlb_miss(struct kvm_vcpu *vcpu, bool store)
                 * All KSEG0 faults are handled by KVM, as the guest kernel does
                 * not expect to ever get them
                 */
-               if (kvm_mips_handle_kseg0_tlb_fault
-                   (vcpu->arch.host_cp0_badvaddr, vcpu, store) < 0) {
-                       run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
-                       ret = RESUME_HOST;
-               }
+               if (kvm_mips_handle_kseg0_tlb_fault(badvaddr, vcpu, store) < 0)
+                       ret = kvm_mips_bad_access(cause, opc, run, vcpu, store);
        } else if (KVM_GUEST_KERNEL_MODE(vcpu)
                   && (KSEGX(badvaddr) == CKSEG0 || KSEGX(badvaddr) == CKSEG1)) {
                /*