Skip to content

Commit c32d7ca

Browse files
ChangSeokBaeKAGA-KOKO
authored andcommitted
x86/fpu: Configure init_fpstate attributes orderly
The init_fpstate setup code is spread out and out of order. The init image is recorded before its scoped features and the buffer size are determined. Determine the scope of init_fpstate components and its size before recording the init state. Also move the relevant code together. Signed-off-by: Chang S. Bae <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 9abf231 commit c32d7ca

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

arch/x86/kernel/fpu/init.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ static void __init fpu__init_system_xstate_size_legacy(void)
210210
fpstate_reset(&current->thread.fpu);
211211
}
212212

213-
static void __init fpu__init_init_fpstate(void)
214-
{
215-
/* Bring init_fpstate size and features up to date */
216-
init_fpstate.size = fpu_kernel_cfg.max_size;
217-
init_fpstate.xfeatures = fpu_kernel_cfg.max_features;
218-
}
219-
220213
/*
221214
* Called on the boot CPU once per system bootup, to set up the initial
222215
* FPU state that is later cloned into all processes:
@@ -236,5 +229,4 @@ void __init fpu__init_system(struct cpuinfo_x86 *c)
236229
fpu__init_system_xstate_size_legacy();
237230
fpu__init_system_xstate(fpu_kernel_cfg.max_size);
238231
fpu__init_task_struct_size();
239-
fpu__init_init_fpstate();
240232
}

arch/x86/kernel/fpu/xstate.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void __init setup_init_fpu_buf(void)
360360

361361
print_xstate_features();
362362

363-
xstate_init_xcomp_bv(&init_fpstate.regs.xsave, fpu_kernel_cfg.max_features);
363+
xstate_init_xcomp_bv(&init_fpstate.regs.xsave, init_fpstate.xfeatures);
364364

365365
/*
366366
* Init all the features state with header.xfeatures being 0x0
@@ -875,6 +875,10 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
875875
update_regset_xstate_info(fpu_user_cfg.max_size,
876876
fpu_user_cfg.max_features);
877877

878+
/* Bring init_fpstate size and features up to date */
879+
init_fpstate.size = fpu_kernel_cfg.max_size;
880+
init_fpstate.xfeatures = fpu_kernel_cfg.max_features;
881+
878882
setup_init_fpu_buf();
879883

880884
/*

0 commit comments

Comments
 (0)