diff options
author | Ingo Molnar <mingo@kernel.org> | 2018-03-27 02:43:39 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-03-27 02:43:39 -0400 |
commit | 0bc91d4ba77156ae9217d25ed7c434540f950d05 (patch) | |
tree | 949c1acf27b106184d8842586740fbbcc9c9ea62 /tools | |
parent | 565977a3d929fc4427769117a8ac976ec16776d5 (diff) | |
parent | 3eb2ce825ea1ad89d20f7a3b5780df850e4be274 (diff) |
Merge tag 'v4.16-rc7' into x86/mm, to fix up conflict
Conflicts:
arch/x86/mm/init_64.c
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
6 files changed, 224 insertions, 6 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index 0b482c0070e0..465995281dcd 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c | |||
@@ -55,6 +55,10 @@ | |||
55 | 55 | ||
56 | #include "main.h" | 56 | #include "main.h" |
57 | 57 | ||
58 | #ifndef BPF_FS_MAGIC | ||
59 | #define BPF_FS_MAGIC 0xcafe4a11 | ||
60 | #endif | ||
61 | |||
58 | void p_err(const char *fmt, ...) | 62 | void p_err(const char *fmt, ...) |
59 | { | 63 | { |
60 | va_list ap; | 64 | va_list ap; |
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc new file mode 100644 index 000000000000..5ba73035e1d9 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | |||
@@ -0,0 +1,46 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe event string type argument | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | echo 0 > events/enable | ||
8 | echo > kprobe_events | ||
9 | |||
10 | case `uname -m` in | ||
11 | x86_64) | ||
12 | ARG2=%si | ||
13 | OFFS=8 | ||
14 | ;; | ||
15 | i[3456]86) | ||
16 | ARG2=%cx | ||
17 | OFFS=4 | ||
18 | ;; | ||
19 | aarch64) | ||
20 | ARG2=%x1 | ||
21 | OFFS=8 | ||
22 | ;; | ||
23 | arm*) | ||
24 | ARG2=%r1 | ||
25 | OFFS=4 | ||
26 | ;; | ||
27 | *) | ||
28 | echo "Please implement other architecture here" | ||
29 | exit_untested | ||
30 | esac | ||
31 | |||
32 | : "Test get argument (1)" | ||
33 | echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string" > kprobe_events | ||
34 | echo 1 > events/kprobes/testprobe/enable | ||
35 | ! echo test >> kprobe_events | ||
36 | tail -n 1 trace | grep -qe "testprobe.* arg1=\"test\"" | ||
37 | |||
38 | echo 0 > events/kprobes/testprobe/enable | ||
39 | : "Test get argument (2)" | ||
40 | echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string arg2=+0(+${OFFS}(${ARG2})):string" > kprobe_events | ||
41 | echo 1 > events/kprobes/testprobe/enable | ||
42 | ! echo test1 test2 >> kprobe_events | ||
43 | tail -n 1 trace | grep -qe "testprobe.* arg1=\"test1\" arg2=\"test2\"" | ||
44 | |||
45 | echo 0 > events/enable | ||
46 | echo > kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc new file mode 100644 index 000000000000..231bcd2c4eb5 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc | |||
@@ -0,0 +1,97 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe event argument syntax | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue | ||
8 | |||
9 | echo 0 > events/enable | ||
10 | echo > kprobe_events | ||
11 | |||
12 | PROBEFUNC="vfs_read" | ||
13 | GOODREG= | ||
14 | BADREG= | ||
15 | GOODSYM="_sdata" | ||
16 | if ! grep -qw ${GOODSYM} /proc/kallsyms ; then | ||
17 | GOODSYM=$PROBEFUNC | ||
18 | fi | ||
19 | BADSYM="deaqswdefr" | ||
20 | SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "` | ||
21 | GOODTYPE="x16" | ||
22 | BADTYPE="y16" | ||
23 | |||
24 | case `uname -m` in | ||
25 | x86_64|i[3456]86) | ||
26 | GOODREG=%ax | ||
27 | BADREG=%ex | ||
28 | ;; | ||
29 | aarch64) | ||
30 | GOODREG=%x0 | ||
31 | BADREG=%ax | ||
32 | ;; | ||
33 | arm*) | ||
34 | GOODREG=%r0 | ||
35 | BADREG=%ax | ||
36 | ;; | ||
37 | esac | ||
38 | |||
39 | test_goodarg() # Good-args | ||
40 | { | ||
41 | while [ "$1" ]; do | ||
42 | echo "p ${PROBEFUNC} $1" > kprobe_events | ||
43 | shift 1 | ||
44 | done; | ||
45 | } | ||
46 | |||
47 | test_badarg() # Bad-args | ||
48 | { | ||
49 | while [ "$1" ]; do | ||
50 | ! echo "p ${PROBEFUNC} $1" > kprobe_events | ||
51 | shift 1 | ||
52 | done; | ||
53 | } | ||
54 | |||
55 | echo > kprobe_events | ||
56 | |||
57 | : "Register access" | ||
58 | test_goodarg ${GOODREG} | ||
59 | test_badarg ${BADREG} | ||
60 | |||
61 | : "Symbol access" | ||
62 | test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10" | ||
63 | test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \ | ||
64 | "@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10" | ||
65 | |||
66 | : "Stack access" | ||
67 | test_goodarg "\$stack" "\$stack0" "\$stack1" | ||
68 | test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" | ||
69 | |||
70 | : "Retval access" | ||
71 | echo "r ${PROBEFUNC} \$retval" > kprobe_events | ||
72 | ! echo "p ${PROBEFUNC} \$retval" > kprobe_events | ||
73 | |||
74 | : "Comm access" | ||
75 | test_goodarg "\$comm" | ||
76 | |||
77 | : "Indirect memory access" | ||
78 | test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ | ||
79 | "+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))" | ||
80 | test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \ | ||
81 | "+10(\$comm)" "+0(${GOODREG})+10" | ||
82 | |||
83 | : "Name assignment" | ||
84 | test_goodarg "varname=${GOODREG}" | ||
85 | test_badarg "varname=varname2=${GOODREG}" | ||
86 | |||
87 | : "Type syntax" | ||
88 | test_goodarg "${GOODREG}:${GOODTYPE}" | ||
89 | test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ | ||
90 | "${GOODTYPE}:${GOODREG}" | ||
91 | |||
92 | : "Combination check" | ||
93 | |||
94 | test_goodarg "\$comm:string" "+0(\$stack):string" | ||
95 | test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" | ||
96 | |||
97 | echo > kprobe_events | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc new file mode 100644 index 000000000000..4fda01a08da4 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/bin/sh | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | # description: Kprobe events - probe points | ||
4 | |||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
6 | |||
7 | TARGET_FUNC=create_trace_kprobe | ||
8 | |||
9 | dec_addr() { # hexaddr | ||
10 | printf "%d" "0x"`echo $1 | tail -c 8` | ||
11 | } | ||
12 | |||
13 | set_offs() { # prev target next | ||
14 | A1=`dec_addr $1` | ||
15 | A2=`dec_addr $2` | ||
16 | A3=`dec_addr $3` | ||
17 | TARGET="0x$2" # an address | ||
18 | PREV=`expr $A1 - $A2` # offset to previous symbol | ||
19 | NEXT=+`expr $A3 - $A2` # offset to next symbol | ||
20 | OVERFLOW=+`printf "0x%x" ${PREV}` # overflow offset to previous symbol | ||
21 | } | ||
22 | |||
23 | # We have to decode symbol addresses to get correct offsets. | ||
24 | # If the offset is not an instruction boundary, it cause -EILSEQ. | ||
25 | set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs` | ||
26 | |||
27 | UINT_TEST=no | ||
28 | # printf "%x" -1 returns (unsigned long)-1. | ||
29 | if [ `printf "%x" -1 | wc -c` != 9 ]; then | ||
30 | UINT_TEST=yes | ||
31 | fi | ||
32 | |||
33 | echo 0 > events/enable | ||
34 | echo > kprobe_events | ||
35 | echo "p:testprobe ${TARGET_FUNC}" > kprobe_events | ||
36 | echo "p:testprobe ${TARGET}" > kprobe_events | ||
37 | echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events | ||
38 | ! echo "p:testprobe ${TARGET_FUNC}${PREV}" > kprobe_events | ||
39 | if [ "${UINT_TEST}" = yes ]; then | ||
40 | ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events | ||
41 | fi | ||
42 | echo > kprobe_events | ||
43 | clear_trace | ||
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c index 361466a2eaef..ade443a88421 100644 --- a/tools/testing/selftests/x86/entry_from_vm86.c +++ b/tools/testing/selftests/x86/entry_from_vm86.c | |||
@@ -95,6 +95,10 @@ asm ( | |||
95 | "int3\n\t" | 95 | "int3\n\t" |
96 | "vmcode_int80:\n\t" | 96 | "vmcode_int80:\n\t" |
97 | "int $0x80\n\t" | 97 | "int $0x80\n\t" |
98 | "vmcode_popf_hlt:\n\t" | ||
99 | "push %ax\n\t" | ||
100 | "popf\n\t" | ||
101 | "hlt\n\t" | ||
98 | "vmcode_umip:\n\t" | 102 | "vmcode_umip:\n\t" |
99 | /* addressing via displacements */ | 103 | /* addressing via displacements */ |
100 | "smsw (2052)\n\t" | 104 | "smsw (2052)\n\t" |
@@ -124,8 +128,8 @@ asm ( | |||
124 | 128 | ||
125 | extern unsigned char vmcode[], end_vmcode[]; | 129 | extern unsigned char vmcode[], end_vmcode[]; |
126 | extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[], | 130 | extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[], |
127 | vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_umip[], | 131 | vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_popf_hlt[], |
128 | vmcode_umip_str[], vmcode_umip_sldt[]; | 132 | vmcode_umip[], vmcode_umip_str[], vmcode_umip_sldt[]; |
129 | 133 | ||
130 | /* Returns false if the test was skipped. */ | 134 | /* Returns false if the test was skipped. */ |
131 | static bool do_test(struct vm86plus_struct *v86, unsigned long eip, | 135 | static bool do_test(struct vm86plus_struct *v86, unsigned long eip, |
@@ -175,7 +179,7 @@ static bool do_test(struct vm86plus_struct *v86, unsigned long eip, | |||
175 | (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) { | 179 | (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) { |
176 | printf("[OK]\tReturned correctly\n"); | 180 | printf("[OK]\tReturned correctly\n"); |
177 | } else { | 181 | } else { |
178 | printf("[FAIL]\tIncorrect return reason\n"); | 182 | printf("[FAIL]\tIncorrect return reason (started at eip = 0x%lx, ended at eip = 0x%lx)\n", eip, v86->regs.eip); |
179 | nerrs++; | 183 | nerrs++; |
180 | } | 184 | } |
181 | 185 | ||
@@ -264,6 +268,9 @@ int main(void) | |||
264 | v86.regs.ds = load_addr / 16; | 268 | v86.regs.ds = load_addr / 16; |
265 | v86.regs.es = load_addr / 16; | 269 | v86.regs.es = load_addr / 16; |
266 | 270 | ||
271 | /* Use the end of the page as our stack. */ | ||
272 | v86.regs.esp = 4096; | ||
273 | |||
267 | assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */ | 274 | assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */ |
268 | 275 | ||
269 | /* #BR -- should deliver SIG??? */ | 276 | /* #BR -- should deliver SIG??? */ |
@@ -295,6 +302,23 @@ int main(void) | |||
295 | v86.regs.eflags &= ~X86_EFLAGS_IF; | 302 | v86.regs.eflags &= ~X86_EFLAGS_IF; |
296 | do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set"); | 303 | do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set"); |
297 | 304 | ||
305 | /* POPF with VIP set but IF clear: should not trap */ | ||
306 | v86.regs.eflags = X86_EFLAGS_VIP; | ||
307 | v86.regs.eax = 0; | ||
308 | do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP set and IF clear"); | ||
309 | |||
310 | /* POPF with VIP set and IF set: should trap */ | ||
311 | v86.regs.eflags = X86_EFLAGS_VIP; | ||
312 | v86.regs.eax = X86_EFLAGS_IF; | ||
313 | do_test(&v86, vmcode_popf_hlt - vmcode, VM86_STI, 0, "POPF with VIP and IF set"); | ||
314 | |||
315 | /* POPF with VIP clear and IF set: should not trap */ | ||
316 | v86.regs.eflags = 0; | ||
317 | v86.regs.eax = X86_EFLAGS_IF; | ||
318 | do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP clear and IF set"); | ||
319 | |||
320 | v86.regs.eflags = 0; | ||
321 | |||
298 | /* INT3 -- should cause #BP */ | 322 | /* INT3 -- should cause #BP */ |
299 | do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3"); | 323 | do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3"); |
300 | 324 | ||
@@ -318,7 +342,7 @@ int main(void) | |||
318 | clearhandler(SIGSEGV); | 342 | clearhandler(SIGSEGV); |
319 | 343 | ||
320 | /* Make sure nothing explodes if we fork. */ | 344 | /* Make sure nothing explodes if we fork. */ |
321 | if (fork() > 0) | 345 | if (fork() == 0) |
322 | return 0; | 346 | return 0; |
323 | 347 | ||
324 | return (nerrs == 0 ? 0 : 1); | 348 | return (nerrs == 0 ? 0 : 1); |
diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c index 1ae1c5a7392e..6f22238f3217 100644 --- a/tools/testing/selftests/x86/ptrace_syscall.c +++ b/tools/testing/selftests/x86/ptrace_syscall.c | |||
@@ -183,8 +183,10 @@ static void test_ptrace_syscall_restart(void) | |||
183 | if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) | 183 | if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) |
184 | err(1, "PTRACE_TRACEME"); | 184 | err(1, "PTRACE_TRACEME"); |
185 | 185 | ||
186 | pid_t pid = getpid(), tid = syscall(SYS_gettid); | ||
187 | |||
186 | printf("\tChild will make one syscall\n"); | 188 | printf("\tChild will make one syscall\n"); |
187 | raise(SIGSTOP); | 189 | syscall(SYS_tgkill, pid, tid, SIGSTOP); |
188 | 190 | ||
189 | syscall(SYS_gettid, 10, 11, 12, 13, 14, 15); | 191 | syscall(SYS_gettid, 10, 11, 12, 13, 14, 15); |
190 | _exit(0); | 192 | _exit(0); |
@@ -301,9 +303,11 @@ static void test_restart_under_ptrace(void) | |||
301 | if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) | 303 | if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) |
302 | err(1, "PTRACE_TRACEME"); | 304 | err(1, "PTRACE_TRACEME"); |
303 | 305 | ||
306 | pid_t pid = getpid(), tid = syscall(SYS_gettid); | ||
307 | |||
304 | printf("\tChild will take a nap until signaled\n"); | 308 | printf("\tChild will take a nap until signaled\n"); |
305 | setsigign(SIGUSR1, SA_RESTART); | 309 | setsigign(SIGUSR1, SA_RESTART); |
306 | raise(SIGSTOP); | 310 | syscall(SYS_tgkill, pid, tid, SIGSTOP); |
307 | 311 | ||
308 | syscall(SYS_pause, 0, 0, 0, 0, 0, 0); | 312 | syscall(SYS_pause, 0, 0, 0, 0, 0, 0); |
309 | _exit(0); | 313 | _exit(0); |