Remove obsolete RELOC_HIDE() macro from compiler-gcc.h
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 6 repliesIn review
- v13 patches 0 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | x86/boot: Disable GCC min-pagesize assumption in boot codearch/ arch/ | +6 | 2 replies | |
| 2/2 | compiler-gcc: Remove obsolete RELOC_HIDE() macroinclude/ include/ | +8 | 4 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | H. Peter Anvin |
|---|---|
| 1/2 | A-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] Remove obsolete RELOC_HIDE() macro from compiler-gcc.h
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/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
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(-)
Signature · 1 line
2.55.0