提交 d7841a4b 编写于 作者: T Takuya Yoshikawa 提交者: Avi Kivity

KVM: x86 emulator: Use opcode::execute for IN/OUT

IN : E4, E5, EC, ED
OUT: E6, E7, EE, EF
Signed-off-by: NTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
上级 46199f33
...@@ -2776,6 +2776,24 @@ static int em_jcxz(struct x86_emulate_ctxt *ctxt) ...@@ -2776,6 +2776,24 @@ static int em_jcxz(struct x86_emulate_ctxt *ctxt)
return X86EMUL_CONTINUE; return X86EMUL_CONTINUE;
} }
static int em_in(struct x86_emulate_ctxt *ctxt)
{
if (!pio_in_emulated(ctxt, ctxt->dst.bytes, ctxt->src.val,
&ctxt->dst.val))
return X86EMUL_IO_NEEDED;
return X86EMUL_CONTINUE;
}
static int em_out(struct x86_emulate_ctxt *ctxt)
{
ctxt->ops->pio_out_emulated(ctxt, ctxt->src.bytes, ctxt->dst.val,
&ctxt->src.val, 1);
/* Disable writeback. */
ctxt->dst.type = OP_NONE;
return X86EMUL_CONTINUE;
}
static int em_cli(struct x86_emulate_ctxt *ctxt) static int em_cli(struct x86_emulate_ctxt *ctxt)
{ {
if (emulator_bad_iopl(ctxt)) if (emulator_bad_iopl(ctxt))
...@@ -3004,6 +3022,8 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt) ...@@ -3004,6 +3022,8 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt)
#define D2bv(_f) D((_f) | ByteOp), D(_f) #define D2bv(_f) D((_f) | ByteOp), D(_f)
#define D2bvIP(_f, _i, _p) DIP((_f) | ByteOp, _i, _p), DIP(_f, _i, _p) #define D2bvIP(_f, _i, _p) DIP((_f) | ByteOp, _i, _p), DIP(_f, _i, _p)
#define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e) #define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e)
#define I2bvIP(_f, _e, _i, _p) \
IIP((_f) | ByteOp, _e, _i, _p), IIP(_f, _e, _i, _p)
#define I6ALU(_f, _e) I2bv((_f) | DstMem | SrcReg | ModRM, _e), \ #define I6ALU(_f, _e) I2bv((_f) | DstMem | SrcReg | ModRM, _e), \
I2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock, _e), \ I2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock, _e), \
...@@ -3217,13 +3237,13 @@ static struct opcode opcode_table[256] = { ...@@ -3217,13 +3237,13 @@ static struct opcode opcode_table[256] = {
/* 0xE0 - 0xE7 */ /* 0xE0 - 0xE7 */
X3(I(SrcImmByte, em_loop)), X3(I(SrcImmByte, em_loop)),
I(SrcImmByte, em_jcxz), I(SrcImmByte, em_jcxz),
D2bvIP(SrcImmUByte | DstAcc, in, check_perm_in), I2bvIP(SrcImmUByte | DstAcc, em_in, in, check_perm_in),
D2bvIP(SrcAcc | DstImmUByte, out, check_perm_out), I2bvIP(SrcAcc | DstImmUByte, em_out, out, check_perm_out),
/* 0xE8 - 0xEF */ /* 0xE8 - 0xEF */
D(SrcImm | Stack), D(SrcImm | ImplicitOps), D(SrcImm | Stack), D(SrcImm | ImplicitOps),
I(SrcImmFAddr | No64, em_jmp_far), D(SrcImmByte | ImplicitOps), I(SrcImmFAddr | No64, em_jmp_far), D(SrcImmByte | ImplicitOps),
D2bvIP(SrcDX | DstAcc, in, check_perm_in), I2bvIP(SrcDX | DstAcc, em_in, in, check_perm_in),
D2bvIP(SrcAcc | DstDX, out, check_perm_out), I2bvIP(SrcAcc | DstDX, em_out, out, check_perm_out),
/* 0xF0 - 0xF7 */ /* 0xF0 - 0xF7 */
N, DI(ImplicitOps, icebp), N, N, N, DI(ImplicitOps, icebp), N, N,
DI(ImplicitOps | Priv, hlt), D(ImplicitOps), DI(ImplicitOps | Priv, hlt), D(ImplicitOps),
...@@ -3325,6 +3345,7 @@ static struct opcode twobyte_table[256] = { ...@@ -3325,6 +3345,7 @@ static struct opcode twobyte_table[256] = {
#undef D2bv #undef D2bv
#undef D2bvIP #undef D2bvIP
#undef I2bv #undef I2bv
#undef I2bvIP
#undef I6ALU #undef I6ALU
static unsigned imm_size(struct x86_emulate_ctxt *ctxt) static unsigned imm_size(struct x86_emulate_ctxt *ctxt)
...@@ -3867,11 +3888,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3867,11 +3888,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
case 0x6c: /* insb */ case 0x6c: /* insb */
case 0x6d: /* insw/insd */ case 0x6d: /* insw/insd */
ctxt->src.val = ctxt->regs[VCPU_REGS_RDX]; ctxt->src.val = ctxt->regs[VCPU_REGS_RDX];
goto do_io_in; rc = em_in(ctxt);
break;
case 0x6e: /* outsb */ case 0x6e: /* outsb */
case 0x6f: /* outsw/outsd */ case 0x6f: /* outsw/outsd */
ctxt->dst.val = ctxt->regs[VCPU_REGS_RDX]; ctxt->dst.val = ctxt->regs[VCPU_REGS_RDX];
goto do_io_out; rc = em_out(ctxt);
break; break;
case 0x70 ... 0x7f: /* jcc (short) */ case 0x70 ... 0x7f: /* jcc (short) */
if (test_cc(ctxt->b, ctxt->eflags)) if (test_cc(ctxt->b, ctxt->eflags))
...@@ -3915,12 +3937,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3915,12 +3937,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
ctxt->src.val = ctxt->regs[VCPU_REGS_RCX]; ctxt->src.val = ctxt->regs[VCPU_REGS_RCX];
rc = em_grp2(ctxt); rc = em_grp2(ctxt);
break; break;
case 0xe4: /* inb */
case 0xe5: /* in */
goto do_io_in;
case 0xe6: /* outb */
case 0xe7: /* out */
goto do_io_out;
case 0xe8: /* call (near) */ { case 0xe8: /* call (near) */ {
long int rel = ctxt->src.val; long int rel = ctxt->src.val;
ctxt->src.val = (unsigned long) ctxt->_eip; ctxt->src.val = (unsigned long) ctxt->_eip;
...@@ -3933,20 +3949,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3933,20 +3949,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
jmp_rel(ctxt, ctxt->src.val); jmp_rel(ctxt, ctxt->src.val);
ctxt->dst.type = OP_NONE; /* Disable writeback. */ ctxt->dst.type = OP_NONE; /* Disable writeback. */
break; break;
case 0xec: /* in al,dx */
case 0xed: /* in (e/r)ax,dx */
do_io_in:
if (!pio_in_emulated(ctxt, ctxt->dst.bytes, ctxt->src.val,
&ctxt->dst.val))
goto done; /* IO is needed */
break;
case 0xee: /* out dx,al */
case 0xef: /* out dx,(e/r)ax */
do_io_out:
ops->pio_out_emulated(ctxt, ctxt->src.bytes, ctxt->dst.val,
&ctxt->src.val, 1);
ctxt->dst.type = OP_NONE; /* Disable writeback. */
break;
case 0xf4: /* hlt */ case 0xf4: /* hlt */
ctxt->ops->halt(ctxt); ctxt->ops->halt(ctxt);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册