linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process
@ 2023-06-13 23:39 Thomas Gleixner
  2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
                   ` (17 more replies)
  0 siblings, 18 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

Hi!

My team and myself are working on sanitizing the x86 boot process,
especially the complete horror show of CPUID evaluation, which is
constructed with hay-wire circuits, duct tape and superglue.

A related goal is to move the initialization of infrastructure which is not
required during early boot out into a later phase of the boot process.
Early boot is fragile and convoluted enough already, so anything which can
move into a later phase is a win.

X86 FPU initialization is one of the obvious parts which has zero
justification to be done early. The only requirement is that it happens
before alternative patching. Doing it early also requires custom command
line parsing which can be obviously avoided when the initialization happens
later.

Alternative patching happens from check_bugs() which is invoked late in
start_kernel(). Moving FPU initialization into that is too late because
check_bugs() is invoked after fork_init(), but fork_init() requires that
the FPU is initialized on X86 as on X86 the size of task_struct depends on
the FPU register buffer size.

In order to avoid another magic function we set out to move check_bugs()
earlier and inspected all incarnations whether there is any reason to do
that so late. It turned out there is none (famous last words), but it also
revealed that check_bugs() is a gross misnomer.

check_bugs() has become a dump ground for finalizing the CPU initialization
before running the rest of the init code.

Most implementations are empty, a few do actual bug checks, some do
alternative patching and one cobbles a CPU advertisment string together...

As a consequence we decided to rename it to arch_cpu_finalize_init(). The
purely mechanical 's/check_bugs/arch_cpu_finalize_init/' would have been
trivial, but having stared at the actual implementations of check_bugs()
had triggered the scavenger reflex already. So I got the mop out and
cleaned it up completely.

The resulting series consists therefore of three parts:

 1) Patches 1-11

    Rename and mop up check_bugs() which removes a solid amount of
    redundant historical copy & pasta crud:

    39 files changed, 161 insertions(+), 321 deletions(-)

    11 out of the 39 changed files are removed completely.

 2) Patches 12-13

    Move the invocation of arch_cpu_finalize_init() earlier in
    start_kernel() and move the x86'ism mem_encrypt_init() into the x86
    space.

 3) Patches 14-17

    Implement the late FPU initialization for X86 on top. Removal of the
    custom early command line parsing is subject to separate x86 specific
    changes. This part #3 is to illustrate the use case for #2.

The series applies on Linus tree and is also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git init

Thanks,

	tglx
---
 a/arch/alpha/include/asm/bugs.h     |   20 ---------
 a/arch/ia64/include/asm/bugs.h      |   20 ---------
 a/arch/loongarch/include/asm/bugs.h |   15 ------
 a/arch/m68k/include/asm/bugs.h      |   21 ---------
 a/arch/parisc/include/asm/bugs.h    |   20 ---------
 a/arch/powerpc/include/asm/bugs.h   |   15 ------
 a/arch/sh/include/asm/bugs.h        |   74 ---------------------------------
 a/arch/sparc/include/asm/bugs.h     |   18 --------
 a/arch/um/include/asm/bugs.h        |    7 ---
 a/arch/xtensa/include/asm/bugs.h    |   18 --------
 a/include/asm-generic/bugs.h        |   11 -----
 arch/Kconfig                        |    3 +
 arch/arm/Kconfig                    |    1 
 arch/arm/include/asm/bugs.h         |    4 -
 arch/arm/kernel/bugs.c              |    3 -
 arch/ia64/Kconfig                   |    1 
 arch/ia64/kernel/setup.c            |    3 -
 arch/loongarch/Kconfig              |    1 
 arch/loongarch/kernel/setup.c       |    4 -
 arch/m68k/Kconfig                   |    1 
 arch/m68k/kernel/setup_mm.c         |    3 -
 arch/mips/Kconfig                   |    1 
 arch/mips/include/asm/bugs.h        |   17 -------
 arch/mips/kernel/setup.c            |   13 +++++
 arch/sh/Kconfig                     |    1 
 arch/sh/include/asm/processor.h     |    2 
 arch/sh/kernel/idle.c               |    1 
 arch/sh/kernel/setup.c              |   55 +++++++++++++++++++++++++
 arch/sparc/Kconfig                  |    1 
 arch/sparc/kernel/setup_32.c        |    7 +++
 arch/um/Kconfig                     |    1 
 arch/um/kernel/um_arch.c            |    3 -
 arch/x86/Kconfig                    |    1 
 arch/x86/include/asm/bugs.h         |    2 
 arch/x86/include/asm/fpu/api.h      |    2 
 arch/x86/include/asm/mem_encrypt.h  |    7 +--
 arch/x86/include/asm/sigframe.h     |    2 
 arch/x86/kernel/cpu/bugs.c          |   51 -----------------------
 arch/x86/kernel/cpu/common.c        |   79 ++++++++++++++++++++++++++++++++----
 arch/x86/kernel/cpu/cpu.h           |    1 
 arch/x86/kernel/fpu/init.c          |    8 +--
 arch/x86/kernel/signal.c            |    4 +
 include/linux/cpu.h                 |    6 ++
 init/main.c                         |   16 -------
 44 files changed, 192 insertions(+), 352 deletions(-)


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 01/17] init: Provide arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  9:28   ` Borislav Petkov
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init() Thomas Gleixner
                   ` (16 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() has become a dump ground for all sorts of activities to
finalize the CPU initialization before running the rest of the init code.

Most are empty, a few do actual bug checks, some do alternative patching
and some cobble a CPU advertisment string together....

Aside of that the current implementation requires duplicated function
declaration and mostly empty header files for them.

Provide a new function arch_cpu_finalize_init(). Provide a generic
declaration if CONFIG_ARCH_HAS_CPU_FINALIZE_INIT is selected and a stub
inline otherwise.

This requires a temporary #ifdef in start_kernel() which will be removed
along with check_bugs() once the architectures are converted over.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/Kconfig        |    3 +++
 include/linux/cpu.h |    6 ++++++
 init/main.c         |    4 ++++
 3 files changed, 13 insertions(+)
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -285,6 +285,9 @@ config ARCH_HAS_DMA_SET_UNCACHED
 config ARCH_HAS_DMA_CLEAR_UNCACHED
 	bool
 
+config ARCH_HAS_CPU_FINALIZE_INIT
+	bool
+
 # Select if arch init_task must go in the __init_task_data section
 config ARCH_TASK_STRUCT_ON_STACK
 	bool
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -184,6 +184,12 @@ void arch_cpu_idle_enter(void);
 void arch_cpu_idle_exit(void);
 void __noreturn arch_cpu_idle_dead(void);
 
+#ifdef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
+void arch_cpu_finalize_init(void);
+#else
+static inline void arch_cpu_finalize_init(void) { }
+#endif
+
 int cpu_report_state(int cpu);
 int cpu_check_up_prepare(int cpu);
 void cpu_set_state_online(int cpu);
--- a/init/main.c
+++ b/init/main.c
@@ -1078,7 +1078,11 @@ asmlinkage __visible void __init __no_sa
 	taskstats_init_early();
 	delayacct_init();
 
+	arch_cpu_finalize_init();
+	/* Temporary conditional until everything has been converted */
+#ifndef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
 	check_bugs();
+#endif
 
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
  2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  9:53   ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 03/17] ARM: cpu: " Thomas Gleixner
                   ` (15 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() is a dump ground for finalizing the CPU bringup. Only parts of
it has to do with actual CPU bugs.

Split it apart into arch_cpu_finalize_init() and cpu_select_mitigations().

Fixup the bogus 32bit comments while at it.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/Kconfig             |    1 
 arch/x86/include/asm/bugs.h  |    2 -
 arch/x86/kernel/cpu/bugs.c   |   51 -----------------------------------------
 arch/x86/kernel/cpu/common.c |   53 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/cpu/cpu.h    |    1 
 5 files changed, 56 insertions(+), 52 deletions(-)

--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -71,6 +71,7 @@ config X86
 	select ARCH_HAS_ACPI_TABLE_UPGRADE	if ACPI
 	select ARCH_HAS_CACHE_LINE_SIZE
 	select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL
 	select ARCH_HAS_DEBUG_VM_PGTABLE	if !X86_PAE
--- a/arch/x86/include/asm/bugs.h
+++ b/arch/x86/include/asm/bugs.h
@@ -4,8 +4,6 @@
 
 #include <asm/processor.h>
 
-extern void check_bugs(void);
-
 #if defined(CONFIG_CPU_SUP_INTEL) && defined(CONFIG_X86_32)
 int ppro_with_ram_bug(void);
 #else
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -9,7 +9,6 @@
  *	- Andrew D. Balsa (code cleanup).
  */
 #include <linux/init.h>
-#include <linux/utsname.h>
 #include <linux/cpu.h>
 #include <linux/module.h>
 #include <linux/nospec.h>
@@ -27,8 +26,6 @@
 #include <asm/msr.h>
 #include <asm/vmx.h>
 #include <asm/paravirt.h>
-#include <asm/alternative.h>
-#include <asm/set_memory.h>
 #include <asm/intel-family.h>
 #include <asm/e820/api.h>
 #include <asm/hypervisor.h>
@@ -125,21 +122,8 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l
 DEFINE_STATIC_KEY_FALSE(mmio_stale_data_clear);
 EXPORT_SYMBOL_GPL(mmio_stale_data_clear);
 
-void __init check_bugs(void)
+void __init cpu_select_mitigations(void)
 {
-	identify_boot_cpu();
-
-	/*
-	 * identify_boot_cpu() initialized SMT support information, let the
-	 * core code know.
-	 */
-	cpu_smt_check_topology();
-
-	if (!IS_ENABLED(CONFIG_SMP)) {
-		pr_info("CPU: ");
-		print_cpu_info(&boot_cpu_data);
-	}
-
 	/*
 	 * Read the SPEC_CTRL MSR to account for reserved bits which may
 	 * have unknown values. AMD64_LS_CFG MSR is cached in the early AMD
@@ -176,39 +160,6 @@ void __init check_bugs(void)
 	md_clear_select_mitigation();
 	srbds_select_mitigation();
 	l1d_flush_select_mitigation();
-
-	arch_smt_update();
-
-#ifdef CONFIG_X86_32
-	/*
-	 * Check whether we are able to run this kernel safely on SMP.
-	 *
-	 * - i386 is no longer supported.
-	 * - In order to run on anything without a TSC, we need to be
-	 *   compiled for a i486.
-	 */
-	if (boot_cpu_data.x86 < 4)
-		panic("Kernel requires i486+ for 'invlpg' and other features");
-
-	init_utsname()->machine[1] =
-		'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
-	alternative_instructions();
-
-	fpu__init_check_bugs();
-#else /* CONFIG_X86_64 */
-	alternative_instructions();
-
-	/*
-	 * Make sure the first 2MB area is not mapped by huge pages
-	 * There are typically fixed size MTRRs in there and overlapping
-	 * MTRRs into large pages causes slow downs.
-	 *
-	 * Right now we don't do that with gbpages because there seems
-	 * very little benefit for that case.
-	 */
-	if (!direct_gbpages)
-		set_memory_4k((unsigned long)__va(0), 1);
-#endif
 }
 
 /*
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -19,11 +19,14 @@
 #include <linux/kprobes.h>
 #include <linux/kgdb.h>
 #include <linux/smp.h>
+#include <linux/cpu.h>
 #include <linux/io.h>
 #include <linux/syscore_ops.h>
 #include <linux/pgtable.h>
 #include <linux/stackprotector.h>
+#include <linux/utsname.h>
 
+#include <asm/alternative.h>
 #include <asm/cmdline.h>
 #include <asm/perf_event.h>
 #include <asm/mmu_context.h>
@@ -59,6 +62,7 @@
 #include <asm/intel-family.h>
 #include <asm/cpu_device_id.h>
 #include <asm/uv/uv.h>
+#include <asm/set_memory.h>
 #include <asm/sigframe.h>
 #include <asm/traps.h>
 #include <asm/sev.h>
@@ -2362,3 +2366,52 @@ void arch_smt_update(void)
 	/* Check whether IPI broadcasting can be enabled */
 	apic_smt_update();
 }
+
+void __init arch_cpu_finalize_init(void)
+{
+	identify_boot_cpu();
+
+	/*
+	 * identify_boot_cpu() initialized SMT support information, let the
+	 * core code know.
+	 */
+	cpu_smt_check_topology();
+
+	if (!IS_ENABLED(CONFIG_SMP)) {
+		pr_info("CPU: ");
+		print_cpu_info(&boot_cpu_data);
+	}
+
+	arch_smt_update();
+
+	cpu_select_mitigations();
+
+	if (IS_ENABLED(CONFIG_X86_32)) {
+		/*
+		 * Check whether this is a real i386 which is not longer
+		 * supported and fixup the utsname.
+		 */
+		if (boot_cpu_data.x86 < 4)
+			panic("Kernel requires i486+ for 'invlpg' and other features");
+
+		init_utsname()->machine[1] =
+			'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
+	}
+
+	alternative_instructions();
+
+	if (IS_ENABLED(CONFIG_X86_64)) {
+		/*
+		 * Make sure the first 2MB area is not mapped by huge pages
+		 * There are typically fixed size MTRRs in there and overlapping
+		 * MTRRs into large pages causes slow downs.
+		 *
+		 * Right now we don't do that with gbpages because there seems
+		 * very little benefit for that case.
+		 */
+		if (!direct_gbpages)
+			set_memory_4k((unsigned long)__va(0), 1);
+	} else {
+		fpu__init_check_bugs();
+	}
+}
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -79,6 +79,7 @@ extern void detect_ht(struct cpuinfo_x86
 extern void check_null_seg_clears_base(struct cpuinfo_x86 *c);
 
 unsigned int aperfmperf_get_khz(int cpu);
+void cpu_select_mitigations(void);
 
 extern void x86_spec_ctrl_setup_ap(void);
 extern void update_srbds_msr(void);


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 03/17] ARM: cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
  2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
  2023-06-13 23:39 ` [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:27   ` [patch 03/17] " Philippe Mathieu-Daudé
  2023-06-13 23:39 ` [patch 04/17] ia64/cpu: " Thomas Gleixner
                   ` (14 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/Kconfig            |    1 +
 arch/arm/include/asm/bugs.h |    4 ----
 arch/arm/kernel/bugs.c      |    3 ++-
 3 files changed, 3 insertions(+), 5 deletions(-)

--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -5,6 +5,7 @@ config ARM
 	select ARCH_32BIT_OFF_T
 	select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE if HAVE_KRETPROBES && FRAME_POINTER && !ARM_UNWIND
 	select ARCH_HAS_BINFMT_FLAT
+	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL if MMU
 	select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE
--- a/arch/arm/include/asm/bugs.h
+++ b/arch/arm/include/asm/bugs.h
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- *  arch/arm/include/asm/bugs.h
- *
  *  Copyright (C) 1995-2003 Russell King
  */
 #ifndef __ASM_BUGS_H
@@ -10,10 +8,8 @@
 extern void check_writebuffer_bugs(void);
 
 #ifdef CONFIG_MMU
-extern void check_bugs(void);
 extern void check_other_bugs(void);
 #else
-#define check_bugs() do { } while (0)
 #define check_other_bugs() do { } while (0)
 #endif
 
--- a/arch/arm/kernel/bugs.c
+++ b/arch/arm/kernel/bugs.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/init.h>
+#include <linux/cpu.h>
 #include <asm/bugs.h>
 #include <asm/proc-fns.h>
 
@@ -11,7 +12,7 @@ void check_other_bugs(void)
 #endif
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	check_writebuffer_bugs();
 	check_other_bugs();


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 04/17] ia64/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (2 preceding siblings ...)
  2023-06-13 23:39 ` [patch 03/17] ARM: cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:24   ` [patch 04/17] " Philippe Mathieu-Daudé
  2023-06-13 23:39 ` [patch 05/17] loongarch/cpu: " Thomas Gleixner
                   ` (13 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, linux-ia64, Russell King, linux-arm-kernel,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-ia64@vger.kernel.org
---
 arch/ia64/Kconfig            |    1 +
 arch/ia64/include/asm/bugs.h |   20 --------------------
 arch/ia64/kernel/setup.c     |    3 +--
 3 files changed, 2 insertions(+), 22 deletions(-)

--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,7 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_BINFMT_ELF_EXTRA_PHDRS
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_DMA_MARK_CLEAN
 	select ARCH_HAS_STRNCPY_FROM_USER
 	select ARCH_HAS_STRNLEN_USER
--- a/arch/ia64/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- *
- * Based on <asm-alpha/bugs.h>.
- *
- * Modified 1998, 1999, 2003
- *	David Mosberger-Tang <davidm@hpl.hp.com>,  Hewlett-Packard Co.
- */
-#ifndef _ASM_IA64_BUGS_H
-#define _ASM_IA64_BUGS_H
-
-#include <asm/processor.h>
-
-extern void check_bugs (void);
-
-#endif /* _ASM_IA64_BUGS_H */
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -1067,8 +1067,7 @@ cpu_init (void)
 	}
 }
 
-void __init
-check_bugs (void)
+void __init arch_cpu_finalize_init(void)
 {
 	ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
 			       (unsigned long) __end___mckinley_e9_bundles);


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 05/17] loongarch/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (3 preceding siblings ...)
  2023-06-13 23:39 ` [patch 04/17] ia64/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:24   ` [patch 05/17] " Philippe Mathieu-Daudé
  2023-06-13 23:39 ` [patch 06/17] m68k/cpu: " Thomas Gleixner
                   ` (12 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Huacai Chen, WANG Xuerui, loongarch, Russell King,
	linux-arm-kernel, linux-ia64, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: loongarch@lists.linux.dev
---
 arch/loongarch/Kconfig            |    1 +
 arch/loongarch/include/asm/bugs.h |   15 ---------------
 arch/loongarch/kernel/setup.c     |    4 ++--
 3 files changed, 3 insertions(+), 17 deletions(-)

--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -10,6 +10,7 @@ config LOONGARCH
 	select ARCH_ENABLE_MEMORY_HOTPLUG
 	select ARCH_ENABLE_MEMORY_HOTREMOVE
 	select ARCH_HAS_ACPI_TABLE_UPGRADE	if ACPI
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
 	select ARCH_HAS_PTE_SPECIAL
--- a/arch/loongarch/include/asm/bugs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
- */
-#ifndef _ASM_BUGS_H
-#define _ASM_BUGS_H
-
-#include <asm/cpu.h>
-#include <asm/cpu-info.h>
-
-extern void check_bugs(void);
-
-#endif /* _ASM_BUGS_H */
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -12,6 +12,7 @@
  */
 #include <linux/init.h>
 #include <linux/acpi.h>
+#include <linux/cpu.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/export.h>
@@ -37,7 +38,6 @@
 #include <asm/addrspace.h>
 #include <asm/alternative.h>
 #include <asm/bootinfo.h>
-#include <asm/bugs.h>
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/dma.h>
@@ -87,7 +87,7 @@ const char *get_system_type(void)
 	return "generic-loongson-machine";
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	alternative_instructions();
 }


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 06/17] m68k/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (4 preceding siblings ...)
  2023-06-13 23:39 ` [patch 05/17] loongarch/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  9:22   ` Geert Uytterhoeven
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 07/17] mips/cpu: " Thomas Gleixner
                   ` (11 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Geert Uytterhoeven, linux-m68k, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
---
 arch/m68k/Kconfig            |    1 +
 arch/m68k/include/asm/bugs.h |   21 ---------------------
 arch/m68k/kernel/setup_mm.c  |    3 ++-
 3 files changed, 3 insertions(+), 22 deletions(-)

--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -4,6 +4,7 @@ config M68K
 	default y
 	select ARCH_32BIT_OFF_T
 	select ARCH_HAS_BINFMT_FLAT
+	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
--- a/arch/m68k/include/asm/bugs.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- *  include/asm-m68k/bugs.h
- *
- *  Copyright (C) 1994  Linus Torvalds
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-#ifdef CONFIG_MMU
-extern void check_bugs(void);	/* in arch/m68k/kernel/setup.c */
-#else
-static void check_bugs(void)
-{
-}
-#endif
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/cpu.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
@@ -504,7 +505,7 @@ static int __init proc_hardware_init(voi
 module_init(proc_hardware_init);
 #endif
 
-void check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 #if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU)
 	if (m68k_fputype == 0) {


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 07/17] mips/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (5 preceding siblings ...)
  2023-06-13 23:39 ` [patch 06/17] m68k/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:25   ` [patch 07/17] " Philippe Mathieu-Daudé
  2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
                   ` (10 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Thomas Bogendoerfer, linux-mips, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org
---
 arch/mips/Kconfig            |    1 +
 arch/mips/include/asm/bugs.h |   17 -----------------
 arch/mips/kernel/setup.c     |   13 +++++++++++++
 3 files changed, 14 insertions(+), 17 deletions(-)

--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -4,6 +4,7 @@ config MIPS
 	default y
 	select ARCH_32BIT_OFF_T if !64BIT
 	select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER if !CC_IS_CLANG || CLANG_VERSION >= 140000
 	select ARCH_HAS_DEBUG_VIRTUAL if !64BIT
 	select ARCH_HAS_FORTIFY_SOURCE
--- a/arch/mips/include/asm/bugs.h
+++ b/arch/mips/include/asm/bugs.h
@@ -1,17 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
  * Copyright (C) 2007  Maciej W. Rozycki
- *
- * Needs:
- *	void check_bugs(void);
  */
 #ifndef _ASM_BUGS_H
 #define _ASM_BUGS_H
 
 #include <linux/bug.h>
-#include <linux/delay.h>
 #include <linux/smp.h>
 
 #include <asm/cpu.h>
@@ -24,17 +18,6 @@ extern void check_bugs64_early(void);
 extern void check_bugs32(void);
 extern void check_bugs64(void);
 
-static inline void __init check_bugs(void)
-{
-	unsigned int cpu = smp_processor_id();
-
-	cpu_data[cpu].udelay_val = loops_per_jiffy;
-	check_bugs32();
-
-	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
-		check_bugs64();
-}
-
 static inline int r4k_daddiu_bug(void)
 {
 	if (!IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -11,6 +11,8 @@
  * Copyright (C) 2000, 2001, 2002, 2007	 Maciej W. Rozycki
  */
 #include <linux/init.h>
+#include <linux/cpu.h>
+#include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/export.h>
 #include <linux/screen_info.h>
@@ -841,3 +843,14 @@ static int __init setnocoherentio(char *
 }
 early_param("nocoherentio", setnocoherentio);
 #endif
+
+void __init arch_cpu_finalize_init(void)
+{
+	unsigned int cpu = smp_processor_id();
+
+	cpu_data[cpu].udelay_val = loops_per_jiffy;
+	check_bugs32();
+
+	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
+		check_bugs64();
+}


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 08/17] sh/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (6 preceding siblings ...)
  2023-06-13 23:39 ` [patch 07/17] mips/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
                     ` (2 more replies)
  2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
                   ` (9 subsequent siblings)
  17 siblings, 3 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer,
	linux-mips, David S. Miller, sparclinux, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-um, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/Kconfig                 |    1 
 arch/sh/include/asm/bugs.h      |   74 ----------------------------------------
 arch/sh/include/asm/processor.h |    2 +
 arch/sh/kernel/idle.c           |    1 
 arch/sh/kernel/setup.c          |   55 +++++++++++++++++++++++++++++
 5 files changed, 59 insertions(+), 74 deletions(-)

--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -6,6 +6,7 @@ config SUPERH
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select ARCH_HAS_BINFMT_FLAT if !MMU
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_GIGANTIC_PAGE
 	select ARCH_HAS_GCOV_PROFILE_ALL
--- a/arch/sh/include/asm/bugs.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_SH_BUGS_H
-#define __ASM_SH_BUGS_H
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-/*
- * I don't know of any Super-H bugs yet.
- */
-
-#include <asm/processor.h>
-
-extern void select_idle_routine(void);
-
-static void __init check_bugs(void)
-{
-	extern unsigned long loops_per_jiffy;
-	char *p = &init_utsname()->machine[2]; /* "sh" */
-
-	select_idle_routine();
-
-	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
-
-	switch (current_cpu_data.family) {
-	case CPU_FAMILY_SH2:
-		*p++ = '2';
-		break;
-	case CPU_FAMILY_SH2A:
-		*p++ = '2';
-		*p++ = 'a';
-		break;
-	case CPU_FAMILY_SH3:
-		*p++ = '3';
-		break;
-	case CPU_FAMILY_SH4:
-		*p++ = '4';
-		break;
-	case CPU_FAMILY_SH4A:
-		*p++ = '4';
-		*p++ = 'a';
-		break;
-	case CPU_FAMILY_SH4AL_DSP:
-		*p++ = '4';
-		*p++ = 'a';
-		*p++ = 'l';
-		*p++ = '-';
-		*p++ = 'd';
-		*p++ = 's';
-		*p++ = 'p';
-		break;
-	case CPU_FAMILY_UNKNOWN:
-		/*
-		 * Specifically use CPU_FAMILY_UNKNOWN rather than
-		 * default:, so we're able to have the compiler whine
-		 * about unhandled enumerations.
-		 */
-		break;
-	}
-
-	printk("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
-
-#ifndef __LITTLE_ENDIAN__
-	/* 'eb' means 'Endian Big' */
-	*p++ = 'e';
-	*p++ = 'b';
-#endif
-	*p = '\0';
-}
-#endif /* __ASM_SH_BUGS_H */
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -166,6 +166,8 @@ extern unsigned int instruction_size(uns
 #define instruction_size(insn)	(2)
 #endif
 
+void select_idle_routine(void);
+
 #endif /* __ASSEMBLY__ */
 
 #include <asm/processor_32.h>
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -15,6 +15,7 @@
 #include <linux/irqflags.h>
 #include <linux/smp.h>
 #include <linux/atomic.h>
+#include <asm/processor.h>
 #include <asm/smp.h>
 #include <asm/bl_bit.h>
 
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -43,6 +43,7 @@
 #include <asm/smp.h>
 #include <asm/mmu_context.h>
 #include <asm/mmzone.h>
+#include <asm/processor.h>
 #include <asm/sparsemem.h>
 #include <asm/platform_early.h>
 
@@ -354,3 +355,57 @@ int test_mode_pin(int pin)
 {
 	return sh_mv.mv_mode_pins() & pin;
 }
+
+void __init arch_cpu_finalize_init(void)
+{
+	char *p = &init_utsname()->machine[2]; /* "sh" */
+
+	select_idle_routine();
+
+	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
+
+	switch (current_cpu_data.family) {
+	case CPU_FAMILY_SH2:
+		*p++ = '2';
+		break;
+	case CPU_FAMILY_SH2A:
+		*p++ = '2';
+		*p++ = 'a';
+		break;
+	case CPU_FAMILY_SH3:
+		*p++ = '3';
+		break;
+	case CPU_FAMILY_SH4:
+		*p++ = '4';
+		break;
+	case CPU_FAMILY_SH4A:
+		*p++ = '4';
+		*p++ = 'a';
+		break;
+	case CPU_FAMILY_SH4AL_DSP:
+		*p++ = '4';
+		*p++ = 'a';
+		*p++ = 'l';
+		*p++ = '-';
+		*p++ = 'd';
+		*p++ = 's';
+		*p++ = 'p';
+		break;
+	case CPU_FAMILY_UNKNOWN:
+		/*
+		 * Specifically use CPU_FAMILY_UNKNOWN rather than
+		 * default:, so we're able to have the compiler whine
+		 * about unhandled enumerations.
+		 */
+		break;
+	}
+
+	pr_info("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
+
+#ifndef __LITTLE_ENDIAN__
+	/* 'eb' means 'Endian Big' */
+	*p++ = 'e';
+	*p++ = 'b';
+#endif
+	*p = '\0';
+}


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 09/17] sparc/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (7 preceding siblings ...)
  2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14 20:41   ` Sam Ravnborg
                     ` (2 more replies)
  2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
                   ` (8 subsequent siblings)
  17 siblings, 3 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, David S. Miller, sparclinux, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer,
	linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-um, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
---
 arch/sparc/Kconfig            |    1 +
 arch/sparc/include/asm/bugs.h |   18 ------------------
 arch/sparc/kernel/setup_32.c  |    7 +++++++
 3 files changed, 8 insertions(+), 18 deletions(-)

--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -52,6 +52,7 @@ config SPARC
 config SPARC32
 	def_bool !64BIT
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CPU_FINALIZE_INIT if !SMP
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select CLZ_TAB
 	select DMA_DIRECT_REMAP
--- a/arch/sparc/include/asm/bugs.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* include/asm/bugs.h:  Sparc probes for various bugs.
- *
- * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net)
- */
-
-#ifdef CONFIG_SPARC32
-#include <asm/cpudata.h>
-#endif
-
-extern unsigned long loops_per_jiffy;
-
-static void __init check_bugs(void)
-{
-#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP)
-	cpu_data(0).udelay_val = loops_per_jiffy;
-#endif
-}
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -412,3 +412,10 @@ static int __init topology_init(void)
 }
 
 subsys_initcall(topology_init);
+
+#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP)
+void __init arch_cpu_finalize_init(void)
+{
+	cpu_data(0).udelay_val = loops_per_jiffy;
+}
+#endif


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 10/17] um/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (8 preceding siblings ...)
  2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  6:51   ` Richard Weinberger
                     ` (2 more replies)
  2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
                   ` (7 subsequent siblings)
  17 siblings, 3 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Richard Weinberger, Anton Ivanov, Johannes Berg,
	linux-um, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-um@lists.infradead.org
---
 arch/um/Kconfig            |    1 +
 arch/um/include/asm/bugs.h |    7 -------
 arch/um/kernel/um_arch.c   |    3 ++-
 3 files changed, 3 insertions(+), 8 deletions(-)

--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -6,6 +6,7 @@ config UML
 	bool
 	default y
 	select ARCH_EPHEMERAL_INODES
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_HAS_KCOV
--- a/arch/um/include/asm/bugs.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __UM_BUGS_H
-#define __UM_BUGS_H
-
-void check_bugs(void);
-
-#endif
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  */
 
+#include <linux/cpu.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/mm.h>
@@ -430,7 +431,7 @@ void __init setup_arch(char **cmdline_p)
 	}
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	arch_check_bugs();
 	os_check_bugs();


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 11/17] init: Remove check_bugs() leftovers
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (9 preceding siblings ...)
  2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  6:14   ` Richard Henderson
                     ` (2 more replies)
  2023-06-13 23:39 ` [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier Thomas Gleixner
                   ` (6 subsequent siblings)
  17 siblings, 3 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Russell King, linux-arm-kernel,
	linux-ia64, Huacai Chen, WANG Xuerui, loongarch,
	Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer, linux-mips,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Tom Lendacky

Everything is converted over to arch_cpu_finalize_init(). Remove the
check_bugs() leftovers including the empty stubs in asm-generic, alpha,
parisc, powerpc and xtensa.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/alpha/include/asm/bugs.h   |   20 --------------------
 arch/parisc/include/asm/bugs.h  |   20 --------------------
 arch/powerpc/include/asm/bugs.h |   15 ---------------
 arch/xtensa/include/asm/bugs.h  |   18 ------------------
 include/asm-generic/bugs.h      |   11 -----------
 init/main.c                     |    5 -----
 6 files changed, 89 deletions(-)

--- a/arch/alpha/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *  include/asm-alpha/bugs.h
- *
- *  Copyright (C) 1994  Linus Torvalds
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-/*
- * I don't know of any alpha bugs yet.. Nice chip
- */
-
-static void check_bugs(void)
-{
-}
--- a/arch/parisc/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- *  include/asm-parisc/bugs.h
- *
- *  Copyright (C) 1999	Mike Shaver
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-#include <asm/processor.h>
-
-static inline void check_bugs(void)
-{
-//	identify_cpu(&boot_cpu_data);
-}
--- a/arch/powerpc/include/asm/bugs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ASM_POWERPC_BUGS_H
-#define _ASM_POWERPC_BUGS_H
-
-/*
- */
-
-/*
- * This file is included by 'init/main.c' to check for
- * architecture-dependent bugs.
- */
-
-static inline void check_bugs(void) { }
-
-#endif	/* _ASM_POWERPC_BUGS_H */
--- a/arch/xtensa/include/asm/bugs.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * include/asm-xtensa/bugs.h
- *
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Xtensa processors don't have any bugs.  :)
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file "COPYING" in the main directory of
- * this archive for more details.
- */
-
-#ifndef _XTENSA_BUGS_H
-#define _XTENSA_BUGS_H
-
-static void check_bugs(void) { }
-
-#endif /* _XTENSA_BUGS_H */
--- a/include/asm-generic/bugs.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_GENERIC_BUGS_H
-#define __ASM_GENERIC_BUGS_H
-/*
- * This file is included by 'init/main.c' to check for
- * architecture-dependent bugs.
- */
-
-static inline void check_bugs(void) { }
-
-#endif	/* __ASM_GENERIC_BUGS_H */
--- a/init/main.c
+++ b/init/main.c
@@ -103,7 +103,6 @@
 #include <net/net_namespace.h>
 
 #include <asm/io.h>
-#include <asm/bugs.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
 #include <asm/cacheflush.h>
@@ -1079,10 +1078,6 @@ asmlinkage __visible void __init __no_sa
 	delayacct_init();
 
 	arch_cpu_finalize_init();
-	/* Temporary conditional until everything has been converted */
-#ifndef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
-	check_bugs();
-#endif
 
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (10 preceding siblings ...)
  2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-15 21:44   ` Edgecombe, Rick P
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Thomas Gleixner
                   ` (5 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

X86 is reworking the boot process so that initializations which are not
required during early boot can be moved into the late boot process and out
of the fragile and restricted initial boot phase.

arch_cpu_finalize_init() is the obvious place to do such initializations,
but arch_cpu_finalize_init() is invoked too late in start_kernel() e.g. for
initializing the FPU completely. fork_init() requires that the FPU is
initialized as the size of task_struct on X86 depends on the size of the
required FPU register buffer.

Fortunately none of the init calls between calibrate_delay() and
arch_cpu_finalize_init() is relevant for the functionality of
arch_cpu_finalize_init().

Invoke it right after calibrate_delay() where everything which is relevant
for arch_cpu_finalize_init() has been set up already.

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 init/main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/init/main.c
+++ b/init/main.c
@@ -1041,6 +1041,8 @@ asmlinkage __visible void __init __no_sa
 	sched_clock_init();
 	calibrate_delay();
 
+	arch_cpu_finalize_init();
+
 	/*
 	 * This needs to be called before any devices perform DMA
 	 * operations that might use the SWIOTLB bounce buffers. It will
@@ -1077,8 +1079,6 @@ asmlinkage __visible void __init __no_sa
 	taskstats_init_early();
 	delayacct_init();
 
-	arch_cpu_finalize_init();
-
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();
 	kcsan_init();


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (11 preceding siblings ...)
  2023-06-13 23:39 ` [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-21 17:12   ` [patch 13/17] " Tom Lendacky
  2023-06-13 23:39 ` [patch 14/17] x86/init: Initialize signal frame size late Thomas Gleixner
                   ` (4 subsequent siblings)
  17 siblings, 2 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Tom Lendacky, Russell King, linux-arm-kernel,
	linux-ia64, Huacai Chen, WANG Xuerui, loongarch,
	Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer, linux-mips,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel

Invoke the X86ism mem_encrypt_init() from X86 arch_cpu_finalize_init() and
remove the weak fallback from the core code.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/include/asm/mem_encrypt.h |    7 ++++---
 arch/x86/kernel/cpu/common.c       |   11 +++++++++++
 init/main.c                        |   13 -------------
 3 files changed, 15 insertions(+), 16 deletions(-)

--- a/arch/x86/include/asm/mem_encrypt.h
+++ b/arch/x86/include/asm/mem_encrypt.h
@@ -51,6 +51,8 @@ void __init mem_encrypt_free_decrypted_m
 
 void __init sev_es_init_vc_handling(void);
 
+void __init mem_encrypt_init(void);
+
 #define __bss_decrypted __section(".bss..decrypted")
 
 #else	/* !CONFIG_AMD_MEM_ENCRYPT */
@@ -83,13 +85,12 @@ early_set_mem_enc_dec_hypercall(unsigned
 
 static inline void mem_encrypt_free_decrypted_mem(void) { }
 
+static inline void mem_encrypt_init(void) { }
+
 #define __bss_decrypted
 
 #endif	/* CONFIG_AMD_MEM_ENCRYPT */
 
-/* Architecture __weak replacement functions */
-void __init mem_encrypt_init(void);
-
 void add_encrypt_protection_map(void);
 
 /*
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/kprobes.h>
 #include <linux/kgdb.h>
+#include <linux/mem_encrypt.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
 #include <linux/io.h>
@@ -2417,4 +2418,14 @@ void __init arch_cpu_finalize_init(void)
 	} else {
 		fpu__init_check_bugs();
 	}
+
+	/*
+	 * This needs to be called before any devices perform DMA
+	 * operations that might use the SWIOTLB bounce buffers. It will
+	 * mark the bounce buffers as decrypted so that their usage will
+	 * not cause "plain-text" data to be decrypted when accessed. It
+	 * must be called after late_time_init() so that Hyper-V x86/x64
+	 * hypercalls work when the SWIOTLB bounce buffers are decrypted.
+	 */
+	mem_encrypt_init();
 }
--- a/init/main.c
+++ b/init/main.c
@@ -95,7 +95,6 @@
 #include <linux/cache.h>
 #include <linux/rodata_test.h>
 #include <linux/jump_label.h>
-#include <linux/mem_encrypt.h>
 #include <linux/kcsan.h>
 #include <linux/init_syscalls.h>
 #include <linux/stackdepot.h>
@@ -786,8 +785,6 @@ void __init __weak thread_stack_cache_in
 }
 #endif
 
-void __init __weak mem_encrypt_init(void) { }
-
 void __init __weak poking_init(void) { }
 
 void __init __weak pgtable_cache_init(void) { }
@@ -1043,16 +1040,6 @@ asmlinkage __visible void __init __no_sa
 
 	arch_cpu_finalize_init();
 
-	/*
-	 * This needs to be called before any devices perform DMA
-	 * operations that might use the SWIOTLB bounce buffers. It will
-	 * mark the bounce buffers as decrypted so that their usage will
-	 * not cause "plain-text" data to be decrypted when accessed. It
-	 * must be called after late_time_init() so that Hyper-V x86/x64
-	 * hypercalls work when the SWIOTLB bounce buffers are decrypted.
-	 */
-	mem_encrypt_init();
-
 	pid_idr_init();
 	anon_vma_init();
 #ifdef CONFIG_X86


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 14/17] x86/init: Initialize signal frame size late
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (12 preceding siblings ...)
  2023-06-13 23:39 ` [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 15/17] x86/fpu: Remove cpuinfo argument from init functions Thomas Gleixner
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

No point in doing this during really early boot. Move it to an early
initcall so that it is set up before possible user mode helpers are started
during device initialization.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/sigframe.h |    2 --
 arch/x86/kernel/cpu/common.c    |    3 ---
 arch/x86/kernel/signal.c        |    4 +++-
 3 files changed, 3 insertions(+), 6 deletions(-)

--- a/arch/x86/include/asm/sigframe.h
+++ b/arch/x86/include/asm/sigframe.h
@@ -85,6 +85,4 @@ struct rt_sigframe_x32 {
 
 #endif /* CONFIG_X86_64 */
 
-void __init init_sigframe_size(void);
-
 #endif /* _ASM_X86_SIGFRAME_H */
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -64,7 +64,6 @@
 #include <asm/cpu_device_id.h>
 #include <asm/uv/uv.h>
 #include <asm/set_memory.h>
-#include <asm/sigframe.h>
 #include <asm/traps.h>
 #include <asm/sev.h>
 
@@ -1607,8 +1606,6 @@ static void __init early_identify_cpu(st
 
 	fpu__init_system(c);
 
-	init_sigframe_size();
-
 #ifdef CONFIG_X86_32
 	/*
 	 * Regardless of whether PCID is enumerated, the SDM says
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -182,7 +182,7 @@ get_sigframe(struct ksignal *ksig, struc
 static unsigned long __ro_after_init max_frame_size;
 static unsigned int __ro_after_init fpu_default_state_size;
 
-void __init init_sigframe_size(void)
+static int __init init_sigframe_size(void)
 {
 	fpu_default_state_size = fpu__get_fpstate_size();
 
@@ -194,7 +194,9 @@ void __init init_sigframe_size(void)
 	max_frame_size = round_up(max_frame_size, FRAME_ALIGNMENT);
 
 	pr_info("max sigframe size: %lu\n", max_frame_size);
+	return 0;
 }
+early_initcall(init_sigframe_size);
 
 unsigned long get_sigframe_size(void)
 {


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 15/17] x86/fpu: Remove cpuinfo argument from init functions
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (13 preceding siblings ...)
  2023-06-13 23:39 ` [patch 14/17] x86/init: Initialize signal frame size late Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 16/17] x86/fpu: Mark init functions __init Thomas Gleixner
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

Nothing in the call chain requires it

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/fpu/api.h |    2 +-
 arch/x86/kernel/cpu/common.c   |    2 +-
 arch/x86/kernel/fpu/init.c     |    6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -109,7 +109,7 @@ extern void fpu_reset_from_exception_fix
 
 /* Boot, hotplug and resume */
 extern void fpu__init_cpu(void);
-extern void fpu__init_system(struct cpuinfo_x86 *c);
+extern void fpu__init_system(void);
 extern void fpu__init_check_bugs(void);
 extern void fpu__resume_cpu(void);
 
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1604,7 +1604,7 @@ static void __init early_identify_cpu(st
 
 	sld_setup(c);
 
-	fpu__init_system(c);
+	fpu__init_system();
 
 #ifdef CONFIG_X86_32
 	/*
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -71,7 +71,7 @@ static bool fpu__probe_without_cpuid(voi
 	return fsw == 0 && (fcw & 0x103f) == 0x003f;
 }
 
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+static void fpu__init_system_early_generic(void)
 {
 	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
 	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
@@ -211,10 +211,10 @@ static void __init fpu__init_system_xsta
  * Called on the boot CPU once per system bootup, to set up the initial
  * FPU state that is later cloned into all processes:
  */
-void __init fpu__init_system(struct cpuinfo_x86 *c)
+void __init fpu__init_system(void)
 {
 	fpstate_reset(&current->thread.fpu);
-	fpu__init_system_early_generic(c);
+	fpu__init_system_early_generic();
 
 	/*
 	 * The FPU has to be operational for some of the


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 16/17] x86/fpu: Mark init functions __init
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (14 preceding siblings ...)
  2023-06-13 23:39 ` [patch 15/17] x86/fpu: Remove cpuinfo argument from init functions Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
  2023-06-28  3:38 ` [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Jan Engelhardt
  17 siblings, 1 reply; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

No point in keeping them around.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/fpu/init.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -53,7 +53,7 @@ void fpu__init_cpu(void)
 	fpu__init_cpu_xstate();
 }
 
-static bool fpu__probe_without_cpuid(void)
+static bool __init fpu__probe_without_cpuid(void)
 {
 	unsigned long cr0;
 	u16 fsw, fcw;
@@ -71,7 +71,7 @@ static bool fpu__probe_without_cpuid(voi
 	return fsw == 0 && (fcw & 0x103f) == 0x003f;
 }
 
-static void fpu__init_system_early_generic(void)
+static void __init fpu__init_system_early_generic(void)
 {
 	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
 	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {


^ permalink raw reply	[flat|nested] 62+ messages in thread

* [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (15 preceding siblings ...)
  2023-06-13 23:39 ` [patch 16/17] x86/fpu: Mark init functions __init Thomas Gleixner
@ 2023-06-13 23:39 ` Thomas Gleixner
  2023-06-14  5:03   ` Chang S. Bae
                     ` (2 more replies)
  2023-06-28  3:38 ` [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Jan Engelhardt
  17 siblings, 3 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-13 23:39 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

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>
---
 arch/x86/kernel/cpu/common.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1604,8 +1604,6 @@ static void __init early_identify_cpu(st
 
 	sld_setup(c);
 
-	fpu__init_system();
-
 #ifdef CONFIG_X86_32
 	/*
 	 * Regardless of whether PCID is enumerated, the SDM says
@@ -2287,8 +2285,6 @@ void cpu_init(void)
 
 	doublefault_init_cpu_tss();
 
-	fpu__init_cpu();
-
 	if (is_uv_system())
 		uv_cpu_init();
 
@@ -2304,6 +2300,7 @@ void cpu_init_secondary(void)
 	 */
 	cpu_init_exception_handling();
 	cpu_init();
+	fpu__init_cpu();
 }
 #endif
 
@@ -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)) {


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-14  5:03   ` Chang S. Bae
  2023-06-14  9:52     ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-09-01 17:30   ` [patch 17/17] " Guenter Roeck
  2 siblings, 1 reply; 62+ messages in thread
From: Chang S. Bae @ 2023-06-14  5:03 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On 6/13/2023 4:39 PM, Thomas Gleixner wrote:
>   
> @@ -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();

fpu__init_cpu() appears to be duplicated here because fpu__init_system() 
invoked this already:

void __init fpu__init_system(void)
{
...
	/*
	 * The FPU has to be operational for some of the
	 * later FPU init activities:
	 */
	fpu__init_cpu();
...
}

https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git/tree/arch/x86/kernel/fpu/init.c?h=init#n223

Thanks,
Chang


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 11/17] init: Remove check_bugs() leftovers
  2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
@ 2023-06-14  6:14   ` Richard Henderson
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:31   ` [patch 11/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Richard Henderson @ 2023-06-14  6:14 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Tom Lendacky

On 6/14/23 01:39, Thomas Gleixner wrote:
> Everything is converted over to arch_cpu_finalize_init(). Remove the
> check_bugs() leftovers including the empty stubs in asm-generic, alpha,
> parisc, powerpc and xtensa.
> 
> Signed-off-by: Thomas Gleixner<tglx@linutronix.de>
> Cc: Richard Henderson<richard.henderson@linaro.org>
> Cc: "James E.J. Bottomley"<James.Bottomley@HansenPartnership.com>
> Cc: Michael Ellerman<mpe@ellerman.id.au>
> Cc: Chris Zankel<chris@zankel.net>
> ---
>   arch/alpha/include/asm/bugs.h   |   20 --------------------
>   arch/parisc/include/asm/bugs.h  |   20 --------------------
>   arch/powerpc/include/asm/bugs.h |   15 ---------------
>   arch/xtensa/include/asm/bugs.h  |   18 ------------------
>   include/asm-generic/bugs.h      |   11 -----------
>   init/main.c                     |    5 -----
>   6 files changed, 89 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 10/17] um/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
@ 2023-06-14  6:51   ` Richard Weinberger
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:28   ` [patch 10/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Richard Weinberger @ 2023-06-14  6:51 UTC (permalink / raw)
  To: tglx
  Cc: linux-kernel, x86, torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, anton ivanov, Johannes Berg, linux-um,
	Russell King, linux-arm-kernel, linux-ia64, Huacai Chen,
	WANG Xuerui, loongarch, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, davem, sparclinux,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky

----- Ursprüngliche Mail -----
> Von: "tglx" <tglx@linutronix.de>
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.

Confirmed. :-)
 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: linux-um@lists.infradead.org

Acked-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 06/17] m68k/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 06/17] m68k/cpu: " Thomas Gleixner
@ 2023-06-14  9:22   ` Geert Uytterhoeven
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: Geert Uytterhoeven @ 2023-06-14  9:22 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, linux-m68k, Russell King, linux-arm-kernel,
	linux-ia64, Huacai Chen, WANG Xuerui, loongarch,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky

On Wed, Jun 14, 2023 at 1:39 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 01/17] init: Provide arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-14  9:28   ` Borislav Petkov
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: Borislav Petkov @ 2023-06-14  9:28 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

Just typos:

On Wed, Jun 14, 2023 at 01:39:22AM +0200, Thomas Gleixner wrote:
> check_bugs() has become a dump ground for all sorts of activities to

"dumping ground"

> finalize the CPU initialization before running the rest of the init code.
> 
> Most are empty, a few do actual bug checks, some do alternative patching
> and some cobble a CPU advertisment string together....

advertisement

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-06-14  5:03   ` Chang S. Bae
@ 2023-06-14  9:52     ` Thomas Gleixner
  0 siblings, 0 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-14  9:52 UTC (permalink / raw)
  To: Chang S. Bae, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On Tue, Jun 13 2023 at 22:03, Chang S. Bae wrote:

> On 6/13/2023 4:39 PM, Thomas Gleixner wrote:
>>   
>> @@ -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();
>
> fpu__init_cpu() appears to be duplicated here because fpu__init_system() 
> invoked this already:
>
> void __init fpu__init_system(void)
> {
> ...
> 	/*
> 	 * The FPU has to be operational for some of the
> 	 * later FPU init activities:
> 	 */
> 	fpu__init_cpu();

Well, that's _before_ xstate initialization and I couldn't convince
myself that it's good enough. All of this is such a horrible mess...

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-14  9:53   ` Thomas Gleixner
  2023-06-14 10:39     ` Borislav Petkov
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  1 sibling, 1 reply; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-14  9:53 UTC (permalink / raw)
  To: LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On Wed, Jun 14 2023 at 01:39, Thomas Gleixner wrote:
> +	/*
> +	 * identify_boot_cpu() initialized SMT support information, let the
> +	 * core code know.
> +	 */
> +	cpu_smt_check_topology();
> +
> +	if (!IS_ENABLED(CONFIG_SMP)) {
> +		pr_info("CPU: ");
> +		print_cpu_info(&boot_cpu_data);
> +	}
> +
> +	arch_smt_update();
> +
> +	cpu_select_mitigations();

That's the wrong order. mitigations must come before the smt
update. Thanks to Boris for spotting it.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init()
  2023-06-14  9:53   ` Thomas Gleixner
@ 2023-06-14 10:39     ` Borislav Petkov
  0 siblings, 0 replies; 62+ messages in thread
From: Borislav Petkov @ 2023-06-14 10:39 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On Wed, Jun 14, 2023 at 11:53:50AM +0200, Thomas Gleixner wrote:
> That's the wrong order. mitigations must come before the smt
> update. Thanks to Boris for spotting it.

Right, with that fixed the ordering looks good now.

Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 09/17] sparc/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
@ 2023-06-14 20:41   ` Sam Ravnborg
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:30   ` [patch 09/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Sam Ravnborg @ 2023-06-14 20:41 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, David S. Miller, sparclinux, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer,
	linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-um, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

On Wed, Jun 14, 2023 at 01:39:35AM +0200, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier
  2023-06-13 23:39 ` [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier Thomas Gleixner
@ 2023-06-15 21:44   ` Edgecombe, Rick P
  2023-06-15 22:03     ` Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  1 sibling, 1 reply; 62+ messages in thread
From: Edgecombe, Rick P @ 2023-06-15 21:44 UTC (permalink / raw)
  To: tglx, linux-kernel
  Cc: chenhuacai, darwi, linux-ia64, glaubitz, Torvalds, Linus, chris,
	ysato, davem, thomas.lendacky, James.Bottomley, mpe, kernel,
	linux-sh, dalias, loongarch, linux, linux-m68k, nik.borisov,
	arnd, anton.ivanov, sparclinux, richard, johannes, linux-um,
	linux-arm-kernel, tsbogend, linux-mips, richard.henderson, geert,
	x86

On Wed, 2023-06-14 at 01:39 +0200, Thomas Gleixner wrote:
> Fortunately none of the init calls between calibrate_delay() and
> arch_cpu_finalize_init() is relevant for the functionality of
> arch_cpu_finalize_init().
> 

Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

I did my best to find a counterpoint to this statement. The only thing
I found was that lockdep_init_task(&init_task) in fork_init() is now
called after the spin_lock() usage in set_memory_4k(). But AFAICT, that
whole lockdep_init_task() call is unneeded because the fields it sets
are already statically initialized. I mention only because I'm not 100%
sure the lockdep_init_task() call is not serving some purpose I'm
missing.

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier
  2023-06-15 21:44   ` Edgecombe, Rick P
@ 2023-06-15 22:03     ` Thomas Gleixner
  0 siblings, 0 replies; 62+ messages in thread
From: Thomas Gleixner @ 2023-06-15 22:03 UTC (permalink / raw)
  To: Edgecombe, Rick P, linux-kernel
  Cc: chenhuacai, darwi, linux-ia64, glaubitz, Torvalds, Linus, chris,
	ysato, davem, thomas.lendacky, James.Bottomley, mpe, kernel,
	linux-sh, dalias, loongarch, linux, linux-m68k, nik.borisov,
	arnd, anton.ivanov, sparclinux, richard, johannes, linux-um,
	linux-arm-kernel, tsbogend, linux-mips, richard.henderson, geert,
	x86

On Thu, Jun 15 2023 at 21:44, Rick P. Edgecombe wrote:
> On Wed, 2023-06-14 at 01:39 +0200, Thomas Gleixner wrote:
>> Fortunately none of the init calls between calibrate_delay() and
>> arch_cpu_finalize_init() is relevant for the functionality of
>> arch_cpu_finalize_init().
>> 
>
> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
>
> I did my best to find a counterpoint to this statement. The only thing
> I found was that lockdep_init_task(&init_task) in fork_init() is now
> called after the spin_lock() usage in set_memory_4k().
>
> But AFAICT, that whole lockdep_init_task() call is unneeded because
> the fields it sets are already statically initialized.

Correct. The call there looks absolute pointless. Peter?

^ permalink raw reply	[flat|nested] 62+ messages in thread

* [tip: x86/boot] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
  2023-06-14  5:03   ` Chang S. Bae
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-09-01 17:30   ` [patch 17/17] " Guenter Roeck
  2 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     b81fac906a8f9e682e513ddd95697ec7a20878d4
Gitweb:        https://git.kernel.org/tip/b81fac906a8f9e682e513ddd95697ec7a20878d4
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:46 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:01 +02:00

x86/fpu: Move FPU initialization into arch_cpu_finalize_init()

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

---
 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 2807e5b..46ebdd6 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -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
@@ -2287,8 +2285,6 @@ void cpu_init(void)
 
 	doublefault_init_cpu_tss();
 
-	fpu__init_cpu();
-
 	if (is_uv_system())
 		uv_cpu_init();
 
@@ -2304,6 +2300,7 @@ void cpu_init_secondary(void)
 	 */
 	cpu_init_exception_handling();
 	cpu_init();
+	fpu__init_cpu();
 }
 #endif
 
@@ -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)) {

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] x86/fpu: Mark init functions __init
  2023-06-13 23:39 ` [patch 16/17] x86/fpu: Mark init functions __init Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  0 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     1703db2b90c91b2eb2d699519fc505fe431dde0e
Gitweb:        https://git.kernel.org/tip/1703db2b90c91b2eb2d699519fc505fe431dde0e
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:45 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:01 +02:00

x86/fpu: Mark init functions __init

No point in keeping them around.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.841685728@linutronix.de

---
 arch/x86/kernel/fpu/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 5001df9..998a08f 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -53,7 +53,7 @@ void fpu__init_cpu(void)
 	fpu__init_cpu_xstate();
 }
 
-static bool fpu__probe_without_cpuid(void)
+static bool __init fpu__probe_without_cpuid(void)
 {
 	unsigned long cr0;
 	u16 fsw, fcw;
@@ -71,7 +71,7 @@ static bool fpu__probe_without_cpuid(void)
 	return fsw == 0 && (fcw & 0x103f) == 0x003f;
 }
 
-static void fpu__init_system_early_generic(void)
+static void __init fpu__init_system_early_generic(void)
 {
 	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
 	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] x86/fpu: Remove cpuinfo argument from init functions
  2023-06-13 23:39 ` [patch 15/17] x86/fpu: Remove cpuinfo argument from init functions Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  0 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     1f34bb2a24643e0087652d81078e4f616562738d
Gitweb:        https://git.kernel.org/tip/1f34bb2a24643e0087652d81078e4f616562738d
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:43 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:01 +02:00

x86/fpu: Remove cpuinfo argument from init functions

Nothing in the call chain requires it

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.783704297@linutronix.de

---
 arch/x86/include/asm/fpu/api.h | 2 +-
 arch/x86/kernel/cpu/common.c   | 2 +-
 arch/x86/kernel/fpu/init.c     | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 503a577..b475d9a 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -109,7 +109,7 @@ extern void fpu_reset_from_exception_fixup(void);
 
 /* Boot, hotplug and resume */
 extern void fpu__init_cpu(void);
-extern void fpu__init_system(struct cpuinfo_x86 *c);
+extern void fpu__init_system(void);
 extern void fpu__init_check_bugs(void);
 extern void fpu__resume_cpu(void);
 
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index b8a4db1..2807e5b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1604,7 +1604,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 	sld_setup(c);
 
-	fpu__init_system(c);
+	fpu__init_system();
 
 #ifdef CONFIG_X86_32
 	/*
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 851eb13..5001df9 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -71,7 +71,7 @@ static bool fpu__probe_without_cpuid(void)
 	return fsw == 0 && (fcw & 0x103f) == 0x003f;
 }
 
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+static void fpu__init_system_early_generic(void)
 {
 	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
 	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
@@ -211,10 +211,10 @@ static void __init fpu__init_system_xstate_size_legacy(void)
  * Called on the boot CPU once per system bootup, to set up the initial
  * FPU state that is later cloned into all processes:
  */
-void __init fpu__init_system(struct cpuinfo_x86 *c)
+void __init fpu__init_system(void)
 {
 	fpstate_reset(&current->thread.fpu);
-	fpu__init_system_early_generic(c);
+	fpu__init_system_early_generic();
 
 	/*
 	 * The FPU has to be operational for some of the

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-21 17:12   ` [patch 13/17] " Tom Lendacky
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     439e17576eb47f26b78c5bbc72e344d4206d2327
Gitweb:        https://git.kernel.org/tip/439e17576eb47f26b78c5bbc72e344d4206d2327
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:41 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()

Invoke the X86ism mem_encrypt_init() from X86 arch_cpu_finalize_init() and
remove the weak fallback from the core code.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.670360645@linutronix.de

---
 arch/x86/include/asm/mem_encrypt.h |  7 ++++---
 arch/x86/kernel/cpu/common.c       | 11 +++++++++++
 init/main.c                        | 13 -------------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h
index b712670..98ce265 100644
--- a/arch/x86/include/asm/mem_encrypt.h
+++ b/arch/x86/include/asm/mem_encrypt.h
@@ -51,6 +51,8 @@ void __init mem_encrypt_free_decrypted_mem(void);
 
 void __init sev_es_init_vc_handling(void);
 
+void __init mem_encrypt_init(void);
+
 #define __bss_decrypted __section(".bss..decrypted")
 
 #else	/* !CONFIG_AMD_MEM_ENCRYPT */
@@ -83,13 +85,12 @@ early_set_mem_enc_dec_hypercall(unsigned long vaddr, int npages, bool enc) {}
 
 static inline void mem_encrypt_free_decrypted_mem(void) { }
 
+static inline void mem_encrypt_init(void) { }
+
 #define __bss_decrypted
 
 #endif	/* CONFIG_AMD_MEM_ENCRYPT */
 
-/* Architecture __weak replacement functions */
-void __init mem_encrypt_init(void);
-
 void add_encrypt_protection_map(void);
 
 /*
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 18612e5..5ee8b31 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/kprobes.h>
 #include <linux/kgdb.h>
+#include <linux/mem_encrypt.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
 #include <linux/io.h>
@@ -2414,4 +2415,14 @@ void __init arch_cpu_finalize_init(void)
 	} else {
 		fpu__init_check_bugs();
 	}
+
+	/*
+	 * This needs to be called before any devices perform DMA
+	 * operations that might use the SWIOTLB bounce buffers. It will
+	 * mark the bounce buffers as decrypted so that their usage will
+	 * not cause "plain-text" data to be decrypted when accessed. It
+	 * must be called after late_time_init() so that Hyper-V x86/x64
+	 * hypercalls work when the SWIOTLB bounce buffers are decrypted.
+	 */
+	mem_encrypt_init();
 }
