From: Marcelo Tosatti <mtosatti@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, gleb@redhat.com, agraf@suse.de,
chao.zhou@intel.com, magnus@boden.cx, kvm@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86: fix KVM_SET_XCRS loop
Date: Thu, 17 Oct 2013 21:04:21 -0300 [thread overview]
Message-ID: <20131018000421.GA6793@amt.cnet> (raw)
In-Reply-To: <1382021447-20216-3-git-send-email-pbonzini@redhat.com>
On Thu, Oct 17, 2013 at 04:50:47PM +0200, Paolo Bonzini wrote:
> The loop was always using 0 as the index. This means that
> any rubbish after the first element of the array went undetected.
> It seems reasonable to assume that no KVM userspace did that.
It is not a typo, look at __kvm_set_xcr when setting
guest_xcrs->xcrs[i].value, with i != 0.
The code is not prepared to deal with XCR != 0 (because its not
implemented in hw).
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/x86.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index f4e1391..f91dff2 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3062,9 +3062,9 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
>
> for (i = 0; i < guest_xcrs->nr_xcrs; i++)
> /* Only support XCR0 currently */
> - if (guest_xcrs->xcrs[0].xcr == XCR_XFEATURE_ENABLED_MASK) {
> + if (guest_xcrs->xcrs[i].xcr == XCR_XFEATURE_ENABLED_MASK) {
> r = __kvm_set_xcr(vcpu, XCR_XFEATURE_ENABLED_MASK,
> - guest_xcrs->xcrs[0].value);
> + guest_xcrs->xcrs[i].value);
> break;
> }
> if (r)
> --
> 1.8.3.1
next prev parent reply other threads:[~2013-10-18 0:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 14:50 [PATCH 0/2] KVM_SET_XCRS fixes Paolo Bonzini
2013-10-17 14:50 ` [PATCH 1/2] KVM: x86: fix KVM_SET_XCRS for CPUs that do not support XSAVE Paolo Bonzini
2013-10-17 14:50 ` [PATCH 2/2] KVM: x86: fix KVM_SET_XCRS loop Paolo Bonzini
2013-10-18 0:04 ` Marcelo Tosatti [this message]
2013-10-18 6:46 ` Paolo Bonzini
2013-10-31 8:32 ` [PATCH 0/2] KVM_SET_XCRS fixes Gleb Natapov
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=20131018000421.GA6793@amt.cnet \
--to=mtosatti@redhat.com \
--cc=agraf@suse.de \
--cc=chao.zhou@intel.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=magnus@boden.cx \
--cc=pbonzini@redhat.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.