From: Uros Bizjak <ubizjak@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH v2 0/2] Remove obsolete RELOC_HIDE() macro from compiler-gcc.h
Date: Fri, 4 Sep 2026 10:25:21 +0200 [thread overview]
Message-ID: <20260904082741.578048-1-ubizjak@gmail.com> (raw)
The GCC specific macro was historically used to workaround very old
compiler bugs (including pre-4.1 ppc64 GCC). These compilers are long
obsolete.
The generic RELOC_HIDE() macro should be used instead.
The removal causes GCC to detect several reads from addresses below 4kB in
the boot and realmode code. GCC treats absolute addresses smaller than the
min-pagesize param (which defaults to 4kB) in the generic address space
as presumed results of pointer arithmetics from NULL. For example, the
following code, when compiled with -O2 -Warray-bounds (included in -Wall):
int foo (void) { return *(int *)0x123; }
will emit a rather cryptic warning:
warning: array subscript 0 is outside array bounds of ‘int[0]’ [-Warray-bounds=]
1 | int foo (void) { return *(int *)0x123; }
| ^~~~~~~~~~~~~
cc1: note: source object is likely at address zero
The early boot environment does not guarantee a minimum page size, so
explicitly setting the minimum page size to zero by adding
--param=min-pagesize=0 to the compiler flags when building the x86
boot and realmode code with GCC inhibits warnings for addresses below 4kB.
A long-term solution is to replace open-coded inline assembly used for
FS/GS memory accesses in arch/x86/boot/ with segment-qualified pointer
dereferences [1]. The compiler allows pointer arithmetic from NULL in
__seg_fs and __seg_gs named address spaces so the --param=min-pagesize=0
parameter is no longer needed.
The v1 patch is available at [2]. v2 leaves the conversion to the __seg_fs
and __seg_gs named address space to follow-up x86 boot code
cleanup patches [1].
[1] https://lore.kernel.org/lkml/20260120195407.1163051-1-hpa@zytor.com/
[2] https://lore.kernel.org/lkml/20251223202038.91200-1-ubizjak@gmail.com/
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Uros Bizjak (2):
x86/boot: Disable GCC min-pagesize assumption in boot code
compiler-gcc: Remove obsolete RELOC_HIDE() macro
arch/x86/boot/Makefile | 3 +++
arch/x86/realmode/rm/Makefile | 3 +++
include/linux/compiler-gcc.h | 25 -------------------------
include/linux/compiler.h | 8 ++++++++
4 files changed, 14 insertions(+), 25 deletions(-)
--
2.55.0
next reply other threads:[~2026-09-04 8:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 8:25 Uros Bizjak [this message]
2026-09-04 8:25 ` [PATCH v2 1/2] x86/boot: Disable GCC min-pagesize assumption in boot code Uros Bizjak
2026-09-04 13:17 ` H. Peter Anvin
2026-09-04 8:25 ` [PATCH v2 2/2] compiler-gcc: Remove obsolete RELOC_HIDE() macro Uros Bizjak
2026-09-04 15:16 ` Linus Torvalds
2026-09-04 15:29 ` Uros Bizjak
2026-09-04 15:39 ` Linus Torvalds
2026-09-05 9:42 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904082741.578048-1-ubizjak@gmail.com \
--to=ubizjak@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®