diff --git a/init/main.c b/init/main.c
index c968c19..32c65f2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -95,7 +95,6 @@
 #include <linux/cache.h>
 #include <linux/rodata_test.h>
 #include <linux/jump_label.h>
-#include <linux/mem_encrypt.h>
 #include <linux/kcsan.h>
 #include <linux/init_syscalls.h>
 #include <linux/stackdepot.h>
@@ -786,8 +785,6 @@ void __init __weak thread_stack_cache_init(void)
 }
 #endif
 
-void __init __weak mem_encrypt_init(void) { }
-
 void __init __weak poking_init(void) { }
 
 void __init __weak pgtable_cache_init(void) { }
@@ -1043,16 +1040,6 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
 
 	arch_cpu_finalize_init();
 
-	/*
-	 * This needs to be called before any devices perform DMA
-	 * operations that might use the SWIOTLB bounce buffers. It will
-	 * mark the bounce buffers as decrypted so that their usage will
-	 * not cause "plain-text" data to be decrypted when accessed. It
-	 * must be called after late_time_init() so that Hyper-V x86/x64
-	 * hypercalls work when the SWIOTLB bounce buffers are decrypted.
-	 */
-	mem_encrypt_init();
-
 	pid_idr_init();
 	anon_vma_init();
 #ifdef CONFIG_X86

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] x86/init: Initialize signal frame size late
  2023-06-13 23:39 ` [patch 14/17] x86/init: Initialize signal frame size late Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  0 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     54d9a91a3d6713d1332e93be13b4eaf0fa54349d
Gitweb:        https://git.kernel.org/tip/54d9a91a3d6713d1332e93be13b4eaf0fa54349d
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:42 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

x86/init: Initialize signal frame size late

No point in doing this during really early boot. Move it to an early
initcall so that it is set up before possible user mode helpers are started
during device initialization.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.727330699@linutronix.de

---
 arch/x86/include/asm/sigframe.h | 2 --
 arch/x86/kernel/cpu/common.c    | 3 ---
 arch/x86/kernel/signal.c        | 4 +++-
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
index 5b1ed65..84eab27 100644
--- a/arch/x86/include/asm/sigframe.h
+++ b/arch/x86/include/asm/sigframe.h
@@ -85,6 +85,4 @@ struct rt_sigframe_x32 {
 
 #endif /* CONFIG_X86_64 */
 
-void __init init_sigframe_size(void);
-
 #endif /* _ASM_X86_SIGFRAME_H */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 5ee8b31..b8a4db1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -64,7 +64,6 @@
 #include <asm/cpu_device_id.h>
 #include <asm/uv/uv.h>
 #include <asm/set_memory.h>
-#include <asm/sigframe.h>
 #include <asm/traps.h>
 #include <asm/sev.h>
 
@@ -1607,8 +1606,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 	fpu__init_system(c);
 
-	init_sigframe_size();
-
 #ifdef CONFIG_X86_32
 	/*
 	 * Regardless of whether PCID is enumerated, the SDM says
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 004cb30..cfeec3e 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -182,7 +182,7 @@ get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size,
 static unsigned long __ro_after_init max_frame_size;
 static unsigned int __ro_after_init fpu_default_state_size;
 
-void __init init_sigframe_size(void)
+static int __init init_sigframe_size(void)
 {
 	fpu_default_state_size = fpu__get_fpstate_size();
 
@@ -194,7 +194,9 @@ void __init init_sigframe_size(void)
 	max_frame_size = round_up(max_frame_size, FRAME_ALIGNMENT);
 
 	pr_info("max sigframe size: %lu\n", max_frame_size);
+	return 0;
 }
+early_initcall(init_sigframe_size);
 
 unsigned long get_sigframe_size(void)
 {

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] init: Invoke arch_cpu_finalize_init() earlier
  2023-06-13 23:39 ` [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier Thomas Gleixner
  2023-06-15 21:44   ` Edgecombe, Rick P
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, Rick Edgecombe, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     9df9d2f0471b4c4702670380b8d8a45b40b23a7d
Gitweb:        https://git.kernel.org/tip/9df9d2f0471b4c4702670380b8d8a45b40b23a7d
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:39 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

init: Invoke arch_cpu_finalize_init() earlier

X86 is reworking the boot process so that initializations which are not
required during early boot can be moved into the late boot process and out
of the fragile and restricted initial boot phase.

arch_cpu_finalize_init() is the obvious place to do such initializations,
but arch_cpu_finalize_init() is invoked too late in start_kernel() e.g. for
initializing the FPU completely. fork_init() requires that the FPU is
initialized as the size of task_struct on X86 depends on the size of the
required FPU register buffer.

Fortunately none of the init calls between calibrate_delay() and
arch_cpu_finalize_init() is relevant for the functionality of
arch_cpu_finalize_init().

Invoke it right after calibrate_delay() where everything which is relevant
for arch_cpu_finalize_init() has been set up already.

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://lore.kernel.org/r/20230613224545.612182854@linutronix.de

---
 init/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 389ac62..c968c19 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1041,6 +1041,8 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
 	sched_clock_init();
 	calibrate_delay();
 
+	arch_cpu_finalize_init();
+
 	/*
 	 * This needs to be called before any devices perform DMA
 	 * operations that might use the SWIOTLB bounce buffers. It will
@@ -1077,8 +1079,6 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
 	taskstats_init_early();
 	delayacct_init();
 
-	arch_cpu_finalize_init();
-
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();
 	kcsan_init();

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] um/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
  2023-06-14  6:51   ` Richard Weinberger
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:28   ` [patch 10/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, Richard Weinberger, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     9349b5cd0908f8afe95529fc7a8cbb1417df9b0c
Gitweb:        https://git.kernel.org/tip/9349b5cd0908f8afe95529fc7a8cbb1417df9b0c
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:36 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

um/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Richard Weinberger <richard@nod.at>
Link: https://lore.kernel.org/r/20230613224545.493148694@linutronix.de

---
 arch/um/Kconfig            | 1 +
 arch/um/include/asm/bugs.h | 7 -------
 arch/um/kernel/um_arch.c   | 3 ++-
 3 files changed, 3 insertions(+), 8 deletions(-)
 delete mode 100644 arch/um/include/asm/bugs.h

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 541a9b1..887cfb6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -6,6 +6,7 @@ config UML
 	bool
 	default y
 	select ARCH_EPHEMERAL_INODES
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_HAS_KCOV
diff --git a/arch/um/include/asm/bugs.h b/arch/um/include/asm/bugs.h
deleted file mode 100644
index 4473942..0000000
--- a/arch/um/include/asm/bugs.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __UM_BUGS_H
-#define __UM_BUGS_H
-
-void check_bugs(void);
-
-#endif
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 0a23a98..918fed7 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  */
 
+#include <linux/cpu.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/mm.h>
@@ -430,7 +431,7 @@ void __init setup_arch(char **cmdline_p)
 	}
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	arch_check_bugs();
 	os_check_bugs();

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] init: Remove check_bugs() leftovers
  2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
  2023-06-14  6:14   ` Richard Henderson
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:31   ` [patch 11/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, Richard Henderson, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     61235b24b9cb37c13fcad5b9596d59a1afdcec30
Gitweb:        https://git.kernel.org/tip/61235b24b9cb37c13fcad5b9596d59a1afdcec30
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:38 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

init: Remove check_bugs() leftovers

Everything is converted over to arch_cpu_finalize_init(). Remove the
check_bugs() leftovers including the empty stubs in asm-generic, alpha,
parisc, powerpc and xtensa.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Link: https://lore.kernel.org/r/20230613224545.553215951@linutronix.de

---
 arch/alpha/include/asm/bugs.h   | 20 --------------------
 arch/parisc/include/asm/bugs.h  | 20 --------------------
 arch/powerpc/include/asm/bugs.h | 15 ---------------
 arch/xtensa/include/asm/bugs.h  | 18 ------------------
 include/asm-generic/bugs.h      | 11 -----------
 init/main.c                     |  5 -----
 6 files changed, 89 deletions(-)
 delete mode 100644 arch/alpha/include/asm/bugs.h
 delete mode 100644 arch/parisc/include/asm/bugs.h
 delete mode 100644 arch/powerpc/include/asm/bugs.h
 delete mode 100644 arch/xtensa/include/asm/bugs.h
 delete mode 100644 include/asm-generic/bugs.h

diff --git a/arch/alpha/include/asm/bugs.h b/arch/alpha/include/asm/bugs.h
deleted file mode 100644
index 78030d1..0000000
--- a/arch/alpha/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *  include/asm-alpha/bugs.h
- *
- *  Copyright (C) 1994  Linus Torvalds
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-/*
- * I don't know of any alpha bugs yet.. Nice chip
- */
-
-static void check_bugs(void)
-{
-}
diff --git a/arch/parisc/include/asm/bugs.h b/arch/parisc/include/asm/bugs.h
deleted file mode 100644
index 0a7f9db..0000000
--- a/arch/parisc/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- *  include/asm-parisc/bugs.h
- *
- *  Copyright (C) 1999	Mike Shaver
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-#include <asm/processor.h>
-
-static inline void check_bugs(void)
-{
-//	identify_cpu(&boot_cpu_data);
-}
diff --git a/arch/powerpc/include/asm/bugs.h b/arch/powerpc/include/asm/bugs.h
deleted file mode 100644
index 01b8f6c..0000000
--- a/arch/powerpc/include/asm/bugs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ASM_POWERPC_BUGS_H
-#define _ASM_POWERPC_BUGS_H
-
-/*
- */
-
-/*
- * This file is included by 'init/main.c' to check for
- * architecture-dependent bugs.
- */
-
-static inline void check_bugs(void) { }
-
-#endif	/* _ASM_POWERPC_BUGS_H */
diff --git a/arch/xtensa/include/asm/bugs.h b/arch/xtensa/include/asm/bugs.h
deleted file mode 100644
index 69b29d1..0000000
--- a/arch/xtensa/include/asm/bugs.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * include/asm-xtensa/bugs.h
- *
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Xtensa processors don't have any bugs.  :)
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License.  See the file "COPYING" in the main directory of
- * this archive for more details.
- */
-
-#ifndef _XTENSA_BUGS_H
-#define _XTENSA_BUGS_H
-
-static void check_bugs(void) { }
-
-#endif /* _XTENSA_BUGS_H */
diff --git a/include/asm-generic/bugs.h b/include/asm-generic/bugs.h
deleted file mode 100644
index 6902183..0000000
--- a/include/asm-generic/bugs.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_GENERIC_BUGS_H
-#define __ASM_GENERIC_BUGS_H
-/*
- * This file is included by 'init/main.c' to check for
- * architecture-dependent bugs.
- */
-
-static inline void check_bugs(void) { }
-
-#endif	/* __ASM_GENERIC_BUGS_H */
diff --git a/init/main.c b/init/main.c
index 77d5316..389ac62 100644
--- a/init/main.c
+++ b/init/main.c
@@ -103,7 +103,6 @@
 #include <net/net_namespace.h>
 
 #include <asm/io.h>
-#include <asm/bugs.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
 #include <asm/cacheflush.h>
@@ -1079,10 +1078,6 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
 	delayacct_init();
 
 	arch_cpu_finalize_init();
-	/* Temporary conditional until everything has been converted */
-#ifndef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
-	check_bugs();
-#endif
 
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] sparc/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
  2023-06-14 20:41   ` Sam Ravnborg
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:30   ` [patch 09/17] " Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, Sam Ravnborg, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     44ade508e3bfac45ae97864587de29eb1a881ec0
Gitweb:        https://git.kernel.org/tip/44ade508e3bfac45ae97864587de29eb1a881ec0
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:35 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

sparc/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://lore.kernel.org/r/20230613224545.431995857@linutronix.de

---
 arch/sparc/Kconfig            |  1 +
 arch/sparc/include/asm/bugs.h | 18 ------------------
 arch/sparc/kernel/setup_32.c  |  7 +++++++
 3 files changed, 8 insertions(+), 18 deletions(-)
 delete mode 100644 arch/sparc/include/asm/bugs.h

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 8535e19..36fd488 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -52,6 +52,7 @@ config SPARC
 config SPARC32
 	def_bool !64BIT
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CPU_FINALIZE_INIT if !SMP
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select CLZ_TAB
 	select DMA_DIRECT_REMAP
diff --git a/arch/sparc/include/asm/bugs.h b/arch/sparc/include/asm/bugs.h
deleted file mode 100644
index 02fa369..0000000
--- a/arch/sparc/include/asm/bugs.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* include/asm/bugs.h:  Sparc probes for various bugs.
- *
- * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net)
- */
-
-#ifdef CONFIG_SPARC32
-#include <asm/cpudata.h>
-#endif
-
-extern unsigned long loops_per_jiffy;
-
-static void __init check_bugs(void)
-{
-#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP)
-	cpu_data(0).udelay_val = loops_per_jiffy;
-#endif
-}
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index c8e0dd9..c9d1ba4 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -412,3 +412,10 @@ static int __init topology_init(void)
 }
 
 subsys_initcall(topology_init);
+
+#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP)
+void __init arch_cpu_finalize_init(void)
+{
+	cpu_data(0).udelay_val = loops_per_jiffy;
+}
+#endif

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] mips/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 07/17] mips/cpu: " Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:25   ` [patch 07/17] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     7f066a22fe353a827a402ee2835e81f045b1574d
Gitweb:        https://git.kernel.org/tip/7f066a22fe353a827a402ee2835e81f045b1574d
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:32 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

mips/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.312438573@linutronix.de

---
 arch/mips/Kconfig            |  1 +
 arch/mips/include/asm/bugs.h | 17 -----------------
 arch/mips/kernel/setup.c     | 13 +++++++++++++
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c2f5498..023d3bd 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -4,6 +4,7 @@ config MIPS
 	default y
 	select ARCH_32BIT_OFF_T if !64BIT
 	select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER if !CC_IS_CLANG || CLANG_VERSION >= 140000
 	select ARCH_HAS_DEBUG_VIRTUAL if !64BIT
 	select ARCH_HAS_FORTIFY_SOURCE
diff --git a/arch/mips/include/asm/bugs.h b/arch/mips/include/asm/bugs.h
index 653f78f..84be74a 100644
--- a/arch/mips/include/asm/bugs.h
+++ b/arch/mips/include/asm/bugs.h
@@ -1,17 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
  * Copyright (C) 2007  Maciej W. Rozycki
- *
- * Needs:
- *	void check_bugs(void);
  */
 #ifndef _ASM_BUGS_H
 #define _ASM_BUGS_H
 
 #include <linux/bug.h>
-#include <linux/delay.h>
 #include <linux/smp.h>
 
 #include <asm/cpu.h>
@@ -24,17 +18,6 @@ extern void check_bugs64_early(void);
 extern void check_bugs32(void);
 extern void check_bugs64(void);
 
-static inline void __init check_bugs(void)
-{
-	unsigned int cpu = smp_processor_id();
-
-	cpu_data[cpu].udelay_val = loops_per_jiffy;
-	check_bugs32();
-
-	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
-		check_bugs64();
-}
-
 static inline int r4k_daddiu_bug(void)
 {
 	if (!IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index febdc55..07a1518 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -11,6 +11,8 @@
  * Copyright (C) 2000, 2001, 2002, 2007	 Maciej W. Rozycki
  */
 #include <linux/init.h>
+#include <linux/cpu.h>
+#include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/export.h>
 #include <linux/screen_info.h>
@@ -840,3 +842,14 @@ static int __init setnocoherentio(char *str)
 }
 early_param("nocoherentio", setnocoherentio);
 #endif
+
+void __init arch_cpu_finalize_init(void)
+{
+	unsigned int cpu = smp_processor_id();
+
+	cpu_data[cpu].udelay_val = loops_per_jiffy;
+	check_bugs32();
+
+	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
+		check_bugs64();
+}

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] sh/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:29   ` [patch 08/17] " Philippe Mathieu-Daudé
  2023-06-25 21:45   ` John Paul Adrian Glaubitz
  2 siblings, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     01eb454e9bfe593f320ecbc9aaec60bf87cd453d
Gitweb:        https://git.kernel.org/tip/01eb454e9bfe593f320ecbc9aaec60bf87cd453d
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:33 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:16:00 +02:00

sh/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.371697797@linutronix.de

---
 arch/sh/Kconfig                 |  1 +-
 arch/sh/include/asm/bugs.h      | 74 +--------------------------------
 arch/sh/include/asm/processor.h |  2 +-
 arch/sh/kernel/idle.c           |  1 +-
 arch/sh/kernel/setup.c          | 55 ++++++++++++++++++++++++-
 5 files changed, 59 insertions(+), 74 deletions(-)
 delete mode 100644 arch/sh/include/asm/bugs.h

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 9652d36..e339745 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -6,6 +6,7 @@ config SUPERH
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
 	select ARCH_HAS_BINFMT_FLAT if !MMU
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_GIGANTIC_PAGE
 	select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/sh/include/asm/bugs.h b/arch/sh/include/asm/bugs.h
deleted file mode 100644
index fe52abb..0000000
--- a/arch/sh/include/asm/bugs.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_SH_BUGS_H
-#define __ASM_SH_BUGS_H
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-/*
- * I don't know of any Super-H bugs yet.
- */
-
-#include <asm/processor.h>
-
-extern void select_idle_routine(void);
-
-static void __init check_bugs(void)
-{
-	extern unsigned long loops_per_jiffy;
-	char *p = &init_utsname()->machine[2]; /* "sh" */
-
-	select_idle_routine();
-
-	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
-
-	switch (current_cpu_data.family) {
-	case CPU_FAMILY_SH2:
-		*p++ = '2';
-		break;
-	case CPU_FAMILY_SH2A:
-		*p++ = '2';
-		*p++ = 'a';
-		break;
-	case CPU_FAMILY_SH3:
-		*p++ = '3';
-		break;
-	case CPU_FAMILY_SH4:
-		*p++ = '4';
-		break;
-	case CPU_FAMILY_SH4A:
-		*p++ = '4';
-		*p++ = 'a';
-		break;
-	case CPU_FAMILY_SH4AL_DSP:
-		*p++ = '4';
-		*p++ = 'a';
-		*p++ = 'l';
-		*p++ = '-';
-		*p++ = 'd';
-		*p++ = 's';
-		*p++ = 'p';
-		break;
-	case CPU_FAMILY_UNKNOWN:
-		/*
-		 * Specifically use CPU_FAMILY_UNKNOWN rather than
-		 * default:, so we're able to have the compiler whine
-		 * about unhandled enumerations.
-		 */
-		break;
-	}
-
-	printk("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
-
-#ifndef __LITTLE_ENDIAN__
-	/* 'eb' means 'Endian Big' */
-	*p++ = 'e';
-	*p++ = 'b';
-#endif
-	*p = '\0';
-}
-#endif /* __ASM_SH_BUGS_H */
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index 85a6c1c..73fba7c 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -166,6 +166,8 @@ extern unsigned int instruction_size(unsigned int insn);
 #define instruction_size(insn)	(2)
 #endif
 
+void select_idle_routine(void);
+
 #endif /* __ASSEMBLY__ */
 
 #include <asm/processor_32.h>
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index d662503..045d93f 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -15,6 +15,7 @@
 #include <linux/irqflags.h>
 #include <linux/smp.h>
 #include <linux/atomic.h>
+#include <asm/processor.h>
 #include <asm/smp.h>
 #include <asm/bl_bit.h>
 
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index af977ec..cf7c0f7 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -43,6 +43,7 @@
 #include <asm/smp.h>
 #include <asm/mmu_context.h>
 #include <asm/mmzone.h>
+#include <asm/processor.h>
 #include <asm/sparsemem.h>
 #include <asm/platform_early.h>
 
@@ -354,3 +355,57 @@ int test_mode_pin(int pin)
 {
 	return sh_mv.mv_mode_pins() & pin;
 }
+
+void __init arch_cpu_finalize_init(void)
+{
+	char *p = &init_utsname()->machine[2]; /* "sh" */
+
+	select_idle_routine();
+
+	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
+
+	switch (current_cpu_data.family) {
+	case CPU_FAMILY_SH2:
+		*p++ = '2';
+		break;
+	case CPU_FAMILY_SH2A:
+		*p++ = '2';
+		*p++ = 'a';
+		break;
+	case CPU_FAMILY_SH3:
+		*p++ = '3';
+		break;
+	case CPU_FAMILY_SH4:
+		*p++ = '4';
+		break;
+	case CPU_FAMILY_SH4A:
+		*p++ = '4';
+		*p++ = 'a';
+		break;
+	case CPU_FAMILY_SH4AL_DSP:
+		*p++ = '4';
+		*p++ = 'a';
+		*p++ = 'l';
+		*p++ = '-';
+		*p++ = 'd';
+		*p++ = 's';
+		*p++ = 'p';
+		break;
+	case CPU_FAMILY_UNKNOWN:
+		/*
+		 * Specifically use CPU_FAMILY_UNKNOWN rather than
+		 * default:, so we're able to have the compiler whine
+		 * about unhandled enumerations.
+		 */
+		break;
+	}
+
+	pr_info("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
+
+#ifndef __LITTLE_ENDIAN__
+	/* 'eb' means 'Endian Big' */
+	*p++ = 'e';
+	*p++ = 'b';
+#endif
+	*p = '\0';
+}

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] m68k/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 06/17] m68k/cpu: " Thomas Gleixner
  2023-06-14  9:22   ` Geert Uytterhoeven
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, Geert Uytterhoeven, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     9ceecc2589b9d7cef6b321339ed8de484eac4b20
Gitweb:        https://git.kernel.org/tip/9ceecc2589b9d7cef6b321339ed8de484eac4b20
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:30 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

m68k/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/20230613224545.254342916@linutronix.de

---
 arch/m68k/Kconfig            |  1 +
 arch/m68k/include/asm/bugs.h | 21 ---------------------
 arch/m68k/kernel/setup_mm.c  |  3 ++-
 3 files changed, 3 insertions(+), 22 deletions(-)
 delete mode 100644 arch/m68k/include/asm/bugs.h

diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 40198a1..dc792b3 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -4,6 +4,7 @@ config M68K
 	default y
 	select ARCH_32BIT_OFF_T
 	select ARCH_HAS_BINFMT_FLAT
+	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
diff --git a/arch/m68k/include/asm/bugs.h b/arch/m68k/include/asm/bugs.h
deleted file mode 100644
index 7455306..0000000
--- a/arch/m68k/include/asm/bugs.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- *  include/asm-m68k/bugs.h
- *
- *  Copyright (C) 1994  Linus Torvalds
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-#ifdef CONFIG_MMU
-extern void check_bugs(void);	/* in arch/m68k/kernel/setup.c */
-#else
-static void check_bugs(void)
-{
-}
-#endif
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index fbff1ce..6f1ae01 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/cpu.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
@@ -504,7 +505,7 @@ static int __init proc_hardware_init(void)
 module_init(proc_hardware_init);
 #endif
 
-void check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 #if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU)
 	if (m68k_fputype == 0) {

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] loongarch/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 05/17] loongarch/cpu: " Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:24   ` [patch 05/17] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     9841c423164787feb8f1442f922b7d80a70c82f1
Gitweb:        https://git.kernel.org/tip/9841c423164787feb8f1442f922b7d80a70c82f1
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:28 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

loongarch/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.195288218@linutronix.de

---
 arch/loongarch/Kconfig            |  1 +
 arch/loongarch/include/asm/bugs.h | 15 ---------------
 arch/loongarch/kernel/setup.c     |  4 ++--
 3 files changed, 3 insertions(+), 17 deletions(-)
 delete mode 100644 arch/loongarch/include/asm/bugs.h

diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index d38b066..cbab4f9 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -10,6 +10,7 @@ config LOONGARCH
 	select ARCH_ENABLE_MEMORY_HOTPLUG
 	select ARCH_ENABLE_MEMORY_HOTREMOVE
 	select ARCH_HAS_ACPI_TABLE_UPGRADE	if ACPI
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_FORTIFY_SOURCE
 	select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
 	select ARCH_HAS_PTE_SPECIAL
diff --git a/arch/loongarch/include/asm/bugs.h b/arch/loongarch/include/asm/bugs.h
deleted file mode 100644
index 9839653..0000000
--- a/arch/loongarch/include/asm/bugs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
- */
-#ifndef _ASM_BUGS_H
-#define _ASM_BUGS_H
-
-#include <asm/cpu.h>
-#include <asm/cpu-info.h>
-
-extern void check_bugs(void);
-
-#endif /* _ASM_BUGS_H */
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index 4444b13..78a0035 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -12,6 +12,7 @@
  */
 #include <linux/init.h>
 #include <linux/acpi.h>
+#include <linux/cpu.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/export.h>
@@ -37,7 +38,6 @@
 #include <asm/addrspace.h>
 #include <asm/alternative.h>
 #include <asm/bootinfo.h>
-#include <asm/bugs.h>
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/dma.h>
@@ -87,7 +87,7 @@ const char *get_system_type(void)
 	return "generic-loongson-machine";
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	alternative_instructions();
 }

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] ia64/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 04/17] ia64/cpu: " Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:24   ` [patch 04/17] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     6c38e3005621800263f117fb00d6787a76e16de7
Gitweb:        https://git.kernel.org/tip/6c38e3005621800263f117fb00d6787a76e16de7
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:27 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

