Skip to contentSkip to conversation

Emulate MMX MOVQ

PATCH Superseded Avi Kivity 1 participant 3 messages Mar 22, 2012

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

cover Emulate MMX MOVQ

This patchset emulates two instructions:

MOVQ mm, mm/m64
MOVQ mm/m64, mm

Needed by https://bugzilla.kernel.org/show_bug.cgi?id=42779.

Changes from v1:
- fix spurious traps propgated into the guest
- delay loading mmx register state until after we're sure it won't trap

Avi Kivity (2):
KVM: x86 emulator: MMX support
KVM: x86 emulator: implement MMX MOVQ (opcodes 0f 6f, 0f 7f)

 arch/x86/include/asm/kvm_emulate.h |    4 +-
 arch/x86/kvm/emulate.c             |  111 ++++++++++++++++++++++++++++++++++--
 2 files changed, 109 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9
author
#1 lore raw

PATCH 1/2 KVM: x86 emulator: MMX support

General support for the MMX instruction set. Special care is taken to trap pending x87 exceptions so that they are properly reflected to the guest.

---
 arch/x86/include/asm/kvm_emulate.h |    4 +-
 arch/x86/kvm/emulate.c             |  103 ++++++++++++++++++++++++++++++++++--
 2 files changed, 102 insertions(+), 5 deletions(-)
arch/x86/include/asm/kvm_emulate.h +3 -1
index c222e1a..1ac46c22 100644
@@ -200,7 +200,7 @@ typedef u32 __attribute__((vector_size(16))) sse128_t;
 
 /* Type, address-of, and value of an instruction's operand. */
 struct operand {
-	enum { OP_REG, OP_MEM, OP_IMM, OP_XMM, OP_NONE } type;
+	enum { OP_REG, OP_MEM, OP_IMM, OP_XMM, OP_MM, OP_NONE } type;
 	unsigned int bytes;
 	union {
 		unsigned long orig_val;
@@ -213,12 +213,14 @@ struct operand {
 			unsigned seg;
 		} mem;
 		unsigned xmm;
+		unsigned mm;
 	} addr;
 	union {
 		unsigned long val;
 		u64 val64;
 		char valptr[sizeof(unsigned long) + 2];
 		sse128_t vec_val;
+		u64 mm_val;
 	};
 };
 
arch/x86/kvm/emulate.c +99 -4

159 lines not on this page · raw message

Signature · 1 line
1.7.9
author
#2 lore raw

PATCH 2/2 KVM: x86 emulator: implement MMX MOVQ (opcodes 0f 6f, 0f 7f)

In reply to Avi Kivity

Needed by some framebuffer drivers. See

https://bugzilla.kernel.org/show_bug.cgi?id=42779

---
 arch/x86/kvm/emulate.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kvm/emulate.c +7 -1
index f87d74e..282baa1 100644
@@ -2927,6 +2927,12 @@ static int em_movdqu(struct x86_emulate_ctxt *ctxt)
 	return X86EMUL_CONTINUE;
 }
 
+static int em_movq(struct x86_emulate_ctxt *ctxt)
+{
+	ctxt->dst.mm_val = ctxt->src.mm_val;
+	return X86EMUL_CONTINUE;
+}
+
 static int em_invlpg(struct x86_emulate_ctxt *ctxt)
 {
 	int rc;
@@ -3466,7 +3472,7 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt)
 };
 
 static struct gprefix pfx_0f_6f_0f_7f = {
-	N, N, N, I(Sse, em_movdqu),
+	I(Mmx, em_movq), N, N, I(Sse, em_movdqu),
 };
 
 static struct opcode opcode_table[256] = {
Signature · 1 line
1.7.9