All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/xstate: Don't special case feature collection
@ 2019-02-25 15:03 Andrew Cooper
  2019-02-25 17:01 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2019-02-25 15:03 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monné

The logic in xstate_init() is a rementent of the pre-featuremask days.
Collect the xstate features in generic_identify(), like all other feature
leaves, after which identify_cpu() will apply the known_feature[] mask derived
from the automatically generated CPUID information.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/cpu/common.c |  4 ++++
 xen/arch/x86/xstate.c     | 13 -------------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index de6c5c9..8090131 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -414,6 +414,10 @@ static void generic_identify(struct cpuinfo_x86 *c)
 			    &c->x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)],
 			    &c->x86_capability[cpufeat_word(X86_FEATURE_PKU)],
 			    &c->x86_capability[cpufeat_word(X86_FEATURE_AVX512_4VNNIW)]);
+	if ( c->cpuid_level >= 0xd )
+		cpuid_count(0xd, 1,
+			    &c->x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)],
+			    &tmp, &tmp, &tmp);
 }
 
 /*
diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index 15edd5d..858d1a6 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -628,19 +628,6 @@ void xstate_init(struct cpuinfo_x86 *c)
         BUG_ON(xsave_cntxt_size != _xstate_ctxt_size(feature_mask));
     }
 
-    /* Check extended XSAVE features. */
-    cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx);
-
-    /* Mask out features not currently understood by Xen. */
-    eax &= (cpufeat_mask(X86_FEATURE_XSAVEOPT) |
-            cpufeat_mask(X86_FEATURE_XSAVEC) |
-            cpufeat_mask(X86_FEATURE_XGETBV1) |
-            cpufeat_mask(X86_FEATURE_XSAVES));
-
-    c->x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)] = eax;
-
-    BUG_ON(eax != boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)]);
-
     if ( setup_xstate_features(bsp) && bsp )
         BUG();
 }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/xstate: Don't special case feature collection
  2019-02-25 15:03 [PATCH] x86/xstate: Don't special case feature collection Andrew Cooper
@ 2019-02-25 17:01 ` Jan Beulich
  2019-02-25 18:12   ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2019-02-25 17:01 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Roger Pau Monne

>>> On 25.02.19 at 16:03, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -414,6 +414,10 @@ static void generic_identify(struct cpuinfo_x86 *c)
>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)],
>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_PKU)],
>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_AVX512_4VNNIW)]);
> +	if ( c->cpuid_level >= 0xd )
> +		cpuid_count(0xd, 1,
> +			    &c->x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)],
> +			    &tmp, &tmp, &tmp);

I think this file is still trying to be Linux style, with a couple of
violations. I do notice that the immediately preceding if() is
the same style as the one you add, but I think it would be
more consistent to omit the blanks immediately inside the
parentheses here. Either way,
Acked-by: Jan Beulich <jbeulich@suse.com>

I take it that you're intentionally using 0xd in favor of
XSTATE_CPUID?

As an aside I wonder why we have cpuid_count_ebx(), but
not e.g. cpuid_count_eax() as would have been useful here.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/xstate: Don't special case feature collection
  2019-02-25 17:01 ` Jan Beulich
@ 2019-02-25 18:12   ` Andrew Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2019-02-25 18:12 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Xen-devel, Wei Liu, Roger Pau Monne

On 25/02/2019 17:01, Jan Beulich wrote:
>>>> On 25.02.19 at 16:03, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/cpu/common.c
>> +++ b/xen/arch/x86/cpu/common.c
>> @@ -414,6 +414,10 @@ static void generic_identify(struct cpuinfo_x86 *c)
>>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)],
>>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_PKU)],
>>  			    &c->x86_capability[cpufeat_word(X86_FEATURE_AVX512_4VNNIW)]);
>> +	if ( c->cpuid_level >= 0xd )
>> +		cpuid_count(0xd, 1,
>> +			    &c->x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)],
>> +			    &tmp, &tmp, &tmp);
> I think this file is still trying to be Linux style, with a couple of
> violations. I do notice that the immediately preceding if() is
> the same style as the one you add, but I think it would be
> more consistent to omit the blanks immediately inside the
> parentheses here.

/sigh - will fix.

>  Either way,
> Acked-by: Jan Beulich <jbeulich@suse.com>
>
> I take it that you're intentionally using 0xd in favor of
> XSTATE_CPUID?

XSTATE_CPUID is a bit of an oddity.  CPUID leaves are much more commonly
referred to in their numeric form, both in the documentation and in
technical discussion.  A specific bonus of using 0xd here is that you
can trivially confirm that it is checked against the correct cpuid_level.

> As an aside I wonder why we have cpuid_count_ebx(), but
> not e.g. cpuid_count_eax() as would have been useful here.

Pass.  I don't find those helpers terribly helpful, because they almost
always lead (over time) to redundant invocations of CPUID.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-25 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 15:03 [PATCH] x86/xstate: Don't special case feature collection Andrew Cooper
2019-02-25 17:01 ` Jan Beulich
2019-02-25 18:12   ` Andrew Cooper

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.