Skip to content

Commit 2ab9c93

Browse files
johnhubbardshuahkh
authored andcommitted
selftests/x86: build sysret_rip.c with clang
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 <[email protected]> Signed-off-by: John Hubbard <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 1158655 commit 2ab9c93

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

tools/testing/selftests/x86/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ $(eval $(call extra-files,ptrace_syscall_32,raw_syscall_helper_32.S))
115115
$(eval $(call extra-files,test_syscall_vdso_32,thunks_32.S))
116116
$(eval $(call extra-files,fsgsbase_restore_64,clang_helpers_64.S))
117117
$(eval $(call extra-files,fsgsbase_restore_32,clang_helpers_32.S))
118+
$(eval $(call extra-files,sysret_rip_64,clang_helpers_64.S))
118119

119120
# check_initial_reg_state is special: it needs a custom entry, and it
120121
# needs to be static so that its interpreter doesn't destroy its initial

tools/testing/selftests/x86/clang_helpers_64.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,20 @@ dereference_seg_base:
99
mov %gs:(0), %rax
1010
ret
1111

12+
.global test_page
13+
.global test_syscall_insn
14+
15+
.pushsection ".text", "ax"
16+
.balign 4096
17+
test_page: .globl test_page
18+
.fill 4094,1,0xcc
19+
20+
test_syscall_insn:
21+
syscall
22+
23+
.ifne . - test_page - 4096
24+
.error "test page is not one page long"
25+
.endif
26+
.popsection
27+
1228
.section .note.GNU-stack,"",%progbits

tools/testing/selftests/x86/sysret_rip.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,13 @@
2222
#include <sys/mman.h>
2323
#include <assert.h>
2424

25-
26-
asm (
27-
".pushsection \".text\", \"ax\"\n\t"
28-
".balign 4096\n\t"
29-
"test_page: .globl test_page\n\t"
30-
".fill 4094,1,0xcc\n\t"
31-
"test_syscall_insn:\n\t"
32-
"syscall\n\t"
33-
".ifne . - test_page - 4096\n\t"
34-
".error \"test page is not one page long\"\n\t"
35-
".endif\n\t"
36-
".popsection"
37-
);
38-
25+
/*
26+
* These items are in clang_helpers_64.S, in order to avoid clang inline asm
27+
* limitations:
28+
*/
29+
void test_syscall_ins(void);
3930
extern const char test_page[];
31+
4032
static void const *current_test_page_addr = test_page;
4133

4234
static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),

0 commit comments

Comments
 (0)