From: Paolo Bonzini <pbonzini@redhat.com>
To: Miltiadis Hatzimihail <hatzimiltos@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Guest SIGILL when different IO is implemented
Date: Thu, 11 May 2017 13:51:08 +0200 [thread overview]
Message-ID: <6e9a0dff-949f-5ac9-2315-cbe0e4c99f58@redhat.com> (raw)
In-Reply-To: <CALUZMn0mRMY7mx5ysWdSamV+UGbjwuif8UxQ47gFDK3fx8Hw2w@mail.gmail.com>
On 11/05/2017 09:00, Miltiadis Hatzimihail wrote:
>
> The interesting thing is that in the ram case the test is passing, but in
> the io is failing. Also, if I try this without KVM, it passes in both cases.
Yes, in the RAM case KVM is not invoked at all.
> So I ve done some reading and for the 2 cases above I get:
>
> - KVM_EXIT_MMIO on memory_region_init_io (KVM attempts and fails to
> emulate MOVSS),
> - KVM_EXIT_EXCEPTION on memory_region_init_ram(QEMU emulates MOVSS)
No, you don't get any exit for memory_region_init_ram.
> Is that right?
>
> Now the question is, if I want to use the IO instead of a RAM, what's the
> best way to solve this?
Please try this KVM patch:
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c25cfaf584e7..53fbd1589d2e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3534,6 +3534,22 @@ static int em_rdpmc(struct x86_emulate_ctxt *ctxt)
return X86EMUL_CONTINUE;
}
+static int em_movss(struct x86_emulate_ctxt *ctxt)
+{
+ memcpy(ctxt->dst.valptr, ctxt->src.valptr, 4);
+ ctxt->op_bytes = 4;
+ ctxt->dst.bytes = 4;
+ return X86EMUL_CONTINUE;
+}
+
+static int em_movsd(struct x86_emulate_ctxt *ctxt)
+{
+ memcpy(ctxt->dst.valptr, ctxt->src.valptr, 8);
+ ctxt->op_bytes = 8;
+ ctxt->dst.bytes = 8;
+ return X86EMUL_CONTINUE;
+}
+
static int em_mov(struct x86_emulate_ctxt *ctxt)
{
memcpy(ctxt->dst.valptr, ctxt->src.valptr, sizeof(ctxt->src.valptr));
@@ -4407,6 +4423,11 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt)
I(Mmx, em_mov), I(Sse | Aligned, em_mov), N, I(Sse | Unaligned, em_mov),
};
+static const struct gprefix pfx_0f_10_0f_11 = {
+ I(Sse | Unaligned, em_mov), I(Sse | Unaligned, em_mov),
+ I(Sse, em_movsd), I(Sse, em_movss),
+};
+
static const struct instr_dual instr_dual_0f_2b = {
I(0, em_mov), N
};
@@ -4626,6 +4647,8 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt)
DI(ImplicitOps | Priv, invd), DI(ImplicitOps | Priv, wbinvd), N, N,
N, D(ImplicitOps | ModRM | SrcMem | NoAccess), N, N,
/* 0x10 - 0x1F */
+ GP(SrcMem | DstReg | ModRM | Mov, &pfx_0f_10_0f_11),
+ GP(SrcReg | DstMem | ModRM | Mov, &pfx_0f_10_0f_11),
N, N, N, N, N, N, N, N,
D(ImplicitOps | ModRM | SrcMem | NoAccess),
N, N, N, N, N, N, D(ImplicitOps | ModRM | SrcMem | NoAccess),
Thanks,
Paolo
next prev parent reply other threads:[~2017-05-11 11:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 7:00 [Qemu-devel] Guest SIGILL when different IO is implemented Miltiadis Hatzimihail
2017-05-11 11:51 ` Paolo Bonzini [this message]
2017-05-11 12:40 ` Miltiadis Hatzimihail
2017-05-11 12:44 ` Paolo Bonzini
2017-05-11 12:47 ` Miltiadis Hatzimihail
2017-05-11 13:11 ` Paolo Bonzini
2017-05-11 13:12 ` Miltiadis Hatzimihail
2017-05-12 7:26 ` Miltiadis Hatzimihail
2017-05-12 12:00 ` Paolo Bonzini
[not found] ` <CALUZMn3-wWyeo3_ONHN52PEDk2Hyin7LoPfjOFtL1Rspq3WYKA@mail.gmail.com>
[not found] ` <8a18aa4b-8151-57f4-f209-6245acb6393e@redhat.com>
[not found] ` <CALUZMn0ppiDx_5jVAmCKqATH7EtDacvarOcY6gF-oh2z3C+3MQ@mail.gmail.com>
2017-05-16 8:11 ` Miltiadis Hatzimihail
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=6e9a0dff-949f-5ac9-2315-cbe0e4c99f58@redhat.com \
--to=pbonzini@redhat.com \
--cc=hatzimiltos@gmail.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).