aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-05-18 09:13:45 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:32:39 -0400
commitc9eaf20f268c7051bfde2ba212c5ea76a6cbc7a1 (patch)
treec2737bcfe831d397a7ec4aec0081889a385e9cf3
parentcb007648de83cf226d69ec76e1c01848b4e8e49f (diff)
KVM: x86 emulator: Implement zero-extended immediate decoding
Absolute jumps use zero extended immediate operands. Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/x86_emulate.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 616de4628d60..a30d5fc17eef 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -60,6 +60,7 @@
60#define SrcImmByte (6<<4) /* 8-bit sign-extended immediate operand. */ 60#define SrcImmByte (6<<4) /* 8-bit sign-extended immediate operand. */
61#define SrcOne (7<<4) /* Implied '1' */ 61#define SrcOne (7<<4) /* Implied '1' */
62#define SrcImmUByte (8<<4) /* 8-bit unsigned immediate operand. */ 62#define SrcImmUByte (8<<4) /* 8-bit unsigned immediate operand. */
63#define SrcImmU (9<<4) /* Immediate operand, unsigned */
63#define SrcMask (0xf<<4) 64#define SrcMask (0xf<<4)
64/* Generic ModRM decode. */ 65/* Generic ModRM decode. */
65#define ModRM (1<<8) 66#define ModRM (1<<8)
@@ -1027,6 +1028,7 @@ done_prefixes:
1027 c->src.type = OP_MEM; 1028 c->src.type = OP_MEM;
1028 break; 1029 break;
1029 case SrcImm: 1030 case SrcImm:
1031 case SrcImmU:
1030 c->src.type = OP_IMM; 1032 c->src.type = OP_IMM;
1031 c->src.ptr = (unsigned long *)c->eip; 1033 c->src.ptr = (unsigned long *)c->eip;
1032 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1034 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
@@ -1044,6 +1046,19 @@ done_prefixes:
1044 c->src.val = insn_fetch(s32, 4, c->eip); 1046 c->src.val = insn_fetch(s32, 4, c->eip);
1045 break; 1047 break;
1046 } 1048 }
1049 if ((c->d & SrcMask) == SrcImmU) {
1050 switch (c->src.bytes) {
1051 case 1:
1052 c->src.val &= 0xff;
1053 break;
1054 case 2:
1055 c->src.val &= 0xffff;
1056 break;
1057 case 4:
1058 c->src.val &= 0xffffffff;
1059 break;
1060 }
1061 }
1047 break; 1062 break;
1048 case SrcImmByte: 1063 case SrcImmByte:
1049 case SrcImmUByte: 1064 case SrcImmUByte: