]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Jun 2023 23:39:46 +0000 (01:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Aug 2023 17:48:24 +0000 (19:48 +0200)
commit b81fac906a8f9e682e513ddd95697ec7a20878d4 upstream

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
Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/cpu/common.c
arch/x86/kernel/smpboot.c

index 55b10872ab8013703e376c7e6a5a145ed8d997a8..98d3c20a12d421e222439ddd0efc810ccac7f9ec 100644 (file)
@@ -1210,8 +1210,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
        cpu_set_bug_bits(c);
 
-       fpu__init_system();
-
 #ifdef CONFIG_X86_32
        /*
         * Regardless of whether PCID is enumerated, the SDM says
@@ -1886,8 +1884,6 @@ void cpu_init(void)
        clear_all_debug_regs();
        dbg_restore_debug_regs();
 
-       fpu__init_cpu();
-
        if (is_uv_system())
                uv_cpu_init();
 
@@ -1950,8 +1946,6 @@ void cpu_init(void)
        clear_all_debug_regs();
        dbg_restore_debug_regs();
 
-       fpu__init_cpu();
-
        load_fixmap_gdt(cpu);
 }
 #endif
@@ -2034,6 +2028,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)) {
index 66f2a950935a51cbff1d834aaec575b00e832d20..aea06e7a6bee8f3fd262159db70928ec2e14bc98 100644 (file)
@@ -232,6 +232,7 @@ static void notrace start_secondary(void *unused)
 #endif
        load_current_idt();
        cpu_init();
+       fpu__init_cpu();
        x86_cpuinit.early_percpu_clock_init();
        preempt_disable();
        smp_callin();