Skip to content

Commit 80ddf5c

Browse files
hcahcaAlexander Gordeev
authored and
Alexander Gordeev
committed
s390: always build relocatable kernel
Nathan Chancellor reported several link errors on s390 with CONFIG_RELOCATABLE disabled, after binutils commit 906f69cf65da ("IBM zSystems: Issue error for *DBL relocs on misaligned symbols"). The binutils commit reveals potential miscompiles that might have happened already before with linker script defined symbols at odd addresses. A similar bug was recently fixed in the kernel with commit c9305b6 ("s390: fix nospec table alignments"). See ClangBuiltLinux#1747 for an analysis from Ulich Weigand. Therefore always build a relocatable kernel to avoid this problem. There is hardly any use-case for non-relocatable kernels, so this shouldn't be controversial. Link: ClangBuiltLinux#1747 Signed-off-by: Heiko Carstens <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 9afea69 commit 80ddf5c

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

arch/s390/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ config EXPOLINE_FULL
568568
endchoice
569569

570570
config RELOCATABLE
571-
bool "Build a relocatable kernel"
572-
default y
571+
def_bool y
573572
help
574573
This builds a kernel image that retains relocation information
575574
so it can be loaded at an arbitrary address.
@@ -578,10 +577,11 @@ config RELOCATABLE
578577
bootup process.
579578
The relocations make the kernel image about 15% larger (compressed
580579
10%), but are discarded at runtime.
580+
Note: this option exists only for documentation purposes, please do
581+
not remove it.
581582

582583
config RANDOMIZE_BASE
583584
bool "Randomize the address of the kernel image (KASLR)"
584-
depends on RELOCATABLE
585585
default y
586586
help
587587
In support of Kernel Address Space Layout Randomization (KASLR),

arch/s390/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ KBUILD_AFLAGS_MODULE += -fPIC
1414
KBUILD_CFLAGS_MODULE += -fPIC
1515
KBUILD_AFLAGS += -m64
1616
KBUILD_CFLAGS += -m64
17-
ifeq ($(CONFIG_RELOCATABLE),y)
1817
KBUILD_CFLAGS += -fPIE
1918
LDFLAGS_vmlinux := -pie
20-
endif
2119
aflags_dwarf := -Wa,-gdwarf-2
2220
KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
2321
ifndef CONFIG_AS_IS_LLVM

arch/s390/boot/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
3737

3838
obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
3939
obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
40-
obj-y += version.o pgm_check_info.o ctype.o ipl_data.o
40+
obj-y += version.o pgm_check_info.o ctype.o ipl_data.o machine_kexec_reloc.o
4141
obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
42-
obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
4342
obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
4443
obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
4544
obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o

arch/s390/boot/startup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ void startup_kernel(void)
291291

292292
clear_bss_section();
293293
copy_bootdata();
294-
if (IS_ENABLED(CONFIG_RELOCATABLE))
295-
handle_relocs(__kaslr_offset);
294+
handle_relocs(__kaslr_offset);
296295

297296
if (__kaslr_offset) {
298297
/*

0 commit comments

Comments
 (0)