]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/expoline: Make modules use kernel expolines
authorVasily Gorbik <gor@linux.ibm.com>
Wed, 17 Jan 2024 10:50:49 +0000 (11:50 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 17 Apr 2024 11:38:03 +0000 (13:38 +0200)
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>
arch/s390/Kconfig
arch/s390/Makefile
arch/s390/include/asm/asm-prototypes.h
arch/s390/include/asm/nospec-branch.h
arch/s390/include/asm/nospec-insn.h
arch/s390/lib/Makefile
arch/s390/lib/expoline.S [moved from arch/s390/lib/expoline/expoline.S with 100% similarity]
arch/s390/lib/expoline/Makefile [deleted file]
scripts/mod/modpost.c

index df6b371ed2145fccd15eafaad81bf546a75ac9d8..a077ded1b9e699771ea8d1db3fe31c9f8561b43f 100644 (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))
index 2dbb2d2f22f99c265ba416176f49e3b9c12f5cf5..64821f54f1e025a436d53ea89eb05a67a1ade5d8 100644 (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
index 56096ae26f296b22a350592d6c354ea83e03a359..f662eb4b9246fb5fc556403e655643ef6ba071d4 100644 (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);
index 82725cf783c70cfcaf511931be6b26dfc4522303..b9c1f3cae84267d05c93f473414c31ce82157eb8 100644 (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 */
index 7a946c42ad13b8de2807d755a63a78ca292f10e6..cb15dd25bf219692f9e3a168d3786ac3d321ff49 100644 (file)
  */
        .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
index 90eac15ea62aaf22b2984e09c7ce4a2b3bc6f504..f43f897d3fc027ad2f5cbf52ba2abc343b6e31ea 100644 (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
diff --git a/arch/s390/lib/expoline/Makefile b/arch/s390/lib/expoline/Makefile
deleted file mode 100644 (file)
index 854631d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-obj-y += expoline.o
index 2f5b91da5afa9ea768caaf0c3e1d1e253fcdfc48..937294ff164fc8fc1ac3c1ed926ec5d1131a43ef 100644 (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;
 }