From: Avi Kivity <avi@redhat.com>
To: Wei Xu <wexu2@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: Re: "KVM internal error. Suberror: 1" with ancient 2.4 kernel as guest
Date: Sun, 27 Mar 2011 13:57:05 +0200 [thread overview]
Message-ID: <4D8F2611.2050005@redhat.com> (raw)
In-Reply-To: <C9B26143.2B6D6%wexu2@cisco.com>
On 03/26/2011 12:12 AM, Wei Xu wrote:
> Jiri& Avi:
>
> I attached the patched I did for movq and movdqa emulation. Please note:
> (1) I only implemented those two. Other instructions like addq may be
> following same way.
> (2) I use same guest_fx_image to hold value and fxsave/fxrstor to copy
> to/from registers. This is not very efficient I admit.
> Any suggestions let me know.
>
Patch is severely whitespace damaged. Please observe the kernel
whitespace style.
I just remembered that I implemented this once - see the (very old)
branch sse-mmio in kvm.git.
> Index: linux/contents/arch/x86/include/asm/kvm_emulate.h
> ===================================================================
> --- linux.orig/contents/arch/x86/include/asm/kvm_emulate.h 2010-07-19 06:42:26.000000000 -0700
> +++ linux/contents/arch/x86/include/asm/kvm_emulate.h 2011-03-21 09:16:39.000000000 -0700
> @@ -116,6 +116,7 @@
> enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type;
> unsigned int bytes;
> unsigned long val, orig_val, *ptr;
> + unsigned long val_simd[2];
> };
Breaks on i386 (ulong is 32-bit).
>
> if (c->src.type == OP_MEM) {
> + void *val;
> c->src.ptr = (unsigned long *)memop;
> c->src.val = 0;
> + if (c->src.bytes> 8) { /* movdq case */
> + c->src.val_simd[0] = c->src.val_simd[1] = 0;
> + val = c->src.val_simd;
> + } else {
> + val =&c->src.val;
> + }
We have a union there for that purpose.
> @@ -2506,6 +2529,55 @@
> if (!test_cc(c->b, ctxt->eflags))
> c->dst.type = OP_NONE; /* no writeback */
> break;
> + case 0x6f: /* movq from mm/m64 to mm; movdqa from xmm/m128 to xmm */
> + if (c->op_bytes == 8){
> + ctxt->vcpu->arch.guest_fx_image.st_space[c->modrm_reg<<2] =
> + (c->src.val& 0x0ffffffff);
> + ctxt->vcpu->arch.guest_fx_image.st_space[(c->modrm_reg<<2)+1] =
> + (c->src.val>> 32);
> + kvm_fx_restore(&ctxt->vcpu->arch.guest_fx_image);
> + c->dst.type = OP_NONE; /* Disable writeback. */
> + break;
> + } else { /* movdqa */
> + ctxt->vcpu->arch.guest_fx_image.xmm_space[c->modrm_reg<<2] =
> + (c->src.val_simd[0]& 0x0ffffffff);
> + ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+1] =
> + (c->src.val_simd[0]>> 32);
> + ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+2] =
> + (c->src.val_simd[1]& 0x0ffffffff);
> + ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+3] =
> + (c->src.val_simd[1]>> 32);
> + kvm_fx_restore(&ctxt->vcpu->arch.guest_fx_image);
> + c->dst.type = OP_NONE; /* Disable writeback. */
> + break;
> + }
> + case 0x7f: /* movq from mm to mm/m64; movdqa from xmm to xmm/m128 */
> + if (c->op_bytes == 8) { /* movq */
> + kvm_fx_save(&ctxt->vcpu->arch.guest_fx_image);
> + if (c->dst.type == OP_MEM) {
> + unsigned long lval,uval;
> + lval = ctxt->vcpu->arch.guest_fx_image.st_space[c->modrm_reg<<2];
> + uval = ctxt->vcpu->arch.guest_fx_image.st_space[(c->modrm_reg<<2)+1];
> + c->dst.val = (uval<<32) + lval;
> + } else {
> + c->dst.type = OP_NONE; /* Disable writeback. */
> + }
> + break;
> + } else { /* movdqa */
> + kvm_fx_save(&ctxt->vcpu->arch.guest_fx_image);
> + if (c->dst.type == OP_MEM) {
> + unsigned long lval,uval;
> + lval = ctxt->vcpu->arch.guest_fx_image.xmm_space[c->modrm_reg<<2];
> + uval = ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+1];
> + c->dst.val_simd[0] = (uval<<32) + lval;
> + lval = ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+2];
> + uval = ctxt->vcpu->arch.guest_fx_image.xmm_space[(c->modrm_reg<<2)+3];
> + c->dst.val_simd[1] = (uval<<32) + lval;
> + } else {
> + c->dst.type = OP_NONE; /* Disable writeback. */
> + }
> + break;
> + }
In my implementation, I just forced the guest mmu to be active, and used
the sse instructions directly.
> Index: linux/contents/include/linux/kvm.h
> ===================================================================
> --- linux.orig/contents/include/linux/kvm.h 2010-07-19 06:42:23.000000000 -0700
> +++ linux/contents/include/linux/kvm.h 2011-03-21 09:16:39.000000000 -0700
> @@ -152,7 +152,7 @@
> /* KVM_EXIT_MMIO */
> struct {
> __u64 phys_addr;
> - __u8 data[8];
> + __u8 data[16];
> __u32 len;
> __u8 is_write;
> } mmio;
This breaks the userspace interface. My implementation split the I/O
into two separate 64-bit writes.
I guess I'll have to rebase it.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-03-27 11:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-31 14:32 "KVM internal error. Suberror: 1" with ancient 2.4 kernel as guest Jiri Kosina
2010-08-31 15:49 ` Avi Kivity
2010-08-31 16:30 ` Avi Kivity
2011-03-21 21:23 ` Wei Xu
2011-03-22 10:54 ` Jiri Kosina
2011-03-25 22:12 ` Wei Xu
2011-03-27 11:57 ` Avi Kivity [this message]
2011-03-28 0:53 ` Wei Xu
2011-03-28 9:23 ` Avi Kivity
2011-03-28 16:31 ` Wei Xu
2011-03-28 16:33 ` Avi Kivity
2011-03-28 16:36 ` Wei Xu
2011-03-28 0:54 ` Wei Xu
2011-03-28 9:24 ` 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=4D8F2611.2050005@redhat.com \
--to=avi@redhat.com \
--cc=jkosina@suse.cz \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=wexu2@cisco.com \
/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.