This patch adds full emulation support for the mfcr instruction.

Signed-off-by: Alexander Graf <ag...@suse.de>
---
 arch/powerpc/include/asm/ppc-opcode.h |  1 +
 arch/powerpc/kvm/emulate.c            | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 3132bb9..ce135be 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -86,6 +86,7 @@
 #define OP_TRAP_64 2
 
 #define OP_31_XOP_TRAP      4
+#define OP_31_XOP_MFCR      19
 #define OP_31_XOP_LWZX      23
 #define OP_31_XOP_DCBST     54
 #define OP_31_XOP_LWZUX     55
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index e688d85..33a34c3 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -473,6 +473,16 @@ int kvmppc_emulate_any_instruction(struct kvm_vcpu *vcpu)
                emulated = kvmppc_emulate_load(vcpu, addr, &value, 4);
                kvmppc_set_gpr(vcpu, get_rt(inst), value);
                break;
+       case 31:
+               switch (get_xop(inst)) {
+               case OP_31_XOP_MFCR:
+                       kvmppc_set_gpr(vcpu, get_rt(inst), kvmppc_get_cr(vcpu));
+                       break;
+               default:
+                       emulated = EMULATE_FAIL;
+                       break;
+               }
+               break;
        default:
                emulated = EMULATE_FAIL;
                break;
-- 
1.8.1.4

--
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