diff mbox

[24/33] KVM: PPC: Add cmpwi/cmpdi instruction emulation

Message ID 1403472217-22263-25-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 emulation for the cmpwi and cmpdi instructions.

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

Patch

diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 8a155dd..5160af9 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -114,6 +114,7 @@ 
 #define OP_31_XOP_LHBRX     790
 #define OP_31_XOP_STHBRX    918
 
+#define OP_CMPI 11
 #define OP_ADDIS 15
 #define OP_ORI  24
 #define OP_ANDI 28
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index bde4c1e..7b8acb0 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -531,6 +531,11 @@  int kvmppc_emulate_any_instruction(struct kvm_vcpu *vcpu)
 		kvmppc_set_gpr(vcpu, get_ra(inst), value);
 		kvmppc_emulate_cmp(vcpu, value, 0, true, 0, is_32bit);
 		break;
+	case OP_CMPI:
+		value = kvmppc_get_gpr(vcpu, get_ra(inst));
+		kvmppc_emulate_cmp(vcpu, value, (s16)get_d(inst), true,
+				   get_rt(inst) >> 2, !(get_rt(inst) & 1));
+		break;
 	case 31:
 		switch (get_xop(inst)) {
 		case OP_31_XOP_MFCR: