Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vasily Gorbik and committed by
Alexander Gordeev
ba05b39d ea84f14d

+30 -22
+1 -1
arch/s390/Kconfig
··· 555 555 If unsure, say N. 556 556 557 557 config EXPOLINE_EXTERN 558 - def_bool n 558 + def_bool y if EXPOLINE 559 559 depends on EXPOLINE 560 560 depends on CC_IS_GCC && GCC_VERSION >= 110200 561 561 depends on $(success,$(srctree)/arch/s390/tools/gcc-thunk-extern.sh $(CC))
-6
arch/s390/Makefile
··· 88 88 89 89 ifdef CONFIG_EXPOLINE 90 90 ifdef CONFIG_EXPOLINE_EXTERN 91 - KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o 92 91 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern 93 92 CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern 94 93 else ··· 166 167 vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg 167 168 vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg 168 169 169 - ifdef CONFIG_EXPOLINE_EXTERN 170 - modules_prepare: expoline_prepare 171 - expoline_prepare: scripts 172 - $(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o 173 - endif 174 170 endif 175 171 176 172 # Don't use tabs in echo arguments
+1
arch/s390/include/asm/asm-prototypes.h
··· 4 4 #include <linux/kvm_host.h> 5 5 #include <linux/ftrace.h> 6 6 #include <asm/fpu.h> 7 + #include <asm/nospec-branch.h> 7 8 #include <asm-generic/asm-prototypes.h> 8 9 9 10 __int128_t __ashlti3(__int128_t a, int b);
+20
arch/s390/include/asm/nospec-branch.h
··· 17 17 return __is_defined(CC_USING_EXPOLINE) && !nospec_disable; 18 18 } 19 19 20 + #ifdef CONFIG_EXPOLINE_EXTERN 21 + 22 + void __s390_indirect_jump_r1(void); 23 + void __s390_indirect_jump_r2(void); 24 + void __s390_indirect_jump_r3(void); 25 + void __s390_indirect_jump_r4(void); 26 + void __s390_indirect_jump_r5(void); 27 + void __s390_indirect_jump_r6(void); 28 + void __s390_indirect_jump_r7(void); 29 + void __s390_indirect_jump_r8(void); 30 + void __s390_indirect_jump_r9(void); 31 + void __s390_indirect_jump_r10(void); 32 + void __s390_indirect_jump_r11(void); 33 + void __s390_indirect_jump_r12(void); 34 + void __s390_indirect_jump_r13(void); 35 + void __s390_indirect_jump_r14(void); 36 + void __s390_indirect_jump_r15(void); 37 + 38 + #endif 39 + 20 40 #endif /* __ASSEMBLY__ */ 21 41 22 42 #endif /* _ASM_S390_EXPOLINE_H */
+7 -6
arch/s390/include/asm/nospec-insn.h
··· 16 16 */ 17 17 .macro __THUNK_PROLOG_NAME name 18 18 #ifdef CONFIG_EXPOLINE_EXTERN 19 - .pushsection .text,"ax",@progbits 20 - __ALIGN 19 + SYM_CODE_START(\name) 21 20 #else 22 21 .pushsection .text.\name,"axG",@progbits,\name,comdat 23 - #endif 24 22 .globl \name 25 23 .hidden \name 26 24 .type \name,@function 27 25 \name: 28 26 CFI_STARTPROC 27 + #endif 29 28 .endm 30 29 31 30 .macro __THUNK_EPILOG_NAME name 32 - CFI_ENDPROC 33 31 #ifdef CONFIG_EXPOLINE_EXTERN 34 - .size \name, .-\name 35 - #endif 32 + SYM_CODE_END(\name) 33 + EXPORT_SYMBOL(\name) 34 + #else 35 + CFI_ENDPROC 36 36 .popsection 37 + #endif 37 38 .endm 38 39 39 40 .macro __THUNK_PROLOG_BR r1
+1 -1
arch/s390/lib/Makefile
··· 23 23 24 24 lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o 25 25 26 - obj-$(CONFIG_EXPOLINE_EXTERN) += expoline/ 26 + obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
-3
arch/s390/lib/expoline/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - obj-y += expoline.o
arch/s390/lib/expoline/expoline.S arch/s390/lib/expoline.S
-5
scripts/mod/modpost.c
··· 601 601 strstarts(symname, "_savevr_") || 602 602 strcmp(symname, ".TOC.") == 0) 603 603 return 1; 604 - 605 - if (info->hdr->e_machine == EM_S390) 606 - /* Expoline thunks are linked on all kernel modules during final link of .ko */ 607 - if (strstarts(symname, "__s390_indirect_jump_r")) 608 - return 1; 609 604 /* Do not ignore this symbol */ 610 605 return 0; 611 606 }