s390/expoline: Make modules use kernel expolines

Currently, kernel modules contain their own set of expoline thunks. In
the case of EXPOLINE_EXTERN, this involves postlinking of precompiled
expoline.o. expoline.o is also necessary for out-of-source tree module
builds.

Now that the kernel modules area is less than 4 GB away from
kernel expoline thunks, make modules use kernel expolines. Also make
EXPOLINE_EXTERN the default if the compiler supports it. This simplifies
build and aligns with the approach adopted by other architectures.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
This commit is contained in:
Vasily Gorbik 2024-01-17 11:50:49 +01:00 committed by Alexander Gordeev
parent ea84f14d2a
commit ba05b39d54
9 changed files with 30 additions and 22 deletions

View File

@ -555,7 +555,7 @@ config EXPOLINE
If unsure, say N.
config EXPOLINE_EXTERN
def_bool n
def_bool y if EXPOLINE
depends on EXPOLINE
depends on CC_IS_GCC && GCC_VERSION >= 110200
depends on $(success,$(srctree)/arch/s390/tools/gcc-thunk-extern.sh $(CC))

View File

@ -88,7 +88,6 @@ endif
ifdef CONFIG_EXPOLINE
ifdef CONFIG_EXPOLINE_EXTERN
KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o
CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
else
@ -167,11 +166,6 @@ vdso_prepare: prepare0
vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg
vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg
ifdef CONFIG_EXPOLINE_EXTERN
modules_prepare: expoline_prepare
expoline_prepare: scripts
$(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o
endif
endif
# Don't use tabs in echo arguments

View File

@ -4,6 +4,7 @@
#include <linux/kvm_host.h>
#include <linux/ftrace.h>
#include <asm/fpu.h>
#include <asm/nospec-branch.h>
#include <asm-generic/asm-prototypes.h>
__int128_t __ashlti3(__int128_t a, int b);

View File

@ -17,6 +17,26 @@ static inline bool nospec_uses_trampoline(void)
return __is_defined(CC_USING_EXPOLINE) && !nospec_disable;
}
#ifdef CONFIG_EXPOLINE_EXTERN
void __s390_indirect_jump_r1(void);
void __s390_indirect_jump_r2(void);
void __s390_indirect_jump_r3(void);
void __s390_indirect_jump_r4(void);
void __s390_indirect_jump_r5(void);
void __s390_indirect_jump_r6(void);
void __s390_indirect_jump_r7(void);
void __s390_indirect_jump_r8(void);
void __s390_indirect_jump_r9(void);
void __s390_indirect_jump_r10(void);
void __s390_indirect_jump_r11(void);
void __s390_indirect_jump_r12(void);
void __s390_indirect_jump_r13(void);
void __s390_indirect_jump_r14(void);
void __s390_indirect_jump_r15(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* _ASM_S390_EXPOLINE_H */

View File

@ -16,24 +16,25 @@
*/
.macro __THUNK_PROLOG_NAME name
#ifdef CONFIG_EXPOLINE_EXTERN
.pushsection .text,"ax",@progbits
__ALIGN
SYM_CODE_START(\name)
#else
.pushsection .text.\name,"axG",@progbits,\name,comdat
#endif
.globl \name
.hidden \name
.type \name,@function
\name:
CFI_STARTPROC
#endif
.endm
.macro __THUNK_EPILOG_NAME name
CFI_ENDPROC
#ifdef CONFIG_EXPOLINE_EXTERN
.size \name, .-\name
#endif
SYM_CODE_END(\name)
EXPORT_SYMBOL(\name)
#else
CFI_ENDPROC
.popsection
#endif
.endm
.macro __THUNK_PROLOG_BR r1

View File

@ -23,4 +23,4 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o
lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline/
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o

View File

@ -1,3 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += expoline.o

View File

@ -601,11 +601,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
strstarts(symname, "_savevr_") ||
strcmp(symname, ".TOC.") == 0)
return 1;
if (info->hdr->e_machine == EM_S390)
/* Expoline thunks are linked on all kernel modules during final link of .ko */
if (strstarts(symname, "__s390_indirect_jump_r"))
return 1;
/* Do not ignore this symbol */
return 0;
}