]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/x86: build sysret_rip.c with clang
authorJohn Hubbard <jhubbard@nvidia.com>
Thu, 4 Jul 2024 07:24:28 +0000 (00:24 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 11 Jul 2024 17:23:55 +0000 (11:23 -0600)
When building with clang, via:

    make LLVM=1 -C tools/testing/selftests

...the build fails because clang's inline asm doesn't support all of the
features that are used in the asm() snippet in sysret_rip.c.

Fix this by moving the asm code into the clang_helpers_64.S file, where
it can be built with the assembler's full set of features.

Acked-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/x86/Makefile
tools/testing/selftests/x86/clang_helpers_64.S
tools/testing/selftests/x86/sysret_rip.c

index 99bc2ef84f5a67e49efa82d515cec91a339786c3..d0bb32bd55385044a65d151e00daebca77fc7535 100644 (file)
@@ -115,6 +115,7 @@ $(eval $(call extra-files,ptrace_syscall_32,raw_syscall_helper_32.S))
 $(eval $(call extra-files,test_syscall_vdso_32,thunks_32.S))
 $(eval $(call extra-files,fsgsbase_restore_64,clang_helpers_64.S))
 $(eval $(call extra-files,fsgsbase_restore_32,clang_helpers_32.S))
+$(eval $(call extra-files,sysret_rip_64,clang_helpers_64.S))
 
 # check_initial_reg_state is special: it needs a custom entry, and it
 # needs to be static so that its interpreter doesn't destroy its initial
index 0d81c71cad971ef6d5402a78262b6bf392fc442b..185a69dbf39cced1dea6f70109f73541b7b1b904 100644 (file)
@@ -9,4 +9,20 @@ dereference_seg_base:
        mov %gs:(0), %rax
        ret
 
+.global test_page
+.global test_syscall_insn
+
+.pushsection ".text", "ax"
+.balign 4096
+test_page: .globl test_page
+       .fill 4094,1,0xcc
+
+test_syscall_insn:
+       syscall
+
+.ifne . - test_page - 4096
+       .error "test page is not one page long"
+.endif
+.popsection
+
 .section .note.GNU-stack,"",%progbits
index 84d74be1d90207abc4e73804b0e8c394d5cc4805..b30de9aaa6d41dfad194e55dd97c6458627a4229 100644 (file)
 #include <sys/mman.h>
 #include <assert.h>
 
-
-asm (
-       ".pushsection \".text\", \"ax\"\n\t"
-       ".balign 4096\n\t"
-       "test_page: .globl test_page\n\t"
-       ".fill 4094,1,0xcc\n\t"
-       "test_syscall_insn:\n\t"
-       "syscall\n\t"
-       ".ifne . - test_page - 4096\n\t"
-       ".error \"test page is not one page long\"\n\t"
-       ".endif\n\t"
-       ".popsection"
-    );
-
+/*
+ * These items are in clang_helpers_64.S, in order to avoid clang inline asm
+ * limitations:
+ */
+void test_syscall_ins(void);
 extern const char test_page[];
+
 static void const *current_test_page_addr = test_page;
 
 static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),