Emulate MMX MOVQ
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. However it seems to fail sometimes in my unit test, generating a math fault at the fwait instruction (which is duly trapped). Hints appreciated.
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 | 98 ++++++++++++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9
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 | 90 ++++++++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 5 deletions(-)
arch/x86/include/asm/kvm_emulate.h +3 -1
@@ -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 +86 -4
146 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 2/2 KVM: x86 emulator: implement MMX MOVQ (opcodes 0f 6f, 0f 7f)
In reply to Avi KivityNeeded 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
@@ -2929,6 +2929,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;
@@ -3468,7 +3474,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
Re: [PATCH 1/2] KVM: x86 emulator: MMX support
In reply to Avi KivityQuoted 6 lines · Avi Kivity
arch/x86/kvm/emulate.c +4
-0+static int flush_pending_x87_faults (struct x86_emulate_ctxt *ctxt) +{ +bool fault = false; +
arch/x86/kvm/emulate.c static bool string_insn_completed(struct x86_emulate_ctxt *ctxt) · line 4101
Quoted 10 lines
arch/x86/kvm/emulate.c +10
-0+ ctxt->ops->get_fpu (ctxt); + asmvolatile ("1: fwait \n\t" +"2: \n\t" +".pushsection .fixup,\"ax\" \n\t" +"3: \n\t" +"movb $1, %[fault] \n\t" +"jmp 2b \n\t" +".popsection \n\t" + _ASM_EXTABLE(1b, 3b) + : [fault]"=rm"(fault));
"=" tells gcc that the asm section unconditionally writes 'fault', so it skips the initialization. Use "+" instead.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.