linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <wanpeng.li@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Fenghua Yu <fenghua.yu@intel.com>,
	stable@vger.kernel.org, Nadav Amit <namit@cs.technion.ac.il>,
	Andy Lutomirski <luto@amacapital.net>
Subject: Re: [CFT PATCH 2/2] KVM: x86: support XSAVES usage in the host
Date: Mon, 24 Nov 2014 11:07:11 +0100	[thread overview]
Message-ID: <5473034F.7030408@redhat.com> (raw)
In-Reply-To: <20141124021009.GB27849@kernel>



On 24/11/2014 03:10, Wanpeng Li wrote:
> Hi Paolo,
> On Fri, Nov 21, 2014 at 07:31:18PM +0100, Paolo Bonzini wrote:
> [...]
>> +		u64 feature = valid & -valid;
>> +		int index = fls64(feature) - 1;
>> +		void *src = get_xsave_addr(xsave, feature);
>> +
>> +	        if (src) {
>> +			u32 size, offset, ecx, edx;
>> +			cpuid_count(XSTATE_CPUID, index,
>> +				    &size, &offset, &ecx, &edx);
>> +	                memcpy(dest + offset, src, size);
> 
> The offset you get is still for compact format

No, it's not, or all old software using XSAVE/XRSTOR would be broken.

The code in arch/x86/kernel/xsave.c agrees with me; compacted offsets
(xsave_comp_offsets) are computed by summing sizes, while non-compacted
offsets (xsave_offsets) come for CPUID.

> , so you almost convert compat 
> format to compat format instead of convert compact format to standard format. 
> In addition, I think convert standard format to compact format should be 
> implemented in put path.

If I do that, userspace is broken because it expects standard format.
Hence, passing XSAVE data to userspace in compact format can be done,
but has to be guarded by an explicitly enabled capability (using
KVM_ENABLE_CAP).

I do not think that's useful, since no supervisor-specific states are
defined yet, and anyway they can be passed using KVM_GET/SET_MSR because
this is not a fast path.

Paolo

  reply	other threads:[~2014-11-24 10:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 18:31 [CFT PATCH 0/2] KVM: support XSAVES usage in the host Paolo Bonzini
2014-11-21 18:31 ` [CFT PATCH 1/2] kvm: x86: mask out XSAVES Paolo Bonzini
2014-11-21 18:31 ` [CFT PATCH 2/2] KVM: x86: support XSAVES usage in the host Paolo Bonzini
2014-11-21 20:06   ` Andy Lutomirski
2014-11-21 21:58     ` Paolo Bonzini
2014-11-24  2:10   ` Wanpeng Li
2014-11-24 10:07     ` Paolo Bonzini [this message]
2014-11-23  8:16 ` [CFT PATCH 0/2] KVM: " Nadav Amit
2014-11-23  8:24   ` Wanpeng Li
2014-11-23  8:31     ` Nadav Amit
2014-11-23  8:34       ` Wanpeng Li
2014-11-24 11:39   ` Paolo Bonzini
2014-11-24 15:28     ` Nadav Amit
2014-11-24 15:54       ` Paolo Bonzini
2014-11-24 17:53       ` Paolo Bonzini
2014-11-24 18:31         ` Nadav Amit

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=5473034F.7030408@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=fenghua.yu@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=namit@cs.technion.ac.il \
    --cc=stable@vger.kernel.org \
    --cc=wanpeng.li@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;
as well as URLs for NNTP newsgroup(s).