login
Header Space

 
 

[PATCH 17/31] KVM: x86 emulator: fix smsw and lmsw with a memory operand

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <kvm-devel@...>
Cc: <linux-kernel@...>
Date: Monday, April 21, 2008 - 6:29 am

lmsw and smsw were implemented only with a register operand.  Extend them
to support a memory operand as well.  Fixes Windows running some display
compatibility test on AMD hosts.

Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 arch/x86/kvm/x86_emulate.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 8e1b32f..46ef78f 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -275,12 +275,15 @@ static u16 group_table[] = {
 	SrcMem | ModRM, 0, SrcMem | ModRM | Stack, 0,
 	[Group7*8] =
 	0, 0, ModRM | SrcMem, ModRM | SrcMem,
-	SrcNone | ModRM | DstMem, 0, SrcMem | ModRM, SrcMem | ModRM | ByteOp,
+	SrcNone | ModRM | DstMem | Mov, 0,
+	SrcMem16 | ModRM | Mov, SrcMem | ModRM | ByteOp,
 };
 
 static u16 group2_table[] = {
 	[Group7*8] =
-	SrcNone | ModRM, 0, 0, 0, SrcNone | ModRM | DstMem, 0, SrcMem | ModRM, 0,
+	SrcNone | ModRM, 0, 0, 0,
+	SrcNone | ModRM | DstMem | Mov, 0,
+	SrcMem16 | ModRM | Mov, 0,
 };
 
 /* EFLAGS bit definitions. */
@@ -1722,6 +1725,8 @@ twobyte_insn:
 				goto done;
 
 			kvm_emulate_hypercall(ctxt->vcpu);
+			/* Disable writeback. */
+			c->dst.type = OP_NONE;
 			break;
 		case 2: /* lgdt */
 			rc = read_descriptor(ctxt, ops, c->src.ptr,
@@ -1729,6 +1734,8 @@ twobyte_insn:
 			if (rc)
 				goto done;
 			realmode_lgdt(ctxt->vcpu, size, address);
+			/* Disable writeback. */
+			c->dst.type = OP_NONE;
 			break;
 		case 3: /* lidt/vmmcall */
 			if (c->modrm_mod == 3 && c->modrm_rm == 1) {
@@ -1744,27 +1751,25 @@ twobyte_insn:
 					goto done;
 				realmode_lidt(ctxt->vcpu, size, address);
 			}
+			/* Disable writeback. */
+			c->dst.type = OP_NONE;
 			break;
 		case 4: /* smsw */
-			if (c->modrm_mod != 3)
-				goto cannot_emulate;
-			*(u16 *)&c->regs[c->modrm_rm]
-				= realmode_get_cr(ctxt->vcpu, 0);
+			c->dst.bytes = 2;
+			c->dst.val = realmode_get_cr(ctxt->vcpu, 0);
 			break;
 		case 6: /* lmsw */
-			if (c->modrm_mod != 3)
-				goto cannot_emulate;
-			realmode_lmsw(ctxt->vcpu, (u16)c->modrm_val,
-						  &ctxt->eflags);
+			realmode_lmsw(ctxt->vcpu, (u16)c->src.val,
+				      &ctxt->eflags);
 			break;
 		case 7: /* invlpg*/
 			emulate_invlpg(ctxt->vcpu, memop);
+			/* Disable writeback. */
+			c->dst.type = OP_NONE;
 			break;
 		default:
 			goto cannot_emulate;
 		}
-		/* Disable writeback. */
-		c->dst.type = OP_NONE;
 		break;
 	case 0x06:
 		emulate_clts(ctxt->vcpu);
-- 
1.5.5

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 30/31] KVM: ppc: Kconfig fixes, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 29/31] KVM: SVM: remove selective CR0 comment, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 17/31] KVM: x86 emulator: fix smsw and lmsw with a me..., Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 20/31] ppc: Export tlb_44x_hwater for KVM, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 13/31] KVM: add ioctls to save/store mpstate, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 09/31] KVM: Add kvm trace userspace interface, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 07/31] KVM: s390: Stub out kvmtrace, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 08/31] KVM: ia64: Stub out kvmtrace, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 06/31] KVM: Add trace markers, Avi Kivity, (Mon Apr 21, 6:29 am)
[PATCH 02/31] KVM: Register ioctl range, Avi Kivity, (Mon Apr 21, 6:29 am)
speck-geostationary