From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Huaitong Han <huaitong.han@intel.com>,
Wei Liu <wei.liu2@citrix.com>, Luwei Kang <luwei.kang@intel.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH for-4.7] x86/cpuid: Calculate a guests xfeature_mask from its featureset
Date: Fri, 3 Jun 2016 12:03:48 +0100 [thread overview]
Message-ID: <57516414.4020200@citrix.com> (raw)
In-Reply-To: <575175BE02000078000F181D@prv-mh.provo.novell.com>
On 03/06/16 11:19, Jan Beulich wrote:
>>>> On 02.06.16 at 18:48, <andrew.cooper3@citrix.com> wrote:
>> @@ -3443,6 +3443,51 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
>> switch ( count )
>> {
>> case 0:
>> + {
>> + uint64_t xfeature_mask = XSTATE_FP_SSE;
>> + uint32_t xstate_size = XSTATE_AREA_MIN_SIZE;
>> +
>> + if ( _ecx & cpufeat_mask(X86_FEATURE_AVX) )
>> + {
>> + xfeature_mask |= XSTATE_YMM;
>> + xstate_size = MAX(xstate_size,
>> + xstate_offsets[_XSTATE_YMM] +
>> + xstate_sizes[_XSTATE_YMM]);
> Any reason not to use the type safe max() here?
Compiler says no. Fixed.
> Also in this first
> construct there's no real reason to use MAX() or max() in the first
> place.
I put it in for code consistency only.
>
>> @@ -1087,19 +1087,48 @@ void pv_cpuid(struct cpu_user_regs *regs)
>> break;
>>
>> case XSTATE_CPUID:
>> - if ( !((!is_control_domain(currd) && !is_hardware_domain(currd)
>> - ? ({
>> - uint32_t ecx;
>> -
>> - domain_cpuid(currd, 1, 0, &tmp, &tmp, &ecx, &tmp);
>> - ecx & pv_featureset[FEATURESET_1c];
>> - })
>> - : cpuid_ecx(1)) & cpufeat_mask(X86_FEATURE_XSAVE)) ||
>> - subleaf >= 63 )
>> +
>> + if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
>> + domain_cpuid(currd, 1, 0, &tmp, &tmp, &_ecx, &tmp);
>> + else
>> + _ecx = cpuid_ecx(1);
>> + _ecx &= pv_featureset[FEATURESET_1c];
>> +
>> + if ( !(_ecx & cpufeat_mask(X86_FEATURE_XSAVE)) || subleaf >= 63 )
>> goto unsupported;
>> switch ( subleaf )
>> {
>> case 0:
>> + {
>> + uint64_t xfeature_mask = XSTATE_FP_SSE;
>> + uint32_t xstate_size = XSTATE_AREA_MIN_SIZE;
>> +
>> + if ( _ecx & cpufeat_mask(X86_FEATURE_AVX) )
>> + {
>> + xfeature_mask |= XSTATE_YMM;
>> + xstate_size = MAX(xstate_size,
>> + xstate_offsets[_XSTATE_YMM] +
>> + xstate_sizes[_XSTATE_YMM]);
>> + }
>> +
>> + if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
>> + domain_cpuid(currd, 0x80000001, 0, &tmp, &tmp, &_ecx, &tmp);
>> + else
>> + _ecx = cpuid_ecx(0x80000001);
>> + _ecx &= pv_featureset[FEATURESET_e1c];
>> +
>> + if ( _ecx & cpufeat_mask(X86_FEATURE_LWP) )
>> + {
>> + xfeature_mask |= XSTATE_LWP;
>> + xstate_size = MAX(xstate_size,
>> + xstate_offsets[_XSTATE_LWP] +
>> + xstate_sizes[_XSTATE_LWP]);
>> + }
> I'm sorry for not noticing in the pre-review that LWP is HVM-only too,
> as per cpufeatureset.h.
So it is. I will triple check all of this.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
prev parent reply other threads:[~2016-06-03 11:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 16:48 [PATCH for-4.7] x86/cpuid: Calculate a guests xfeature_mask from its featureset Andrew Cooper
2016-06-02 17:03 ` Wei Liu
2016-06-03 2:50 ` Kang, Luwei
2016-06-03 7:34 ` Andrew Cooper
2016-06-03 7:37 ` Kang, Luwei
2016-06-03 10:19 ` Jan Beulich
2016-06-03 11:03 ` Andrew Cooper [this message]
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=57516414.4020200@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=huaitong.han@intel.com \
--cc=luwei.kang@intel.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).