diff mbox

[18/33] KVM: PPC: Add mfcr instruction emulation

Message ID 1403472217-22263-19-git-send-email-agraf@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Graf June 22, 2014, 9:23 p.m. UTC
This patch adds full emulation support for the mfcr instruction.

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

Patch

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;