Skip to content

Commit 35a77d4

Browse files
KAGA-KOKOsuryasaimadhu
authored andcommitted
x86/fpu/xsave: Initialize offset/size cache early
Reading XSTATE feature information from CPUID over and over does not make sense. The information has to be cached anyway, so it can be done early. Prepare for runtime calculation of XSTATE offsets and allow consolidation of the size calculation functions in a later step. Rename the function while at it as it does not setup any features. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20220324134623.519411939@linutronix.de
1 parent d47f71f commit 35a77d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kernel/fpu/xstate.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static bool xfeature_enabled(enum xfeature xfeature)
180180
* Record the offsets and sizes of various xstates contained
181181
* in the XSAVE state memory layout.
182182
*/
183-
static void __init setup_xstate_features(void)
183+
static void __init setup_xstate_cache(void)
184184
{
185185
u32 eax, ebx, ecx, edx, i;
186186
/* start at the beginning of the "extended state" */
@@ -390,7 +390,6 @@ static void __init setup_init_fpu_buf(void)
390390
if (!boot_cpu_has(X86_FEATURE_XSAVE))
391391
return;
392392

393-
setup_xstate_features();
394393
print_xstate_features();
395394

396395
xstate_init_xcomp_bv(&init_fpstate.regs.xsave, fpu_kernel_cfg.max_features);
@@ -906,6 +905,10 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
906905

907906
/* Enable xstate instructions to be able to continue with initialization: */
908907
fpu__init_cpu_xstate();
908+
909+
/* Cache size, offset and flags for initialization */
910+
setup_xstate_cache();
911+
909912
err = init_xstate_size();
910913
if (err)
911914
goto out_disable;

0 commit comments

Comments
 (0)