All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH non-atomic-injection] x86 emulator: Add cwd/cdq/cqo instruction (opcode 0x99)
@ 2010-08-19 14:25 Mohammed Gamal
  2010-08-22 11:34 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Mohammed Gamal @ 2010-08-19 14:25 UTC (permalink / raw)
  To: avi; +Cc: kvm, Mohammed Gamal

Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
 arch/x86/kvm/emulate.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index ee4bb69..fddf76d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2421,7 +2421,7 @@ static struct opcode opcode_table[256] = {
 	/* 0x90 - 0x97 */
 	X8(D(SrcAcc | DstReg)),
 	/* 0x98 - 0x9F */
-	D(DstAcc | SrcNone), N, D(SrcImmFAddr | No64), N,
+	D(DstAcc | SrcNone), D(ImplicitOps), D(SrcImmFAddr | No64), N,
 	D(ImplicitOps | Stack), D(ImplicitOps | Stack), N, N,
 	/* 0xA0 - 0xA7 */
 	D(ByteOp | DstAcc | SrcMem | Mov | MemAbs), D(DstAcc | SrcMem | Mov | MemAbs),
@@ -3161,6 +3161,20 @@ special_insn:
 		case 8: c->dst.val = (s32)c->dst.val; break;
 		}
 		break;
+	case 0x99: /* cwd/cdq/cqo */ {
+		unsigned long rax = c->regs[VCPU_REGS_RAX];
+		unsigned long sign_bit = 1 << ((c->op_bytes * 8) - 1);
+
+		if (rax & sign_bit) {
+			switch (c->op_bytes) {
+			case 2: c->regs[VCPU_REGS_RDX] = 0xffff; break;
+			case 4: c->regs[VCPU_REGS_RDX] = 0xffffffff; break;
+			case 8: c->regs[VCPU_REGS_RDX] = 0xffffffffffffffff; break;
+			}
+		} else 
+			c->regs[VCPU_REGS_RDX] = 0;
+		}
+		break;
 	case 0x9c: /* pushf */
 		c->src.val =  (unsigned long) ctxt->eflags;
 		emulate_push(ctxt, ops);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-22 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-19 14:25 [PATCH non-atomic-injection] x86 emulator: Add cwd/cdq/cqo instruction (opcode 0x99) Mohammed Gamal
2010-08-22 11:34 ` Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.