All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH] s390: always build relocatable kernel
Date: Mon, 31 Oct 2022 08:55:09 -0700	[thread overview]
Message-ID: <Y1/v3TwIT1yEFm+o@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20221030182202.2062705-1-hca@linux.ibm.com>

On Sun, Oct 30, 2022 at 07:22:02PM +0100, Heiko Carstens wrote:
> 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 c9305b6c1f52
> ("s390: fix nospec table alignments").
> 
> See https://github.com/ClangBuiltLinux/linux/issues/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: https://github.com/ClangBuiltLinux/linux/issues/1747
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/s390/Kconfig        | 6 +++---
>  arch/s390/Makefile       | 2 --
>  arch/s390/boot/Makefile  | 3 +--
>  arch/s390/boot/startup.c | 3 +--
>  4 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index 318fce77601d..de575af02ffe 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -568,8 +568,7 @@ config EXPOLINE_FULL
>  endchoice
>  
>  config RELOCATABLE
> -	bool "Build a relocatable kernel"
> -	default y
> +	def_bool y
>  	help
>  	  This builds a kernel image that retains relocation information
>  	  so it can be loaded at an arbitrary address.
> @@ -578,10 +577,11 @@ config RELOCATABLE
>  	  bootup process.
>  	  The relocations make the kernel image about 15% larger (compressed
>  	  10%), but are discarded at runtime.
> +	  Note: this option exists only for documentation purposes, please do
> +	  not remove it.
>  
>  config RANDOMIZE_BASE
>  	bool "Randomize the address of the kernel image (KASLR)"
> -	depends on RELOCATABLE
>  	default y
>  	help
>  	  In support of Kernel Address Space Layout Randomization (KASLR),
> diff --git a/arch/s390/Makefile b/arch/s390/Makefile
> index de6d8b2ea4d8..b3235ab0ace8 100644
> --- a/arch/s390/Makefile
> +++ b/arch/s390/Makefile
> @@ -14,10 +14,8 @@ KBUILD_AFLAGS_MODULE += -fPIC
>  KBUILD_CFLAGS_MODULE += -fPIC
>  KBUILD_AFLAGS	+= -m64
>  KBUILD_CFLAGS	+= -m64
> -ifeq ($(CONFIG_RELOCATABLE),y)
>  KBUILD_CFLAGS	+= -fPIE
>  LDFLAGS_vmlinux	:= -pie
> -endif
>  aflags_dwarf	:= -Wa,-gdwarf-2
>  KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
>  ifndef CONFIG_AS_IS_LLVM
> diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
> index 883357a211a3..d52c3e2e16bc 100644
> --- a/arch/s390/boot/Makefile
> +++ b/arch/s390/boot/Makefile
> @@ -37,9 +37,8 @@ CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
>  
>  obj-y	:= head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o
>  obj-y	+= string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
> -obj-y	+= version.o pgm_check_info.o ctype.o ipl_data.o
> +obj-y	+= version.o pgm_check_info.o ctype.o ipl_data.o machine_kexec_reloc.o
>  obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE))	+= uv.o
> -obj-$(CONFIG_RELOCATABLE)	+= machine_kexec_reloc.o
>  obj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr.o
>  obj-y	+= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
>  obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
> diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c
> index 6e7f01ca53e6..47ca3264c023 100644
> --- a/arch/s390/boot/startup.c
> +++ b/arch/s390/boot/startup.c
> @@ -291,8 +291,7 @@ void startup_kernel(void)
>  
>  	clear_bss_section();
>  	copy_bootdata();
> -	if (IS_ENABLED(CONFIG_RELOCATABLE))
> -		handle_relocs(__kaslr_offset);
> +	handle_relocs(__kaslr_offset);
>  
>  	if (__kaslr_offset) {
>  		/*
> -- 
> 2.34.1
> 

      reply	other threads:[~2022-10-31 15:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 18:22 [PATCH] s390: always build relocatable kernel Heiko Carstens
2022-10-31 15:55 ` Nathan Chancellor [this message]

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=Y1/v3TwIT1yEFm+o@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.