* [PATCH] KVM: x86: emulate movdqa
@ 2012-03-22 18:31 Stefan Hajnoczi
2012-03-25 12:05 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-03-22 18:31 UTC (permalink / raw)
To: kvm; +Cc: Avi Kivity, Takuya Yoshikawa, Stefan Hajnoczi
An Ubuntu 9.10 Karmic Koala guest is unable to boot or install due to
missing movdqa emulation:
kvm_exit: reason EXCEPTION_NMI rip 0x7fef3e025a7b info 7fef3e799000 80000b0e
kvm_page_fault: address 7fef3e799000 error_code f
kvm_emulate_insn: 0:7fef3e025a7b: 66 0f 7f 07 (prot64)
movdqa %xmm0,(%rdi)
This patch adds movdqa to the emulator but does not implement #GP when
the memory operand is unaligned to 16 bytes. Alignment checking is
performed in guest mode, so it works most of the time except for corner
cases where the emulator sees the instruction but the guest never
executed it (guest code modified by another vcpu while the emulator is
executing).
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
This is the patch I tested against the movdqa kvm-unit-test that I submitted.
It still doesn't include #GP on unaligned memory. I'm not sure of the
appropriate place in the emulator where the alignment check should be added.
Perhaps __linearize()?
arch/x86/kvm/emulate.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 8375622..7ca022b 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2790,7 +2790,7 @@ static int em_rdpmc(struct x86_emulate_ctxt *ctxt)
static int em_mov(struct x86_emulate_ctxt *ctxt)
{
- ctxt->dst.val = ctxt->src.val;
+ memcpy(ctxt->dst.valptr, ctxt->src.valptr, ctxt->op_bytes);
return X86EMUL_CONTINUE;
}
@@ -2870,12 +2870,6 @@ static int em_mov_sreg_rm(struct x86_emulate_ctxt *ctxt)
return load_segment_descriptor(ctxt, sel, ctxt->modrm_reg);
}
-static int em_movdqu(struct x86_emulate_ctxt *ctxt)
-{
- memcpy(&ctxt->dst.vec_val, &ctxt->src.vec_val, ctxt->op_bytes);
- return X86EMUL_CONTINUE;
-}
-
static int em_invlpg(struct x86_emulate_ctxt *ctxt)
{
int rc;
@@ -3415,7 +3409,7 @@ static struct opcode group11[] = {
};
static struct gprefix pfx_0f_6f_0f_7f = {
- N, N, N, I(Sse, em_movdqu),
+ N, I(Sse, em_mov), N, I(Sse, em_mov),
};
static struct opcode opcode_table[256] = {
--
1.7.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] KVM: x86: emulate movdqa
2012-03-22 18:31 [PATCH] KVM: x86: emulate movdqa Stefan Hajnoczi
@ 2012-03-25 12:05 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2012-03-25 12:05 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: kvm, Takuya Yoshikawa
On 03/22/2012 08:31 PM, Stefan Hajnoczi wrote:
> An Ubuntu 9.10 Karmic Koala guest is unable to boot or install due to
> missing movdqa emulation:
>
> kvm_exit: reason EXCEPTION_NMI rip 0x7fef3e025a7b info 7fef3e799000 80000b0e
> kvm_page_fault: address 7fef3e799000 error_code f
> kvm_emulate_insn: 0:7fef3e025a7b: 66 0f 7f 07 (prot64)
>
> movdqa %xmm0,(%rdi)
>
> This patch adds movdqa to the emulator but does not implement #GP when
> the memory operand is unaligned to 16 bytes. Alignment checking is
> performed in guest mode, so it works most of the time except for corner
> cases where the emulator sees the instruction but the guest never
> executed it (guest code modified by another vcpu while the emulator is
> executing).
>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
> This is the patch I tested against the movdqa kvm-unit-test that I submitted.
> It still doesn't include #GP on unaligned memory. I'm not sure of the
> appropriate place in the emulator where the alignment check should be added.
> Perhaps __linearize()?
__linearize() is too deep, we've lost track of our 'struct operand' and
whether we need to check or not.
On the other hand, all other places don't have any knowledge of the
segment base.
Perhaps we should linearize into a new field of struct operand, instead
of on the fly.
Patch itself is fine, will soon see mmx movq to complement it.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-25 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 18:31 [PATCH] KVM: x86: emulate movdqa Stefan Hajnoczi
2012-03-25 12:05 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox