[PATCH 26/50] KVM: x86 emulator: Add support for mov seg, r (0x8e) instruction

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Avi Kivity
Date: Thursday, June 26, 2008 - 5:28 am

From: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>

Add support for mov r, sreg (0x8c) instruction.

[avi: drop the sreg decoding table in favor of 1:1 encoding]

Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
Signed-off-by: Laurent Vivier <laurent.vivier@bull.net>
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 arch/x86/kvm/x86_emulate.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 21d7ff6..b049b6b 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -138,7 +138,8 @@ static u16 opcode_table[256] = {
 	/* 0x88 - 0x8F */
 	ByteOp | DstMem | SrcReg | ModRM | Mov, DstMem | SrcReg | ModRM | Mov,
 	ByteOp | DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
-	0, ModRM | DstReg, 0, Group | Group1A,
+	0, ModRM | DstReg,
+	DstReg | SrcMem | ModRM | Mov, Group | Group1A,
 	/* 0x90 - 0x9F */
 	0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, ImplicitOps | Stack, ImplicitOps | Stack, 0, 0,
@@ -1520,6 +1521,28 @@ special_insn:
 	case 0x8d: /* lea r16/r32, m */
 		c->dst.val = c->modrm_ea;
 		break;
+	case 0x8e: { /* mov seg, r/m16 */
+		uint16_t sel;
+		int type_bits;
+		int err;
+
+		sel = c->src.val;
+		if (c->modrm_reg <= 5) {
+			type_bits = (c->modrm_reg == 1) ? 9 : 1;
+			err = kvm_load_segment_descriptor(ctxt->vcpu, sel,
+							  type_bits, c->modrm_reg);
+		} else {
+			printk(KERN_INFO "Invalid segreg in modrm byte 0x%02x\n",
+					c->modrm);
+			goto cannot_emulate;
+		}
+
+		if (err < 0)
+			goto cannot_emulate;
+
+		c->dst.type = OP_NONE;  /* Disable writeback. */
+		break;
+	}
 	case 0x8f:		/* pop (sole member of Grp1a) */
 		rc = emulate_grp1a(ctxt, ops);
 		if (rc != 0)
-- 
1.5.6

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

Messages in current thread:
[PATCH 06/50] KVM: add missing kvmtrace bits, Avi Kivity, (Thu Jun 26, 5:27 am)
[PATCH 07/50] KVM: SVM: add missing kvmtrace markers, Avi Kivity, (Thu Jun 26, 5:27 am)
[PATCH 10/50] KVM: PIT: support mode 3, Avi Kivity, (Thu Jun 26, 5:27 am)
[PATCH 18/50] KVM: IOAPIC/LAPIC: Enable NMI support, Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 21/50] KVM: MTRR support, Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 26/50] KVM: x86 emulator: Add support for mov seg, ..., Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 28/50] KVM: MMU: Optimize prefetch_page(), Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 32/50] KVM: MMU: Avoid page prefetch on SVM, Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 40/50] KVM: Support mixed endian machines, Avi Kivity, (Thu Jun 26, 5:28 am)
[PATCH 50/50] KVM: MMU: Fix printk format, Avi Kivity, (Thu Jun 26, 5:28 am)