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

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).