@@ -228,13 +228,14 @@ void fpu__init_cpu_xstate(void)
228
228
* states can be set here.
229
229
*/
230
230
xsetbv (XCR_XFEATURE_ENABLED_MASK , xfeatures_mask_user ());
231
+
232
+ /*
233
+ * MSR_IA32_XSS sets supervisor states managed by XSAVES.
234
+ */
235
+ if (boot_cpu_has (X86_FEATURE_XSAVES ))
236
+ wrmsrl (MSR_IA32_XSS , xfeatures_mask_supervisor ());
231
237
}
232
238
233
- /*
234
- * Note that in the future we will likely need a pair of
235
- * functions here: one for user xstates and the other for
236
- * system xstates. For now, they are the same.
237
- */
238
239
static bool xfeature_enabled (enum xfeature xfeature )
239
240
{
240
241
return xfeatures_mask_all & BIT_ULL (xfeature );
@@ -625,9 +626,6 @@ static void do_extra_xstate_size_checks(void)
625
626
* the size of the *user* states. If we use it to size a buffer
626
627
* that we use 'XSAVES' on, we could potentially overflow the
627
628
* buffer because 'XSAVES' saves system states too.
628
- *
629
- * Note that we do not currently set any bits on IA32_XSS so
630
- * 'XCR0 | IA32_XSS == XCR0' for now.
631
629
*/
632
630
static unsigned int __init get_xsaves_size (void )
633
631
{
@@ -750,7 +748,12 @@ void __init fpu__init_system_xstate(void)
750
748
cpuid_count (XSTATE_CPUID , 0 , & eax , & ebx , & ecx , & edx );
751
749
xfeatures_mask_all = eax + ((u64 )edx << 32 );
752
750
753
- /* Place supervisor features in xfeatures_mask_all here */
751
+ /*
752
+ * Find supervisor xstates supported by the processor.
753
+ */
754
+ cpuid_count (XSTATE_CPUID , 1 , & eax , & ebx , & ecx , & edx );
755
+ xfeatures_mask_all |= ecx + ((u64 )edx << 32 );
756
+
754
757
if ((xfeatures_mask_user () & XFEATURE_MASK_FPSSE ) != XFEATURE_MASK_FPSSE ) {
755
758
/*
756
759
* This indicates that something really unexpected happened
@@ -810,6 +813,13 @@ void fpu__resume_cpu(void)
810
813
*/
811
814
if (boot_cpu_has (X86_FEATURE_XSAVE ))
812
815
xsetbv (XCR_XFEATURE_ENABLED_MASK , xfeatures_mask_user ());
816
+
817
+ /*
818
+ * Restore IA32_XSS. The same CPUID bit enumerates support
819
+ * of XSAVES and MSR_IA32_XSS.
820
+ */
821
+ if (boot_cpu_has (X86_FEATURE_XSAVES ))
822
+ wrmsrl (MSR_IA32_XSS , xfeatures_mask_supervisor ());
813
823
}
814
824
815
825
/*
0 commit comments