ia64/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.137045745@linutronix.de

---
 arch/ia64/Kconfig            |  1 +
 arch/ia64/include/asm/bugs.h | 20 --------------------
 arch/ia64/kernel/setup.c     |  3 +--
 3 files changed, 2 insertions(+), 22 deletions(-)
 delete mode 100644 arch/ia64/include/asm/bugs.h

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 21fa63c..2cd93e6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,7 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_BINFMT_ELF_EXTRA_PHDRS
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_DMA_MARK_CLEAN
 	select ARCH_HAS_STRNCPY_FROM_USER
 	select ARCH_HAS_STRNLEN_USER
diff --git a/arch/ia64/include/asm/bugs.h b/arch/ia64/include/asm/bugs.h
deleted file mode 100644
index 0d6b9bd..0000000
--- a/arch/ia64/include/asm/bugs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- *
- * Based on <asm-alpha/bugs.h>.
- *
- * Modified 1998, 1999, 2003
- *	David Mosberger-Tang <davidm@hpl.hp.com>,  Hewlett-Packard Co.
- */
-#ifndef _ASM_IA64_BUGS_H
-#define _ASM_IA64_BUGS_H
-
-#include <asm/processor.h>
-
-extern void check_bugs (void);
-
-#endif /* _ASM_IA64_BUGS_H */
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index c057280..9009f18 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -1067,8 +1067,7 @@ cpu_init (void)
 	}
 }
 
