Commit b250e605 authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: add SrcImmU16 operand type

Used for RET NEAR instructions.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 0ef753b8
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#define SrcImmFAddr (0xb<<4) /* Source is immediate far address */ #define SrcImmFAddr (0xb<<4) /* Source is immediate far address */
#define SrcMemFAddr (0xc<<4) /* Source is far address in memory */ #define SrcMemFAddr (0xc<<4) /* Source is far address in memory */
#define SrcAcc (0xd<<4) /* Source Accumulator */ #define SrcAcc (0xd<<4) /* Source Accumulator */
#define SrcImmU16 (0xe<<4) /* Immediate operand, unsigned, 16 bits */
#define SrcMask (0xf<<4) #define SrcMask (0xf<<4)
/* Generic ModRM decode. */ /* Generic ModRM decode. */
#define ModRM (1<<8) #define ModRM (1<<8)
...@@ -2678,13 +2679,17 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt) ...@@ -2678,13 +2679,17 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
srcmem_common: srcmem_common:
c->src = memop; c->src = memop;
break; break;
case SrcImmU16:
c->src.bytes = 2;
goto srcimm;
case SrcImm: case SrcImm:
case SrcImmU: case SrcImmU:
c->src.type = OP_IMM;
c->src.addr.mem = c->eip;
c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
if (c->src.bytes == 8) if (c->src.bytes == 8)
c->src.bytes = 4; c->src.bytes = 4;
srcimm:
c->src.type = OP_IMM;
c->src.addr.mem = c->eip;
/* NB. Immediates are sign-extended as necessary. */ /* NB. Immediates are sign-extended as necessary. */
switch (c->src.bytes) { switch (c->src.bytes) {
case 1: case 1:
...@@ -2697,7 +2702,8 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt) ...@@ -2697,7 +2702,8 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt)
c->src.val = insn_fetch(s32, 4, c->eip); c->src.val = insn_fetch(s32, 4, c->eip);
break; break;
} }
if ((c->d & SrcMask) == SrcImmU) { if ((c->d & SrcMask) == SrcImmU
|| (c->d & SrcMask) == SrcImmU16) {
switch (c->src.bytes) { switch (c->src.bytes) {
case 1: case 1:
c->src.val &= 0xff; c->src.val &= 0xff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment