Skip to content

Commit

Permalink
x86/fpu: Set up init_fpstate orderly
Browse files Browse the repository at this point in the history
The init_fpstate initialization code is spreaded out. The init data is
stored in init_fpstate.xsave ealier before its correspondent features
and size are configured there.

Configure the size and features before establishing the XSTATE buffer for
init state.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
  • Loading branch information
ChangSeokBae committed Aug 9, 2022
1 parent 3d7cb6b commit c17cdb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 0 additions & 8 deletions arch/x86/kernel/fpu/init.c
Expand Up @@ -210,13 +210,6 @@ static void __init fpu__init_system_xstate_size_legacy(void)
fpstate_reset(&current->thread.fpu);
}

static void __init fpu__init_init_fpstate(void)
{
/* Bring init_fpstate size and features up to date */
init_fpstate.size = fpu_kernel_cfg.max_size;
init_fpstate.xfeatures = fpu_kernel_cfg.max_features;
}

/*
* Called on the boot CPU once per system bootup, to set up the initial
* FPU state that is later cloned into all processes:
Expand All @@ -236,5 +229,4 @@ void __init fpu__init_system(struct cpuinfo_x86 *c)
fpu__init_system_xstate_size_legacy();
fpu__init_system_xstate(fpu_kernel_cfg.max_size);
fpu__init_task_struct_size();
fpu__init_init_fpstate();
}
6 changes: 5 additions & 1 deletion arch/x86/kernel/fpu/xstate.c
Expand Up @@ -360,7 +360,7 @@ static void __init setup_init_fpu_buf(void)

print_xstate_features();

xstate_init_xcomp_bv(&init_fpstate.regs.xsave, fpu_kernel_cfg.max_features);
xstate_init_xcomp_bv(&init_fpstate.regs.xsave, init_fpstate.xfeatures);

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

/* Bring init_fpstate size and features up to date */
init_fpstate.size = fpu_kernel_cfg.max_size;
init_fpstate.xfeatures = fpu_kernel_cfg.max_features;

setup_init_fpu_buf();

/*
Expand Down

0 comments on commit c17cdb7

Please sign in to comment.