kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86 emulator: disable writeback for TEST
@ 2011-09-11  8:23 Avi Kivity
  2011-09-12 12:37 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Avi Kivity @ 2011-09-11  8:23 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm; +Cc: ya su

The TEST instruction doesn't write its destination operand.  This
could cause problems if an MMIO register was accessed using the TEST
instruction.  Recently Windows XP was observed to use TEST against
the APIC ICR; this can cause spurious IPIs.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/emulate.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c636ee7..c37f67e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1670,6 +1670,8 @@ static int em_grp3(struct x86_emulate_ctxt *ctxt)
 	switch (ctxt->modrm_reg) {
 	case 0 ... 1:	/* test */
 		emulate_2op_SrcV(ctxt, "test");
+		/* Disable writeback. */
+		ctxt->dst.type = OP_NONE;
 		break;
 	case 2:	/* not */
 		ctxt->dst.val = ~ctxt->dst.val;
@@ -2513,6 +2515,8 @@ static int em_cmp(struct x86_emulate_ctxt *ctxt)
 static int em_test(struct x86_emulate_ctxt *ctxt)
 {
 	emulate_2op_SrcV(ctxt, "test");
+	/* Disable writeback. */
+	ctxt->dst.type = OP_NONE;
 	return X86EMUL_CONTINUE;
 }
 
-- 
1.7.6.1


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

* Re: [PATCH] KVM: x86 emulator: disable writeback for TEST
  2011-09-11  8:23 [PATCH] KVM: x86 emulator: disable writeback for TEST Avi Kivity
@ 2011-09-12 12:37 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2011-09-12 12:37 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, ya su

On Sun, Sep 11, 2011 at 11:23:02AM +0300, Avi Kivity wrote:
> The TEST instruction doesn't write its destination operand.  This
> could cause problems if an MMIO register was accessed using the TEST
> instruction.  Recently Windows XP was observed to use TEST against
> the APIC ICR; this can cause spurious IPIs.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>

Applied, thanks.


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

end of thread, other threads:[~2011-09-12 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-11  8:23 [PATCH] KVM: x86 emulator: disable writeback for TEST Avi Kivity
2011-09-12 12:37 ` Marcelo Tosatti

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).