Commit d037d7fb authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Aichun Shi
Browse files

x86/fpu: Move FPU initialization into arch_cpu_finalize_init()

stable inclusion
from stable-v5.10.189
commit 4ae1cbb730bd574d57d3996d4c20974972d47009
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8LVBS
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4ae1cbb730bd574d57d3996d4c20974972d47009



-------------------------------------

Intel-SIG: commit 4ae1cbb730bd ("x86/fpu: Move FPU initialization into arch_cpu_finalize_init()")
Backport x86 related patches from 5.10.189 upstream

-------------------------------------

commit b81fac90 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: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.902376621@linutronix.de


Signed-off-by: default avatarDaniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAichun Shi <aichun.shi@intel.com>
parent 38d43f61
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1452,8 +1452,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)

	sld_setup(c);

	fpu__init_system();

	init_sigframe_size();

#ifdef CONFIG_X86_32
@@ -2161,8 +2159,6 @@ void cpu_init(void)

	doublefault_init_cpu_tss();

	fpu__init_cpu();

	if (is_uv_system())
		uv_cpu_init();

@@ -2178,6 +2174,7 @@ void cpu_init_secondary(void)
	 */
	cpu_init_exception_handling();
	cpu_init();
	fpu__init_cpu();
}
#endif

@@ -2272,6 +2269,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)) {