-void __init
-check_bugs (void)
+void __init arch_cpu_finalize_init(void)
 {
 	ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
 			       (unsigned long) __end___mckinley_e9_bundles);

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] ARM: cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 03/17] ARM: cpu: " Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  2023-06-25 21:27   ` [patch 03/17] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     ee31bb0524a2e7c99b03f50249a411cc1eaa411f
Gitweb:        https://git.kernel.org/tip/ee31bb0524a2e7c99b03f50249a411cc1eaa411f
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:25 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

ARM: cpu: Switch to arch_cpu_finalize_init()

check_bugs() is about to be phased out. Switch over to the new
arch_cpu_finalize_init() implementation.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224545.078124882@linutronix.de

---
 arch/arm/Kconfig            | 1 +
 arch/arm/include/asm/bugs.h | 4 ----
 arch/arm/kernel/bugs.c      | 3 ++-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0fb4b21..d6ebe3e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -5,6 +5,7 @@ config ARM
 	select ARCH_32BIT_OFF_T
 	select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE if HAVE_KRETPROBES && FRAME_POINTER && !ARM_UNWIND
 	select ARCH_HAS_BINFMT_FLAT
+	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL if MMU
 	select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE
diff --git a/arch/arm/include/asm/bugs.h b/arch/arm/include/asm/bugs.h
index 97a312b..fe38555 100644
--- a/arch/arm/include/asm/bugs.h
+++ b/arch/arm/include/asm/bugs.h
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- *  arch/arm/include/asm/bugs.h
- *
  *  Copyright (C) 1995-2003 Russell King
  */
 #ifndef __ASM_BUGS_H
@@ -10,10 +8,8 @@
 extern void check_writebuffer_bugs(void);
 
 #ifdef CONFIG_MMU
-extern void check_bugs(void);
 extern void check_other_bugs(void);
 #else
-#define check_bugs() do { } while (0)
 #define check_other_bugs() do { } while (0)
 #endif
 
diff --git a/arch/arm/kernel/bugs.c b/arch/arm/kernel/bugs.c
index 14c8dbb..087bce6 100644
--- a/arch/arm/kernel/bugs.c
+++ b/arch/arm/kernel/bugs.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/init.h>
+#include <linux/cpu.h>
 #include <asm/bugs.h>
 #include <asm/proc-fns.h>
 
@@ -11,7 +12,7 @@ void check_other_bugs(void)
 #endif
 }
 
-void __init check_bugs(void)
+void __init arch_cpu_finalize_init(void)
 {
 	check_writebuffer_bugs();
 	check_other_bugs();

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] init: Provide arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
  2023-06-14  9:28   ` Borislav Petkov
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     7725acaa4f0c04fbefb0e0d342635b967bb7d414
Gitweb:        https://git.kernel.org/tip/7725acaa4f0c04fbefb0e0d342635b967bb7d414
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:22 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

init: Provide arch_cpu_finalize_init()

check_bugs() has become a dumping ground for all sorts of activities to
finalize the CPU initialization before running the rest of the init code.

Most are empty, a few do actual bug checks, some do alternative patching
and some cobble a CPU advertisement string together....

Aside of that the current implementation requires duplicated function
declaration and mostly empty header files for them.

Provide a new function arch_cpu_finalize_init(). Provide a generic
declaration if CONFIG_ARCH_HAS_CPU_FINALIZE_INIT is selected and a stub
inline otherwise.

This requires a temporary #ifdef in start_kernel() which will be removed
along with check_bugs() once the architectures are converted over.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230613224544.957805717@linutronix.de

---
 arch/Kconfig        | 3 +++
 include/linux/cpu.h | 6 ++++++
 init/main.c         | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 205fd23..171e6b5 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -285,6 +285,9 @@ config ARCH_HAS_DMA_SET_UNCACHED
 config ARCH_HAS_DMA_CLEAR_UNCACHED
 	bool
 
+config ARCH_HAS_CPU_FINALIZE_INIT
+	bool
+
 # Select if arch init_task must go in the __init_task_data section
 config ARCH_TASK_STRUCT_ON_STACK
 	bool
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 8582a71..4893c4a 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -184,6 +184,12 @@ void arch_cpu_idle_enter(void);
 void arch_cpu_idle_exit(void);
 void __noreturn arch_cpu_idle_dead(void);
 
+#ifdef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
+void arch_cpu_finalize_init(void);
+#else
+static inline void arch_cpu_finalize_init(void) { }
+#endif
+
 int cpu_report_state(int cpu);
 int cpu_check_up_prepare(int cpu);
 void cpu_set_state_online(int cpu);
diff --git a/init/main.c b/init/main.c
index af50044..77d5316 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1078,7 +1078,11 @@ asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(v
 	taskstats_init_early();
 	delayacct_init();
 
+	arch_cpu_finalize_init();
+	/* Temporary conditional until everything has been converted */
+#ifndef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT
 	check_bugs();
+#endif
 
 	acpi_subsystem_init();
 	arch_post_acpi_subsys_init();

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [tip: x86/boot] x86/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init() Thomas Gleixner
  2023-06-14  9:53   ` Thomas Gleixner
