* [PATCH] KVM: x86 emulator: add CBW/CWDE/CDQE instruction emulation
@ 2010-08-18 8:43 Wei Yongjun
2010-08-18 8:44 ` [PATCH] test: Add real mode test for cbw/cwde instruction Wei Yongjun
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2010-08-18 8:43 UTC (permalink / raw)
To: Avi Kivity, kvm
Add CBW/CWDE/CDQE instruction emulation.(opcode 0x98)
Used by FreeBSD's boot loader.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/emulate.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 46b7da8..1d36c38 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2290,7 +2290,7 @@ static struct opcode opcode_table[256] = {
/* 0x90 - 0x97 */
X8(D(SrcAcc | DstReg)),
/* 0x98 - 0x9F */
- N, N, D(SrcImmFAddr | No64), N,
+ D(DstAcc | SrcNone), N, 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),
@@ -3011,6 +3011,13 @@ special_insn:
if (c->dst.addr.reg == &c->regs[VCPU_REGS_RAX])
break;
goto xchg;
+ case 0x98: /* cbw/cwde/cdqe */
+ switch (c->op_bytes) {
+ case 2: c->dst.val = (s8)c->dst.val; break;
+ case 4: c->dst.val = (s16)c->dst.val; break;
+ case 8: c->dst.val = (s32)c->dst.val; break;
+ }
+ 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] 3+ messages in thread* [PATCH] test: Add real mode test for cbw/cwde instruction
2010-08-18 8:43 [PATCH] KVM: x86 emulator: add CBW/CWDE/CDQE instruction emulation Wei Yongjun
@ 2010-08-18 8:44 ` Wei Yongjun
2010-08-18 10:34 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2010-08-18 8:44 UTC (permalink / raw)
To: Avi Kivity, kvm
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
x86/realmode.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index bedd175..ce8fb18 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1236,6 +1236,32 @@ void test_loopcc(void)
print_serial("LOOPcc short Test 3: PASS\n");
}
+void test_cbw(void)
+{
+ struct regs inregs = { 0 }, outregs;
+
+ MK_INSN(cbw, "mov $0xFE, %eax \n\t"
+ "cbw\n\t");
+ MK_INSN(cwde, "mov $0xFFFE, %eax \n\t"
+ "cwde\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_cbw,
+ insn_cbw_end - insn_cbw);
+ if (outregs.eax != 0xFFFE)
+ print_serial("cbw test1: FAIL\n");
+ else
+ print_serial("cbw test 1: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_cwde,
+ insn_cwde_end - insn_cwde);
+ if (outregs.eax != 0xFFFFFFFE)
+ print_serial("cwde test1: FAIL\n");
+ else
+ print_serial("cwde test 1: PASS\n");
+}
+
void realmode_start(void)
{
test_null();
@@ -1264,6 +1290,7 @@ void realmode_start(void)
test_div();
test_idiv();
test_loopcc();
+ test_cbw();
exit(0);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-18 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-18 8:43 [PATCH] KVM: x86 emulator: add CBW/CWDE/CDQE instruction emulation Wei Yongjun
2010-08-18 8:44 ` [PATCH] test: Add real mode test for cbw/cwde instruction Wei Yongjun
2010-08-18 10:34 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).