From: Avi Kivity <avi@redhat.com>
To: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Subject: Re: [RFC] KVM: x86: emulate movdqa
Date: Sun, 08 Jan 2012 12:32:59 +0200 [thread overview]
Message-ID: <4F0970DB.6060405@redhat.com> (raw)
In-Reply-To: <1325932011-2728-1-git-send-email-stefanha@linux.vnet.ibm.com>
On 01/07/2012 12:26 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)
Install udis86 (and udsi86-devel) and build trace-cmd; it will decode
the opcode for you.
>
> movdqa %xmm0,(%rdi)
>
> This patch adds movdqa to the emulator but does not implement #GP when
> the memory operand is unaligned to 16 bytes. I'm not sure whether
> alignment checking can be implemented as an opcode .flag or if it needs
> to be done in em_movdqa().
It should actually be automatic when the Sse flag is present, since it's
the norm for almost all SSE instructions. There should be a .flag to
override it for movdqu.
> A more fundamental question: why do we have to emulate this guest
> userspace SSE instruction in the first place? This host machine lacks
> EPT but can't we service the page fault and then retry execution inside
> the guest?
Not when the target is mmio - there is no possible mapping. With your
patch, is there a kvm_mmio trace right after the movdqa emulation?
>
> +static int em_movdqa(struct x86_emulate_ctxt *ctxt)
> +{
> + /* TODO alignment */
> + memcpy(&ctxt->dst.vec_val, &ctxt->src.vec_val, ctxt->op_bytes);
> + return X86EMUL_CONTINUE;
> +}
em_mov() should be adjusted to work here.
> +
> static int em_movdqu(struct x86_emulate_ctxt *ctxt)
> {
> memcpy(&ctxt->dst.vec_val, &ctxt->src.vec_val, ctxt->op_bytes);
> @@ -3115,7 +3122,7 @@ static struct opcode group11[] = {
> };
>
> static struct gprefix pfx_0f_6f_0f_7f = {
> - N, N, N, I(Sse, em_movdqu),
> + N, I(Sse, em_movdqa), N, I(Sse, em_movdqu),
> };
>
Need the Mov flag too (I see it's missing for movdqu as well); otherwise
the emulator will RMW the destination.
Don't forget a unit test (for both the aligned and unaligned case).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-01-08 10:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-07 10:26 [RFC] KVM: x86: emulate movdqa Stefan Hajnoczi
2012-01-08 10:32 ` Avi Kivity [this message]
2012-01-08 16:21 ` Stefan Hajnoczi
2012-01-08 16:36 ` Gleb Natapov
2012-01-08 16:41 ` Avi Kivity
2012-01-09 8:52 ` Takuya Yoshikawa
2012-01-09 10:02 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0970DB.6060405@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=stefanha@linux.vnet.ibm.com \
--cc=yoshikawa.takuya@oss.ntt.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.