aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorNadav Amit <namit@cs.technion.ac.il>2014-11-02 04:55:00 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2014-11-08 02:20:54 -0500
commited9aad215ff3374ffd720b83d26fda91e4367090 (patch)
treef0f3e9b04ee18a8541bc3e5b74938d7e76f67752 /arch/x86/kvm/emulate.c
parent7f187922ddf6b67f2999a76dcb71663097b75497 (diff)
KVM: x86: MOVNTI emulation min opsize is not respected
Commit 3b32004a66e9 ("KVM: x86: movnti minimum op size of 32-bit is not kept") did not fully fix the minimum operand size of MONTI emulation. Still, MOVNTI may be mistakenly performed using 16-bit opsize. This patch add No16 flag to mark an instruction does not support 16-bits operand size. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index dab9b74c29de..e020fed0b019 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -167,6 +167,7 @@
167#define NoBigReal ((u64)1 << 50) /* No big real mode */ 167#define NoBigReal ((u64)1 << 50) /* No big real mode */
168#define PrivUD ((u64)1 << 51) /* #UD instead of #GP on CPL > 0 */ 168#define PrivUD ((u64)1 << 51) /* #UD instead of #GP on CPL > 0 */
169#define NearBranch ((u64)1 << 52) /* Near branches */ 169#define NearBranch ((u64)1 << 52) /* Near branches */
170#define No16 ((u64)1 << 53) /* No 16 bit operand */
170 171
171#define DstXacc (DstAccLo | SrcAccHi | SrcWrite) 172#define DstXacc (DstAccLo | SrcAccHi | SrcWrite)
172 173
@@ -4134,7 +4135,7 @@ static const struct opcode twobyte_table[256] = {
4134 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), 4135 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
4135 /* 0xC0 - 0xC7 */ 4136 /* 0xC0 - 0xC7 */
4136 F2bv(DstMem | SrcReg | ModRM | SrcWrite | Lock, em_xadd), 4137 F2bv(DstMem | SrcReg | ModRM | SrcWrite | Lock, em_xadd),
4137 N, D(DstMem | SrcReg | ModRM | Mov), 4138 N, I(DstMem | SrcReg | ModRM | No16 | Mov, em_mov),
4138 N, N, N, GD(0, &group9), 4139 N, N, N, GD(0, &group9),
4139 /* 0xC8 - 0xCF */ 4140 /* 0xC8 - 0xCF */
4140 X8(I(DstReg, em_bswap)), 4141 X8(I(DstReg, em_bswap)),
@@ -4571,7 +4572,8 @@ done_prefixes:
4571 return EMULATION_FAILED; 4572 return EMULATION_FAILED;
4572 4573
4573 if (unlikely(ctxt->d & 4574 if (unlikely(ctxt->d &
4574 (NotImpl|Stack|Op3264|Sse|Mmx|Intercept|CheckPerm|NearBranch))) { 4575 (NotImpl|Stack|Op3264|Sse|Mmx|Intercept|CheckPerm|NearBranch|
4576 No16))) {
4575 /* 4577 /*
4576 * These are copied unconditionally here, and checked unconditionally 4578 * These are copied unconditionally here, and checked unconditionally
4577 * in x86_emulate_insn. 4579 * in x86_emulate_insn.
@@ -4596,6 +4598,9 @@ done_prefixes:
4596 ctxt->op_bytes = 4; 4598 ctxt->op_bytes = 4;
4597 } 4599 }
4598 4600
4601 if ((ctxt->d & No16) && ctxt->op_bytes == 2)
4602 ctxt->op_bytes = 4;
4603
4599 if (ctxt->d & Sse) 4604 if (ctxt->d & Sse)
4600 ctxt->op_bytes = 16; 4605 ctxt->op_bytes = 16;
4601 else if (ctxt->d & Mmx) 4606 else if (ctxt->d & Mmx)
@@ -5061,11 +5066,6 @@ twobyte_insn:
5061 ctxt->dst.val = (ctxt->src.bytes == 1) ? (s8) ctxt->src.val : 5066 ctxt->dst.val = (ctxt->src.bytes == 1) ? (s8) ctxt->src.val :
5062 (s16) ctxt->src.val; 5067 (s16) ctxt->src.val;
5063 break; 5068 break;
5064 case 0xc3: /* movnti */
5065 ctxt->dst.bytes = ctxt->op_bytes;
5066 ctxt->dst.val = (ctxt->op_bytes == 8) ? (u64) ctxt->src.val :
5067 (u32) ctxt->src.val;
5068 break;
5069 default: 5069 default:
5070 goto cannot_emulate; 5070 goto cannot_emulate;
5071 } 5071 }