@ 2023-06-16  9:24   ` tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 62+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2023-06-16  9:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Thomas Gleixner, Borislav Petkov (AMD), x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     7c7077a72674402654f3291354720cd73cdf649e
Gitweb:        https://git.kernel.org/tip/7c7077a72674402654f3291354720cd73cdf649e
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 14 Jun 2023 01:39:24 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Jun 2023 10:15:59 +02:00

x86/cpu: Switch to arch_cpu_finalize_init()

check_bugs() is a dumping ground for finalizing the CPU bringup. Only parts of
it has to do with actual CPU bugs.

Split it apart into arch_cpu_finalize_init() and cpu_select_mitigations().

Fixup the bogus 32bit comments while at it.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230613224545.019583869@linutronix.de

---
 arch/x86/Kconfig             |  1 +-
 arch/x86/include/asm/bugs.h  |  2 +-
 arch/x86/kernel/cpu/bugs.c   | 51 +----------------------------------
 arch/x86/kernel/cpu/common.c | 53 +++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/cpu/cpu.h    |  1 +-
 5 files changed, 56 insertions(+), 52 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 53bab12..e8ebafa 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -71,6 +71,7 @@ config X86
 	select ARCH_HAS_ACPI_TABLE_UPGRADE	if ACPI
 	select ARCH_HAS_CACHE_LINE_SIZE
 	select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
+	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL
 	select ARCH_HAS_DEBUG_VM_PGTABLE	if !X86_PAE
diff --git a/arch/x86/include/asm/bugs.h b/arch/x86/include/asm/bugs.h
index 92ae283..f25ca2d 100644
--- a/arch/x86/include/asm/bugs.h
+++ b/arch/x86/include/asm/bugs.h
@@ -4,8 +4,6 @@
 
 #include <asm/processor.h>
 
-extern void check_bugs(void);
-
 #if defined(CONFIG_CPU_SUP_INTEL) && defined(CONFIG_X86_32)
 int ppro_with_ram_bug(void);
 #else
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 182af64..9e2a918 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -9,7 +9,6 @@
  *	- Andrew D. Balsa (code cleanup).
  */
 #include <linux/init.h>
-#include <linux/utsname.h>
 #include <linux/cpu.h>
 #include <linux/module.h>
 #include <linux/nospec.h>
@@ -27,8 +26,6 @@
 #include <asm/msr.h>
 #include <asm/vmx.h>
 #include <asm/paravirt.h>
-#include <asm/alternative.h>
-#include <asm/set_memory.h>
 #include <asm/intel-family.h>
 #include <asm/e820/api.h>
 #include <asm/hypervisor.h>
@@ -125,21 +122,8 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
 DEFINE_STATIC_KEY_FALSE(mmio_stale_data_clear);
 EXPORT_SYMBOL_GPL(mmio_stale_data_clear);
 
-void __init check_bugs(void)
+void __init cpu_select_mitigations(void)
 {
-	identify_boot_cpu();
-
-	/*
-	 * identify_boot_cpu() initialized SMT support information, let the
-	 * core code know.
-	 */
-	cpu_smt_check_topology();
-
-	if (!IS_ENABLED(CONFIG_SMP)) {
-		pr_info("CPU: ");
-		print_cpu_info(&boot_cpu_data);
-	}
-
 	/*
 	 * Read the SPEC_CTRL MSR to account for reserved bits which may
 	 * have unknown values. AMD64_LS_CFG MSR is cached in the early AMD
@@ -176,39 +160,6 @@ void __init check_bugs(void)
 	md_clear_select_mitigation();
 	srbds_select_mitigation();
 	l1d_flush_select_mitigation();
-
-	arch_smt_update();
-
-#ifdef CONFIG_X86_32
-	/*
-	 * Check whether we are able to run this kernel safely on SMP.
-	 *
-	 * - i386 is no longer supported.
-	 * - In order to run on anything without a TSC, we need to be
-	 *   compiled for a i486.
-	 */
-	if (boot_cpu_data.x86 < 4)
-		panic("Kernel requires i486+ for 'invlpg' and other features");
-
-	init_utsname()->machine[1] =
-		'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
-	alternative_instructions();
-
-	fpu__init_check_bugs();
-#else /* CONFIG_X86_64 */
-	alternative_instructions();
-
-	/*
-	 * Make sure the first 2MB area is not mapped by huge pages
-	 * There are typically fixed size MTRRs in there and overlapping
-	 * MTRRs into large pages causes slow downs.
-	 *
-	 * Right now we don't do that with gbpages because there seems
-	 * very little benefit for that case.
-	 */
-	if (!direct_gbpages)
-		set_memory_4k((unsigned long)__va(0), 1);
-#endif
 }
 
 /*
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 80710a6..18612e5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -19,11 +19,14 @@
 #include <linux/kprobes.h>
 #include <linux/kgdb.h>
 #include <linux/smp.h>
+#include <linux/cpu.h>
 #include <linux/io.h>
 #include <linux/syscore_ops.h>
 #include <linux/pgtable.h>
 #include <linux/stackprotector.h>
+#include <linux/utsname.h>
 
+#include <asm/alternative.h>
 #include <asm/cmdline.h>
 #include <asm/perf_event.h>
 #include <asm/mmu_context.h>
@@ -59,6 +62,7 @@
 #include <asm/intel-family.h>
 #include <asm/cpu_device_id.h>
 #include <asm/uv/uv.h>
+#include <asm/set_memory.h>
 #include <asm/sigframe.h>
 #include <asm/traps.h>
 #include <asm/sev.h>
@@ -2362,3 +2366,52 @@ void arch_smt_update(void)
 	/* Check whether IPI broadcasting can be enabled */
 	apic_smt_update();
 }
+
+void __init arch_cpu_finalize_init(void)
+{
+	identify_boot_cpu();
+
+	/*
+	 * identify_boot_cpu() initialized SMT support information, let the
+	 * core code know.
+	 */
+	cpu_smt_check_topology();
+
+	if (!IS_ENABLED(CONFIG_SMP)) {
+		pr_info("CPU: ");
+		print_cpu_info(&boot_cpu_data);
+	}
+
+	cpu_select_mitigations();
+
+	arch_smt_update();
+
+	if (IS_ENABLED(CONFIG_X86_32)) {
+		/*
+		 * Check whether this is a real i386 which is not longer
+		 * supported and fixup the utsname.
+		 */
+		if (boot_cpu_data.x86 < 4)
+			panic("Kernel requires i486+ for 'invlpg' and other features");
+
+		init_utsname()->machine[1] =
+			'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
+	}
+
+	alternative_instructions();
+
+	if (IS_ENABLED(CONFIG_X86_64)) {
+		/*
+		 * Make sure the first 2MB area is not mapped by huge pages
+		 * There are typically fixed size MTRRs in there and overlapping
+		 * MTRRs into large pages causes slow downs.
+		 *
+		 * Right now we don't do that with gbpages because there seems
+		 * very little benefit for that case.
+		 */
+		if (!direct_gbpages)
+			set_memory_4k((unsigned long)__va(0), 1);
+	} else {
+		fpu__init_check_bugs();
+	}
+}
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index f97b0fe..1c44630 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -79,6 +79,7 @@ extern void detect_ht(struct cpuinfo_x86 *c);
 extern void check_null_seg_clears_base(struct cpuinfo_x86 *c);
 
 unsigned int aperfmperf_get_khz(int cpu);
+void cpu_select_mitigations(void);
 
 extern void x86_spec_ctrl_setup_ap(void);
 extern void update_srbds_msr(void);

^ permalink raw reply related	[flat|nested] 62+ messages in thread

* Re: [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-21 17:12   ` Tom Lendacky
  1 sibling, 0 replies; 62+ messages in thread
From: Tom Lendacky @ 2023-06-21 17:12 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel

On 6/13/23 18:39, Thomas Gleixner wrote:
> Invoke the X86ism mem_encrypt_init() from X86 arch_cpu_finalize_init() and
> remove the weak fallback from the core code.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>   arch/x86/include/asm/mem_encrypt.h |    7 ++++---
>   arch/x86/kernel/cpu/common.c       |   11 +++++++++++
>   init/main.c                        |   13 -------------
>   3 files changed, 15 insertions(+), 16 deletions(-)
> 

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 04/17] ia64/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 04/17] ia64/cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:24   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:24 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, linux-ia64, Russell King, linux-arm-kernel,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-ia64@vger.kernel.org
> ---
>   arch/ia64/Kconfig            |    1 +
>   arch/ia64/include/asm/bugs.h |   20 --------------------
>   arch/ia64/kernel/setup.c     |    3 +--
>   3 files changed, 2 insertions(+), 22 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 05/17] loongarch/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 05/17] loongarch/cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:24   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:24 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Huacai Chen, WANG Xuerui, loongarch, Russell King,
	linux-arm-kernel, linux-ia64, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: WANG Xuerui <kernel@xen0n.name>
> Cc: loongarch@lists.linux.dev
> ---
>   arch/loongarch/Kconfig            |    1 +
>   arch/loongarch/include/asm/bugs.h |   15 ---------------
>   arch/loongarch/kernel/setup.c     |    4 ++--
>   3 files changed, 3 insertions(+), 17 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 07/17] mips/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 07/17] mips/cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:25   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:25 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Thomas Bogendoerfer, linux-mips, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: linux-mips@vger.kernel.org
> ---
>   arch/mips/Kconfig            |    1 +
>   arch/mips/include/asm/bugs.h |   17 -----------------
>   arch/mips/kernel/setup.c     |   13 +++++++++++++
>   3 files changed, 14 insertions(+), 17 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 03/17] ARM: cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 03/17] ARM: cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:27   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:27 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arm-kernel@lists.infradead.org
> ---
>   arch/arm/Kconfig            |    1 +
>   arch/arm/include/asm/bugs.h |    4 ----
>   arch/arm/kernel/bugs.c      |    3 ++-
>   3 files changed, 3 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 10/17] um/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
  2023-06-14  6:51   ` Richard Weinberger
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:28   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:28 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Richard Weinberger, Anton Ivanov, Johannes Berg,
	linux-um, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: linux-um@lists.infradead.org
> ---
>   arch/um/Kconfig            |    1 +
>   arch/um/include/asm/bugs.h |    7 -------
>   arch/um/kernel/um_arch.c   |    3 ++-
>   3 files changed, 3 insertions(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 08/17] sh/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:29   ` Philippe Mathieu-Daudé
  2023-06-25 21:45   ` John Paul Adrian Glaubitz
  2 siblings, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:29 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer,
	linux-mips, David S. Miller, sparclinux, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-um, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Cc: linux-sh@vger.kernel.org
> ---
>   arch/sh/Kconfig                 |    1
>   arch/sh/include/asm/bugs.h      |   74 ----------------------------------------
>   arch/sh/include/asm/processor.h |    2 +
>   arch/sh/kernel/idle.c           |    1
>   arch/sh/kernel/setup.c          |   55 +++++++++++++++++++++++++++++
>   5 files changed, 59 insertions(+), 74 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 09/17] sparc/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
  2023-06-14 20:41   ` Sam Ravnborg
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:30   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:30 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, David S. Miller, sparclinux, Russell King,
	linux-arm-kernel, linux-ia64, Huacai Chen, WANG Xuerui,
	loongarch, Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer,
	linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-um, Richard Henderson,
	James E.J. Bottomley, Michael Ellerman, Chris Zankel,
	Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
> ---
>   arch/sparc/Kconfig            |    1 +
>   arch/sparc/include/asm/bugs.h |   18 ------------------
>   arch/sparc/kernel/setup_32.c  |    7 +++++++
>   3 files changed, 8 insertions(+), 18 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 11/17] init: Remove check_bugs() leftovers
  2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
  2023-06-14  6:14   ` Richard Henderson
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-06-25 21:31   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 62+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-25 21:31 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Russell King, linux-arm-kernel,
	linux-ia64, Huacai Chen, WANG Xuerui, loongarch,
	Geert Uytterhoeven, linux-m68k, Thomas Bogendoerfer, linux-mips,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Tom Lendacky

On 14/6/23 01:39, Thomas Gleixner wrote:
> Everything is converted over to arch_cpu_finalize_init(). Remove the
> check_bugs() leftovers including the empty stubs in asm-generic, alpha,
> parisc, powerpc and xtensa.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Chris Zankel <chris@zankel.net>
> ---
>   arch/alpha/include/asm/bugs.h   |   20 --------------------
>   arch/parisc/include/asm/bugs.h  |   20 --------------------
>   arch/powerpc/include/asm/bugs.h |   15 ---------------
>   arch/xtensa/include/asm/bugs.h  |   18 ------------------
>   include/asm-generic/bugs.h      |   11 -----------
>   init/main.c                     |    5 -----
>   6 files changed, 89 deletions(-)

Yay!

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 08/17] sh/cpu: Switch to arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
  2023-06-25 21:29   ` [patch 08/17] " Philippe Mathieu-Daudé
