linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: X86: Remove stale values from ctxt->memop before emulation
@ 2012-05-04 16:14 Joerg Roedel
  2012-05-06  8:21 ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Joerg Roedel @ 2012-05-04 16:14 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, linux-kernel, Joerg Roedel

When instruction decoding begins there could be stale values
in the ctxt->memop structure. This causes problems when an
instruction is emulated with more op-bytes then the guest
wants (like the bsr instruction which is always emulated
with 4 or 8 op-bytes).

The stale value in this structure causes the unit-test for
the bsrw instruction to fail. Initialize the memop.val with
0 to prevent such bugs (an alternative fix could be to
always emulate instructions with the number of op-bytes
requested by the guest).

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/emulate.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index d4bf50c..1b516ec 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3937,6 +3937,7 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
 	struct opcode opcode;
 
 	ctxt->memop.type = OP_NONE;
+	ctxt->memop.val  = 0;
 	ctxt->memopp = NULL;
 	ctxt->_eip = ctxt->eip;
 	ctxt->fetch.start = ctxt->_eip;
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-14  8:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-04 16:14 [PATCH] KVM: X86: Remove stale values from ctxt->memop before emulation Joerg Roedel
2012-05-06  8:21 ` Avi Kivity
2012-05-07 10:12   ` Joerg Roedel
2012-05-07 10:18     ` Avi Kivity
2012-05-07 10:43       ` Joerg Roedel
2012-05-14  8:32     ` 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).