From: Avi Kivity <avi@redhat.com>
To: Sheng Yang <sheng@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH v3] KVM: x86: XSAVE/XRSTOR live migration support
Date: Sun, 13 Jun 2010 11:26:18 +0300 [thread overview]
Message-ID: <4C14962A.9030608@redhat.com> (raw)
In-Reply-To: <1276230971-5990-1-git-send-email-sheng@linux.intel.com>
On 06/11/2010 07:36 AM, Sheng Yang wrote:
> This patch enable save/restore of xsave state.
>
> +static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
> + struct kvm_xsave *guest_xsave)
> +{
> + u64 xstate_bv =
> + *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)];
> + int size;
> +
> + if (cpu_has_xsave) {
> + if (xstate_bv& XSTATE_YMM)
> + size = XSAVE_YMM_OFFSET + XSAVE_YMM_SIZE;
> + else
> + size = XSAVE_HDR_OFFSET + XSAVE_HDR_SIZE;
> + memcpy(&vcpu->arch.guest_fpu.state->xsave,
> + guest_xsave->region, size);
>
This allows userspace to overflow host memory by specifying XSTATE_YMM
on a host that doesn't support it.
Better to just use the host's size of the structure.
> + } else {
> + if (xstate_bv& ~XSTATE_FPSSE)
> + return -EINVAL;
> + size = sizeof(struct i387_fxsave_struct);
> + memcpy(&vcpu->arch.guest_fpu.state->fxsave,
> + guest_xsave->region, size);
> + }
> + return 0;
> +}
> +
>
> +
> +static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
> + struct kvm_xcrs *guest_xcrs)
> +{
> + int i, r = 0;
> +
> + if (!cpu_has_xsave)
> + return -EINVAL;
>
Too strict?
> +
> + if (guest_xcrs->nr_xcrs> KVM_MAX_XCRS)
> + return -EFAULT;
>
EFAULT is for faults during access to userspace. EINVAL or E2BIG.
Need to ensure flags is 0 for forward compatibility.
> +
> + for (i = 0; i< guest_xcrs->nr_xcrs; i++)
> + /* Only support XCR0 currently */
> + if (guest_xcrs->xcrs[0].xcr == XCR_XFEATURE_ENABLED_MASK) {
> + r = __kvm_set_xcr(vcpu, XCR_XFEATURE_ENABLED_MASK,
> + guest_xcrs->xcrs[0].value);
> + break;
> + }
> + if (r)
> + r = -EFAULT;
>
EINVAL
> + return r;
> +}
> +
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-06-13 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 4:36 [PATCH v3] KVM: x86: XSAVE/XRSTOR live migration support Sheng Yang
2010-06-13 8:26 ` Avi Kivity [this message]
2010-06-13 9:10 ` Sheng Yang
2010-06-13 9:13 ` Avi Kivity
2010-06-13 9:29 ` [PATCH v4] " Sheng Yang
2010-06-14 20:33 ` Marcelo Tosatti
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=4C14962A.9030608@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=sheng@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox