Skip to content

Commit

Permalink
x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
Browse files Browse the repository at this point in the history
Initializing the FPU during the early boot process is a pointless
exercise. Early boot is convoluted and fragile enough.

Nothing requires that the FPU is set up early. It has to be initialized
before fork_init() because the task_struct size depends on the FPU register
buffer size.

Move the initialization to arch_cpu_finalize_init() which is the perfect
place to do so.

No functional change.

This allows to remove quite some of the custom early command line parsing,
but that's subject to the next installment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.902376621@linutronix.de
  • Loading branch information
Thomas Gleixner committed Jun 16, 2023
1 parent 1703db2 commit b81fac9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,8 +1604,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)

sld_setup(c);

fpu__init_system();

#ifdef CONFIG_X86_32
/*
* Regardless of whether PCID is enumerated, the SDM says
Expand Down Expand Up @@ -2287,8 +2285,6 @@ void cpu_init(void)

doublefault_init_cpu_tss();

fpu__init_cpu();

if (is_uv_system())
uv_cpu_init();

Expand All @@ -2304,6 +2300,7 @@ void cpu_init_secondary(void)
*/
cpu_init_exception_handling();
cpu_init();
fpu__init_cpu();
}
#endif

Expand Down Expand Up @@ -2396,6 +2393,13 @@ void __init arch_cpu_finalize_init(void)
'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
}

/*
* Must be before alternatives because it might set or clear
* feature bits.
*/
fpu__init_system();
fpu__init_cpu();

alternative_instructions();

if (IS_ENABLED(CONFIG_X86_64)) {
Expand Down

0 comments on commit b81fac9

Please sign in to comment.