[PATCH v1 00/14] x86 boot code cleanups, batch 1

H. Peter Anvin posted 14 patches 2 weeks, 3 days ago
arch/x86/Kconfig                    |  85 ++++---------------------
arch/x86/boot/Makefile              |   4 +-
arch/x86/boot/a20.c                 |  34 +++++-----
arch/x86/boot/boot.h                | 116 ++++++++++------------------------
arch/x86/boot/cmdline.c             |  79 ++++++++++++++++++-----
arch/x86/boot/compressed/Makefile   |   2 -
arch/x86/boot/compressed/cmdline.c  |  29 ---------
arch/x86/boot/compressed/error.c    |   2 -
arch/x86/boot/compressed/head_32.S  |   2 -
arch/x86/boot/compressed/head_64.S  |   4 --
arch/x86/boot/{ => compressed}/io.h |   0
arch/x86/boot/compressed/misc.c     |   8 ---
arch/x86/boot/compressed/misc.h     |   2 +-
arch/x86/boot/compressed/tdx.c      |   2 +-
arch/x86/boot/header.S              | 123 ++++++++----------------------------
arch/x86/boot/main.c                |  43 ++++++-------
arch/x86/boot/pm.c                  |   5 +-
arch/x86/boot/regs.c                |   3 +-
arch/x86/boot/setup.ld              |  26 ++++----
arch/x86/boot/start16.S             | 108 +++++++++++++++++++++++++++++++
arch/x86/boot/video-bios.c          |   5 +-
arch/x86/boot/video-mode.c          |   5 +-
arch/x86/boot/video.c               |   7 +-
arch/x86/realmode/rm/wakemain.c     |   4 --
arch/x86/realmode/rm/wakeup_asm.S   |  10 +--
include/linux/compiler-gcc.h        |  25 --------
include/linux/compiler.h            |   8 +++
27 files changed, 316 insertions(+), 425 deletions(-)
[PATCH v1 00/14] x86 boot code cleanups, batch 1
Posted by H. Peter Anvin 2 weeks, 3 days ago
From: "H. Peter Anvin" (Intel) <hpa@zytor.com>

Uros Bizjak was kind enough to look over my RFC patchset, and so I
feel confident enough to call this a v1 patchset now.

The difference versus RFC are:

1. Remove .code16 from header.S (Uros Bizjak).

2. Split out the changed handling of the old (ancient by now) command
   pointer protocol into a separate patch - it had accidentally gotten
   mixed into two(!) mostly unrelated patches.

3. Added a missing barrier(); to a20.c, made necessary by having the
   compiler aware of fs/gs memory.

4. While changing a20.c anyway, tidy up and optimize the code a bit.

Again, the only potentially controversial thing here is removing the
options for non-relocatable kernels and building kernels without the
EFI stub. Those configurations should be considered obsolete, and they
don't add any cost to the runtime kernel.

This patchset also includes the removal of the gcc-specific version of
the RELOC_HIDE() macro, by Uros Bizjak, as the other changes in this
patchset makes that possible. Per Uros, this is holding back gcc
development, so it seems pretty important.

I am calling this "batch 1", because I have quite a few more cleanups
still being worked on; this patchset will be a prerequisite for those,
obviously.

This patchset is also available as a git tree:

	git://git.zytor.com/linux/kernel/boot.git hpa/boot1
	https://git.zytor.com/linux/kernel/boot/log/?h=hpa/boot1

The patches are:

    01/14: x86/realmode: remove I/O port paravirtualization
    02/14: x86/realmode: make %gs == 0 an invariant
    03/14: x86/boot: use <linux/compiler.h>
    04/14: x86/boot: modernize the segment structure for the header and setup
    05/14: x86/boot: call puts() from within die()
    06/14: x86/boot: add comment barriers for the different headers
    07/14: x86/boot: factor out the 16-bit startup code from header.S
    08/14: x86: make CONFIG_EFI_STUB unconditional
    09/14: x86/boot: make the relocatable kernel unconditional
    10/14: x86/boot: explicitly put the old command line pointer in header.S
    11/14: x86/boot: use __seg_fs and __seg_gs in the real-mode boot code
    12/14: x86/boot: tweak a20.c for better code generation
    13/14: x86/boot: simplify x86/boot/cmdline.c by using __seg_fs
    14/14: compiler-gcc: Remove obsolete RELOC_HIDE() macro (Uros Bizjak)

--- 
 arch/x86/Kconfig                    |  85 ++++---------------------
 arch/x86/boot/Makefile              |   4 +-
 arch/x86/boot/a20.c                 |  34 +++++-----
 arch/x86/boot/boot.h                | 116 ++++++++++------------------------
 arch/x86/boot/cmdline.c             |  79 ++++++++++++++++++-----
 arch/x86/boot/compressed/Makefile   |   2 -
 arch/x86/boot/compressed/cmdline.c  |  29 ---------
 arch/x86/boot/compressed/error.c    |   2 -
 arch/x86/boot/compressed/head_32.S  |   2 -
 arch/x86/boot/compressed/head_64.S  |   4 --
 arch/x86/boot/{ => compressed}/io.h |   0
 arch/x86/boot/compressed/misc.c     |   8 ---
 arch/x86/boot/compressed/misc.h     |   2 +-
 arch/x86/boot/compressed/tdx.c      |   2 +-
 arch/x86/boot/header.S              | 123 ++++++++----------------------------
 arch/x86/boot/main.c                |  43 ++++++-------
 arch/x86/boot/pm.c                  |   5 +-
 arch/x86/boot/regs.c                |   3 +-
 arch/x86/boot/setup.ld              |  26 ++++----
 arch/x86/boot/start16.S             | 108 +++++++++++++++++++++++++++++++
 arch/x86/boot/video-bios.c          |   5 +-
 arch/x86/boot/video-mode.c          |   5 +-
 arch/x86/boot/video.c               |   7 +-
 arch/x86/realmode/rm/wakemain.c     |   4 --
 arch/x86/realmode/rm/wakeup_asm.S   |  10 +--
 include/linux/compiler-gcc.h        |  25 --------
 include/linux/compiler.h            |   8 +++
 27 files changed, 316 insertions(+), 425 deletions(-)
Re: [PATCH v1 00/14] x86 boot code cleanups, batch 1
Posted by Uros Bizjak 2 weeks, 2 days ago
On Tue, Jan 20, 2026 at 8:54 PM H. Peter Anvin <hpa@zytor.com> wrote:

> This patchset also includes the removal of the gcc-specific version of
> the RELOC_HIDE() macro, by Uros Bizjak, as the other changes in this
> patchset makes that possible. Per Uros, this is holding back gcc
> development, so it seems pretty important.

Not that this issue is holding back GCC *development*, the historic
kludge unnecessarily suppresses optimizations that could be applied by
the compiler to produce better code.

Thanks,
Uros.