@ 2023-06-25 21:45   ` John Paul Adrian Glaubitz
  2 siblings, 0 replies; 62+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-06-25 21:45 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Yoshinori Sato, Rich Felker, linux-sh,
	Russell King, linux-arm-kernel, linux-ia64, Huacai Chen,
	WANG Xuerui, loongarch, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky

On Wed, 2023-06-14 at 01:39 +0200, Thomas Gleixner wrote:
> check_bugs() is about to be phased out. Switch over to the new
> arch_cpu_finalize_init() implementation.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Cc: linux-sh@vger.kernel.org
> ---
>  arch/sh/Kconfig                 |    1 
>  arch/sh/include/asm/bugs.h      |   74 ----------------------------------------
>  arch/sh/include/asm/processor.h |    2 +
>  arch/sh/kernel/idle.c           |    1 
>  arch/sh/kernel/setup.c          |   55 +++++++++++++++++++++++++++++
>  5 files changed, 59 insertions(+), 74 deletions(-)
> 
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -6,6 +6,7 @@ config SUPERH
>  	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
>  	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
>  	select ARCH_HAS_BINFMT_FLAT if !MMU
> +	select ARCH_HAS_CPU_FINALIZE_INIT
>  	select ARCH_HAS_CURRENT_STACK_POINTER
>  	select ARCH_HAS_GIGANTIC_PAGE
>  	select ARCH_HAS_GCOV_PROFILE_ALL
> --- a/arch/sh/include/asm/bugs.h
> +++ /dev/null
> @@ -1,74 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -#ifndef __ASM_SH_BUGS_H
> -#define __ASM_SH_BUGS_H
> -
> -/*
> - * This is included by init/main.c to check for architecture-dependent bugs.
> - *
> - * Needs:
> - *	void check_bugs(void);
> - */
> -
> -/*
> - * I don't know of any Super-H bugs yet.
> - */
> -
> -#include <asm/processor.h>
> -
> -extern void select_idle_routine(void);
> -
> -static void __init check_bugs(void)
> -{
> -	extern unsigned long loops_per_jiffy;
> -	char *p = &init_utsname()->machine[2]; /* "sh" */
> -
> -	select_idle_routine();
> -
> -	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
> -
> -	switch (current_cpu_data.family) {
> -	case CPU_FAMILY_SH2:
> -		*p++ = '2';
> -		break;
> -	case CPU_FAMILY_SH2A:
> -		*p++ = '2';
> -		*p++ = 'a';
> -		break;
> -	case CPU_FAMILY_SH3:
> -		*p++ = '3';
> -		break;
> -	case CPU_FAMILY_SH4:
> -		*p++ = '4';
> -		break;
> -	case CPU_FAMILY_SH4A:
> -		*p++ = '4';
> -		*p++ = 'a';
> -		break;
> -	case CPU_FAMILY_SH4AL_DSP:
> -		*p++ = '4';
> -		*p++ = 'a';
> -		*p++ = 'l';
> -		*p++ = '-';
> -		*p++ = 'd';
> -		*p++ = 's';
> -		*p++ = 'p';
> -		break;
> -	case CPU_FAMILY_UNKNOWN:
> -		/*
> -		 * Specifically use CPU_FAMILY_UNKNOWN rather than
> -		 * default:, so we're able to have the compiler whine
> -		 * about unhandled enumerations.
> -		 */
> -		break;
> -	}
> -
> -	printk("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
> -
> -#ifndef __LITTLE_ENDIAN__
> -	/* 'eb' means 'Endian Big' */
> -	*p++ = 'e';
> -	*p++ = 'b';
> -#endif
> -	*p = '\0';
> -}
> -#endif /* __ASM_SH_BUGS_H */
> --- a/arch/sh/include/asm/processor.h
> +++ b/arch/sh/include/asm/processor.h
> @@ -166,6 +166,8 @@ extern unsigned int instruction_size(uns
>  #define instruction_size(insn)	(2)
>  #endif
>  
> +void select_idle_routine(void);
> +
>  #endif /* __ASSEMBLY__ */
>  
>  #include <asm/processor_32.h>
> --- a/arch/sh/kernel/idle.c
> +++ b/arch/sh/kernel/idle.c
> @@ -15,6 +15,7 @@
>  #include <linux/irqflags.h>
>  #include <linux/smp.h>
>  #include <linux/atomic.h>
> +#include <asm/processor.h>
>  #include <asm/smp.h>
>  #include <asm/bl_bit.h>
>  
> --- a/arch/sh/kernel/setup.c
> +++ b/arch/sh/kernel/setup.c
> @@ -43,6 +43,7 @@
>  #include <asm/smp.h>
>  #include <asm/mmu_context.h>
>  #include <asm/mmzone.h>
> +#include <asm/processor.h>
>  #include <asm/sparsemem.h>
>  #include <asm/platform_early.h>
>  
> @@ -354,3 +355,57 @@ int test_mode_pin(int pin)
>  {
>  	return sh_mv.mv_mode_pins() & pin;
>  }
> +
> +void __init arch_cpu_finalize_init(void)
> +{
> +	char *p = &init_utsname()->machine[2]; /* "sh" */
> +
> +	select_idle_routine();
> +
> +	current_cpu_data.loops_per_jiffy = loops_per_jiffy;
> +
> +	switch (current_cpu_data.family) {
> +	case CPU_FAMILY_SH2:
> +		*p++ = '2';
> +		break;
> +	case CPU_FAMILY_SH2A:
> +		*p++ = '2';
> +		*p++ = 'a';
> +		break;
> +	case CPU_FAMILY_SH3:
> +		*p++ = '3';
> +		break;
> +	case CPU_FAMILY_SH4:
> +		*p++ = '4';
> +		break;
> +	case CPU_FAMILY_SH4A:
> +		*p++ = '4';
> +		*p++ = 'a';
> +		break;
> +	case CPU_FAMILY_SH4AL_DSP:
> +		*p++ = '4';
> +		*p++ = 'a';
> +		*p++ = 'l';
> +		*p++ = '-';
> +		*p++ = 'd';
> +		*p++ = 's';
> +		*p++ = 'p';
> +		break;
> +	case CPU_FAMILY_UNKNOWN:
> +		/*
> +		 * Specifically use CPU_FAMILY_UNKNOWN rather than
> +		 * default:, so we're able to have the compiler whine
> +		 * about unhandled enumerations.
> +		 */
> +		break;
> +	}
> +
> +	pr_info("CPU: %s\n", get_cpu_subtype(&current_cpu_data));
> +
> +#ifndef __LITTLE_ENDIAN__
> +	/* 'eb' means 'Endian Big' */
> +	*p++ = 'e';
> +	*p++ = 'b';
> +#endif
> +	*p = '\0';
> +}

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process
  2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
                   ` (16 preceding siblings ...)
  2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
@ 2023-06-28  3:38 ` Jan Engelhardt
  17 siblings, 0 replies; 62+ messages in thread
From: Jan Engelhardt @ 2023-06-28  3:38 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky

On Wednesday 2023-06-14 01:39, Thomas Gleixner wrote:

>Hi!
>
>My team and myself are working on sanitizing the x86 boot process,
>especially the complete horror show of CPUID evaluation, which is
>constructed with hay-wire circuits, duct tape and superglue.

What's with Intel and its glue analogies? Not to mention it stuck very 
well, if I may say so myself (not to mention the glue in the co 
struction of the 12th Intel series).

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
  2023-06-14  5:03   ` Chang S. Bae
  2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
@ 2023-09-01 17:30   ` Guenter Roeck
  2023-09-01 18:00     ` Nikolay Borisov
  2023-09-01 18:02     ` Nikolay Borisov
  2 siblings, 2 replies; 62+ messages in thread
From: Guenter Roeck @ 2023-09-01 17:30 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Nikolay Borisov, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky, semenzato

Hi,

On Wed, Jun 14, 2023 at 01:39:46AM +0200, Thomas Gleixner wrote:
> 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>

The backport of this patch into chromeos-5.10 and chromeos-5.15 via stable
relase merges is causing various Chromebooks (not all of them) to crash
early during boot. Subsequent fixes have not addressed the problem for us,
so we already reverted the patch from chromeos-5.15 and will revert it
from chromeos-5.10 as well.

I don't know if this is a Chromebook specific problem, or if it affects
mainline, so this is just a heads-up in case others experience similar
problems.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-09-01 17:30   ` [patch 17/17] " Guenter Roeck
@ 2023-09-01 18:00     ` Nikolay Borisov
  2023-09-01 18:21       ` Guenter Roeck
  2023-09-01 18:02     ` Nikolay Borisov
  1 sibling, 1 reply; 62+ messages in thread
From: Nikolay Borisov @ 2023-09-01 18:00 UTC (permalink / raw)
  To: Guenter Roeck, Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Ahmed S. Darwish, Arnd Bergmann,
	Russell King, linux-arm-kernel, linux-ia64, Huacai Chen,
	WANG Xuerui, loongarch, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky, semenzato



On 1.09.23 г. 20:30 ч., Guenter Roeck wrote:
> Hi,
> 
> On Wed, Jun 14, 2023 at 01:39:46AM +0200, Thomas Gleixner wrote:
>> 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>
> 
> The backport of this patch into chromeos-5.10 and chromeos-5.15 via stable
> relase merges is causing various Chromebooks (not all of them) to crash
> early during boot. Subsequent fixes have not addressed the problem for us,
> so we already reverted the patch from chromeos-5.15 and will revert it
> from chromeos-5.10 as well.
> 
> I don't know if this is a Chromebook specific problem, or if it affects
> mainline, so this is just a heads-up in case others experience similar
> problems.


Looking at 5.15 the following prerequisites are likely missing:

af8060279968 ("mm: Move mm_cachep initialization to mm_init()")
5b93a83649c7 ("x86/mm: Initialize text poking earlier")


Can you test with those patches backported to 5.15.y and see if it works?
> 
> Thanks,
> Guenter

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-09-01 17:30   ` [patch 17/17] " Guenter Roeck
  2023-09-01 18:00     ` Nikolay Borisov
@ 2023-09-01 18:02     ` Nikolay Borisov
  2023-09-01 21:09       ` Guenter Roeck
  1 sibling, 1 reply; 62+ messages in thread
From: Nikolay Borisov @ 2023-09-01 18:02 UTC (permalink / raw)
  To: Guenter Roeck, Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Ahmed S. Darwish, Arnd Bergmann,
	Russell King, linux-arm-kernel, linux-ia64, Huacai Chen,
	WANG Xuerui, loongarch, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky, semenzato



On 1.09.23 г. 20:30 ч., Guenter Roeck wrote:
> Hi,
> 
> On Wed, Jun 14, 2023 at 01:39:46AM +0200, Thomas Gleixner wrote:
>> 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>
> 
> The backport of this patch into chromeos-5.10 and chromeos-5.15 via stable
> relase merges is causing various Chromebooks (not all of them) to crash
> early during boot. Subsequent fixes have not addressed the problem for us,
> so we already reverted the patch from chromeos-5.15 and will revert it
> from chromeos-5.10 as well.
> 
> I don't know if this is a Chromebook specific problem, or if it affects
> mainline, so this is just a heads-up in case others experience similar
> problems.


Another thing - if you choose to revert the arch_finalize patch then 
bear in mind that the GDS' 'force' option is rendered inoperable as the 
FPU can't be disabled due to the way things are sequenced.
> 
> Thanks,
> Guenter

^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-09-01 18:00     ` Nikolay Borisov
@ 2023-09-01 18:21       ` Guenter Roeck
  0 siblings, 0 replies; 62+ messages in thread
From: Guenter Roeck @ 2023-09-01 18:21 UTC (permalink / raw)
  To: Nikolay Borisov, Thomas Gleixner
  Cc: LKML, x86, Linus Torvalds, Ahmed S. Darwish, Arnd Bergmann,
	Russell King, linux-arm-kernel, linux-ia64, Huacai Chen,
	WANG Xuerui, loongarch, Geert Uytterhoeven, linux-m68k,
	Thomas Bogendoerfer, linux-mips, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, David S. Miller, sparclinux,
	Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um,
	Richard Henderson, James E.J. Bottomley, Michael Ellerman,
	Chris Zankel, Tom Lendacky, semenzato

On 9/1/23 11:00, Nikolay Borisov wrote:
> 
> 
> On 1.09.23 г. 20:30 ч., Guenter Roeck wrote:
>> Hi,
>>
>> On Wed, Jun 14, 2023 at 01:39:46AM +0200, Thomas Gleixner wrote:
>>> 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>
>>
>> The backport of this patch into chromeos-5.10 and chromeos-5.15 via stable
>> relase merges is causing various Chromebooks (not all of them) to crash
>> early during boot. Subsequent fixes have not addressed the problem for us,
>> so we already reverted the patch from chromeos-5.15 and will revert it
>> from chromeos-5.10 as well.
>>
>> I don't know if this is a Chromebook specific problem, or if it affects
>> mainline, so this is just a heads-up in case others experience similar
>> problems.
> 
> 
> Looking at 5.15 the following prerequisites are likely missing:
> 
> af8060279968 ("mm: Move mm_cachep initialization to mm_init()")
> 5b93a83649c7 ("x86/mm: Initialize text poking earlier")
> 
> 
> Can you test with those patches backported to 5.15.y and see if it works?

Both patches are already in v5.10.y and 5.15.y, so unfortunately
that doesn't help.

Guenter


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
  2023-09-01 18:02     ` Nikolay Borisov
@ 2023-09-01 21:09       ` Guenter Roeck
  0 siblings, 0 replies; 62+ messages in thread
From: Guenter Roeck @ 2023-09-01 21:09 UTC (permalink / raw)
  To: Nikolay Borisov
  Cc: Thomas Gleixner, LKML, x86, Linus Torvalds, Ahmed S. Darwish,
	Arnd Bergmann, Russell King, linux-arm-kernel, linux-ia64,
	Huacai Chen, WANG Xuerui, loongarch, Geert Uytterhoeven,
	linux-m68k, Thomas Bogendoerfer, linux-mips, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, linux-sh,
	David S. Miller, sparclinux, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, Richard Henderson, James E.J. Bottomley,
	Michael Ellerman, Chris Zankel, Tom Lendacky, semenzato

On Fri, Sep 01, 2023 at 09:02:19PM +0300, Nikolay Borisov wrote:
> 
> 
> On 1.09.23 г. 20:30 ч., Guenter Roeck wrote:
> > Hi,
> > 
> > On Wed, Jun 14, 2023 at 01:39:46AM +0200, Thomas Gleixner wrote:
> > > 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>
> > 
> > The backport of this patch into chromeos-5.10 and chromeos-5.15 via stable
> > relase merges is causing various Chromebooks (not all of them) to crash
> > early during boot. Subsequent fixes have not addressed the problem for us,
> > so we already reverted the patch from chromeos-5.15 and will revert it
> > from chromeos-5.10 as well.
> > 
> > I don't know if this is a Chromebook specific problem, or if it affects
> > mainline, so this is just a heads-up in case others experience similar
> > problems.
> 
> 
> Another thing - if you choose to revert the arch_finalize patch then bear in
> mind that the GDS' 'force' option is rendered inoperable as the FPU can't be
> disabled due to the way things are sequenced.

I understand, but that is still better than not being able to boot
in the first place.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2023-09-01 22:55 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 23:39 [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Thomas Gleixner
2023-06-13 23:39 ` [patch 01/17] init: Provide arch_cpu_finalize_init() Thomas Gleixner
2023-06-14  9:28   ` Borislav Petkov
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 02/17] x86/cpu: Switch to arch_cpu_finalize_init() Thomas Gleixner
2023-06-14  9:53   ` Thomas Gleixner
2023-06-14 10:39     ` Borislav Petkov
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 03/17] ARM: cpu: " Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:27   ` [patch 03/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 04/17] ia64/cpu: " Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:24   ` [patch 04/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 05/17] loongarch/cpu: " Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:24   ` [patch 05/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 06/17] m68k/cpu: " Thomas Gleixner
2023-06-14  9:22   ` Geert Uytterhoeven
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 07/17] mips/cpu: " Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:25   ` [patch 07/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 08/17] sh/cpu: " Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:29   ` [patch 08/17] " Philippe Mathieu-Daudé
2023-06-25 21:45   ` John Paul Adrian Glaubitz
2023-06-13 23:39 ` [patch 09/17] sparc/cpu: " Thomas Gleixner
2023-06-14 20:41   ` Sam Ravnborg
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:30   ` [patch 09/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 10/17] um/cpu: " Thomas Gleixner
2023-06-14  6:51   ` Richard Weinberger
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:28   ` [patch 10/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 11/17] init: Remove check_bugs() leftovers Thomas Gleixner
2023-06-14  6:14   ` Richard Henderson
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-25 21:31   ` [patch 11/17] " Philippe Mathieu-Daudé
2023-06-13 23:39 ` [patch 12/17] init: Invoke arch_cpu_finalize_init() earlier Thomas Gleixner
2023-06-15 21:44   ` Edgecombe, Rick P
2023-06-15 22:03     ` Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 13/17] init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init() Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-21 17:12   ` [patch 13/17] " Tom Lendacky
2023-06-13 23:39 ` [patch 14/17] x86/init: Initialize signal frame size late Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 15/17] x86/fpu: Remove cpuinfo argument from init functions Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 16/17] x86/fpu: Mark init functions __init Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-06-13 23:39 ` [patch 17/17] x86/fpu: Move FPU initialization into arch_cpu_finalize_init() Thomas Gleixner
2023-06-14  5:03   ` Chang S. Bae
2023-06-14  9:52     ` Thomas Gleixner
2023-06-16  9:24   ` [tip: x86/boot] " tip-bot2 for Thomas Gleixner
2023-09-01 17:30   ` [patch 17/17] " Guenter Roeck
2023-09-01 18:00     ` Nikolay Borisov
2023-09-01 18:21       ` Guenter Roeck
2023-09-01 18:02     ` Nikolay Borisov
2023-09-01 21:09       ` Guenter Roeck
2023-06-28  3:38 ` [patch 00/17] init, treewide, x86: Cleanup check_bugs() and start sanitizing the x86 boot process Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).