Commit ba05b39d authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Alexander Gordeev

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: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent ea84f14d
...@@ -555,7 +555,7 @@ config EXPOLINE ...@@ -555,7 +555,7 @@ config EXPOLINE
If unsure, say N. If unsure, say N.
config EXPOLINE_EXTERN config EXPOLINE_EXTERN
def_bool n def_bool y if EXPOLINE
depends on EXPOLINE depends on EXPOLINE
depends on CC_IS_GCC && GCC_VERSION >= 110200 depends on CC_IS_GCC && GCC_VERSION >= 110200
depends on $(success,$(srctree)/arch/s390/tools/gcc-thunk-extern.sh $(CC)) depends on $(success,$(srctree)/arch/s390/tools/gcc-thunk-extern.sh $(CC))
......
...@@ -88,7 +88,6 @@ endif ...@@ -88,7 +88,6 @@ endif
ifdef CONFIG_EXPOLINE ifdef CONFIG_EXPOLINE
ifdef CONFIG_EXPOLINE_EXTERN ifdef CONFIG_EXPOLINE_EXTERN
KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o
CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
else else
...@@ -167,11 +166,6 @@ vdso_prepare: prepare0 ...@@ -167,11 +166,6 @@ vdso_prepare: prepare0
vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg
vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.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 endif
# Don't use tabs in echo arguments # Don't use tabs in echo arguments
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/kvm_host.h> #include <linux/kvm_host.h>
#include <linux/ftrace.h> #include <linux/ftrace.h>
#include <asm/fpu.h> #include <asm/fpu.h>
#include <asm/nospec-branch.h>
#include <asm-generic/asm-prototypes.h> #include <asm-generic/asm-prototypes.h>
__int128_t __ashlti3(__int128_t a, int b); __int128_t __ashlti3(__int128_t a, int b);
......
...@@ -17,6 +17,26 @@ static inline bool nospec_uses_trampoline(void) ...@@ -17,6 +17,26 @@ static inline bool nospec_uses_trampoline(void)
return __is_defined(CC_USING_EXPOLINE) && !nospec_disable; 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 /* __ASSEMBLY__ */
#endif /* _ASM_S390_EXPOLINE_H */ #endif /* _ASM_S390_EXPOLINE_H */
...@@ -16,24 +16,25 @@ ...@@ -16,24 +16,25 @@
*/ */
.macro __THUNK_PROLOG_NAME name .macro __THUNK_PROLOG_NAME name
#ifdef CONFIG_EXPOLINE_EXTERN #ifdef CONFIG_EXPOLINE_EXTERN
.pushsection .text,"ax",@progbits SYM_CODE_START(\name)
__ALIGN
#else #else
.pushsection .text.\name,"axG",@progbits,\name,comdat .pushsection .text.\name,"axG",@progbits,\name,comdat
#endif
.globl \name .globl \name
.hidden \name .hidden \name
.type \name,@function .type \name,@function
\name: \name:
CFI_STARTPROC CFI_STARTPROC
#endif
.endm .endm
.macro __THUNK_EPILOG_NAME name .macro __THUNK_EPILOG_NAME name
CFI_ENDPROC
#ifdef CONFIG_EXPOLINE_EXTERN #ifdef CONFIG_EXPOLINE_EXTERN
.size \name, .-\name SYM_CODE_END(\name)
#endif EXPORT_SYMBOL(\name)
#else
CFI_ENDPROC
.popsection .popsection
#endif
.endm .endm
.macro __THUNK_PROLOG_BR r1 .macro __THUNK_PROLOG_BR r1
......
...@@ -23,4 +23,4 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o ...@@ -23,4 +23,4 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o
lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline/ obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
# SPDX-License-Identifier: GPL-2.0
obj-y += expoline.o
...@@ -601,11 +601,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) ...@@ -601,11 +601,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
strstarts(symname, "_savevr_") || strstarts(symname, "_savevr_") ||
strcmp(symname, ".TOC.") == 0) strcmp(symname, ".TOC.") == 0)
return 1; 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 */ /* Do not ignore this symbol */
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment