Skip to content

Commit ba05b39

Browse files
Vasily GorbikAlexander Gordeev
authored andcommitted
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>
1 parent ea84f14 commit ba05b39

9 files changed

Lines changed: 30 additions & 22 deletions

File tree

arch/s390/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ config EXPOLINE
555555
If unsure, say N.
556556

557557
config EXPOLINE_EXTERN
558-
def_bool n
558+
def_bool y if EXPOLINE
559559
depends on EXPOLINE
560560
depends on CC_IS_GCC && GCC_VERSION >= 110200
561561
depends on $(success,$(srctree)/arch/s390/tools/gcc-thunk-extern.sh $(CC))

arch/s390/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ endif
8888

8989
ifdef CONFIG_EXPOLINE
9090
ifdef CONFIG_EXPOLINE_EXTERN
91-
KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o
9291
CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
9392
CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
9493
else
@@ -167,11 +166,6 @@ vdso_prepare: prepare0
167166
vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg
168167
vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg
169168

170-
ifdef CONFIG_EXPOLINE_EXTERN
171-
modules_prepare: expoline_prepare
172-
expoline_prepare: scripts
173-
$(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o
174-
endif
175169
endif
176170

177171
# Don't use tabs in echo arguments

arch/s390/include/asm/asm-prototypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/kvm_host.h>
55
#include <linux/ftrace.h>
66
#include <asm/fpu.h>
7+
#include <asm/nospec-branch.h>
78
#include <asm-generic/asm-prototypes.h>
89

910
__int128_t __ashlti3(__int128_t a, int b);

arch/s390/include/asm/nospec-branch.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ static inline bool nospec_uses_trampoline(void)
1717
return __is_defined(CC_USING_EXPOLINE) && !nospec_disable;
1818
}
1919

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+
2040
#endif /* __ASSEMBLY__ */
2141

2242
#endif /* _ASM_S390_EXPOLINE_H */

arch/s390/include/asm/nospec-insn.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,25 @@
1616
*/
1717
.macro __THUNK_PROLOG_NAME name
1818
#ifdef CONFIG_EXPOLINE_EXTERN
19-
.pushsection .text,"ax",@progbits
20-
__ALIGN
19+
SYM_CODE_START(\name)
2120
#else
2221
.pushsection .text.\name,"axG",@progbits,\name,comdat
23-
#endif
2422
.globl \name
2523
.hidden \name
2624
.type \name,@function
2725
\name:
2826
CFI_STARTPROC
27+
#endif
2928
.endm
3029

3130
.macro __THUNK_EPILOG_NAME name
32-
CFI_ENDPROC
3331
#ifdef CONFIG_EXPOLINE_EXTERN
34-
.size \name, .-\name
35-
#endif
32+
SYM_CODE_END(\name)
33+
EXPORT_SYMBOL(\name)
34+
#else
35+
CFI_ENDPROC
3636
.popsection
37+
#endif
3738
.endm
3839

3940
.macro __THUNK_PROLOG_BR r1

arch/s390/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o
2323

2424
lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
2525

26-
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline/
26+
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o

arch/s390/lib/expoline/Makefile

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/mod/modpost.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
601601
strstarts(symname, "_savevr_") ||
602602
strcmp(symname, ".TOC.") == 0)
603603
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;
609604
/* Do not ignore this symbol */
610605
return 0;
611606
}

0 commit comments

Comments
 (0)