From: Thomas Gleixner tglx@linutronix.de
mainline inclusion from mainline-v6.5-rc1 commit b81fac906a8f9e682e513ddd95697ec7a20878d4 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7XLNT CVE: CVE-2022-40982
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
---------------------------
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 conflicts: arch/x86/kernel/cpu/common.c Signed-off-by: Zeng Heng zengheng4@huawei.com --- arch/x86/kernel/cpu/common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 9c7a376d636e..c1e607d2098b 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1439,8 +1439,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
sld_setup(c);
- fpu__init_system(); - init_sigframe_size();
#ifdef CONFIG_X86_32 @@ -2148,8 +2146,6 @@ void cpu_init(void)
doublefault_init_cpu_tss();
- fpu__init_cpu(); - if (is_uv_system()) uv_cpu_init();
@@ -2165,6 +2161,7 @@ void cpu_init_secondary(void) */ cpu_init_exception_handling(); cpu_init(); + fpu__init_cpu(); } #endif
@@ -2241,6 +2238,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)) {