Skip to contentSkip to conversation

KVM: x86 emulator: disable writeback for TEST

PATCH Applied Avi Kivity 2 participants 2 messages Sep 11, 2011 – Sep 12, 2011

Subsystems (3)
lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: x86 emulator: disable writeback for TEST

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.

---
 arch/x86/kvm/emulate.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/x86/kvm/emulate.c +4 -0
index c636ee7..c37f67e 100644
@@ -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;
 }
 
Signature · 1 line
1.7.6.1
#1 lore raw
Quoted 6 lines · Avi Kivity

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.

Applied, thanks.