Commit 15505679 authored by James Hogan's avatar James Hogan Committed by Paolo Bonzini

MIPS: KVM: Pass reserved instruction exceptions to guest

Previously a reserved instruction exception while in guest code would
cause a KVM internal error if kvm_mips_handle_ri() didn't recognise the
instruction (including a RDHWR from an unrecognised hardware register).

However the guest OS should really have the opportunity to catch the
exception so that it can take the appropriate actions such as sending a
SIGILL to the guest user process or emulating the instruction itself.

Therefore in these cases emulate a guest RI exception and only return
EMULATE_FAIL if that fails, being careful to revert the PC first in case
the exception occurred in a branch delay slot in which case the PC will
already point to the branch target.

Also turn the printk messages relating to these cases into kvm_debug
messages so that they aren't usually visible.

This allows crashme to run in the guest without killing the entire VM.
Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sanjay Lal <sanjayl@kymasys.com>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 22027945
...@@ -1571,17 +1571,17 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc, ...@@ -1571,17 +1571,17 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc,
arch->gprs[rt] = kvm_read_c0_guest_userlocal(cop0); arch->gprs[rt] = kvm_read_c0_guest_userlocal(cop0);
#else #else
/* UserLocal not implemented */ /* UserLocal not implemented */
er = kvm_mips_emulate_ri_exc(cause, opc, run, vcpu); er = EMULATE_FAIL;
#endif #endif
break; break;
default: default:
printk("RDHWR not supported\n"); kvm_debug("RDHWR %#x not supported @ %p\n", rd, opc);
er = EMULATE_FAIL; er = EMULATE_FAIL;
break; break;
} }
} else { } else {
printk("Emulate RI not supported @ %p: %#x\n", opc, inst); kvm_debug("Emulate RI not supported @ %p: %#x\n", opc, inst);
er = EMULATE_FAIL; er = EMULATE_FAIL;
} }
...@@ -1590,6 +1590,7 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc, ...@@ -1590,6 +1590,7 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc,
*/ */
if (er == EMULATE_FAIL) { if (er == EMULATE_FAIL) {
vcpu->arch.pc = curr_pc; vcpu->arch.pc = curr_pc;
er = kvm_mips_emulate_ri_exc(cause, opc, run, vcpu);
} }
return er; return er;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment