lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070617165201.GA23885@dreamland.darkstar.lan>
Date:	Sun, 17 Jun 2007 18:52:01 +0200
From:	Luca Tettamanti <kronos.it@...il.com>
To:	Avi Kivity <avi@...ranet.com>
Cc:	kvm-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] kvm: Fix x86 emulator writeback

When the old value and new one are the same the emulator skips the
write; this is undesiderable when the destination is a MMIO area and the
write shall be performed regardless of the previous value. This
optimization breaks e.g. a Linux guest APIC compiled without
X86_GOOD_APIC.

Remove the check and always perform the writeback stage in the
emulation.

Signed-Off-By: Luca Tettamanti <kronos.it@...il.com>

---
 drivers/kvm/x86_emulate.c |   60 +++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index a4a8481..cea9f3a 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -1057,40 +1057,38 @@ done_prefixes:
 	}
 
 writeback:
-	if ((d & Mov) || (dst.orig_val != dst.val)) {
-		switch (dst.type) {
-		case OP_REG:
-			/* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
-			switch (dst.bytes) {
-			case 1:
-				*(u8 *)dst.ptr = (u8)dst.val;
-				break;
-			case 2:
-				*(u16 *)dst.ptr = (u16)dst.val;
-				break;
-			case 4:
-				*dst.ptr = (u32)dst.val;
-				break;	/* 64b: zero-ext */
-			case 8:
-				*dst.ptr = dst.val;
-				break;
-			}
+	switch (dst.type) {
+	case OP_REG:
+		/* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
+		switch (dst.bytes) {
+		case 1:
+			*(u8 *)dst.ptr = (u8)dst.val;
 			break;
-		case OP_MEM:
-			if (lock_prefix)
-				rc = ops->cmpxchg_emulated((unsigned long)dst.
-							   ptr, &dst.orig_val,
-							   &dst.val, dst.bytes,
-							   ctxt);
-			else
-				rc = ops->write_emulated((unsigned long)dst.ptr,
-							 &dst.val, dst.bytes,
-							 ctxt);
-			if (rc != 0)
-				goto done;
-		default:
+		case 2:
+			*(u16 *)dst.ptr = (u16)dst.val;
+			break;
+		case 4:
+			*dst.ptr = (u32)dst.val;
+			break;	/* 64b: zero-ext */
+		case 8:
+			*dst.ptr = dst.val;
 			break;
 		}
+		break;
+	case OP_MEM:
+		if (lock_prefix)
+			rc = ops->cmpxchg_emulated((unsigned long)dst.
+						   ptr, &dst.orig_val,
+						   &dst.val, dst.bytes,
+						   ctxt);
+		else
+			rc = ops->write_emulated((unsigned long)dst.ptr,
+						 &dst.val, dst.bytes,
+						 ctxt);
+		if (rc != 0)
+			goto done;
+	default:
+		break;
 	}
 
 	/* Commit shadow register state. */

Luca
-- 
Software is like sex; it's better when it's free.
Linus Torvalds
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