This is a note to let you know that I have just added a patch titled

    MIPS: KVM: Pass reserved instruction exceptions to guest

to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree 
which can be found at:

 
http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.11.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

>From 601f48b64bb897630769c2ff7f353c1b0b7e3288 Mon Sep 17 00:00:00 2001
From: James Hogan <james.ho...@imgtec.com>
Date: Fri, 14 Mar 2014 13:06:07 +0000
Subject: MIPS: KVM: Pass reserved instruction exceptions to guest

commit 15505679362270d02c449626385cb74af8905514 upstream.

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: James Hogan <james.ho...@imgtec.com>
Cc: Ralf Baechle <r...@linux-mips.org>
Cc: Gleb Natapov <g...@kernel.org>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Sanjay Lal <sanj...@kymasys.com>
Cc: linux-m...@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
Signed-off-by: Luis Henriques <luis.henriq...@canonical.com>
---
 arch/mips/kvm/kvm_mips_emul.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kvm/kvm_mips_emul.c b/arch/mips/kvm/kvm_mips_emul.c
index 4b6274b..e75ef82 100644
--- a/arch/mips/kvm/kvm_mips_emul.c
+++ b/arch/mips/kvm/kvm_mips_emul.c
@@ -1571,17 +1571,17 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc,
                        arch->gprs[rt] = kvm_read_c0_guest_userlocal(cop0);
 #else
                        /* UserLocal not implemented */
-                       er = kvm_mips_emulate_ri_exc(cause, opc, run, vcpu);
+                       er = EMULATE_FAIL;
 #endif
                        break;

                default:
-                       printk("RDHWR not supported\n");
+                       kvm_debug("RDHWR %#x not supported @ %p\n", rd, opc);
                        er = EMULATE_FAIL;
                        break;
                }
        } 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;
        }

@@ -1590,6 +1590,7 @@ kvm_mips_handle_ri(unsigned long cause, uint32_t *opc,
         */
        if (er == EMULATE_FAIL) {
                vcpu->arch.pc = curr_pc;
+               er = kvm_mips_emulate_ri_exc(cause, opc, run, vcpu);
        }
        return er;
 }
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to