diff options
Diffstat (limited to 'tools')
102 files changed, 2202 insertions, 946 deletions
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h index 637b7263cb86..833ed9a16adf 100644 --- a/tools/arch/powerpc/include/uapi/asm/kvm.h +++ b/tools/arch/powerpc/include/uapi/asm/kvm.h | |||
@@ -632,6 +632,8 @@ struct kvm_ppc_cpu_char { | |||
632 | #define KVM_REG_PPC_TIDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbc) | 632 | #define KVM_REG_PPC_TIDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbc) |
633 | #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) | 633 | #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) |
634 | 634 | ||
635 | #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) | ||
636 | |||
635 | /* Transactional Memory checkpointed state: | 637 | /* Transactional Memory checkpointed state: |
636 | * This is all GPRs, all VSX regs and a subset of SPRs | 638 | * This is all GPRs, all VSX regs and a subset of SPRs |
637 | */ | 639 | */ |
diff --git a/tools/arch/s390/include/uapi/asm/unistd.h b/tools/arch/s390/include/uapi/asm/unistd.h deleted file mode 100644 index 725120939051..000000000000 --- a/tools/arch/s390/include/uapi/asm/unistd.h +++ /dev/null | |||
@@ -1,412 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
2 | /* | ||
3 | * S390 version | ||
4 | * | ||
5 | * Derived from "include/asm-i386/unistd.h" | ||
6 | */ | ||
7 | |||
8 | #ifndef _UAPI_ASM_S390_UNISTD_H_ | ||
9 | #define _UAPI_ASM_S390_UNISTD_H_ | ||
10 | |||
11 | /* | ||
12 | * This file contains the system call numbers. | ||
13 | */ | ||
14 | |||
15 | #define __NR_exit 1 | ||
16 | #define __NR_fork 2 | ||
17 | #define __NR_read 3 | ||
18 | #define __NR_write 4 | ||
19 | #define __NR_open 5 | ||
20 | #define __NR_close 6 | ||
21 | #define __NR_restart_syscall 7 | ||
22 | #define __NR_creat 8 | ||
23 | #define __NR_link 9 | ||
24 | #define __NR_unlink 10 | ||
25 | #define __NR_execve 11 | ||
26 | #define __NR_chdir 12 | ||
27 | #define __NR_mknod 14 | ||
28 | #define __NR_chmod 15 | ||
29 | #define __NR_lseek 19 | ||
30 | #define __NR_getpid 20 | ||
31 | #define __NR_mount 21 | ||
32 | #define __NR_umount 22 | ||
33 | #define __NR_ptrace 26 | ||
34 | #define __NR_alarm 27 | ||
35 | #define __NR_pause 29 | ||
36 | #define __NR_utime 30 | ||
37 | #define __NR_access 33 | ||
38 | #define __NR_nice 34 | ||
39 | #define __NR_sync 36 | ||
40 | #define __NR_kill 37 | ||
41 | #define __NR_rename 38 | ||
42 | #define __NR_mkdir 39 | ||
43 | #define __NR_rmdir 40 | ||
44 | #define __NR_dup 41 | ||
45 | #define __NR_pipe 42 | ||
46 | #define __NR_times 43 | ||
47 | #define __NR_brk 45 | ||
48 | #define __NR_signal 48 | ||
49 | #define __NR_acct 51 | ||
50 | #define __NR_umount2 52 | ||
51 | #define __NR_ioctl 54 | ||
52 | #define __NR_fcntl 55 | ||
53 | #define __NR_setpgid 57 | ||
54 | #define __NR_umask 60 | ||
55 | #define __NR_chroot 61 | ||
56 | #define __NR_ustat 62 | ||
57 | #define __NR_dup2 63 | ||
58 | #define __NR_getppid 64 | ||
59 | #define __NR_getpgrp 65 | ||
60 | #define __NR_setsid 66 | ||
61 | #define __NR_sigaction 67 | ||
62 | #define __NR_sigsuspend 72 | ||
63 | #define __NR_sigpending 73 | ||
64 | #define __NR_sethostname 74 | ||
65 | #define __NR_setrlimit 75 | ||
66 | #define __NR_getrusage 77 | ||
67 | #define __NR_gettimeofday 78 | ||
68 | #define __NR_settimeofday 79 | ||
69 | #define __NR_symlink 83 | ||
70 | #define __NR_readlink 85 | ||
71 | #define __NR_uselib 86 | ||
72 | #define __NR_swapon 87 | ||
73 | #define __NR_reboot 88 | ||
74 | #define __NR_readdir 89 | ||
75 | #define __NR_mmap 90 | ||
76 | #define __NR_munmap 91 | ||
77 | #define __NR_truncate 92 | ||
78 | #define __NR_ftruncate 93 | ||
79 | #define __NR_fchmod 94 | ||
80 | #define __NR_getpriority 96 | ||
81 | #define __NR_setpriority 97 | ||
82 | #define __NR_statfs 99 | ||
83 | #define __NR_fstatfs 100 | ||
84 | #define __NR_socketcall 102 | ||
85 | #define __NR_syslog 103 | ||
86 | #define __NR_setitimer 104 | ||
87 | #define __NR_getitimer 105 | ||
88 | #define __NR_stat 106 | ||
89 | #define __NR_lstat 107 | ||
90 | #define __NR_fstat 108 | ||
91 | #define __NR_lookup_dcookie 110 | ||
92 | #define __NR_vhangup 111 | ||
93 | #define __NR_idle 112 | ||
94 | #define __NR_wait4 114 | ||
95 | #define __NR_swapoff 115 | ||
96 | #define __NR_sysinfo 116 | ||
97 | #define __NR_ipc 117 | ||
98 | #define __NR_fsync 118 | ||
99 | #define __NR_sigreturn 119 | ||
100 | #define __NR_clone 120 | ||
101 | #define __NR_setdomainname 121 | ||
102 | #define __NR_uname 122 | ||
103 | #define __NR_adjtimex 124 | ||
104 | #define __NR_mprotect 125 | ||
105 | #define __NR_sigprocmask 126 | ||
106 | #define __NR_create_module 127 | ||
107 | #define __NR_init_module 128 | ||
108 | #define __NR_delete_module 129 | ||
109 | #define __NR_get_kernel_syms 130 | ||
110 | #define __NR_quotactl 131 | ||
111 | #define __NR_getpgid 132 | ||
112 | #define __NR_fchdir 133 | ||
113 | #define __NR_bdflush 134 | ||
114 | #define __NR_sysfs 135 | ||
115 | #define __NR_personality 136 | ||
116 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
117 | #define __NR_getdents 141 | ||
118 | #define __NR_flock 143 | ||
119 | #define __NR_msync 144 | ||
120 | #define __NR_readv 145 | ||
121 | #define __NR_writev 146 | ||
122 | #define __NR_getsid 147 | ||
123 | #define __NR_fdatasync 148 | ||
124 | #define __NR__sysctl 149 | ||
125 | #define __NR_mlock 150 | ||
126 | #define __NR_munlock 151 | ||
127 | #define __NR_mlockall 152 | ||
128 | #define __NR_munlockall 153 | ||
129 | #define __NR_sched_setparam 154 | ||
130 | #define __NR_sched_getparam 155 | ||
131 | #define __NR_sched_setscheduler 156 | ||
132 | #define __NR_sched_getscheduler 157 | ||
133 | #define __NR_sched_yield 158 | ||
134 | #define __NR_sched_get_priority_max 159 | ||
135 | #define __NR_sched_get_priority_min 160 | ||
136 | #define __NR_sched_rr_get_interval 161 | ||
137 | #define __NR_nanosleep 162 | ||
138 | #define __NR_mremap 163 | ||
139 | #define __NR_query_module 167 | ||
140 | #define __NR_poll 168 | ||
141 | #define __NR_nfsservctl 169 | ||
142 | #define __NR_prctl 172 | ||
143 | #define __NR_rt_sigreturn 173 | ||
144 | #define __NR_rt_sigaction 174 | ||
145 | #define __NR_rt_sigprocmask 175 | ||
146 | #define __NR_rt_sigpending 176 | ||
147 | #define __NR_rt_sigtimedwait 177 | ||
148 | #define __NR_rt_sigqueueinfo 178 | ||
149 | #define __NR_rt_sigsuspend 179 | ||
150 | #define __NR_pread64 180 | ||
151 | #define __NR_pwrite64 181 | ||
152 | #define __NR_getcwd 183 | ||
153 | #define __NR_capget 184 | ||
154 | #define __NR_capset 185 | ||
155 | #define __NR_sigaltstack 186 | ||
156 | #define __NR_sendfile 187 | ||
157 | #define __NR_getpmsg 188 | ||
158 | #define __NR_putpmsg 189 | ||
159 | #define __NR_vfork 190 | ||
160 | #define __NR_pivot_root 217 | ||
161 | #define __NR_mincore 218 | ||
162 | #define __NR_madvise 219 | ||
163 | #define __NR_getdents64 220 | ||
164 | #define __NR_readahead 222 | ||
165 | #define __NR_setxattr 224 | ||
166 | #define __NR_lsetxattr 225 | ||
167 | #define __NR_fsetxattr 226 | ||
168 | #define __NR_getxattr 227 | ||
169 | #define __NR_lgetxattr 228 | ||
170 | #define __NR_fgetxattr 229 | ||
171 | #define __NR_listxattr 230 | ||
172 | #define __NR_llistxattr 231 | ||
173 | #define __NR_flistxattr 232 | ||
174 | #define __NR_removexattr 233 | ||
175 | #define __NR_lremovexattr 234 | ||
176 | #define __NR_fremovexattr 235 | ||
177 | #define __NR_gettid 236 | ||
178 | #define __NR_tkill 237 | ||
179 | #define __NR_futex 238 | ||
180 | #define __NR_sched_setaffinity 239 | ||
181 | #define __NR_sched_getaffinity 240 | ||
182 | #define __NR_tgkill 241 | ||
183 | /* Number 242 is reserved for tux */ | ||
184 | #define __NR_io_setup 243 | ||
185 | #define __NR_io_destroy 244 | ||
186 | #define __NR_io_getevents 245 | ||
187 | #define __NR_io_submit 246 | ||
188 | #define __NR_io_cancel 247 | ||
189 | #define __NR_exit_group 248 | ||
190 | #define __NR_epoll_create 249 | ||
191 | #define __NR_epoll_ctl 250 | ||
192 | #define __NR_epoll_wait 251 | ||
193 | #define __NR_set_tid_address 252 | ||
194 | #define __NR_fadvise64 253 | ||
195 | #define __NR_timer_create 254 | ||
196 | #define __NR_timer_settime 255 | ||
197 | #define __NR_timer_gettime 256 | ||
198 | #define __NR_timer_getoverrun 257 | ||
199 | #define __NR_timer_delete 258 | ||
200 | #define __NR_clock_settime 259 | ||
201 | #define __NR_clock_gettime 260 | ||
202 | #define __NR_clock_getres 261 | ||
203 | #define __NR_clock_nanosleep 262 | ||
204 | /* Number 263 is reserved for vserver */ | ||
205 | #define __NR_statfs64 265 | ||
206 | #define __NR_fstatfs64 266 | ||
207 | #define __NR_remap_file_pages 267 | ||
208 | #define __NR_mbind 268 | ||
209 | #define __NR_get_mempolicy 269 | ||
210 | #define __NR_set_mempolicy 270 | ||
211 | #define __NR_mq_open 271 | ||
212 | #define __NR_mq_unlink 272 | ||
213 | #define __NR_mq_timedsend 273 | ||
214 | #define __NR_mq_timedreceive 274 | ||
215 | #define __NR_mq_notify 275 | ||
216 | #define __NR_mq_getsetattr 276 | ||
217 | #define __NR_kexec_load 277 | ||
218 | #define __NR_add_key 278 | ||
219 | #define __NR_request_key 279 | ||
220 | #define __NR_keyctl 280 | ||
221 | #define __NR_waitid 281 | ||
222 | #define __NR_ioprio_set 282 | ||
223 | #define __NR_ioprio_get 283 | ||
224 | #define __NR_inotify_init 284 | ||
225 | #define __NR_inotify_add_watch 285 | ||
226 | #define __NR_inotify_rm_watch 286 | ||
227 | #define __NR_migrate_pages 287 | ||
228 | #define __NR_openat 288 | ||
229 | #define __NR_mkdirat 289 | ||
230 | #define __NR_mknodat 290 | ||
231 | #define __NR_fchownat 291 | ||
232 | #define __NR_futimesat 292 | ||
233 | #define __NR_unlinkat 294 | ||
234 | #define __NR_renameat 295 | ||
235 | #define __NR_linkat 296 | ||
236 | #define __NR_symlinkat 297 | ||
237 | #define __NR_readlinkat 298 | ||
238 | #define __NR_fchmodat 299 | ||
239 | #define __NR_faccessat 300 | ||
240 | #define __NR_pselect6 301 | ||
241 | #define __NR_ppoll 302 | ||
242 | #define __NR_unshare 303 | ||
243 | #define __NR_set_robust_list 304 | ||
244 | #define __NR_get_robust_list 305 | ||
245 | #define __NR_splice 306 | ||
246 | #define __NR_sync_file_range 307 | ||
247 | #define __NR_tee 308 | ||
248 | #define __NR_vmsplice 309 | ||
249 | #define __NR_move_pages 310 | ||
250 | #define __NR_getcpu 311 | ||
251 | #define __NR_epoll_pwait 312 | ||
252 | #define __NR_utimes 313 | ||
253 | #define __NR_fallocate 314 | ||
254 | #define __NR_utimensat 315 | ||
255 | #define __NR_signalfd 316 | ||
256 | #define __NR_timerfd 317 | ||
257 | #define __NR_eventfd 318 | ||
258 | #define __NR_timerfd_create 319 | ||
259 | #define __NR_timerfd_settime 320 | ||
260 | #define __NR_timerfd_gettime 321 | ||
261 | #define __NR_signalfd4 322 | ||
262 | #define __NR_eventfd2 323 | ||
263 | #define __NR_inotify_init1 324 | ||
264 | #define __NR_pipe2 325 | ||
265 | #define __NR_dup3 326 | ||
266 | #define __NR_epoll_create1 327 | ||
267 | #define __NR_preadv 328 | ||
268 | #define __NR_pwritev 329 | ||
269 | #define __NR_rt_tgsigqueueinfo 330 | ||
270 | #define __NR_perf_event_open 331 | ||
271 | #define __NR_fanotify_init 332 | ||
272 | #define __NR_fanotify_mark 333 | ||
273 | #define __NR_prlimit64 334 | ||
274 | #define __NR_name_to_handle_at 335 | ||
275 | #define __NR_open_by_handle_at 336 | ||
276 | #define __NR_clock_adjtime 337 | ||
277 | #define __NR_syncfs 338 | ||
278 | #define __NR_setns 339 | ||
279 | #define __NR_process_vm_readv 340 | ||
280 | #define __NR_process_vm_writev 341 | ||
281 | #define __NR_s390_runtime_instr 342 | ||
282 | #define __NR_kcmp 343 | ||
283 | #define __NR_finit_module 344 | ||
284 | #define __NR_sched_setattr 345 | ||
285 | #define __NR_sched_getattr 346 | ||
286 | #define __NR_renameat2 347 | ||
287 | #define __NR_seccomp 348 | ||
288 | #define __NR_getrandom 349 | ||
289 | #define __NR_memfd_create 350 | ||
290 | #define __NR_bpf 351 | ||
291 | #define __NR_s390_pci_mmio_write 352 | ||
292 | #define __NR_s390_pci_mmio_read 353 | ||
293 | #define __NR_execveat 354 | ||
294 | #define __NR_userfaultfd 355 | ||
295 | #define __NR_membarrier 356 | ||
296 | #define __NR_recvmmsg 357 | ||
297 | #define __NR_sendmmsg 358 | ||
298 | #define __NR_socket 359 | ||
299 | #define __NR_socketpair 360 | ||
300 | #define __NR_bind 361 | ||
301 | #define __NR_connect 362 | ||
302 | #define __NR_listen 363 | ||
303 | #define __NR_accept4 364 | ||
304 | #define __NR_getsockopt 365 | ||
305 | #define __NR_setsockopt 366 | ||
306 | #define __NR_getsockname 367 | ||
307 | #define __NR_getpeername 368 | ||
308 | #define __NR_sendto 369 | ||
309 | #define __NR_sendmsg 370 | ||
310 | #define __NR_recvfrom 371 | ||
311 | #define __NR_recvmsg 372 | ||
312 | #define __NR_shutdown 373 | ||
313 | #define __NR_mlock2 374 | ||
314 | #define __NR_copy_file_range 375 | ||
315 | #define __NR_preadv2 376 | ||
316 | #define __NR_pwritev2 377 | ||
317 | #define __NR_s390_guarded_storage 378 | ||
318 | #define __NR_statx 379 | ||
319 | #define __NR_s390_sthyi 380 | ||
320 | #define NR_syscalls 381 | ||
321 | |||
322 | /* | ||
323 | * There are some system calls that are not present on 64 bit, some | ||
324 | * have a different name although they do the same (e.g. __NR_chown32 | ||
325 | * is __NR_chown on 64 bit). | ||
326 | */ | ||
327 | #ifndef __s390x__ | ||
328 | |||
329 | #define __NR_time 13 | ||
330 | #define __NR_lchown 16 | ||
331 | #define __NR_setuid 23 | ||
332 | #define __NR_getuid 24 | ||
333 | #define __NR_stime 25 | ||
334 | #define __NR_setgid 46 | ||
335 | #define __NR_getgid 47 | ||
336 | #define __NR_geteuid 49 | ||
337 | #define __NR_getegid 50 | ||
338 | #define __NR_setreuid 70 | ||
339 | #define __NR_setregid 71 | ||
340 | #define __NR_getrlimit 76 | ||
341 | #define __NR_getgroups 80 | ||
342 | #define __NR_setgroups 81 | ||
343 | #define __NR_fchown 95 | ||
344 | #define __NR_ioperm 101 | ||
345 | #define __NR_setfsuid 138 | ||
346 | #define __NR_setfsgid 139 | ||
347 | #define __NR__llseek 140 | ||
348 | #define __NR__newselect 142 | ||
349 | #define __NR_setresuid 164 | ||
350 | #define __NR_getresuid 165 | ||
351 | #define __NR_setresgid 170 | ||
352 | #define __NR_getresgid 171 | ||
353 | #define __NR_chown 182 | ||
354 | #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ | ||
355 | #define __NR_mmap2 192 | ||
356 | #define __NR_truncate64 193 | ||
357 | #define __NR_ftruncate64 194 | ||
358 | #define __NR_stat64 195 | ||
359 | #define __NR_lstat64 196 | ||
360 | #define __NR_fstat64 197 | ||
361 | #define __NR_lchown32 198 | ||
362 | #define __NR_getuid32 199 | ||
363 | #define __NR_getgid32 200 | ||
364 | #define __NR_geteuid32 201 | ||
365 | #define __NR_getegid32 202 | ||
366 | #define __NR_setreuid32 203 | ||
367 | #define __NR_setregid32 204 | ||
368 | #define __NR_getgroups32 205 | ||
369 | #define __NR_setgroups32 206 | ||
370 | #define __NR_fchown32 207 | ||
371 | #define __NR_setresuid32 208 | ||
372 | #define __NR_getresuid32 209 | ||
373 | #define __NR_setresgid32 210 | ||
374 | #define __NR_getresgid32 211 | ||
375 | #define __NR_chown32 212 | ||
376 | #define __NR_setuid32 213 | ||
377 | #define __NR_setgid32 214 | ||
378 | #define __NR_setfsuid32 215 | ||
379 | #define __NR_setfsgid32 216 | ||
380 | #define __NR_fcntl64 221 | ||
381 | #define __NR_sendfile64 223 | ||
382 | #define __NR_fadvise64_64 264 | ||
383 | #define __NR_fstatat64 293 | ||
384 | |||
385 | #else | ||
386 | |||
387 | #define __NR_select 142 | ||
388 | #define __NR_getrlimit 191 /* SuS compliant getrlimit */ | ||
389 | #define __NR_lchown 198 | ||
390 | #define __NR_getuid 199 | ||
391 | #define __NR_getgid 200 | ||
392 | #define __NR_geteuid 201 | ||
393 | #define __NR_getegid 202 | ||
394 | #define __NR_setreuid 203 | ||
395 | #define __NR_setregid 204 | ||
396 | #define __NR_getgroups 205 | ||
397 | #define __NR_setgroups 206 | ||
398 | #define __NR_fchown 207 | ||
399 | #define __NR_setresuid 208 | ||
400 | #define __NR_getresuid 209 | ||
401 | #define __NR_setresgid 210 | ||
402 | #define __NR_getresgid 211 | ||
403 | #define __NR_chown 212 | ||
404 | #define __NR_setuid 213 | ||
405 | #define __NR_setgid 214 | ||
406 | #define __NR_setfsuid 215 | ||
407 | #define __NR_setfsgid 216 | ||
408 | #define __NR_newfstatat 293 | ||
409 | |||
410 | #endif | ||
411 | |||
412 | #endif /* _UAPI_ASM_S390_UNISTD_H_ */ | ||
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index 1d9199e1c2ad..f41079da38c5 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h | |||
@@ -210,8 +210,10 @@ | |||
210 | 210 | ||
211 | #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ | 211 | #define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */ |
212 | #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */ | 212 | #define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */ |
213 | #define X86_FEATURE_SEV ( 7*32+20) /* AMD Secure Encrypted Virtualization */ | ||
213 | 214 | ||
214 | #define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */ | 215 | #define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */ |
216 | #define X86_FEATURE_USE_IBRS_FW ( 7*32+22) /* "" Use IBRS during runtime firmware calls */ | ||
215 | 217 | ||
216 | /* Virtualization flags: Linux defined, word 8 */ | 218 | /* Virtualization flags: Linux defined, word 8 */ |
217 | #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ | 219 | #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ |
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/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 3a0396d87c42..185acfa229b5 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c | |||
@@ -244,7 +244,7 @@ static int do_batch(int argc, char **argv) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | if (errno && errno != ENOENT) { | 246 | if (errno && errno != ENOENT) { |
247 | perror("reading batch file failed"); | 247 | p_err("reading batch file failed: %s", strerror(errno)); |
248 | err = -1; | 248 | err = -1; |
249 | } else { | 249 | } else { |
250 | p_info("processed %d lines", lines); | 250 | p_info("processed %d lines", lines); |
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index e8e2baaf93c2..e549e329be82 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -774,6 +774,9 @@ static int do_dump(int argc, char **argv) | |||
774 | n < 0 ? strerror(errno) : "short write"); | 774 | n < 0 ? strerror(errno) : "short write"); |
775 | goto err_free; | 775 | goto err_free; |
776 | } | 776 | } |
777 | |||
778 | if (json_output) | ||
779 | jsonw_null(json_wtr); | ||
777 | } else { | 780 | } else { |
778 | if (member_len == &info.jited_prog_len) { | 781 | if (member_len == &info.jited_prog_len) { |
779 | const char *name = NULL; | 782 | const char *name = NULL; |
diff --git a/tools/cgroup/Makefile b/tools/cgroup/Makefile index 860fa151640a..ffca068e4a76 100644 --- a/tools/cgroup/Makefile +++ b/tools/cgroup/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for cgroup tools | 2 | # Makefile for cgroup tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | CFLAGS = -Wall -Wextra | 4 | CFLAGS = -Wall -Wextra |
6 | 5 | ||
7 | all: cgroup_event_listener | 6 | all: cgroup_event_listener |
diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile index 805a2c0cf4cd..240eda014b37 100644 --- a/tools/gpio/Makefile +++ b/tools/gpio/Makefile | |||
@@ -12,8 +12,6 @@ endif | |||
12 | # (this improves performance and avoids hard-to-debug behaviour); | 12 | # (this improves performance and avoids hard-to-debug behaviour); |
13 | MAKEFLAGS += -r | 13 | MAKEFLAGS += -r |
14 | 14 | ||
15 | CC = $(CROSS_COMPILE)gcc | ||
16 | LD = $(CROSS_COMPILE)ld | ||
17 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
18 | 16 | ||
19 | ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon | 17 | ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon |
diff --git a/tools/hv/Makefile b/tools/hv/Makefile index 1139d71fa0cf..5db5e62cebda 100644 --- a/tools/hv/Makefile +++ b/tools/hv/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for Hyper-V tools | 2 | # Makefile for Hyper-V tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | WARNINGS = -Wall -Wextra | 4 | WARNINGS = -Wall -Wextra |
6 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) | 5 | CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) |
7 | 6 | ||
diff --git a/tools/iio/Makefile b/tools/iio/Makefile index a08e7a47d6a3..332ed2f6c2c2 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile | |||
@@ -12,8 +12,6 @@ endif | |||
12 | # (this improves performance and avoids hard-to-debug behaviour); | 12 | # (this improves performance and avoids hard-to-debug behaviour); |
13 | MAKEFLAGS += -r | 13 | MAKEFLAGS += -r |
14 | 14 | ||
15 | CC = $(CROSS_COMPILE)gcc | ||
16 | LD = $(CROSS_COMPILE)ld | ||
17 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
18 | 16 | ||
19 | ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer | 17 | ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer |
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h index ac3c6503ca27..536ee4febd74 100644 --- a/tools/include/uapi/drm/i915_drm.h +++ b/tools/include/uapi/drm/i915_drm.h | |||
@@ -86,6 +86,62 @@ enum i915_mocs_table_index { | |||
86 | I915_MOCS_CACHED, | 86 | I915_MOCS_CACHED, |
87 | }; | 87 | }; |
88 | 88 | ||
89 | /* | ||
90 | * Different engines serve different roles, and there may be more than one | ||
91 | * engine serving each role. enum drm_i915_gem_engine_class provides a | ||
92 | * classification of the role of the engine, which may be used when requesting | ||
93 | * operations to be performed on a certain subset of engines, or for providing | ||
94 | * information about that group. | ||
95 | */ | ||
96 | enum drm_i915_gem_engine_class { | ||
97 | I915_ENGINE_CLASS_RENDER = 0, | ||
98 | I915_ENGINE_CLASS_COPY = 1, | ||
99 | I915_ENGINE_CLASS_VIDEO = 2, | ||
100 | I915_ENGINE_CLASS_VIDEO_ENHANCE = 3, | ||
101 | |||
102 | I915_ENGINE_CLASS_INVALID = -1 | ||
103 | }; | ||
104 | |||
105 | /** | ||
106 | * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915 | ||
107 | * | ||
108 | */ | ||
109 | |||
110 | enum drm_i915_pmu_engine_sample { | ||
111 | I915_SAMPLE_BUSY = 0, | ||
112 | I915_SAMPLE_WAIT = 1, | ||
113 | I915_SAMPLE_SEMA = 2 | ||
114 | }; | ||
115 | |||
116 | #define I915_PMU_SAMPLE_BITS (4) | ||
117 | #define I915_PMU_SAMPLE_MASK (0xf) | ||
118 | #define I915_PMU_SAMPLE_INSTANCE_BITS (8) | ||
119 | #define I915_PMU_CLASS_SHIFT \ | ||
120 | (I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS) | ||
121 | |||
122 | #define __I915_PMU_ENGINE(class, instance, sample) \ | ||
123 | ((class) << I915_PMU_CLASS_SHIFT | \ | ||
124 | (instance) << I915_PMU_SAMPLE_BITS | \ | ||
125 | (sample)) | ||
126 | |||
127 | #define I915_PMU_ENGINE_BUSY(class, instance) \ | ||
128 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY) | ||
129 | |||
130 | #define I915_PMU_ENGINE_WAIT(class, instance) \ | ||
131 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT) | ||
132 | |||
133 | #define I915_PMU_ENGINE_SEMA(class, instance) \ | ||
134 | __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA) | ||
135 | |||
136 | #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | ||
137 | |||
138 | #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0) | ||
139 | #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1) | ||
140 | #define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2) | ||
141 | #define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3) | ||
142 | |||
143 | #define I915_PMU_LAST I915_PMU_RC6_RESIDENCY | ||
144 | |||
89 | /* Each region is a minimum of 16k, and there are at most 255 of them. | 145 | /* Each region is a minimum of 16k, and there are at most 255 of them. |
90 | */ | 146 | */ |
91 | #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use | 147 | #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use |
@@ -450,6 +506,27 @@ typedef struct drm_i915_irq_wait { | |||
450 | */ | 506 | */ |
451 | #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49 | 507 | #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49 |
452 | 508 | ||
509 | /* | ||
510 | * Query whether every context (both per-file default and user created) is | ||
511 | * isolated (insofar as HW supports). If this parameter is not true, then | ||
512 | * freshly created contexts may inherit values from an existing context, | ||
513 | * rather than default HW values. If true, it also ensures (insofar as HW | ||
514 | * supports) that all state set by this context will not leak to any other | ||
515 | * context. | ||
516 | * | ||
517 | * As not every engine across every gen support contexts, the returned | ||
518 | * value reports the support of context isolation for individual engines by | ||
519 | * returning a bitmask of each engine class set to true if that class supports | ||
520 | * isolation. | ||
521 | */ | ||
522 | #define I915_PARAM_HAS_CONTEXT_ISOLATION 50 | ||
523 | |||
524 | /* Frequency of the command streamer timestamps given by the *_TIMESTAMP | ||
525 | * registers. This used to be fixed per platform but from CNL onwards, this | ||
526 | * might vary depending on the parts. | ||
527 | */ | ||
528 | #define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51 | ||
529 | |||
453 | typedef struct drm_i915_getparam { | 530 | typedef struct drm_i915_getparam { |
454 | __s32 param; | 531 | __s32 param; |
455 | /* | 532 | /* |
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index 8616131e2c61..6d9447700e18 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h | |||
@@ -163,6 +163,7 @@ enum { | |||
163 | IFLA_IF_NETNSID, | 163 | IFLA_IF_NETNSID, |
164 | IFLA_CARRIER_UP_COUNT, | 164 | IFLA_CARRIER_UP_COUNT, |
165 | IFLA_CARRIER_DOWN_COUNT, | 165 | IFLA_CARRIER_DOWN_COUNT, |
166 | IFLA_NEW_IFINDEX, | ||
166 | __IFLA_MAX | 167 | __IFLA_MAX |
167 | }; | 168 | }; |
168 | 169 | ||
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 8fb90a0819c3..7b26d4b0b052 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h | |||
@@ -761,6 +761,7 @@ struct kvm_ppc_resize_hpt { | |||
761 | #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 | 761 | #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 |
762 | #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 | 762 | #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 |
763 | #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) | 763 | #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) |
764 | #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list) | ||
764 | 765 | ||
765 | /* | 766 | /* |
766 | * Extension capability list. | 767 | * Extension capability list. |
@@ -934,6 +935,7 @@ struct kvm_ppc_resize_hpt { | |||
934 | #define KVM_CAP_S390_AIS_MIGRATION 150 | 935 | #define KVM_CAP_S390_AIS_MIGRATION 150 |
935 | #define KVM_CAP_PPC_GET_CPU_CHAR 151 | 936 | #define KVM_CAP_PPC_GET_CPU_CHAR 151 |
936 | #define KVM_CAP_S390_BPB 152 | 937 | #define KVM_CAP_S390_BPB 152 |
938 | #define KVM_CAP_GET_MSR_FEATURES 153 | ||
937 | 939 | ||
938 | #ifdef KVM_CAP_IRQ_ROUTING | 940 | #ifdef KVM_CAP_IRQ_ROUTING |
939 | 941 | ||
@@ -1362,6 +1364,96 @@ struct kvm_s390_ucas_mapping { | |||
1362 | /* Available with KVM_CAP_S390_CMMA_MIGRATION */ | 1364 | /* Available with KVM_CAP_S390_CMMA_MIGRATION */ |
1363 | #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) | 1365 | #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) |
1364 | #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) | 1366 | #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) |
1367 | /* Memory Encryption Commands */ | ||
1368 | #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) | ||
1369 | |||
1370 | struct kvm_enc_region { | ||
1371 | __u64 addr; | ||
1372 | __u64 size; | ||
1373 | }; | ||
1374 | |||
1375 | #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) | ||
1376 | #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) | ||
1377 | |||
1378 | /* Secure Encrypted Virtualization command */ | ||
1379 | enum sev_cmd_id { | ||
1380 | /* Guest initialization commands */ | ||
1381 | KVM_SEV_INIT = 0, | ||
1382 | KVM_SEV_ES_INIT, | ||
1383 | /* Guest launch commands */ | ||
1384 | KVM_SEV_LAUNCH_START, | ||
1385 | KVM_SEV_LAUNCH_UPDATE_DATA, | ||
1386 | KVM_SEV_LAUNCH_UPDATE_VMSA, | ||
1387 | KVM_SEV_LAUNCH_SECRET, | ||
1388 | KVM_SEV_LAUNCH_MEASURE, | ||
1389 | KVM_SEV_LAUNCH_FINISH, | ||
1390 | /* Guest migration commands (outgoing) */ | ||
1391 | KVM_SEV_SEND_START, | ||
1392 | KVM_SEV_SEND_UPDATE_DATA, | ||
1393 | KVM_SEV_SEND_UPDATE_VMSA, | ||
1394 | KVM_SEV_SEND_FINISH, | ||
1395 | /* Guest migration commands (incoming) */ | ||
1396 | KVM_SEV_RECEIVE_START, | ||
1397 | KVM_SEV_RECEIVE_UPDATE_DATA, | ||
1398 | KVM_SEV_RECEIVE_UPDATE_VMSA, | ||
1399 | KVM_SEV_RECEIVE_FINISH, | ||
1400 | /* Guest status and debug commands */ | ||
1401 | KVM_SEV_GUEST_STATUS, | ||
1402 | KVM_SEV_DBG_DECRYPT, | ||
1403 | KVM_SEV_DBG_ENCRYPT, | ||
1404 | /* Guest certificates commands */ | ||
1405 | KVM_SEV_CERT_EXPORT, | ||
1406 | |||
1407 | KVM_SEV_NR_MAX, | ||
1408 | }; | ||
1409 | |||
1410 | struct kvm_sev_cmd { | ||
1411 | __u32 id; | ||
1412 | __u64 data; | ||
1413 | __u32 error; | ||
1414 | __u32 sev_fd; | ||
1415 | }; | ||
1416 | |||
1417 | struct kvm_sev_launch_start { | ||
1418 | __u32 handle; | ||
1419 | __u32 policy; | ||
1420 | __u64 dh_uaddr; | ||
1421 | __u32 dh_len; | ||
1422 | __u64 session_uaddr; | ||
1423 | __u32 session_len; | ||
1424 | }; | ||
1425 | |||
1426 | struct kvm_sev_launch_update_data { | ||
1427 | __u64 uaddr; | ||
1428 | __u32 len; | ||
1429 | }; | ||
1430 | |||
1431 | |||
1432 | struct kvm_sev_launch_secret { | ||
1433 | __u64 hdr_uaddr; | ||
1434 | __u32 hdr_len; | ||
1435 | __u64 guest_uaddr; | ||
1436 | __u32 guest_len; | ||
1437 | __u64 trans_uaddr; | ||
1438 | __u32 trans_len; | ||
1439 | }; | ||
1440 | |||
1441 | struct kvm_sev_launch_measure { | ||
1442 | __u64 uaddr; | ||
1443 | __u32 len; | ||
1444 | }; | ||
1445 | |||
1446 | struct kvm_sev_guest_status { | ||
1447 | __u32 handle; | ||
1448 | __u32 policy; | ||
1449 | __u32 state; | ||
1450 | }; | ||
1451 | |||
1452 | struct kvm_sev_dbg { | ||
1453 | __u64 src_uaddr; | ||
1454 | __u64 dst_uaddr; | ||
1455 | __u32 len; | ||
1456 | }; | ||
1365 | 1457 | ||
1366 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | 1458 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) |
1367 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) | 1459 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) |
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index a5684d0968b4..5898c22ba310 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat | |||
@@ -33,7 +33,7 @@ import resource | |||
33 | import struct | 33 | import struct |
34 | import re | 34 | import re |
35 | import subprocess | 35 | import subprocess |
36 | from collections import defaultdict | 36 | from collections import defaultdict, namedtuple |
37 | 37 | ||
38 | VMX_EXIT_REASONS = { | 38 | VMX_EXIT_REASONS = { |
39 | 'EXCEPTION_NMI': 0, | 39 | 'EXCEPTION_NMI': 0, |
@@ -228,6 +228,7 @@ IOCTL_NUMBERS = { | |||
228 | } | 228 | } |
229 | 229 | ||
230 | ENCODING = locale.getpreferredencoding(False) | 230 | ENCODING = locale.getpreferredencoding(False) |
231 | TRACE_FILTER = re.compile(r'^[^\(]*$') | ||
231 | 232 | ||
232 | 233 | ||
233 | class Arch(object): | 234 | class Arch(object): |
@@ -260,6 +261,11 @@ class Arch(object): | |||
260 | return ArchX86(SVM_EXIT_REASONS) | 261 | return ArchX86(SVM_EXIT_REASONS) |
261 | return | 262 | return |
262 | 263 | ||
264 | def tracepoint_is_child(self, field): | ||
265 | if (TRACE_FILTER.match(field)): | ||
266 | return None | ||
267 | return field.split('(', 1)[0] | ||
268 | |||
263 | 269 | ||
264 | class ArchX86(Arch): | 270 | class ArchX86(Arch): |
265 | def __init__(self, exit_reasons): | 271 | def __init__(self, exit_reasons): |
@@ -267,6 +273,10 @@ class ArchX86(Arch): | |||
267 | self.ioctl_numbers = IOCTL_NUMBERS | 273 | self.ioctl_numbers = IOCTL_NUMBERS |
268 | self.exit_reasons = exit_reasons | 274 | self.exit_reasons = exit_reasons |
269 | 275 | ||
276 | def debugfs_is_child(self, field): | ||
277 | """ Returns name of parent if 'field' is a child, None otherwise """ | ||
278 | return None | ||
279 | |||
270 | 280 | ||
271 | class ArchPPC(Arch): | 281 | class ArchPPC(Arch): |
272 | def __init__(self): | 282 | def __init__(self): |
@@ -282,6 +292,10 @@ class ArchPPC(Arch): | |||
282 | self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 | 292 | self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 |
283 | self.exit_reasons = {} | 293 | self.exit_reasons = {} |
284 | 294 | ||
295 | def debugfs_is_child(self, field): | ||
296 | """ Returns name of parent if 'field' is a child, None otherwise """ | ||
297 | return None | ||
298 | |||
285 | 299 | ||
286 | class ArchA64(Arch): | 300 | class ArchA64(Arch): |
287 | def __init__(self): | 301 | def __init__(self): |
@@ -289,6 +303,10 @@ class ArchA64(Arch): | |||
289 | self.ioctl_numbers = IOCTL_NUMBERS | 303 | self.ioctl_numbers = IOCTL_NUMBERS |
290 | self.exit_reasons = AARCH64_EXIT_REASONS | 304 | self.exit_reasons = AARCH64_EXIT_REASONS |
291 | 305 | ||
306 | def debugfs_is_child(self, field): | ||
307 | """ Returns name of parent if 'field' is a child, None otherwise """ | ||
308 | return None | ||
309 | |||
292 | 310 | ||
293 | class ArchS390(Arch): | 311 | class ArchS390(Arch): |
294 | def __init__(self): | 312 | def __init__(self): |
@@ -296,6 +314,12 @@ class ArchS390(Arch): | |||
296 | self.ioctl_numbers = IOCTL_NUMBERS | 314 | self.ioctl_numbers = IOCTL_NUMBERS |
297 | self.exit_reasons = None | 315 | self.exit_reasons = None |
298 | 316 | ||
317 | def debugfs_is_child(self, field): | ||
318 | """ Returns name of parent if 'field' is a child, None otherwise """ | ||
319 | if field.startswith('instruction_'): | ||
320 | return 'exit_instruction' | ||
321 | |||
322 | |||
299 | ARCH = Arch.get_arch() | 323 | ARCH = Arch.get_arch() |
300 | 324 | ||
301 | 325 | ||
@@ -331,9 +355,6 @@ class perf_event_attr(ctypes.Structure): | |||
331 | PERF_TYPE_TRACEPOINT = 2 | 355 | PERF_TYPE_TRACEPOINT = 2 |
332 | PERF_FORMAT_GROUP = 1 << 3 | 356 | PERF_FORMAT_GROUP = 1 << 3 |
333 | 357 | ||
334 | PATH_DEBUGFS_TRACING = '/sys/kernel/debug/tracing' | ||
335 | PATH_DEBUGFS_KVM = '/sys/kernel/debug/kvm' | ||
336 | |||
337 | 358 | ||
338 | class Group(object): | 359 | class Group(object): |
339 | """Represents a perf event group.""" | 360 | """Represents a perf event group.""" |
@@ -376,8 +397,8 @@ class Event(object): | |||
376 | self.syscall = self.libc.syscall | 397 | self.syscall = self.libc.syscall |
377 | self.name = name | 398 | self.name = name |
378 | self.fd = None | 399 | self.fd = None |
379 | self.setup_event(group, trace_cpu, trace_pid, trace_point, | 400 | self._setup_event(group, trace_cpu, trace_pid, trace_point, |
380 | trace_filter, trace_set) | 401 | trace_filter, trace_set) |
381 | 402 | ||
382 | def __del__(self): | 403 | def __del__(self): |
383 | """Closes the event's file descriptor. | 404 | """Closes the event's file descriptor. |
@@ -390,7 +411,7 @@ class Event(object): | |||
390 | if self.fd: | 411 | if self.fd: |
391 | os.close(self.fd) | 412 | os.close(self.fd) |
392 | 413 | ||
393 | def perf_event_open(self, attr, pid, cpu, group_fd, flags): | 414 | def _perf_event_open(self, attr, pid, cpu, group_fd, flags): |
394 | """Wrapper for the sys_perf_evt_open() syscall. | 415 | """Wrapper for the sys_perf_evt_open() syscall. |
395 | 416 | ||
396 | Used to set up performance events, returns a file descriptor or -1 | 417 | Used to set up performance events, returns a file descriptor or -1 |
@@ -409,7 +430,7 @@ class Event(object): | |||
409 | ctypes.c_int(pid), ctypes.c_int(cpu), | 430 | ctypes.c_int(pid), ctypes.c_int(cpu), |
410 | ctypes.c_int(group_fd), ctypes.c_long(flags)) | 431 | ctypes.c_int(group_fd), ctypes.c_long(flags)) |
411 | 432 | ||
412 | def setup_event_attribute(self, trace_set, trace_point): | 433 | def _setup_event_attribute(self, trace_set, trace_point): |
413 | """Returns an initialized ctype perf_event_attr struct.""" | 434 | """Returns an initialized ctype perf_event_attr struct.""" |
414 | 435 | ||
415 | id_path = os.path.join(PATH_DEBUGFS_TRACING, 'events', trace_set, | 436 | id_path = os.path.join(PATH_DEBUGFS_TRACING, 'events', trace_set, |
@@ -419,8 +440,8 @@ class Event(object): | |||
419 | event_attr.config = int(open(id_path).read()) | 440 | event_attr.config = int(open(id_path).read()) |
420 | return event_attr | 441 | return event_attr |
421 | 442 | ||
422 | def setup_event(self, group, trace_cpu, trace_pid, trace_point, | 443 | def _setup_event(self, group, trace_cpu, trace_pid, trace_point, |
423 | trace_filter, trace_set): | 444 | trace_filter, trace_set): |
424 | """Sets up the perf event in Linux. | 445 | """Sets up the perf event in Linux. |
425 | 446 | ||
426 | Issues the syscall to register the event in the kernel and | 447 | Issues the syscall to register the event in the kernel and |
@@ -428,7 +449,7 @@ class Event(object): | |||
428 | 449 | ||
429 | """ | 450 | """ |
430 | 451 | ||
431 | event_attr = self.setup_event_attribute(trace_set, trace_point) | 452 | event_attr = self._setup_event_attribute(trace_set, trace_point) |
432 | 453 | ||
433 | # First event will be group leader. | 454 | # First event will be group leader. |
434 | group_leader = -1 | 455 | group_leader = -1 |
@@ -437,8 +458,8 @@ class Event(object): | |||
437 | if group.events: | 458 | if group.events: |
438 | group_leader = group.events[0].fd | 459 | group_leader = group.events[0].fd |
439 | 460 | ||
440 | fd = self.perf_event_open(event_attr, trace_pid, | 461 | fd = self._perf_event_open(event_attr, trace_pid, |
441 | trace_cpu, group_leader, 0) | 462 | trace_cpu, group_leader, 0) |
442 | if fd == -1: | 463 | if fd == -1: |
443 | err = ctypes.get_errno() | 464 | err = ctypes.get_errno() |
444 | raise OSError(err, os.strerror(err), | 465 | raise OSError(err, os.strerror(err), |
@@ -475,6 +496,10 @@ class Event(object): | |||
475 | 496 | ||
476 | class Provider(object): | 497 | class Provider(object): |
477 | """Encapsulates functionalities used by all providers.""" | 498 | """Encapsulates functionalities used by all providers.""" |
499 | def __init__(self, pid): | ||
500 | self.child_events = False | ||
501 | self.pid = pid | ||
502 | |||
478 | @staticmethod | 503 | @staticmethod |
479 | def is_field_wanted(fields_filter, field): | 504 | def is_field_wanted(fields_filter, field): |
480 | """Indicate whether field is valid according to fields_filter.""" | 505 | """Indicate whether field is valid according to fields_filter.""" |
@@ -500,12 +525,12 @@ class TracepointProvider(Provider): | |||
500 | """ | 525 | """ |
501 | def __init__(self, pid, fields_filter): | 526 | def __init__(self, pid, fields_filter): |
502 | self.group_leaders = [] | 527 | self.group_leaders = [] |
503 | self.filters = self.get_filters() | 528 | self.filters = self._get_filters() |
504 | self.update_fields(fields_filter) | 529 | self.update_fields(fields_filter) |
505 | self.pid = pid | 530 | super(TracepointProvider, self).__init__(pid) |
506 | 531 | ||
507 | @staticmethod | 532 | @staticmethod |
508 | def get_filters(): | 533 | def _get_filters(): |
509 | """Returns a dict of trace events, their filter ids and | 534 | """Returns a dict of trace events, their filter ids and |
510 | the values that can be filtered. | 535 | the values that can be filtered. |
511 | 536 | ||
@@ -521,8 +546,8 @@ class TracepointProvider(Provider): | |||
521 | filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) | 546 | filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) |
522 | return filters | 547 | return filters |
523 | 548 | ||
524 | def get_available_fields(self): | 549 | def _get_available_fields(self): |
525 | """Returns a list of available event's of format 'event name(filter | 550 | """Returns a list of available events of format 'event name(filter |
526 | name)'. | 551 | name)'. |
527 | 552 | ||
528 | All available events have directories under | 553 | All available events have directories under |
@@ -549,11 +574,12 @@ class TracepointProvider(Provider): | |||
549 | 574 | ||
550 | def update_fields(self, fields_filter): | 575 | def update_fields(self, fields_filter): |
551 | """Refresh fields, applying fields_filter""" | 576 | """Refresh fields, applying fields_filter""" |
552 | self.fields = [field for field in self.get_available_fields() | 577 | self.fields = [field for field in self._get_available_fields() |
553 | if self.is_field_wanted(fields_filter, field)] | 578 | if self.is_field_wanted(fields_filter, field) or |
579 | ARCH.tracepoint_is_child(field)] | ||
554 | 580 | ||
555 | @staticmethod | 581 | @staticmethod |
556 | def get_online_cpus(): | 582 | def _get_online_cpus(): |
557 | """Returns a list of cpu id integers.""" | 583 | """Returns a list of cpu id integers.""" |
558 | def parse_int_list(list_string): | 584 | def parse_int_list(list_string): |
559 | """Returns an int list from a string of comma separated integers and | 585 | """Returns an int list from a string of comma separated integers and |
@@ -575,17 +601,17 @@ class TracepointProvider(Provider): | |||
575 | cpu_string = cpu_list.readline() | 601 | cpu_string = cpu_list.readline() |
576 | return parse_int_list(cpu_string) | 602 | return parse_int_list(cpu_string) |
577 | 603 | ||
578 | def setup_traces(self): | 604 | def _setup_traces(self): |
579 | """Creates all event and group objects needed to be able to retrieve | 605 | """Creates all event and group objects needed to be able to retrieve |
580 | data.""" | 606 | data.""" |
581 | fields = self.get_available_fields() | 607 | fields = self._get_available_fields() |
582 | if self._pid > 0: | 608 | if self._pid > 0: |
583 | # Fetch list of all threads of the monitored pid, as qemu | 609 | # Fetch list of all threads of the monitored pid, as qemu |
584 | # starts a thread for each vcpu. | 610 | # starts a thread for each vcpu. |
585 | path = os.path.join('/proc', str(self._pid), 'task') | 611 | path = os.path.join('/proc', str(self._pid), 'task') |
586 | groupids = self.walkdir(path)[1] | 612 | groupids = self.walkdir(path)[1] |
587 | else: | 613 | else: |
588 | groupids = self.get_online_cpus() | 614 | groupids = self._get_online_cpus() |
589 | 615 | ||
590 | # The constant is needed as a buffer for python libs, std | 616 | # The constant is needed as a buffer for python libs, std |
591 | # streams and other files that the script opens. | 617 | # streams and other files that the script opens. |
@@ -663,7 +689,7 @@ class TracepointProvider(Provider): | |||
663 | # The garbage collector will get rid of all Event/Group | 689 | # The garbage collector will get rid of all Event/Group |
664 | # objects and open files after removing the references. | 690 | # objects and open files after removing the references. |
665 | self.group_leaders = [] | 691 | self.group_leaders = [] |
666 | self.setup_traces() | 692 | self._setup_traces() |
667 | self.fields = self._fields | 693 | self.fields = self._fields |
668 | 694 | ||
669 | def read(self, by_guest=0): | 695 | def read(self, by_guest=0): |
@@ -671,8 +697,12 @@ class TracepointProvider(Provider): | |||
671 | ret = defaultdict(int) | 697 | ret = defaultdict(int) |
672 | for group in self.group_leaders: | 698 | for group in self.group_leaders: |
673 | for name, val in group.read().items(): | 699 | for name, val in group.read().items(): |
674 | if name in self._fields: | 700 | if name not in self._fields: |
675 | ret[name] += val | 701 | continue |
702 | parent = ARCH.tracepoint_is_child(name) | ||
703 | if parent: | ||
704 | name += ' ' + parent | ||
705 | ret[name] += val | ||
676 | return ret | 706 | return ret |
677 | 707 | ||
678 | def reset(self): | 708 | def reset(self): |
@@ -690,11 +720,11 @@ class DebugfsProvider(Provider): | |||
690 | self._baseline = {} | 720 | self._baseline = {} |
691 | self.do_read = True | 721 | self.do_read = True |
692 | self.paths = [] | 722 | self.paths = [] |
693 | self.pid = pid | 723 | super(DebugfsProvider, self).__init__(pid) |
694 | if include_past: | 724 | if include_past: |
695 | self.restore() | 725 | self._restore() |
696 | 726 | ||
697 | def get_available_fields(self): | 727 | def _get_available_fields(self): |
698 | """"Returns a list of available fields. | 728 | """"Returns a list of available fields. |
699 | 729 | ||
700 | The fields are all available KVM debugfs files | 730 | The fields are all available KVM debugfs files |
@@ -704,8 +734,9 @@ class DebugfsProvider(Provider): | |||
704 | 734 | ||
705 | def update_fields(self, fields_filter): | 735 | def update_fields(self, fields_filter): |
706 | """Refresh fields, applying fields_filter""" | 736 | """Refresh fields, applying fields_filter""" |
707 | self._fields = [field for field in self.get_available_fields() | 737 | self._fields = [field for field in self._get_available_fields() |
708 | if self.is_field_wanted(fields_filter, field)] | 738 | if self.is_field_wanted(fields_filter, field) or |
739 | ARCH.debugfs_is_child(field)] | ||
709 | 740 | ||
710 | @property | 741 | @property |
711 | def fields(self): | 742 | def fields(self): |
@@ -758,7 +789,7 @@ class DebugfsProvider(Provider): | |||
758 | paths.append(dir) | 789 | paths.append(dir) |
759 | for path in paths: | 790 | for path in paths: |
760 | for field in self._fields: | 791 | for field in self._fields: |
761 | value = self.read_field(field, path) | 792 | value = self._read_field(field, path) |
762 | key = path + field | 793 | key = path + field |
763 | if reset == 1: | 794 | if reset == 1: |
764 | self._baseline[key] = value | 795 | self._baseline[key] = value |
@@ -766,20 +797,21 @@ class DebugfsProvider(Provider): | |||
766 | self._baseline[key] = 0 | 797 | self._baseline[key] = 0 |
767 | if self._baseline.get(key, -1) == -1: | 798 | if self._baseline.get(key, -1) == -1: |
768 | self._baseline[key] = value | 799 | self._baseline[key] = value |
769 | increment = (results.get(field, 0) + value - | 800 | parent = ARCH.debugfs_is_child(field) |
770 | self._baseline.get(key, 0)) | 801 | if parent: |
771 | if by_guest: | 802 | field = field + ' ' + parent |
772 | pid = key.split('-')[0] | 803 | else: |
773 | if pid in results: | 804 | if by_guest: |
774 | results[pid] += increment | 805 | field = key.split('-')[0] # set 'field' to 'pid' |
775 | else: | 806 | increment = value - self._baseline.get(key, 0) |
776 | results[pid] = increment | 807 | if field in results: |
808 | results[field] += increment | ||
777 | else: | 809 | else: |
778 | results[field] = increment | 810 | results[field] = increment |
779 | 811 | ||
780 | return results | 812 | return results |
781 | 813 | ||
782 | def read_field(self, field, path): | 814 | def _read_field(self, field, path): |
783 | """Returns the value of a single field from a specific VM.""" | 815 | """Returns the value of a single field from a specific VM.""" |
784 | try: | 816 | try: |
785 | return int(open(os.path.join(PATH_DEBUGFS_KVM, | 817 | return int(open(os.path.join(PATH_DEBUGFS_KVM, |
@@ -794,12 +826,15 @@ class DebugfsProvider(Provider): | |||
794 | self._baseline = {} | 826 | self._baseline = {} |
795 | self.read(1) | 827 | self.read(1) |
796 | 828 | ||
797 | def restore(self): | 829 | def _restore(self): |
798 | """Reset field counters""" | 830 | """Reset field counters""" |
799 | self._baseline = {} | 831 | self._baseline = {} |
800 | self.read(2) | 832 | self.read(2) |
801 | 833 | ||
802 | 834 | ||
835 | EventStat = namedtuple('EventStat', ['value', 'delta']) | ||
836 | |||
837 | |||
803 | class Stats(object): | 838 | class Stats(object): |
804 | """Manages the data providers and the data they provide. | 839 | """Manages the data providers and the data they provide. |
805 | 840 | ||
@@ -808,13 +843,13 @@ class Stats(object): | |||
808 | 843 | ||
809 | """ | 844 | """ |
810 | def __init__(self, options): | 845 | def __init__(self, options): |
811 | self.providers = self.get_providers(options) | 846 | self.providers = self._get_providers(options) |
812 | self._pid_filter = options.pid | 847 | self._pid_filter = options.pid |
813 | self._fields_filter = options.fields | 848 | self._fields_filter = options.fields |
814 | self.values = {} | 849 | self.values = {} |
850 | self._child_events = False | ||
815 | 851 | ||
816 | @staticmethod | 852 | def _get_providers(self, options): |
817 | def get_providers(options): | ||
818 | """Returns a list of data providers depending on the passed options.""" | 853 | """Returns a list of data providers depending on the passed options.""" |
819 | providers = [] | 854 | providers = [] |
820 | 855 | ||
@@ -826,7 +861,7 @@ class Stats(object): | |||
826 | 861 | ||
827 | return providers | 862 | return providers |
828 | 863 | ||
829 | def update_provider_filters(self): | 864 | def _update_provider_filters(self): |
830 | """Propagates fields filters to providers.""" | 865 | """Propagates fields filters to providers.""" |
831 | # As we reset the counters when updating the fields we can | 866 | # As we reset the counters when updating the fields we can |
832 | # also clear the cache of old values. | 867 | # also clear the cache of old values. |
@@ -847,7 +882,7 @@ class Stats(object): | |||
847 | def fields_filter(self, fields_filter): | 882 | def fields_filter(self, fields_filter): |
848 | if fields_filter != self._fields_filter: | 883 | if fields_filter != self._fields_filter: |
849 | self._fields_filter = fields_filter | 884 | self._fields_filter = fields_filter |
850 | self.update_provider_filters() | 885 | self._update_provider_filters() |
851 | 886 | ||
852 | @property | 887 | @property |
853 | def pid_filter(self): | 888 | def pid_filter(self): |
@@ -861,16 +896,33 @@ class Stats(object): | |||
861 | for provider in self.providers: | 896 | for provider in self.providers: |
862 | provider.pid = self._pid_filter | 897 | provider.pid = self._pid_filter |
863 | 898 | ||
899 | @property | ||
900 | def child_events(self): | ||
901 | return self._child_events | ||
902 | |||
903 | @child_events.setter | ||
904 | def child_events(self, val): | ||
905 | self._child_events = val | ||
906 | for provider in self.providers: | ||
907 | provider.child_events = val | ||
908 | |||
864 | def get(self, by_guest=0): | 909 | def get(self, by_guest=0): |
865 | """Returns a dict with field -> (value, delta to last value) of all | 910 | """Returns a dict with field -> (value, delta to last value) of all |
866 | provider data.""" | 911 | provider data. |
912 | Key formats: | ||
913 | * plain: 'key' is event name | ||
914 | * child-parent: 'key' is in format '<child> <parent>' | ||
915 | * pid: 'key' is the pid of the guest, and the record contains the | ||
916 | aggregated event data | ||
917 | These formats are generated by the providers, and handled in class TUI. | ||
918 | """ | ||
867 | for provider in self.providers: | 919 | for provider in self.providers: |
868 | new = provider.read(by_guest=by_guest) | 920 | new = provider.read(by_guest=by_guest) |
869 | for key in new if by_guest else provider.fields: | 921 | for key in new: |
870 | oldval = self.values.get(key, (0, 0))[0] | 922 | oldval = self.values.get(key, EventStat(0, 0)).value |
871 | newval = new.get(key, 0) | 923 | newval = new.get(key, 0) |
872 | newdelta = newval - oldval | 924 | newdelta = newval - oldval |
873 | self.values[key] = (newval, newdelta) | 925 | self.values[key] = EventStat(newval, newdelta) |
874 | return self.values | 926 | return self.values |
875 | 927 | ||
876 | def toggle_display_guests(self, to_pid): | 928 | def toggle_display_guests(self, to_pid): |
@@ -899,10 +951,10 @@ class Stats(object): | |||
899 | self.get(to_pid) | 951 | self.get(to_pid) |
900 | return 0 | 952 | return 0 |
901 | 953 | ||
954 | |||
902 | DELAY_DEFAULT = 3.0 | 955 | DELAY_DEFAULT = 3.0 |
903 | MAX_GUEST_NAME_LEN = 48 | 956 | MAX_GUEST_NAME_LEN = 48 |
904 | MAX_REGEX_LEN = 44 | 957 | MAX_REGEX_LEN = 44 |
905 | DEFAULT_REGEX = r'^[^\(]*$' | ||
906 | SORT_DEFAULT = 0 | 958 | SORT_DEFAULT = 0 |
907 | 959 | ||
908 | 960 | ||
@@ -969,7 +1021,7 @@ class Tui(object): | |||
969 | 1021 | ||
970 | return res | 1022 | return res |
971 | 1023 | ||
972 | def print_all_gnames(self, row): | 1024 | def _print_all_gnames(self, row): |
973 | """Print a list of all running guests along with their pids.""" | 1025 | """Print a list of all running guests along with their pids.""" |
974 | self.screen.addstr(row, 2, '%8s %-60s' % | 1026 | self.screen.addstr(row, 2, '%8s %-60s' % |
975 | ('Pid', 'Guest Name (fuzzy list, might be ' | 1027 | ('Pid', 'Guest Name (fuzzy list, might be ' |
@@ -1032,19 +1084,13 @@ class Tui(object): | |||
1032 | 1084 | ||
1033 | return name | 1085 | return name |
1034 | 1086 | ||
1035 | def update_drilldown(self): | 1087 | def _update_pid(self, pid): |
1036 | """Sets or removes a filter that only allows fields without braces.""" | ||
1037 | if not self.stats.fields_filter: | ||
1038 | self.stats.fields_filter = DEFAULT_REGEX | ||
1039 | |||
1040 | elif self.stats.fields_filter == DEFAULT_REGEX: | ||
1041 | self.stats.fields_filter = None | ||
1042 | |||
1043 | def update_pid(self, pid): | ||
1044 | """Propagates pid selection to stats object.""" | 1088 | """Propagates pid selection to stats object.""" |
1089 | self.screen.addstr(4, 1, 'Updating pid filter...') | ||
1090 | self.screen.refresh() | ||
1045 | self.stats.pid_filter = pid | 1091 | self.stats.pid_filter = pid |
1046 | 1092 | ||
1047 | def refresh_header(self, pid=None): | 1093 | def _refresh_header(self, pid=None): |
1048 | """Refreshes the header.""" | 1094 | """Refreshes the header.""" |
1049 | if pid is None: | 1095 | if pid is None: |
1050 | pid = self.stats.pid_filter | 1096 | pid = self.stats.pid_filter |
@@ -1059,8 +1105,7 @@ class Tui(object): | |||
1059 | .format(pid, gname), curses.A_BOLD) | 1105 | .format(pid, gname), curses.A_BOLD) |
1060 | else: | 1106 | else: |
1061 | self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD) | 1107 | self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD) |
1062 | if self.stats.fields_filter and self.stats.fields_filter \ | 1108 | if self.stats.fields_filter: |
1063 | != DEFAULT_REGEX: | ||
1064 | regex = self.stats.fields_filter | 1109 | regex = self.stats.fields_filter |
1065 | if len(regex) > MAX_REGEX_LEN: | 1110 | if len(regex) > MAX_REGEX_LEN: |
1066 | regex = regex[:MAX_REGEX_LEN] + '...' | 1111 | regex = regex[:MAX_REGEX_LEN] + '...' |
@@ -1075,56 +1120,99 @@ class Tui(object): | |||
1075 | self.screen.addstr(4, 1, 'Collecting data...') | 1120 | self.screen.addstr(4, 1, 'Collecting data...') |
1076 | self.screen.refresh() | 1121 | self.screen.refresh() |
1077 | 1122 | ||
1078 | def refresh_body(self, sleeptime): | 1123 | def _refresh_body(self, sleeptime): |
1124 | def is_child_field(field): | ||
1125 | return field.find('(') != -1 | ||
1126 | |||
1127 | def insert_child(sorted_items, child, values, parent): | ||
1128 | num = len(sorted_items) | ||
1129 | for i in range(0, num): | ||
1130 | # only add child if parent is present | ||
1131 | if parent.startswith(sorted_items[i][0]): | ||
1132 | sorted_items.insert(i + 1, (' ' + child, values)) | ||
1133 | |||
1134 | def get_sorted_events(self, stats): | ||
1135 | """ separate parent and child events """ | ||
1136 | if self._sorting == SORT_DEFAULT: | ||
1137 | def sortkey((_k, v)): | ||
1138 | # sort by (delta value, overall value) | ||
1139 | return (v.delta, v.value) | ||
1140 | else: | ||
1141 | def sortkey((_k, v)): | ||
1142 | # sort by overall value | ||
1143 | return v.value | ||
1144 | |||
1145 | childs = [] | ||
1146 | sorted_items = [] | ||
1147 | # we can't rule out child events to appear prior to parents even | ||
1148 | # when sorted - separate out all children first, and add in later | ||
1149 | for key, values in sorted(stats.items(), key=sortkey, | ||
1150 | reverse=True): | ||
1151 | if values == (0, 0): | ||
1152 | continue | ||
1153 | if key.find(' ') != -1: | ||
1154 | if not self.stats.child_events: | ||
1155 | continue | ||
1156 | childs.insert(0, (key, values)) | ||
1157 | else: | ||
1158 | sorted_items.append((key, values)) | ||
1159 | if self.stats.child_events: | ||
1160 | for key, values in childs: | ||
1161 | (child, parent) = key.split(' ') | ||
1162 | insert_child(sorted_items, child, values, parent) | ||
1163 | |||
1164 | return sorted_items | ||
1165 | |||
1079 | row = 3 | 1166 | row = 3 |
1080 | self.screen.move(row, 0) | 1167 | self.screen.move(row, 0) |
1081 | self.screen.clrtobot() | 1168 | self.screen.clrtobot() |
1082 | stats = self.stats.get(self._display_guests) | 1169 | stats = self.stats.get(self._display_guests) |
1083 | 1170 | total = 0. | |
1084 | def sortCurAvg(x): | 1171 | ctotal = 0. |
1085 | # sort by current events if available | 1172 | for key, values in stats.items(): |
1086 | if stats[x][1]: | 1173 | if self._display_guests: |
1087 | return (-stats[x][1], -stats[x][0]) | 1174 | if self.get_gname_from_pid(key): |
1175 | total += values.value | ||
1176 | continue | ||
1177 | if not key.find(' ') != -1: | ||
1178 | total += values.value | ||
1088 | else: | 1179 | else: |
1089 | return (0, -stats[x][0]) | 1180 | ctotal += values.value |
1181 | if total == 0.: | ||
1182 | # we don't have any fields, or all non-child events are filtered | ||
1183 | total = ctotal | ||
1090 | 1184 | ||
1091 | def sortTotal(x): | 1185 | # print events |
1092 | # sort by totals | ||
1093 | return (0, -stats[x][0]) | ||
1094 | total = 0. | ||
1095 | for key in stats.keys(): | ||
1096 | if key.find('(') is -1: | ||
1097 | total += stats[key][0] | ||
1098 | if self._sorting == SORT_DEFAULT: | ||
1099 | sortkey = sortCurAvg | ||
1100 | else: | ||
1101 | sortkey = sortTotal | ||
1102 | tavg = 0 | 1186 | tavg = 0 |
1103 | for key in sorted(stats.keys(), key=sortkey): | 1187 | tcur = 0 |
1104 | if row >= self.screen.getmaxyx()[0] - 1: | 1188 | for key, values in get_sorted_events(self, stats): |
1105 | break | 1189 | if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0): |
1106 | values = stats[key] | ||
1107 | if not values[0] and not values[1]: | ||
1108 | break | 1190 | break |
1109 | if values[0] is not None: | 1191 | if self._display_guests: |
1110 | cur = int(round(values[1] / sleeptime)) if values[1] else '' | 1192 | key = self.get_gname_from_pid(key) |
1111 | if self._display_guests: | 1193 | if not key: |
1112 | key = self.get_gname_from_pid(key) | 1194 | continue |
1113 | self.screen.addstr(row, 1, '%-40s %10d%7.1f %8s' % | 1195 | cur = int(round(values.delta / sleeptime)) if values.delta else '' |
1114 | (key, values[0], values[0] * 100 / total, | 1196 | if key[0] != ' ': |
1115 | cur)) | 1197 | if values.delta: |
1116 | if cur is not '' and key.find('(') is -1: | 1198 | tcur += values.delta |
1117 | tavg += cur | 1199 | ptotal = values.value |
1200 | ltotal = total | ||
1201 | else: | ||
1202 | ltotal = ptotal | ||
1203 | self.screen.addstr(row, 1, '%-40s %10d%7.1f %8s' % (key, | ||
1204 | values.value, | ||
1205 | values.value * 100 / float(ltotal), cur)) | ||
1118 | row += 1 | 1206 | row += 1 |
1119 | if row == 3: | 1207 | if row == 3: |
1120 | self.screen.addstr(4, 1, 'No matching events reported yet') | 1208 | self.screen.addstr(4, 1, 'No matching events reported yet') |
1121 | else: | 1209 | if row > 4: |
1210 | tavg = int(round(tcur / sleeptime)) if tcur > 0 else '' | ||
1122 | self.screen.addstr(row, 1, '%-40s %10d %8s' % | 1211 | self.screen.addstr(row, 1, '%-40s %10d %8s' % |
1123 | ('Total', total, tavg if tavg else ''), | 1212 | ('Total', total, tavg), curses.A_BOLD) |
1124 | curses.A_BOLD) | ||
1125 | self.screen.refresh() | 1213 | self.screen.refresh() |
1126 | 1214 | ||
1127 | def show_msg(self, text): | 1215 | def _show_msg(self, text): |
1128 | """Display message centered text and exit on key press""" | 1216 | """Display message centered text and exit on key press""" |
1129 | hint = 'Press any key to continue' | 1217 | hint = 'Press any key to continue' |
1130 | curses.cbreak() | 1218 | curses.cbreak() |
@@ -1139,16 +1227,16 @@ class Tui(object): | |||
1139 | curses.A_STANDOUT) | 1227 | curses.A_STANDOUT) |
1140 | self.screen.getkey() | 1228 | self.screen.getkey() |
1141 | 1229 | ||
1142 | def show_help_interactive(self): | 1230 | def _show_help_interactive(self): |
1143 | """Display help with list of interactive commands""" | 1231 | """Display help with list of interactive commands""" |
1144 | msg = (' b toggle events by guests (debugfs only, honors' | 1232 | msg = (' b toggle events by guests (debugfs only, honors' |
1145 | ' filters)', | 1233 | ' filters)', |
1146 | ' c clear filter', | 1234 | ' c clear filter', |
1147 | ' f filter by regular expression', | 1235 | ' f filter by regular expression', |
1148 | ' g filter by guest name', | 1236 | ' g filter by guest name/PID', |
1149 | ' h display interactive commands reference', | 1237 | ' h display interactive commands reference', |
1150 | ' o toggle sorting order (Total vs CurAvg/s)', | 1238 | ' o toggle sorting order (Total vs CurAvg/s)', |
1151 | ' p filter by PID', | 1239 | ' p filter by guest name/PID', |
1152 | ' q quit', | 1240 | ' q quit', |
1153 | ' r reset stats', | 1241 | ' r reset stats', |
1154 | ' s set update interval', | 1242 | ' s set update interval', |
@@ -1165,14 +1253,15 @@ class Tui(object): | |||
1165 | self.screen.addstr(row, 0, line) | 1253 | self.screen.addstr(row, 0, line) |
1166 | row += 1 | 1254 | row += 1 |
1167 | self.screen.getkey() | 1255 | self.screen.getkey() |
1168 | self.refresh_header() | 1256 | self._refresh_header() |
1169 | 1257 | ||
1170 | def show_filter_selection(self): | 1258 | def _show_filter_selection(self): |
1171 | """Draws filter selection mask. | 1259 | """Draws filter selection mask. |
1172 | 1260 | ||
1173 | Asks for a valid regex and sets the fields filter accordingly. | 1261 | Asks for a valid regex and sets the fields filter accordingly. |
1174 | 1262 | ||
1175 | """ | 1263 | """ |
1264 | msg = '' | ||
1176 | while True: | 1265 | while True: |
1177 | self.screen.erase() | 1266 | self.screen.erase() |
1178 | self.screen.addstr(0, 0, | 1267 | self.screen.addstr(0, 0, |
@@ -1181,61 +1270,25 @@ class Tui(object): | |||
1181 | self.screen.addstr(2, 0, | 1270 | self.screen.addstr(2, 0, |
1182 | "Current regex: {0}" | 1271 | "Current regex: {0}" |
1183 | .format(self.stats.fields_filter)) | 1272 | .format(self.stats.fields_filter)) |
1273 | self.screen.addstr(5, 0, msg) | ||
1184 | self.screen.addstr(3, 0, "New regex: ") | 1274 | self.screen.addstr(3, 0, "New regex: ") |
1185 | curses.echo() | 1275 | curses.echo() |
1186 | regex = self.screen.getstr().decode(ENCODING) | 1276 | regex = self.screen.getstr().decode(ENCODING) |
1187 | curses.noecho() | 1277 | curses.noecho() |
1188 | if len(regex) == 0: | 1278 | if len(regex) == 0: |
1189 | self.stats.fields_filter = DEFAULT_REGEX | 1279 | self.stats.fields_filter = '' |
1190 | self.refresh_header() | 1280 | self._refresh_header() |
1191 | return | 1281 | return |
1192 | try: | 1282 | try: |
1193 | re.compile(regex) | 1283 | re.compile(regex) |
1194 | self.stats.fields_filter = regex | 1284 | self.stats.fields_filter = regex |
1195 | self.refresh_header() | 1285 | self._refresh_header() |
1196 | return | 1286 | return |
1197 | except re.error: | 1287 | except re.error: |
1288 | msg = '"' + regex + '": Not a valid regular expression' | ||
1198 | continue | 1289 | continue |
1199 | 1290 | ||
1200 | def show_vm_selection_by_pid(self): | 1291 | def _show_set_update_interval(self): |
1201 | """Draws PID selection mask. | ||
1202 | |||
1203 | Asks for a pid until a valid pid or 0 has been entered. | ||
1204 | |||
1205 | """ | ||
1206 | msg = '' | ||
1207 | while True: | ||
1208 | self.screen.erase() | ||
1209 | self.screen.addstr(0, 0, | ||
1210 | 'Show statistics for specific pid.', | ||
1211 | curses.A_BOLD) | ||
1212 | self.screen.addstr(1, 0, | ||
1213 | 'This might limit the shown data to the trace ' | ||
1214 | 'statistics.') | ||
1215 | self.screen.addstr(5, 0, msg) | ||
1216 | self.print_all_gnames(7) | ||
1217 | |||
1218 | curses.echo() | ||
1219 | self.screen.addstr(3, 0, "Pid [0 or pid]: ") | ||
1220 | pid = self.screen.getstr().decode(ENCODING) | ||
1221 | curses.noecho() | ||
1222 | |||
1223 | try: | ||
1224 | if len(pid) > 0: | ||
1225 | pid = int(pid) | ||
1226 | if pid != 0 and not os.path.isdir(os.path.join('/proc/', | ||
1227 | str(pid))): | ||
1228 | msg = '"' + str(pid) + '": Not a running process' | ||
1229 | continue | ||
1230 | else: | ||
1231 | pid = 0 | ||
1232 | self.refresh_header(pid) | ||
1233 | self.update_pid(pid) | ||
1234 | break | ||
1235 | except ValueError: | ||
1236 | msg = '"' + str(pid) + '": Not a valid pid' | ||
1237 | |||
1238 | def show_set_update_interval(self): | ||
1239 | """Draws update interval selection mask.""" | 1292 | """Draws update interval selection mask.""" |
1240 | msg = '' | 1293 | msg = '' |
1241 | while True: | 1294 | while True: |
@@ -1265,60 +1318,67 @@ class Tui(object): | |||
1265 | 1318 | ||
1266 | except ValueError: | 1319 | except ValueError: |
1267 | msg = '"' + str(val) + '": Invalid value' | 1320 | msg = '"' + str(val) + '": Invalid value' |
1268 | self.refresh_header() | 1321 | self._refresh_header() |
1269 | 1322 | ||
1270 | def show_vm_selection_by_guest_name(self): | 1323 | def _show_vm_selection_by_guest(self): |
1271 | """Draws guest selection mask. | 1324 | """Draws guest selection mask. |
1272 | 1325 | ||
1273 | Asks for a guest name until a valid guest name or '' is entered. | 1326 | Asks for a guest name or pid until a valid guest name or '' is entered. |
1274 | 1327 | ||
1275 | """ | 1328 | """ |
1276 | msg = '' | 1329 | msg = '' |
1277 | while True: | 1330 | while True: |
1278 | self.screen.erase() | 1331 | self.screen.erase() |
1279 | self.screen.addstr(0, 0, | 1332 | self.screen.addstr(0, 0, |
1280 | 'Show statistics for specific guest.', | 1333 | 'Show statistics for specific guest or pid.', |
1281 | curses.A_BOLD) | 1334 | curses.A_BOLD) |
1282 | self.screen.addstr(1, 0, | 1335 | self.screen.addstr(1, 0, |
1283 | 'This might limit the shown data to the trace ' | 1336 | 'This might limit the shown data to the trace ' |
1284 | 'statistics.') | 1337 | 'statistics.') |
1285 | self.screen.addstr(5, 0, msg) | 1338 | self.screen.addstr(5, 0, msg) |
1286 | self.print_all_gnames(7) | 1339 | self._print_all_gnames(7) |
1287 | curses.echo() | 1340 | curses.echo() |
1288 | self.screen.addstr(3, 0, "Guest [ENTER or guest]: ") | 1341 | curses.curs_set(1) |
1289 | gname = self.screen.getstr().decode(ENCODING) | 1342 | self.screen.addstr(3, 0, "Guest or pid [ENTER exits]: ") |
1343 | guest = self.screen.getstr().decode(ENCODING) | ||
1290 | curses.noecho() | 1344 | curses.noecho() |
1291 | 1345 | ||
1292 | if not gname: | 1346 | pid = 0 |
1293 | self.refresh_header(0) | 1347 | if not guest or guest == '0': |
1294 | self.update_pid(0) | ||
1295 | break | 1348 | break |
1296 | else: | 1349 | if guest.isdigit(): |
1297 | pids = [] | 1350 | if not os.path.isdir(os.path.join('/proc/', guest)): |
1298 | try: | 1351 | msg = '"' + guest + '": Not a running process' |
1299 | pids = self.get_pid_from_gname(gname) | ||
1300 | except: | ||
1301 | msg = '"' + gname + '": Internal error while searching, ' \ | ||
1302 | 'use pid filter instead' | ||
1303 | continue | ||
1304 | if len(pids) == 0: | ||
1305 | msg = '"' + gname + '": Not an active guest' | ||
1306 | continue | 1352 | continue |
1307 | if len(pids) > 1: | 1353 | pid = int(guest) |
1308 | msg = '"' + gname + '": Multiple matches found, use pid ' \ | ||
1309 | 'filter instead' | ||
1310 | continue | ||
1311 | self.refresh_header(pids[0]) | ||
1312 | self.update_pid(pids[0]) | ||
1313 | break | 1354 | break |
1355 | pids = [] | ||
1356 | try: | ||
1357 | pids = self.get_pid_from_gname(guest) | ||
1358 | except: | ||
1359 | msg = '"' + guest + '": Internal error while searching, ' \ | ||
1360 | 'use pid filter instead' | ||
1361 | continue | ||
1362 | if len(pids) == 0: | ||
1363 | msg = '"' + guest + '": Not an active guest' | ||
1364 | continue | ||
1365 | if len(pids) > 1: | ||
1366 | msg = '"' + guest + '": Multiple matches found, use pid ' \ | ||
1367 | 'filter instead' | ||
1368 | continue | ||
1369 | pid = pids[0] | ||
1370 | break | ||
1371 | curses.curs_set(0) | ||
1372 | self._refresh_header(pid) | ||
1373 | self._update_pid(pid) | ||
1314 | 1374 | ||
1315 | def show_stats(self): | 1375 | def show_stats(self): |
1316 | """Refreshes the screen and processes user input.""" | 1376 | """Refreshes the screen and processes user input.""" |
1317 | sleeptime = self._delay_initial | 1377 | sleeptime = self._delay_initial |
1318 | self.refresh_header() | 1378 | self._refresh_header() |
1319 | start = 0.0 # result based on init value never appears on screen | 1379 | start = 0.0 # result based on init value never appears on screen |
1320 | while True: | 1380 | while True: |
1321 | self.refresh_body(time.time() - start) | 1381 | self._refresh_body(time.time() - start) |
1322 | curses.halfdelay(int(sleeptime * 10)) | 1382 | curses.halfdelay(int(sleeptime * 10)) |
1323 | start = time.time() | 1383 | start = time.time() |
1324 | sleeptime = self._delay_regular | 1384 | sleeptime = self._delay_regular |
@@ -1327,47 +1387,39 @@ class Tui(object): | |||
1327 | if char == 'b': | 1387 | if char == 'b': |
1328 | self._display_guests = not self._display_guests | 1388 | self._display_guests = not self._display_guests |
1329 | if self.stats.toggle_display_guests(self._display_guests): | 1389 | if self.stats.toggle_display_guests(self._display_guests): |
1330 | self.show_msg(['Command not available with tracepoints' | 1390 | self._show_msg(['Command not available with ' |
1331 | ' enabled', 'Restart with debugfs only ' | 1391 | 'tracepoints enabled', 'Restart with ' |
1332 | '(see option \'-d\') and try again!']) | 1392 | 'debugfs only (see option \'-d\') and ' |
1393 | 'try again!']) | ||
1333 | self._display_guests = not self._display_guests | 1394 | self._display_guests = not self._display_guests |
1334 | self.refresh_header() | 1395 | self._refresh_header() |
1335 | if char == 'c': | 1396 | if char == 'c': |
1336 | self.stats.fields_filter = DEFAULT_REGEX | 1397 | self.stats.fields_filter = '' |
1337 | self.refresh_header(0) | 1398 | self._refresh_header(0) |
1338 | self.update_pid(0) | 1399 | self._update_pid(0) |
1339 | if char == 'f': | 1400 | if char == 'f': |
1340 | curses.curs_set(1) | 1401 | curses.curs_set(1) |
1341 | self.show_filter_selection() | 1402 | self._show_filter_selection() |
1342 | curses.curs_set(0) | 1403 | curses.curs_set(0) |
1343 | sleeptime = self._delay_initial | 1404 | sleeptime = self._delay_initial |
1344 | if char == 'g': | 1405 | if char == 'g' or char == 'p': |
1345 | curses.curs_set(1) | 1406 | self._show_vm_selection_by_guest() |
1346 | self.show_vm_selection_by_guest_name() | ||
1347 | curses.curs_set(0) | ||
1348 | sleeptime = self._delay_initial | 1407 | sleeptime = self._delay_initial |
1349 | if char == 'h': | 1408 | if char == 'h': |
1350 | self.show_help_interactive() | 1409 | self._show_help_interactive() |
1351 | if char == 'o': | 1410 | if char == 'o': |
1352 | self._sorting = not self._sorting | 1411 | self._sorting = not self._sorting |
1353 | if char == 'p': | ||
1354 | curses.curs_set(1) | ||
1355 | self.show_vm_selection_by_pid() | ||
1356 | curses.curs_set(0) | ||
1357 | sleeptime = self._delay_initial | ||
1358 | if char == 'q': | 1412 | if char == 'q': |
1359 | break | 1413 | break |
1360 | if char == 'r': | 1414 | if char == 'r': |
1361 | self.stats.reset() | 1415 | self.stats.reset() |
1362 | if char == 's': | 1416 | if char == 's': |
1363 | curses.curs_set(1) | 1417 | curses.curs_set(1) |
1364 | self.show_set_update_interval() | 1418 | self._show_set_update_interval() |
1365 | curses.curs_set(0) | 1419 | curses.curs_set(0) |
1366 | sleeptime = self._delay_initial | 1420 | sleeptime = self._delay_initial |
1367 | if char == 'x': | 1421 | if char == 'x': |
1368 | self.update_drilldown() | 1422 | self.stats.child_events = not self.stats.child_events |
1369 | # prevents display of current values on next refresh | ||
1370 | self.stats.get(self._display_guests) | ||
1371 | except KeyboardInterrupt: | 1423 | except KeyboardInterrupt: |
1372 | break | 1424 | break |
1373 | except curses.error: | 1425 | except curses.error: |
@@ -1380,9 +1432,9 @@ def batch(stats): | |||
1380 | s = stats.get() | 1432 | s = stats.get() |
1381 | time.sleep(1) | 1433 | time.sleep(1) |
1382 | s = stats.get() | 1434 | s = stats.get() |
1383 | for key in sorted(s.keys()): | 1435 | for key, values in sorted(s.items()): |
1384 | values = s[key] | 1436 | print('%-42s%10d%10d' % (key.split(' ')[0], values.value, |
1385 | print('%-42s%10d%10d' % (key, values[0], values[1])) | 1437 | values.delta)) |
1386 | except KeyboardInterrupt: | 1438 | except KeyboardInterrupt: |
1387 | pass | 1439 | pass |
1388 | 1440 | ||
@@ -1392,14 +1444,14 @@ def log(stats): | |||
1392 | keys = sorted(stats.get().keys()) | 1444 | keys = sorted(stats.get().keys()) |
1393 | 1445 | ||
1394 | def banner(): | 1446 | def banner(): |
1395 | for k in keys: | 1447 | for key in keys: |
1396 | print(k, end=' ') | 1448 | print(key.split(' ')[0], end=' ') |
1397 | print() | 1449 | print() |
1398 | 1450 | ||
1399 | def statline(): | 1451 | def statline(): |
1400 | s = stats.get() | 1452 | s = stats.get() |
1401 | for k in keys: | 1453 | for key in keys: |
1402 | print(' %9d' % s[k][1], end=' ') | 1454 | print(' %9d' % s[key].delta, end=' ') |
1403 | print() | 1455 | print() |
1404 | line = 0 | 1456 | line = 0 |
1405 | banner_repeat = 20 | 1457 | banner_repeat = 20 |
@@ -1504,7 +1556,7 @@ Press any other key to refresh statistics immediately. | |||
1504 | ) | 1556 | ) |
1505 | optparser.add_option('-f', '--fields', | 1557 | optparser.add_option('-f', '--fields', |
1506 | action='store', | 1558 | action='store', |
1507 | default=DEFAULT_REGEX, | 1559 | default='', |
1508 | dest='fields', | 1560 | dest='fields', |
1509 | help='''fields to display (regex) | 1561 | help='''fields to display (regex) |
1510 | "-f help" for a list of available events''', | 1562 | "-f help" for a list of available events''', |
@@ -1539,17 +1591,6 @@ Press any other key to refresh statistics immediately. | |||
1539 | 1591 | ||
1540 | def check_access(options): | 1592 | def check_access(options): |
1541 | """Exits if the current user can't access all needed directories.""" | 1593 | """Exits if the current user can't access all needed directories.""" |
1542 | if not os.path.exists('/sys/kernel/debug'): | ||
1543 | sys.stderr.write('Please enable CONFIG_DEBUG_FS in your kernel.') | ||
1544 | sys.exit(1) | ||
1545 | |||
1546 | if not os.path.exists(PATH_DEBUGFS_KVM): | ||
1547 | sys.stderr.write("Please make sure, that debugfs is mounted and " | ||
1548 | "readable by the current user:\n" | ||
1549 | "('mount -t debugfs debugfs /sys/kernel/debug')\n" | ||
1550 | "Also ensure, that the kvm modules are loaded.\n") | ||
1551 | sys.exit(1) | ||
1552 | |||
1553 | if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints or | 1594 | if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints or |
1554 | not options.debugfs): | 1595 | not options.debugfs): |
1555 | sys.stderr.write("Please enable CONFIG_TRACING in your kernel " | 1596 | sys.stderr.write("Please enable CONFIG_TRACING in your kernel " |
@@ -1567,7 +1608,33 @@ def check_access(options): | |||
1567 | return options | 1608 | return options |
1568 | 1609 | ||
1569 | 1610 | ||
1611 | def assign_globals(): | ||
1612 | global PATH_DEBUGFS_KVM | ||
1613 | global PATH_DEBUGFS_TRACING | ||
1614 | |||
1615 | debugfs = '' | ||
1616 | for line in file('/proc/mounts'): | ||
1617 | if line.split(' ')[0] == 'debugfs': | ||
1618 | debugfs = line.split(' ')[1] | ||
1619 | break | ||
1620 | if debugfs == '': | ||
1621 | sys.stderr.write("Please make sure that CONFIG_DEBUG_FS is enabled in " | ||
1622 | "your kernel, mounted and\nreadable by the current " | ||
1623 | "user:\n" | ||
1624 | "('mount -t debugfs debugfs /sys/kernel/debug')\n") | ||
1625 | sys.exit(1) | ||
1626 | |||
1627 | PATH_DEBUGFS_KVM = os.path.join(debugfs, 'kvm') | ||
1628 | PATH_DEBUGFS_TRACING = os.path.join(debugfs, 'tracing') | ||
1629 | |||
1630 | if not os.path.exists(PATH_DEBUGFS_KVM): | ||
1631 | sys.stderr.write("Please make sure that CONFIG_KVM is enabled in " | ||
1632 | "your kernel and that the modules are loaded.\n") | ||
1633 | sys.exit(1) | ||
1634 | |||
1635 | |||
1570 | def main(): | 1636 | def main(): |
1637 | assign_globals() | ||
1571 | options = get_options() | 1638 | options = get_options() |
1572 | options = check_access(options) | 1639 | options = check_access(options) |
1573 | 1640 | ||
diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt index b5b3810c9e94..0811d860fe75 100644 --- a/tools/kvm/kvm_stat/kvm_stat.txt +++ b/tools/kvm/kvm_stat/kvm_stat.txt | |||
@@ -35,13 +35,13 @@ INTERACTIVE COMMANDS | |||
35 | 35 | ||
36 | *f*:: filter by regular expression | 36 | *f*:: filter by regular expression |
37 | 37 | ||
38 | *g*:: filter by guest name | 38 | *g*:: filter by guest name/PID |
39 | 39 | ||
40 | *h*:: display interactive commands reference | 40 | *h*:: display interactive commands reference |
41 | 41 | ||
42 | *o*:: toggle sorting order (Total vs CurAvg/s) | 42 | *o*:: toggle sorting order (Total vs CurAvg/s) |
43 | 43 | ||
44 | *p*:: filter by PID | 44 | *p*:: filter by guest name/PID |
45 | 45 | ||
46 | *q*:: quit | 46 | *q*:: quit |
47 | 47 | ||
diff --git a/tools/laptop/freefall/Makefile b/tools/laptop/freefall/Makefile index 5f758c489a20..b572d94255f6 100644 --- a/tools/laptop/freefall/Makefile +++ b/tools/laptop/freefall/Makefile | |||
@@ -2,7 +2,6 @@ | |||
2 | PREFIX ?= /usr | 2 | PREFIX ?= /usr |
3 | SBINDIR ?= sbin | 3 | SBINDIR ?= sbin |
4 | INSTALL ?= install | 4 | INSTALL ?= install |
5 | CC = $(CROSS_COMPILE)gcc | ||
6 | 5 | ||
7 | TARGET = freefall | 6 | TARGET = freefall |
8 | 7 | ||
diff --git a/tools/leds/Makefile b/tools/leds/Makefile index c379af003807..7b6bed13daaa 100644 --- a/tools/leds/Makefile +++ b/tools/leds/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for LEDs tools | 2 | # Makefile for LEDs tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | CFLAGS = -Wall -Wextra -g -I../../include/uapi | 4 | CFLAGS = -Wall -Wextra -g -I../../include/uapi |
6 | 5 | ||
7 | all: uledmon led_hw_brightness_mon | 6 | all: uledmon led_hw_brightness_mon |
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 97073d649c1a..5bbbf285af74 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1060,11 +1060,12 @@ bpf_program__reloc_text(struct bpf_program *prog, struct bpf_object *obj, | |||
1060 | prog->insns = new_insn; | 1060 | prog->insns = new_insn; |
1061 | prog->main_prog_cnt = prog->insns_cnt; | 1061 | prog->main_prog_cnt = prog->insns_cnt; |
1062 | prog->insns_cnt = new_cnt; | 1062 | prog->insns_cnt = new_cnt; |
1063 | pr_debug("added %zd insn from %s to prog %s\n", | ||
1064 | text->insns_cnt, text->section_name, | ||
1065 | prog->section_name); | ||
1063 | } | 1066 | } |
1064 | insn = &prog->insns[relo->insn_idx]; | 1067 | insn = &prog->insns[relo->insn_idx]; |
1065 | insn->imm += prog->main_prog_cnt - relo->insn_idx; | 1068 | insn->imm += prog->main_prog_cnt - relo->insn_idx; |
1066 | pr_debug("added %zd insn from %s to prog %s\n", | ||
1067 | text->insns_cnt, text->section_name, prog->section_name); | ||
1068 | return 0; | 1069 | return 0; |
1069 | } | 1070 | } |
1070 | 1071 | ||
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 57254f5b2779..694abc628e9b 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "builtin.h" | 29 | #include "builtin.h" |
30 | #include "check.h" | 30 | #include "check.h" |
31 | 31 | ||
32 | bool no_fp, no_unreachable; | 32 | bool no_fp, no_unreachable, retpoline, module; |
33 | 33 | ||
34 | static const char * const check_usage[] = { | 34 | static const char * const check_usage[] = { |
35 | "objtool check [<options>] file.o", | 35 | "objtool check [<options>] file.o", |
@@ -39,6 +39,8 @@ static const char * const check_usage[] = { | |||
39 | const struct option check_options[] = { | 39 | const struct option check_options[] = { |
40 | OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), | 40 | OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), |
41 | OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), | 41 | OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), |
42 | OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"), | ||
43 | OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"), | ||
42 | OPT_END(), | 44 | OPT_END(), |
43 | }; | 45 | }; |
44 | 46 | ||
@@ -53,5 +55,5 @@ int cmd_check(int argc, const char **argv) | |||
53 | 55 | ||
54 | objname = argv[0]; | 56 | objname = argv[0]; |
55 | 57 | ||
56 | return check(objname, no_fp, no_unreachable, false); | 58 | return check(objname, false); |
57 | } | 59 | } |
diff --git a/tools/objtool/builtin-orc.c b/tools/objtool/builtin-orc.c index 91e8e19ff5e0..77ea2b97117d 100644 --- a/tools/objtool/builtin-orc.c +++ b/tools/objtool/builtin-orc.c | |||
@@ -25,7 +25,6 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <subcmd/parse-options.h> | ||
29 | #include "builtin.h" | 28 | #include "builtin.h" |
30 | #include "check.h" | 29 | #include "check.h" |
31 | 30 | ||
@@ -36,9 +35,6 @@ static const char *orc_usage[] = { | |||
36 | NULL, | 35 | NULL, |
37 | }; | 36 | }; |
38 | 37 | ||
39 | extern const struct option check_options[]; | ||
40 | extern bool no_fp, no_unreachable; | ||
41 | |||
42 | int cmd_orc(int argc, const char **argv) | 38 | int cmd_orc(int argc, const char **argv) |
43 | { | 39 | { |
44 | const char *objname; | 40 | const char *objname; |
@@ -54,7 +50,7 @@ int cmd_orc(int argc, const char **argv) | |||
54 | 50 | ||
55 | objname = argv[0]; | 51 | objname = argv[0]; |
56 | 52 | ||
57 | return check(objname, no_fp, no_unreachable, true); | 53 | return check(objname, true); |
58 | } | 54 | } |
59 | 55 | ||
60 | if (!strcmp(argv[0], "dump")) { | 56 | if (!strcmp(argv[0], "dump")) { |
diff --git a/tools/objtool/builtin.h b/tools/objtool/builtin.h index dd526067fed5..28ff40e19a14 100644 --- a/tools/objtool/builtin.h +++ b/tools/objtool/builtin.h | |||
@@ -17,6 +17,11 @@ | |||
17 | #ifndef _BUILTIN_H | 17 | #ifndef _BUILTIN_H |
18 | #define _BUILTIN_H | 18 | #define _BUILTIN_H |
19 | 19 | ||
20 | #include <subcmd/parse-options.h> | ||
21 | |||
22 | extern const struct option check_options[]; | ||
23 | extern bool no_fp, no_unreachable, retpoline, module; | ||
24 | |||
20 | extern int cmd_check(int argc, const char **argv); | 25 | extern int cmd_check(int argc, const char **argv); |
21 | extern int cmd_orc(int argc, const char **argv); | 26 | extern int cmd_orc(int argc, const char **argv); |
22 | 27 | ||
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b00b1896547e..92b6a2c21631 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <string.h> | 18 | #include <string.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | 20 | ||
21 | #include "builtin.h" | ||
21 | #include "check.h" | 22 | #include "check.h" |
22 | #include "elf.h" | 23 | #include "elf.h" |
23 | #include "special.h" | 24 | #include "special.h" |
@@ -33,7 +34,6 @@ struct alternative { | |||
33 | }; | 34 | }; |
34 | 35 | ||
35 | const char *objname; | 36 | const char *objname; |
36 | static bool no_fp; | ||
37 | struct cfi_state initial_func_cfi; | 37 | struct cfi_state initial_func_cfi; |
38 | 38 | ||
39 | struct instruction *find_insn(struct objtool_file *file, | 39 | struct instruction *find_insn(struct objtool_file *file, |
@@ -497,6 +497,7 @@ static int add_jump_destinations(struct objtool_file *file) | |||
497 | * disguise, so convert them accordingly. | 497 | * disguise, so convert them accordingly. |
498 | */ | 498 | */ |
499 | insn->type = INSN_JUMP_DYNAMIC; | 499 | insn->type = INSN_JUMP_DYNAMIC; |
500 | insn->retpoline_safe = true; | ||
500 | continue; | 501 | continue; |
501 | } else { | 502 | } else { |
502 | /* sibling call */ | 503 | /* sibling call */ |
@@ -548,7 +549,8 @@ static int add_call_destinations(struct objtool_file *file) | |||
548 | if (!insn->call_dest && !insn->ignore) { | 549 | if (!insn->call_dest && !insn->ignore) { |
549 | WARN_FUNC("unsupported intra-function call", | 550 | WARN_FUNC("unsupported intra-function call", |
550 | insn->sec, insn->offset); | 551 | insn->sec, insn->offset); |
551 | WARN("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE."); | 552 | if (retpoline) |
553 | WARN("If this is a retpoline, please patch it in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE."); | ||
552 | return -1; | 554 | return -1; |
553 | } | 555 | } |
554 | 556 | ||
@@ -852,8 +854,14 @@ static int add_switch_table(struct objtool_file *file, struct symbol *func, | |||
852 | * This is a fairly uncommon pattern which is new for GCC 6. As of this | 854 | * This is a fairly uncommon pattern which is new for GCC 6. As of this |
853 | * writing, there are 11 occurrences of it in the allmodconfig kernel. | 855 | * writing, there are 11 occurrences of it in the allmodconfig kernel. |
854 | * | 856 | * |
857 | * As of GCC 7 there are quite a few more of these and the 'in between' code | ||
858 | * is significant. Esp. with KASAN enabled some of the code between the mov | ||
859 | * and jmpq uses .rodata itself, which can confuse things. | ||
860 | * | ||
855 | * TODO: Once we have DWARF CFI and smarter instruction decoding logic, | 861 | * TODO: Once we have DWARF CFI and smarter instruction decoding logic, |
856 | * ensure the same register is used in the mov and jump instructions. | 862 | * ensure the same register is used in the mov and jump instructions. |
863 | * | ||
864 | * NOTE: RETPOLINE made it harder still to decode dynamic jumps. | ||
857 | */ | 865 | */ |
858 | static struct rela *find_switch_table(struct objtool_file *file, | 866 | static struct rela *find_switch_table(struct objtool_file *file, |
859 | struct symbol *func, | 867 | struct symbol *func, |
@@ -875,12 +883,25 @@ static struct rela *find_switch_table(struct objtool_file *file, | |||
875 | text_rela->addend + 4); | 883 | text_rela->addend + 4); |
876 | if (!rodata_rela) | 884 | if (!rodata_rela) |
877 | return NULL; | 885 | return NULL; |
886 | |||
878 | file->ignore_unreachables = true; | 887 | file->ignore_unreachables = true; |
879 | return rodata_rela; | 888 | return rodata_rela; |
880 | } | 889 | } |
881 | 890 | ||
882 | /* case 3 */ | 891 | /* case 3 */ |
883 | func_for_each_insn_continue_reverse(file, func, insn) { | 892 | /* |
893 | * Backward search using the @first_jump_src links, these help avoid | ||
894 | * much of the 'in between' code. Which avoids us getting confused by | ||
895 | * it. | ||
896 | */ | ||
897 | for (insn = list_prev_entry(insn, list); | ||
898 | |||
899 | &insn->list != &file->insn_list && | ||
900 | insn->sec == func->sec && | ||
901 | insn->offset >= func->offset; | ||
902 | |||
903 | insn = insn->first_jump_src ?: list_prev_entry(insn, list)) { | ||
904 | |||
884 | if (insn->type == INSN_JUMP_DYNAMIC) | 905 | if (insn->type == INSN_JUMP_DYNAMIC) |
885 | break; | 906 | break; |
886 | 907 | ||
@@ -904,20 +925,42 @@ static struct rela *find_switch_table(struct objtool_file *file, | |||
904 | if (find_symbol_containing(file->rodata, text_rela->addend)) | 925 | if (find_symbol_containing(file->rodata, text_rela->addend)) |
905 | continue; | 926 | continue; |
906 | 927 | ||
907 | return find_rela_by_dest(file->rodata, text_rela->addend); | 928 | rodata_rela = find_rela_by_dest(file->rodata, text_rela->addend); |
929 | if (!rodata_rela) | ||
930 | continue; | ||
931 | |||
932 | return rodata_rela; | ||
908 | } | 933 | } |
909 | 934 | ||
910 | return NULL; | 935 | return NULL; |
911 | } | 936 | } |
912 | 937 | ||
938 | |||
913 | static int add_func_switch_tables(struct objtool_file *file, | 939 | static int add_func_switch_tables(struct objtool_file *file, |
914 | struct symbol *func) | 940 | struct symbol *func) |
915 | { | 941 | { |
916 | struct instruction *insn, *prev_jump = NULL; | 942 | struct instruction *insn, *last = NULL, *prev_jump = NULL; |
917 | struct rela *rela, *prev_rela = NULL; | 943 | struct rela *rela, *prev_rela = NULL; |
918 | int ret; | 944 | int ret; |
919 | 945 | ||
920 | func_for_each_insn(file, func, insn) { | 946 | func_for_each_insn(file, func, insn) { |
947 | if (!last) | ||
948 | last = insn; | ||
949 | |||
950 | /* | ||
951 | * Store back-pointers for unconditional forward jumps such | ||
952 | * that find_switch_table() can back-track using those and | ||
953 | * avoid some potentially confusing code. | ||
954 | */ | ||
955 | if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest && | ||
956 | insn->offset > last->offset && | ||
957 | insn->jump_dest->offset > insn->offset && | ||
958 | !insn->jump_dest->first_jump_src) { | ||
959 | |||
960 | insn->jump_dest->first_jump_src = insn; | ||
961 | last = insn->jump_dest; | ||
962 | } | ||
963 | |||
921 | if (insn->type != INSN_JUMP_DYNAMIC) | 964 | if (insn->type != INSN_JUMP_DYNAMIC) |
922 | continue; | 965 | continue; |
923 | 966 | ||
@@ -1071,6 +1114,41 @@ static int read_unwind_hints(struct objtool_file *file) | |||
1071 | return 0; | 1114 | return 0; |
1072 | } | 1115 | } |
1073 | 1116 | ||
1117 | static int read_retpoline_hints(struct objtool_file *file) | ||
1118 | { | ||
1119 | struct section *sec; | ||
1120 | struct instruction *insn; | ||
1121 | struct rela *rela; | ||
1122 | |||
1123 | sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); | ||
1124 | if (!sec) | ||
1125 | return 0; | ||
1126 | |||
1127 | list_for_each_entry(rela, &sec->rela_list, list) { | ||
1128 | if (rela->sym->type != STT_SECTION) { | ||
1129 | WARN("unexpected relocation symbol type in %s", sec->name); | ||
1130 | return -1; | ||
1131 | } | ||
1132 | |||
1133 | insn = find_insn(file, rela->sym->sec, rela->addend); | ||
1134 | if (!insn) { | ||
1135 | WARN("bad .discard.retpoline_safe entry"); | ||
1136 | return -1; | ||
1137 | } | ||
1138 | |||
1139 | if (insn->type != INSN_JUMP_DYNAMIC && | ||
1140 | insn->type != INSN_CALL_DYNAMIC) { | ||
1141 | WARN_FUNC("retpoline_safe hint not an indirect jump/call", | ||
1142 | insn->sec, insn->offset); | ||
1143 | return -1; | ||
1144 | } | ||
1145 | |||
1146 | insn->retpoline_safe = true; | ||
1147 | } | ||
1148 | |||
1149 | return 0; | ||
1150 | } | ||
1151 | |||
1074 | static int decode_sections(struct objtool_file *file) | 1152 | static int decode_sections(struct objtool_file *file) |
1075 | { | 1153 | { |
1076 | int ret; | 1154 | int ret; |
@@ -1109,6 +1187,10 @@ static int decode_sections(struct objtool_file *file) | |||
1109 | if (ret) | 1187 | if (ret) |
1110 | return ret; | 1188 | return ret; |
1111 | 1189 | ||
1190 | ret = read_retpoline_hints(file); | ||
1191 | if (ret) | ||
1192 | return ret; | ||
1193 | |||
1112 | return 0; | 1194 | return 0; |
1113 | } | 1195 | } |
1114 | 1196 | ||
@@ -1854,6 +1936,38 @@ static int validate_unwind_hints(struct objtool_file *file) | |||
1854 | return warnings; | 1936 | return warnings; |
1855 | } | 1937 | } |
1856 | 1938 | ||
1939 | static int validate_retpoline(struct objtool_file *file) | ||
1940 | { | ||
1941 | struct instruction *insn; | ||
1942 | int warnings = 0; | ||
1943 | |||
1944 | for_each_insn(file, insn) { | ||
1945 | if (insn->type != INSN_JUMP_DYNAMIC && | ||
1946 | insn->type != INSN_CALL_DYNAMIC) | ||
1947 | continue; | ||
1948 | |||
1949 | if (insn->retpoline_safe) | ||
1950 | continue; | ||
1951 | |||
1952 | /* | ||
1953 | * .init.text code is ran before userspace and thus doesn't | ||
1954 | * strictly need retpolines, except for modules which are | ||
1955 | * loaded late, they very much do need retpoline in their | ||
1956 | * .init.text | ||
1957 | */ | ||
1958 | if (!strcmp(insn->sec->name, ".init.text") && !module) | ||
1959 | continue; | ||
1960 | |||
1961 | WARN_FUNC("indirect %s found in RETPOLINE build", | ||
1962 | insn->sec, insn->offset, | ||
1963 | insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call"); | ||
1964 | |||
1965 | warnings++; | ||
1966 | } | ||
1967 | |||
1968 | return warnings; | ||
1969 | } | ||
1970 | |||
1857 | static bool is_kasan_insn(struct instruction *insn) | 1971 | static bool is_kasan_insn(struct instruction *insn) |
1858 | { | 1972 | { |
1859 | return (insn->type == INSN_CALL && | 1973 | return (insn->type == INSN_CALL && |
@@ -1899,13 +2013,19 @@ static bool ignore_unreachable_insn(struct instruction *insn) | |||
1899 | if (is_kasan_insn(insn) || is_ubsan_insn(insn)) | 2013 | if (is_kasan_insn(insn) || is_ubsan_insn(insn)) |
1900 | return true; | 2014 | return true; |
1901 | 2015 | ||
1902 | if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest) { | 2016 | if (insn->type == INSN_JUMP_UNCONDITIONAL) { |
1903 | insn = insn->jump_dest; | 2017 | if (insn->jump_dest && |
1904 | continue; | 2018 | insn->jump_dest->func == insn->func) { |
2019 | insn = insn->jump_dest; | ||
2020 | continue; | ||
2021 | } | ||
2022 | |||
2023 | break; | ||
1905 | } | 2024 | } |
1906 | 2025 | ||
1907 | if (insn->offset + insn->len >= insn->func->offset + insn->func->len) | 2026 | if (insn->offset + insn->len >= insn->func->offset + insn->func->len) |
1908 | break; | 2027 | break; |
2028 | |||
1909 | insn = list_next_entry(insn, list); | 2029 | insn = list_next_entry(insn, list); |
1910 | } | 2030 | } |
1911 | 2031 | ||
@@ -1979,13 +2099,12 @@ static void cleanup(struct objtool_file *file) | |||
1979 | elf_close(file->elf); | 2099 | elf_close(file->elf); |
1980 | } | 2100 | } |
1981 | 2101 | ||
1982 | int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc) | 2102 | int check(const char *_objname, bool orc) |
1983 | { | 2103 | { |
1984 | struct objtool_file file; | 2104 | struct objtool_file file; |
1985 | int ret, warnings = 0; | 2105 | int ret, warnings = 0; |
1986 | 2106 | ||
1987 | objname = _objname; | 2107 | objname = _objname; |
1988 | no_fp = _no_fp; | ||
1989 | 2108 | ||
1990 | file.elf = elf_open(objname, orc ? O_RDWR : O_RDONLY); | 2109 | file.elf = elf_open(objname, orc ? O_RDWR : O_RDONLY); |
1991 | if (!file.elf) | 2110 | if (!file.elf) |
@@ -2009,6 +2128,13 @@ int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc) | |||
2009 | if (list_empty(&file.insn_list)) | 2128 | if (list_empty(&file.insn_list)) |
2010 | goto out; | 2129 | goto out; |
2011 | 2130 | ||
2131 | if (retpoline) { | ||
2132 | ret = validate_retpoline(&file); | ||
2133 | if (ret < 0) | ||
2134 | return ret; | ||
2135 | warnings += ret; | ||
2136 | } | ||
2137 | |||
2012 | ret = validate_functions(&file); | 2138 | ret = validate_functions(&file); |
2013 | if (ret < 0) | 2139 | if (ret < 0) |
2014 | goto out; | 2140 | goto out; |
diff --git a/tools/objtool/check.h b/tools/objtool/check.h index dbadb304a410..c6b68fcb926f 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/check.h | |||
@@ -45,8 +45,10 @@ struct instruction { | |||
45 | unsigned char type; | 45 | unsigned char type; |
46 | unsigned long immediate; | 46 | unsigned long immediate; |
47 | bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts; | 47 | bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts; |
48 | bool retpoline_safe; | ||
48 | struct symbol *call_dest; | 49 | struct symbol *call_dest; |
49 | struct instruction *jump_dest; | 50 | struct instruction *jump_dest; |
51 | struct instruction *first_jump_src; | ||
50 | struct list_head alts; | 52 | struct list_head alts; |
51 | struct symbol *func; | 53 | struct symbol *func; |
52 | struct stack_op stack_op; | 54 | struct stack_op stack_op; |
@@ -62,7 +64,7 @@ struct objtool_file { | |||
62 | bool ignore_unreachables, c_file, hints; | 64 | bool ignore_unreachables, c_file, hints; |
63 | }; | 65 | }; |
64 | 66 | ||
65 | int check(const char *objname, bool no_fp, bool no_unreachable, bool orc); | 67 | int check(const char *objname, bool orc); |
66 | 68 | ||
67 | struct instruction *find_insn(struct objtool_file *file, | 69 | struct instruction *find_insn(struct objtool_file *file, |
68 | struct section *sec, unsigned long offset); | 70 | struct section *sec, unsigned long offset); |
diff --git a/tools/perf/Documentation/perf-data.txt b/tools/perf/Documentation/perf-data.txt index f0796a47dfa3..90bb4aabe4f8 100644 --- a/tools/perf/Documentation/perf-data.txt +++ b/tools/perf/Documentation/perf-data.txt | |||
@@ -30,6 +30,10 @@ OPTIONS for 'convert' | |||
30 | -i:: | 30 | -i:: |
31 | Specify input perf data file path. | 31 | Specify input perf data file path. |
32 | 32 | ||
33 | -f:: | ||
34 | --force:: | ||
35 | Don't complain, do it. | ||
36 | |||
33 | -v:: | 37 | -v:: |
34 | --verbose:: | 38 | --verbose:: |
35 | Be more verbose (show counter open errors, etc). | 39 | Be more verbose (show counter open errors, etc). |
diff --git a/tools/perf/Documentation/perf-kallsyms.txt b/tools/perf/Documentation/perf-kallsyms.txt index 954ea9e21236..cf9f4040ea5c 100644 --- a/tools/perf/Documentation/perf-kallsyms.txt +++ b/tools/perf/Documentation/perf-kallsyms.txt | |||
@@ -8,7 +8,7 @@ perf-kallsyms - Searches running kernel for symbols | |||
8 | SYNOPSIS | 8 | SYNOPSIS |
9 | -------- | 9 | -------- |
10 | [verse] | 10 | [verse] |
11 | 'perf kallsyms <options> symbol_name[,symbol_name...]' | 11 | 'perf kallsyms' [<options>] symbol_name[,symbol_name...] |
12 | 12 | ||
13 | DESCRIPTION | 13 | DESCRIPTION |
14 | ----------- | 14 | ----------- |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9b0351d3ce34..012328038594 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -146,12 +146,6 @@ define allow-override | |||
146 | $(eval $(1) = $(2))) | 146 | $(eval $(1) = $(2))) |
147 | endef | 147 | endef |
148 | 148 | ||
149 | # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix. | ||
150 | $(call allow-override,CC,$(CROSS_COMPILE)gcc) | ||
151 | $(call allow-override,AR,$(CROSS_COMPILE)ar) | ||
152 | $(call allow-override,LD,$(CROSS_COMPILE)ld) | ||
153 | $(call allow-override,CXX,$(CROSS_COMPILE)g++) | ||
154 | |||
155 | LD += $(EXTRA_LDFLAGS) | 149 | LD += $(EXTRA_LDFLAGS) |
156 | 150 | ||
157 | HOSTCC ?= gcc | 151 | HOSTCC ?= gcc |
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile index 48228de415d0..dfa6e3103437 100644 --- a/tools/perf/arch/s390/Makefile +++ b/tools/perf/arch/s390/Makefile | |||
@@ -10,15 +10,19 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 | |||
10 | 10 | ||
11 | out := $(OUTPUT)arch/s390/include/generated/asm | 11 | out := $(OUTPUT)arch/s390/include/generated/asm |
12 | header := $(out)/syscalls_64.c | 12 | header := $(out)/syscalls_64.c |
13 | sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h | 13 | syskrn := $(srctree)/arch/s390/kernel/syscalls/syscall.tbl |
14 | sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/ | 14 | sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls |
15 | sysdef := $(sysprf)/syscall.tbl | ||
15 | systbl := $(sysprf)/mksyscalltbl | 16 | systbl := $(sysprf)/mksyscalltbl |
16 | 17 | ||
17 | # Create output directory if not already present | 18 | # Create output directory if not already present |
18 | _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') | 19 | _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') |
19 | 20 | ||
20 | $(header): $(sysdef) $(systbl) | 21 | $(header): $(sysdef) $(systbl) |
21 | $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@ | 22 | @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ |
23 | (diff -B $(sysdef) $(syskrn) >/dev/null) \ | ||
24 | || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true | ||
25 | $(Q)$(SHELL) '$(systbl)' $(sysdef) > $@ | ||
22 | 26 | ||
23 | clean:: | 27 | clean:: |
24 | $(call QUIET_CLEAN, s390) $(RM) $(header) | 28 | $(call QUIET_CLEAN, s390) $(RM) $(header) |
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl index 7fa0d0abd419..72ecbb676370 100755 --- a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl +++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl | |||
@@ -3,25 +3,23 @@ | |||
3 | # | 3 | # |
4 | # Generate system call table for perf | 4 | # Generate system call table for perf |
5 | # | 5 | # |
6 | # | 6 | # Copyright IBM Corp. 2017, 2018 |
7 | # Copyright IBM Corp. 2017 | ||
8 | # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | 7 | # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> |
9 | # | 8 | # |
10 | 9 | ||
11 | gcc=$1 | 10 | SYSCALL_TBL=$1 |
12 | input=$2 | ||
13 | 11 | ||
14 | if ! test -r $input; then | 12 | if ! test -r $SYSCALL_TBL; then |
15 | echo "Could not read input file" >&2 | 13 | echo "Could not read input file" >&2 |
16 | exit 1 | 14 | exit 1 |
17 | fi | 15 | fi |
18 | 16 | ||
19 | create_table() | 17 | create_table() |
20 | { | 18 | { |
21 | local max_nr | 19 | local max_nr nr abi sc discard |
22 | 20 | ||
23 | echo 'static const char *syscalltbl_s390_64[] = {' | 21 | echo 'static const char *syscalltbl_s390_64[] = {' |
24 | while read sc nr; do | 22 | while read nr abi sc discard; do |
25 | printf '\t[%d] = "%s",\n' $nr $sc | 23 | printf '\t[%d] = "%s",\n' $nr $sc |
26 | max_nr=$nr | 24 | max_nr=$nr |
27 | done | 25 | done |
@@ -29,8 +27,6 @@ create_table() | |||
29 | echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr" | 27 | echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr" |
30 | } | 28 | } |
31 | 29 | ||
32 | 30 | grep -E "^[[:digit:]]+[[:space:]]+(common|64)" $SYSCALL_TBL \ | |
33 | $gcc -m64 -E -dM -x c $input \ | 31 | |sort -k1 -n \ |
34 | |sed -ne 's/^#define __NR_//p' \ | ||
35 | |sort -t' ' -k2 -nu \ | ||
36 | |create_table | 32 | |create_table |
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl new file mode 100644 index 000000000000..b38d48464368 --- /dev/null +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl | |||
@@ -0,0 +1,390 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note | ||
2 | # | ||
3 | # System call table for s390 | ||
4 | # | ||
5 | # Format: | ||
6 | # | ||
7 | # <nr> <abi> <syscall> <entry-64bit> <compat-entry> | ||
8 | # | ||
9 | # where <abi> can be common, 64, or 32 | ||
10 | |||
11 | 1 common exit sys_exit sys_exit | ||
12 | 2 common fork sys_fork sys_fork | ||
13 | 3 common read sys_read compat_sys_s390_read | ||
14 | 4 common write sys_write compat_sys_s390_write | ||
15 | 5 common open sys_open compat_sys_open | ||
16 | 6 common close sys_close sys_close | ||
17 | 7 common restart_syscall sys_restart_syscall sys_restart_syscall | ||
18 | 8 common creat sys_creat compat_sys_creat | ||
19 | 9 common link sys_link compat_sys_link | ||
20 | 10 common unlink sys_unlink compat_sys_unlink | ||
21 | 11 common execve sys_execve compat_sys_execve | ||
22 | 12 common chdir sys_chdir compat_sys_chdir | ||
23 | 13 32 time - compat_sys_time | ||
24 | 14 common mknod sys_mknod compat_sys_mknod | ||
25 | 15 common chmod sys_chmod compat_sys_chmod | ||
26 | 16 32 lchown - compat_sys_s390_lchown16 | ||
27 | 19 common lseek sys_lseek compat_sys_lseek | ||
28 | 20 common getpid sys_getpid sys_getpid | ||
29 | 21 common mount sys_mount compat_sys_mount | ||
30 | 22 common umount sys_oldumount compat_sys_oldumount | ||
31 | 23 32 setuid - compat_sys_s390_setuid16 | ||
32 | 24 32 getuid - compat_sys_s390_getuid16 | ||
33 | 25 32 stime - compat_sys_stime | ||
34 | 26 common ptrace sys_ptrace compat_sys_ptrace | ||
35 | 27 common alarm sys_alarm sys_alarm | ||
36 | 29 common pause sys_pause sys_pause | ||
37 | 30 common utime sys_utime compat_sys_utime | ||
38 | 33 common access sys_access compat_sys_access | ||
39 | 34 common nice sys_nice sys_nice | ||
40 | 36 common sync sys_sync sys_sync | ||
41 | 37 common kill sys_kill sys_kill | ||
42 | 38 common rename sys_rename compat_sys_rename | ||
43 | 39 common mkdir sys_mkdir compat_sys_mkdir | ||
44 | 40 common rmdir sys_rmdir compat_sys_rmdir | ||
45 | 41 common dup sys_dup sys_dup | ||
46 | 42 common pipe sys_pipe compat_sys_pipe | ||
47 | 43 common times sys_times compat_sys_times | ||
48 | 45 common brk sys_brk compat_sys_brk | ||
49 | 46 32 setgid - compat_sys_s390_setgid16 | ||
50 | 47 32 getgid - compat_sys_s390_getgid16 | ||
51 | 48 common signal sys_signal compat_sys_signal | ||
52 | 49 32 geteuid - compat_sys_s390_geteuid16 | ||
53 | 50 32 getegid - compat_sys_s390_getegid16 | ||
54 | 51 common acct sys_acct compat_sys_acct | ||
55 | 52 common umount2 sys_umount compat_sys_umount | ||
56 | 54 common ioctl sys_ioctl compat_sys_ioctl | ||
57 | 55 common fcntl sys_fcntl compat_sys_fcntl | ||
58 | 57 common setpgid sys_setpgid sys_setpgid | ||
59 | 60 common umask sys_umask sys_umask | ||
60 | 61 common chroot sys_chroot compat_sys_chroot | ||
61 | 62 common ustat sys_ustat compat_sys_ustat | ||
62 | 63 common dup2 sys_dup2 sys_dup2 | ||
63 | 64 common getppid sys_getppid sys_getppid | ||
64 | 65 common getpgrp sys_getpgrp sys_getpgrp | ||
65 | 66 common setsid sys_setsid sys_setsid | ||
66 | 67 common sigaction sys_sigaction compat_sys_sigaction | ||
67 | 70 32 setreuid - compat_sys_s390_setreuid16 | ||
68 | 71 32 setregid - compat_sys_s390_setregid16 | ||
69 | 72 common sigsuspend sys_sigsuspend compat_sys_sigsuspend | ||
70 | 73 common sigpending sys_sigpending compat_sys_sigpending | ||
71 | 74 common sethostname sys_sethostname compat_sys_sethostname | ||
72 | 75 common setrlimit sys_setrlimit compat_sys_setrlimit | ||
73 | 76 32 getrlimit - compat_sys_old_getrlimit | ||
74 | 77 common getrusage sys_getrusage compat_sys_getrusage | ||
75 | 78 common gettimeofday sys_gettimeofday compat_sys_gettimeofday | ||
76 | 79 common settimeofday sys_settimeofday compat_sys_settimeofday | ||
77 | 80 32 getgroups - compat_sys_s390_getgroups16 | ||
78 | 81 32 setgroups - compat_sys_s390_setgroups16 | ||
79 | 83 common symlink sys_symlink compat_sys_symlink | ||
80 | 85 common readlink sys_readlink compat_sys_readlink | ||
81 | 86 common uselib sys_uselib compat_sys_uselib | ||
82 | 87 common swapon sys_swapon compat_sys_swapon | ||
83 | 88 common reboot sys_reboot compat_sys_reboot | ||
84 | 89 common readdir - compat_sys_old_readdir | ||
85 | 90 common mmap sys_old_mmap compat_sys_s390_old_mmap | ||
86 | 91 common munmap sys_munmap compat_sys_munmap | ||
87 | 92 common truncate sys_truncate compat_sys_truncate | ||
88 | 93 common ftruncate sys_ftruncate compat_sys_ftruncate | ||
89 | 94 common fchmod sys_fchmod sys_fchmod | ||
90 | 95 32 fchown - compat_sys_s390_fchown16 | ||
91 | 96 common getpriority sys_getpriority sys_getpriority | ||
92 | 97 common setpriority sys_setpriority sys_setpriority | ||
93 | 99 common statfs sys_statfs compat_sys_statfs | ||
94 | 100 common fstatfs sys_fstatfs compat_sys_fstatfs | ||
95 | 101 32 ioperm - - | ||
96 | 102 common socketcall sys_socketcall compat_sys_socketcall | ||
97 | 103 common syslog sys_syslog compat_sys_syslog | ||
98 | 104 common setitimer sys_setitimer compat_sys_setitimer | ||
99 | 105 common getitimer sys_getitimer compat_sys_getitimer | ||
100 | 106 common stat sys_newstat compat_sys_newstat | ||
101 | 107 common lstat sys_newlstat compat_sys_newlstat | ||
102 | 108 common fstat sys_newfstat compat_sys_newfstat | ||
103 | 110 common lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie | ||
104 | 111 common vhangup sys_vhangup sys_vhangup | ||
105 | 112 common idle - - | ||
106 | 114 common wait4 sys_wait4 compat_sys_wait4 | ||
107 | 115 common swapoff sys_swapoff compat_sys_swapoff | ||
108 | 116 common sysinfo sys_sysinfo compat_sys_sysinfo | ||
109 | 117 common ipc sys_s390_ipc compat_sys_s390_ipc | ||
110 | 118 common fsync sys_fsync sys_fsync | ||
111 | 119 common sigreturn sys_sigreturn compat_sys_sigreturn | ||
112 | 120 common clone sys_clone compat_sys_clone | ||
113 | 121 common setdomainname sys_setdomainname compat_sys_setdomainname | ||
114 | 122 common uname sys_newuname compat_sys_newuname | ||
115 | 124 common adjtimex sys_adjtimex compat_sys_adjtimex | ||
116 | 125 common mprotect sys_mprotect compat_sys_mprotect | ||
117 | 126 common sigprocmask sys_sigprocmask compat_sys_sigprocmask | ||
118 | 127 common create_module - - | ||
119 | 128 common init_module sys_init_module compat_sys_init_module | ||
120 | 129 common delete_module sys_delete_module compat_sys_delete_module | ||
121 | 130 common get_kernel_syms - - | ||
122 | 131 common quotactl sys_quotactl compat_sys_quotactl | ||
123 | 132 common getpgid sys_getpgid sys_getpgid | ||
124 | 133 common fchdir sys_fchdir sys_fchdir | ||
125 | 134 common bdflush sys_bdflush compat_sys_bdflush | ||
126 | 135 common sysfs sys_sysfs compat_sys_sysfs | ||
127 | 136 common personality sys_s390_personality sys_s390_personality | ||
128 | 137 common afs_syscall - - | ||
129 | 138 32 setfsuid - compat_sys_s390_setfsuid16 | ||
130 | 139 32 setfsgid - compat_sys_s390_setfsgid16 | ||
131 | 140 32 _llseek - compat_sys_llseek | ||
132 | 141 common getdents sys_getdents compat_sys_getdents | ||
133 | 142 32 _newselect - compat_sys_select | ||
134 | 142 64 select sys_select - | ||
135 | 143 common flock sys_flock sys_flock | ||
136 | 144 common msync sys_msync compat_sys_msync | ||
137 | 145 common readv sys_readv compat_sys_readv | ||
138 | 146 common writev sys_writev compat_sys_writev | ||
139 | 147 common getsid sys_getsid sys_getsid | ||
140 | 148 common fdatasync sys_fdatasync sys_fdatasync | ||
141 | 149 common _sysctl sys_sysctl compat_sys_sysctl | ||
142 | 150 common mlock sys_mlock compat_sys_mlock | ||
143 | 151 common munlock sys_munlock compat_sys_munlock | ||
144 | 152 common mlockall sys_mlockall sys_mlockall | ||
145 | 153 common munlockall sys_munlockall sys_munlockall | ||
146 | 154 common sched_setparam sys_sched_setparam compat_sys_sched_setparam | ||
147 | 155 common sched_getparam sys_sched_getparam compat_sys_sched_getparam | ||
148 | 156 common sched_setscheduler sys_sched_setscheduler compat_sys_sched_setscheduler | ||
149 | 157 common sched_getscheduler sys_sched_getscheduler sys_sched_getscheduler | ||
150 | 158 common sched_yield sys_sched_yield sys_sched_yield | ||
151 | 159 common sched_get_priority_max sys_sched_get_priority_max sys_sched_get_priority_max | ||
152 | 160 common sched_get_priority_min sys_sched_get_priority_min sys_sched_get_priority_min | ||
153 | 161 common sched_rr_get_interval sys_sched_rr_get_interval compat_sys_sched_rr_get_interval | ||
154 | 162 common nanosleep sys_nanosleep compat_sys_nanosleep | ||
155 | 163 common mremap sys_mremap compat_sys_mremap | ||
156 | 164 32 setresuid - compat_sys_s390_setresuid16 | ||
157 | 165 32 getresuid - compat_sys_s390_getresuid16 | ||
158 | 167 common query_module - - | ||
159 | 168 common poll sys_poll compat_sys_poll | ||
160 | 169 common nfsservctl - - | ||
161 | 170 32 setresgid - compat_sys_s390_setresgid16 | ||
162 | 171 32 getresgid - compat_sys_s390_getresgid16 | ||
163 | 172 common prctl sys_prctl compat_sys_prctl | ||
164 | 173 common rt_sigreturn sys_rt_sigreturn compat_sys_rt_sigreturn | ||
165 | 174 common rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction | ||
166 | 175 common rt_sigprocmask sys_rt_sigprocmask compat_sys_rt_sigprocmask | ||
167 | 176 common rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending | ||
168 | 177 common rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait | ||
169 | 178 common rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo | ||
170 | 179 common rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend | ||
171 | 180 common pread64 sys_pread64 compat_sys_s390_pread64 | ||
172 | 181 common pwrite64 sys_pwrite64 compat_sys_s390_pwrite64 | ||
173 | 182 32 chown - compat_sys_s390_chown16 | ||
174 | 183 common getcwd sys_getcwd compat_sys_getcwd | ||
175 | 184 common capget sys_capget compat_sys_capget | ||
176 | 185 common capset sys_capset compat_sys_capset | ||
177 | 186 common sigaltstack sys_sigaltstack compat_sys_sigaltstack | ||
178 | 187 common sendfile sys_sendfile64 compat_sys_sendfile | ||
179 | 188 common getpmsg - - | ||
180 | 189 common putpmsg - - | ||
181 | 190 common vfork sys_vfork sys_vfork | ||
182 | 191 32 ugetrlimit - compat_sys_getrlimit | ||
183 | 191 64 getrlimit sys_getrlimit - | ||
184 | 192 32 mmap2 - compat_sys_s390_mmap2 | ||
185 | 193 32 truncate64 - compat_sys_s390_truncate64 | ||
186 | 194 32 ftruncate64 - compat_sys_s390_ftruncate64 | ||
187 | 195 32 stat64 - compat_sys_s390_stat64 | ||
188 | 196 32 lstat64 - compat_sys_s390_lstat64 | ||
189 | 197 32 fstat64 - compat_sys_s390_fstat64 | ||
190 | 198 32 lchown32 - compat_sys_lchown | ||
191 | 198 64 lchown sys_lchown - | ||
192 | 199 32 getuid32 - sys_getuid | ||
193 | 199 64 getuid sys_getuid - | ||
194 | 200 32 getgid32 - sys_getgid | ||
195 | 200 64 getgid sys_getgid - | ||
196 | 201 32 geteuid32 - sys_geteuid | ||
197 | 201 64 geteuid sys_geteuid - | ||
198 | 202 32 getegid32 - sys_getegid | ||
199 | 202 64 getegid sys_getegid - | ||
200 | 203 32 setreuid32 - sys_setreuid | ||
201 | 203 64 setreuid sys_setreuid - | ||
202 | 204 32 setregid32 - sys_setregid | ||
203 | 204 64 setregid sys_setregid - | ||
204 | 205 32 getgroups32 - compat_sys_getgroups | ||
205 | 205 64 getgroups sys_getgroups - | ||
206 | 206 32 setgroups32 - compat_sys_setgroups | ||
207 | 206 64 setgroups sys_setgroups - | ||
208 | 207 32 fchown32 - sys_fchown | ||
209 | 207 64 fchown sys_fchown - | ||
210 | 208 32 setresuid32 - sys_setresuid | ||
211 | 208 64 setresuid sys_setresuid - | ||
212 | 209 32 getresuid32 - compat_sys_getresuid | ||
213 | 209 64 getresuid sys_getresuid - | ||
214 | 210 32 setresgid32 - sys_setresgid | ||
215 | 210 64 setresgid sys_setresgid - | ||
216 | 211 32 getresgid32 - compat_sys_getresgid | ||
217 | 211 64 getresgid sys_getresgid - | ||
218 | 212 32 chown32 - compat_sys_chown | ||
219 | 212 64 chown sys_chown - | ||
220 | 213 32 setuid32 - sys_setuid | ||
221 | 213 64 setuid sys_setuid - | ||
222 | 214 32 setgid32 - sys_setgid | ||
223 | 214 64 setgid sys_setgid - | ||
224 | 215 32 setfsuid32 - sys_setfsuid | ||
225 | 215 64 setfsuid sys_setfsuid - | ||
226 | 216 32 setfsgid32 - sys_setfsgid | ||
227 | 216 64 setfsgid sys_setfsgid - | ||
228 | 217 common pivot_root sys_pivot_root compat_sys_pivot_root | ||
229 | 218 common mincore sys_mincore compat_sys_mincore | ||
230 | 219 common madvise sys_madvise compat_sys_madvise | ||
231 | 220 common getdents64 sys_getdents64 compat_sys_getdents64 | ||
232 | 221 32 fcntl64 - compat_sys_fcntl64 | ||
233 | 222 common readahead sys_readahead compat_sys_s390_readahead | ||
234 | 223 32 sendfile64 - compat_sys_sendfile64 | ||
235 | 224 common setxattr sys_setxattr compat_sys_setxattr | ||
236 | 225 common lsetxattr sys_lsetxattr compat_sys_lsetxattr | ||
237 | 226 common fsetxattr sys_fsetxattr compat_sys_fsetxattr | ||
238 | 227 common getxattr sys_getxattr compat_sys_getxattr | ||
239 | 228 common lgetxattr sys_lgetxattr compat_sys_lgetxattr | ||
240 | 229 common fgetxattr sys_fgetxattr compat_sys_fgetxattr | ||
241 | 230 common listxattr sys_listxattr compat_sys_listxattr | ||
242 | 231 common llistxattr sys_llistxattr compat_sys_llistxattr | ||
243 | 232 common flistxattr sys_flistxattr compat_sys_flistxattr | ||
244 | 233 common removexattr sys_removexattr compat_sys_removexattr | ||
245 | 234 common lremovexattr sys_lremovexattr compat_sys_lremovexattr | ||
246 | 235 common fremovexattr sys_fremovexattr compat_sys_fremovexattr | ||
247 | 236 common gettid sys_gettid sys_gettid | ||
248 | 237 common tkill sys_tkill sys_tkill | ||
249 | 238 common futex sys_futex compat_sys_futex | ||
250 | 239 common sched_setaffinity sys_sched_setaffinity compat_sys_sched_setaffinity | ||
251 | 240 common sched_getaffinity sys_sched_getaffinity compat_sys_sched_getaffinity | ||
252 | 241 common tgkill sys_tgkill sys_tgkill | ||
253 | 243 common io_setup sys_io_setup compat_sys_io_setup | ||
254 | 244 common io_destroy sys_io_destroy compat_sys_io_destroy | ||
255 | 245 common io_getevents sys_io_getevents compat_sys_io_getevents | ||
256 | 246 common io_submit sys_io_submit compat_sys_io_submit | ||
257 | 247 common io_cancel sys_io_cancel compat_sys_io_cancel | ||
258 | 248 common exit_group sys_exit_group sys_exit_group | ||
259 | 249 common epoll_create sys_epoll_create sys_epoll_create | ||
260 | 250 common epoll_ctl sys_epoll_ctl compat_sys_epoll_ctl | ||
261 | 251 common epoll_wait sys_epoll_wait compat_sys_epoll_wait | ||
262 | 252 common set_tid_address sys_set_tid_address compat_sys_set_tid_address | ||
263 | 253 common fadvise64 sys_fadvise64_64 compat_sys_s390_fadvise64 | ||
264 | 254 common timer_create sys_timer_create compat_sys_timer_create | ||
265 | 255 common timer_settime sys_timer_settime compat_sys_timer_settime | ||
266 | 256 common timer_gettime sys_timer_gettime compat_sys_timer_gettime | ||
267 | 257 common timer_getoverrun sys_timer_getoverrun sys_timer_getoverrun | ||
268 | 258 common timer_delete sys_timer_delete sys_timer_delete | ||
269 | 259 common clock_settime sys_clock_settime compat_sys_clock_settime | ||
270 | 260 common clock_gettime sys_clock_gettime compat_sys_clock_gettime | ||
271 | 261 common clock_getres sys_clock_getres compat_sys_clock_getres | ||
272 | 262 common clock_nanosleep sys_clock_nanosleep compat_sys_clock_nanosleep | ||
273 | 264 32 fadvise64_64 - compat_sys_s390_fadvise64_64 | ||
274 | 265 common statfs64 sys_statfs64 compat_sys_statfs64 | ||
275 | 266 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64 | ||
276 | 267 common remap_file_pages sys_remap_file_pages compat_sys_remap_file_pages | ||
277 | 268 common mbind sys_mbind compat_sys_mbind | ||
278 | 269 common get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy | ||
279 | 270 common set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy | ||
280 | 271 common mq_open sys_mq_open compat_sys_mq_open | ||
281 | 272 common mq_unlink sys_mq_unlink compat_sys_mq_unlink | ||
282 | 273 common mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend | ||
283 | 274 common mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive | ||
284 | 275 common mq_notify sys_mq_notify compat_sys_mq_notify | ||
285 | 276 common mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr | ||
286 | 277 common kexec_load sys_kexec_load compat_sys_kexec_load | ||
287 | 278 common add_key sys_add_key compat_sys_add_key | ||
288 | 279 common request_key sys_request_key compat_sys_request_key | ||
289 | 280 common keyctl sys_keyctl compat_sys_keyctl | ||
290 | 281 common waitid sys_waitid compat_sys_waitid | ||
291 | 282 common ioprio_set sys_ioprio_set sys_ioprio_set | ||
292 | 283 common ioprio_get sys_ioprio_get sys_ioprio_get | ||
293 | 284 common inotify_init sys_inotify_init sys_inotify_init | ||
294 | 285 common inotify_add_watch sys_inotify_add_watch compat_sys_inotify_add_watch | ||
295 | 286 common inotify_rm_watch sys_inotify_rm_watch sys_inotify_rm_watch | ||
296 | 287 common migrate_pages sys_migrate_pages compat_sys_migrate_pages | ||
297 | 288 common openat sys_openat compat_sys_openat | ||
298 | 289 common mkdirat sys_mkdirat compat_sys_mkdirat | ||
299 | 290 common mknodat sys_mknodat compat_sys_mknodat | ||
300 | 291 common fchownat sys_fchownat compat_sys_fchownat | ||
301 | 292 common futimesat sys_futimesat compat_sys_futimesat | ||
302 | 293 32 fstatat64 - compat_sys_s390_fstatat64 | ||
303 | 293 64 newfstatat sys_newfstatat - | ||
304 | 294 common unlinkat sys_unlinkat compat_sys_unlinkat | ||
305 | 295 common renameat sys_renameat compat_sys_renameat | ||
306 | 296 common linkat sys_linkat compat_sys_linkat | ||
307 | 297 common symlinkat sys_symlinkat compat_sys_symlinkat | ||
308 | 298 common readlinkat sys_readlinkat compat_sys_readlinkat | ||
309 | 299 common fchmodat sys_fchmodat compat_sys_fchmodat | ||
310 | 300 common faccessat sys_faccessat compat_sys_faccessat | ||
311 | 301 common pselect6 sys_pselect6 compat_sys_pselect6 | ||
312 | 302 common ppoll sys_ppoll compat_sys_ppoll | ||
313 | 303 common unshare sys_unshare compat_sys_unshare | ||
314 | 304 common set_robust_list sys_set_robust_list compat_sys_set_robust_list | ||
315 | 305 common get_robust_list sys_get_robust_list compat_sys_get_robust_list | ||
316 | 306 common splice sys_splice compat_sys_splice | ||
317 | 307 common sync_file_range sys_sync_file_range compat_sys_s390_sync_file_range | ||
318 | 308 common tee sys_tee compat_sys_tee | ||
319 | 309 common vmsplice sys_vmsplice compat_sys_vmsplice | ||
320 | 310 common move_pages sys_move_pages compat_sys_move_pages | ||
321 | 311 common getcpu sys_getcpu compat_sys_getcpu | ||
322 | 312 common epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait | ||
323 | 313 common utimes sys_utimes compat_sys_utimes | ||
324 | 314 common fallocate sys_fallocate compat_sys_s390_fallocate | ||
325 | 315 common utimensat sys_utimensat compat_sys_utimensat | ||
326 | 316 common signalfd sys_signalfd compat_sys_signalfd | ||
327 | 317 common timerfd - - | ||
328 | 318 common eventfd sys_eventfd sys_eventfd | ||
329 | 319 common timerfd_create sys_timerfd_create sys_timerfd_create | ||
330 | 320 common timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime | ||
331 | 321 common timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime | ||
332 | 322 common signalfd4 sys_signalfd4 compat_sys_signalfd4 | ||
333 | 323 common eventfd2 sys_eventfd2 sys_eventfd2 | ||
334 | 324 common inotify_init1 sys_inotify_init1 sys_inotify_init1 | ||
335 | 325 common pipe2 sys_pipe2 compat_sys_pipe2 | ||
336 | 326 common dup3 sys_dup3 sys_dup3 | ||
337 | 327 common epoll_create1 sys_epoll_create1 sys_epoll_create1 | ||
338 | 328 common preadv sys_preadv compat_sys_preadv | ||
339 | 329 common pwritev sys_pwritev compat_sys_pwritev | ||
340 | 330 common rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo | ||
341 | 331 common perf_event_open sys_perf_event_open compat_sys_perf_event_open | ||
342 | 332 common fanotify_init sys_fanotify_init sys_fanotify_init | ||
343 | 333 common fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark | ||
344 | 334 common prlimit64 sys_prlimit64 compat_sys_prlimit64 | ||
345 | 335 common name_to_handle_at sys_name_to_handle_at compat_sys_name_to_handle_at | ||
346 | 336 common open_by_handle_at sys_open_by_handle_at compat_sys_open_by_handle_at | ||
347 | 337 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime | ||
348 | 338 common syncfs sys_syncfs sys_syncfs | ||
349 | 339 common setns sys_setns sys_setns | ||
350 | 340 common process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv | ||
351 | 341 common process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev | ||
352 | 342 common s390_runtime_instr sys_s390_runtime_instr sys_s390_runtime_instr | ||
353 | 343 common kcmp sys_kcmp compat_sys_kcmp | ||
354 | 344 common finit_module sys_finit_module compat_sys_finit_module | ||
355 | 345 common sched_setattr sys_sched_setattr compat_sys_sched_setattr | ||
356 | 346 common sched_getattr sys_sched_getattr compat_sys_sched_getattr | ||
357 | 347 common renameat2 sys_renameat2 compat_sys_renameat2 | ||
358 | 348 common seccomp sys_seccomp compat_sys_seccomp | ||
359 | 349 common getrandom sys_getrandom compat_sys_getrandom | ||
360 | 350 common memfd_create sys_memfd_create compat_sys_memfd_create | ||
361 | 351 common bpf sys_bpf compat_sys_bpf | ||
362 | 352 common s390_pci_mmio_write sys_s390_pci_mmio_write compat_sys_s390_pci_mmio_write | ||
363 | 353 common s390_pci_mmio_read sys_s390_pci_mmio_read compat_sys_s390_pci_mmio_read | ||
364 | 354 common execveat sys_execveat compat_sys_execveat | ||
365 | 355 common userfaultfd sys_userfaultfd sys_userfaultfd | ||
366 | 356 common membarrier sys_membarrier sys_membarrier | ||
367 | 357 common recvmmsg sys_recvmmsg compat_sys_recvmmsg | ||
368 | 358 common sendmmsg sys_sendmmsg compat_sys_sendmmsg | ||
369 | 359 common socket sys_socket sys_socket | ||
370 | 360 common socketpair sys_socketpair compat_sys_socketpair | ||
371 | 361 common bind sys_bind compat_sys_bind | ||
372 | 362 common connect sys_connect compat_sys_connect | ||
373 | 363 common listen sys_listen sys_listen | ||
374 | 364 common accept4 sys_accept4 compat_sys_accept4 | ||
375 | 365 common getsockopt sys_getsockopt compat_sys_getsockopt | ||
376 | 366 common setsockopt sys_setsockopt compat_sys_setsockopt | ||
377 | 367 common getsockname sys_getsockname compat_sys_getsockname | ||
378 | 368 common getpeername sys_getpeername compat_sys_getpeername | ||
379 | 369 common sendto sys_sendto compat_sys_sendto | ||
380 | 370 common sendmsg sys_sendmsg compat_sys_sendmsg | ||
381 | 371 common recvfrom sys_recvfrom compat_sys_recvfrom | ||
382 | 372 common recvmsg sys_recvmsg compat_sys_recvmsg | ||
383 | 373 common shutdown sys_shutdown sys_shutdown | ||
384 | 374 common mlock2 sys_mlock2 compat_sys_mlock2 | ||
385 | 375 common copy_file_range sys_copy_file_range compat_sys_copy_file_range | ||
386 | 376 common preadv2 sys_preadv2 compat_sys_preadv2 | ||
387 | 377 common pwritev2 sys_pwritev2 compat_sys_pwritev2 | ||
388 | 378 common s390_guarded_storage sys_s390_guarded_storage compat_sys_s390_guarded_storage | ||
389 | 379 common statx sys_statx compat_sys_statx | ||
390 | 380 common s390_sthyi sys_s390_sthyi compat_sys_s390_sthyi | ||
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c0815a37fdb5..539c3d460158 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
@@ -2245,7 +2245,7 @@ static int perf_c2c__browse_cacheline(struct hist_entry *he) | |||
2245 | c2c_browser__update_nr_entries(browser); | 2245 | c2c_browser__update_nr_entries(browser); |
2246 | 2246 | ||
2247 | while (1) { | 2247 | while (1) { |
2248 | key = hist_browser__run(browser, "? - help"); | 2248 | key = hist_browser__run(browser, "? - help", true); |
2249 | 2249 | ||
2250 | switch (key) { | 2250 | switch (key) { |
2251 | case 's': | 2251 | case 's': |
@@ -2314,7 +2314,7 @@ static int perf_c2c__hists_browse(struct hists *hists) | |||
2314 | c2c_browser__update_nr_entries(browser); | 2314 | c2c_browser__update_nr_entries(browser); |
2315 | 2315 | ||
2316 | while (1) { | 2316 | while (1) { |
2317 | key = hist_browser__run(browser, "? - help"); | 2317 | key = hist_browser__run(browser, "? - help", true); |
2318 | 2318 | ||
2319 | switch (key) { | 2319 | switch (key) { |
2320 | case 'q': | 2320 | case 'q': |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index bf4ca749d1ac..a217623fec2e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -881,6 +881,15 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
881 | } | 881 | } |
882 | } | 882 | } |
883 | 883 | ||
884 | /* | ||
885 | * If we have just single event and are sending data | ||
886 | * through pipe, we need to force the ids allocation, | ||
887 | * because we synthesize event name through the pipe | ||
888 | * and need the id for that. | ||
889 | */ | ||
890 | if (data->is_pipe && rec->evlist->nr_entries == 1) | ||
891 | rec->opts.sample_id = true; | ||
892 | |||
884 | if (record__open(rec) != 0) { | 893 | if (record__open(rec) != 0) { |
885 | err = -1; | 894 | err = -1; |
886 | goto out_child; | 895 | goto out_child; |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 42a52dcc41cd..4ad5dc649716 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -530,7 +530,8 @@ static int report__browse_hists(struct report *rep) | |||
530 | case 1: | 530 | case 1: |
531 | ret = perf_evlist__tui_browse_hists(evlist, help, NULL, | 531 | ret = perf_evlist__tui_browse_hists(evlist, help, NULL, |
532 | rep->min_percent, | 532 | rep->min_percent, |
533 | &session->header.env); | 533 | &session->header.env, |
534 | true); | ||
534 | /* | 535 | /* |
535 | * Usually "ret" is the last pressed key, and we only | 536 | * Usually "ret" is the last pressed key, and we only |
536 | * care if the key notifies us to switch data file. | 537 | * care if the key notifies us to switch data file. |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 98bf9d32f222..54a4c152edb3 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -917,7 +917,7 @@ static void print_metric_csv(void *ctx, | |||
917 | char buf[64], *vals, *ends; | 917 | char buf[64], *vals, *ends; |
918 | 918 | ||
919 | if (unit == NULL || fmt == NULL) { | 919 | if (unit == NULL || fmt == NULL) { |
920 | fprintf(out, "%s%s%s%s", csv_sep, csv_sep, csv_sep, csv_sep); | 920 | fprintf(out, "%s%s", csv_sep, csv_sep); |
921 | return; | 921 | return; |
922 | } | 922 | } |
923 | snprintf(buf, sizeof(buf), fmt, val); | 923 | snprintf(buf, sizeof(buf), fmt, val); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c6ccda52117d..35ac016fcb98 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -283,8 +283,9 @@ static void perf_top__print_sym_table(struct perf_top *top) | |||
283 | 283 | ||
284 | printf("%-*.*s\n", win_width, win_width, graph_dotted_line); | 284 | printf("%-*.*s\n", win_width, win_width, graph_dotted_line); |
285 | 285 | ||
286 | if (hists->stats.nr_lost_warned != | 286 | if (!top->record_opts.overwrite && |
287 | hists->stats.nr_events[PERF_RECORD_LOST]) { | 287 | (hists->stats.nr_lost_warned != |
288 | hists->stats.nr_events[PERF_RECORD_LOST])) { | ||
288 | hists->stats.nr_lost_warned = | 289 | hists->stats.nr_lost_warned = |
289 | hists->stats.nr_events[PERF_RECORD_LOST]; | 290 | hists->stats.nr_events[PERF_RECORD_LOST]; |
290 | color_fprintf(stdout, PERF_COLOR_RED, | 291 | color_fprintf(stdout, PERF_COLOR_RED, |
@@ -611,7 +612,8 @@ static void *display_thread_tui(void *arg) | |||
611 | 612 | ||
612 | perf_evlist__tui_browse_hists(top->evlist, help, &hbt, | 613 | perf_evlist__tui_browse_hists(top->evlist, help, &hbt, |
613 | top->min_percent, | 614 | top->min_percent, |
614 | &top->session->header.env); | 615 | &top->session->header.env, |
616 | !top->record_opts.overwrite); | ||
615 | 617 | ||
616 | done = 1; | 618 | done = 1; |
617 | return NULL; | 619 | return NULL; |
@@ -807,15 +809,23 @@ static void perf_event__process_sample(struct perf_tool *tool, | |||
807 | 809 | ||
808 | static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | 810 | static void perf_top__mmap_read_idx(struct perf_top *top, int idx) |
809 | { | 811 | { |
812 | struct record_opts *opts = &top->record_opts; | ||
813 | struct perf_evlist *evlist = top->evlist; | ||
810 | struct perf_sample sample; | 814 | struct perf_sample sample; |
811 | struct perf_evsel *evsel; | 815 | struct perf_evsel *evsel; |
816 | struct perf_mmap *md; | ||
812 | struct perf_session *session = top->session; | 817 | struct perf_session *session = top->session; |
813 | union perf_event *event; | 818 | union perf_event *event; |
814 | struct machine *machine; | 819 | struct machine *machine; |
820 | u64 end, start; | ||
815 | int ret; | 821 | int ret; |
816 | 822 | ||
817 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { | 823 | md = opts->overwrite ? &evlist->overwrite_mmap[idx] : &evlist->mmap[idx]; |
818 | ret = perf_evlist__parse_sample(top->evlist, event, &sample); | 824 | if (perf_mmap__read_init(md, opts->overwrite, &start, &end) < 0) |
825 | return; | ||
826 | |||
827 | while ((event = perf_mmap__read_event(md, opts->overwrite, &start, end)) != NULL) { | ||
828 | ret = perf_evlist__parse_sample(evlist, event, &sample); | ||
819 | if (ret) { | 829 | if (ret) { |
820 | pr_err("Can't parse sample, err = %d\n", ret); | 830 | pr_err("Can't parse sample, err = %d\n", ret); |
821 | goto next_event; | 831 | goto next_event; |
@@ -869,16 +879,120 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
869 | } else | 879 | } else |
870 | ++session->evlist->stats.nr_unknown_events; | 880 | ++session->evlist->stats.nr_unknown_events; |
871 | next_event: | 881 | next_event: |
872 | perf_evlist__mmap_consume(top->evlist, idx); | 882 | perf_mmap__consume(md, opts->overwrite); |
873 | } | 883 | } |
884 | |||
885 | perf_mmap__read_done(md); | ||
874 | } | 886 | } |
875 | 887 | ||
876 | static void perf_top__mmap_read(struct perf_top *top) | 888 | static void perf_top__mmap_read(struct perf_top *top) |
877 | { | 889 | { |
890 | bool overwrite = top->record_opts.overwrite; | ||
891 | struct perf_evlist *evlist = top->evlist; | ||
892 | unsigned long long start, end; | ||
878 | int i; | 893 | int i; |
879 | 894 | ||
895 | start = rdclock(); | ||
896 | if (overwrite) | ||
897 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_DATA_PENDING); | ||
898 | |||
880 | for (i = 0; i < top->evlist->nr_mmaps; i++) | 899 | for (i = 0; i < top->evlist->nr_mmaps; i++) |
881 | perf_top__mmap_read_idx(top, i); | 900 | perf_top__mmap_read_idx(top, i); |
901 | |||
902 | if (overwrite) { | ||
903 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_EMPTY); | ||
904 | perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING); | ||
905 | } | ||
906 | end = rdclock(); | ||
907 | |||
908 | if ((end - start) > (unsigned long long)top->delay_secs * NSEC_PER_SEC) | ||
909 | ui__warning("Too slow to read ring buffer.\n" | ||
910 | "Please try increasing the period (-c) or\n" | ||
911 | "decreasing the freq (-F) or\n" | ||
912 | "limiting the number of CPUs (-C)\n"); | ||
913 | } | ||
914 | |||
915 | /* | ||
916 | * Check per-event overwrite term. | ||
917 | * perf top should support consistent term for all events. | ||
918 | * - All events don't have per-event term | ||
919 | * E.g. "cpu/cpu-cycles/,cpu/instructions/" | ||
920 | * Nothing change, return 0. | ||
921 | * - All events have same per-event term | ||
922 | * E.g. "cpu/cpu-cycles,no-overwrite/,cpu/instructions,no-overwrite/ | ||
923 | * Using the per-event setting to replace the opts->overwrite if | ||
924 | * they are different, then return 0. | ||
925 | * - Events have different per-event term | ||
926 | * E.g. "cpu/cpu-cycles,overwrite/,cpu/instructions,no-overwrite/" | ||
927 | * Return -1 | ||
928 | * - Some of the event set per-event term, but some not. | ||
929 | * E.g. "cpu/cpu-cycles/,cpu/instructions,no-overwrite/" | ||
930 | * Return -1 | ||
931 | */ | ||
932 | static int perf_top__overwrite_check(struct perf_top *top) | ||
933 | { | ||
934 | struct record_opts *opts = &top->record_opts; | ||
935 | struct perf_evlist *evlist = top->evlist; | ||
936 | struct perf_evsel_config_term *term; | ||
937 | struct list_head *config_terms; | ||
938 | struct perf_evsel *evsel; | ||
939 | int set, overwrite = -1; | ||
940 | |||
941 | evlist__for_each_entry(evlist, evsel) { | ||
942 | set = -1; | ||
943 | config_terms = &evsel->config_terms; | ||
944 | list_for_each_entry(term, config_terms, list) { | ||
945 | if (term->type == PERF_EVSEL__CONFIG_TERM_OVERWRITE) | ||
946 | set = term->val.overwrite ? 1 : 0; | ||
947 | } | ||
948 | |||
949 | /* no term for current and previous event (likely) */ | ||
950 | if ((overwrite < 0) && (set < 0)) | ||
951 | continue; | ||
952 | |||
953 | /* has term for both current and previous event, compare */ | ||
954 | if ((overwrite >= 0) && (set >= 0) && (overwrite != set)) | ||
955 | return -1; | ||
956 | |||
957 | /* no term for current event but has term for previous one */ | ||
958 | if ((overwrite >= 0) && (set < 0)) | ||
959 | return -1; | ||
960 | |||
961 | /* has term for current event */ | ||
962 | if ((overwrite < 0) && (set >= 0)) { | ||
963 | /* if it's first event, set overwrite */ | ||
964 | if (evsel == perf_evlist__first(evlist)) | ||
965 | overwrite = set; | ||
966 | else | ||
967 | return -1; | ||
968 | } | ||
969 | } | ||
970 | |||
971 | if ((overwrite >= 0) && (opts->overwrite != overwrite)) | ||
972 | opts->overwrite = overwrite; | ||
973 | |||
974 | return 0; | ||
975 | } | ||
976 | |||
977 | static int perf_top_overwrite_fallback(struct perf_top *top, | ||
978 | struct perf_evsel *evsel) | ||
979 | { | ||
980 | struct record_opts *opts = &top->record_opts; | ||
981 | struct perf_evlist *evlist = top->evlist; | ||
982 | struct perf_evsel *counter; | ||
983 | |||
984 | if (!opts->overwrite) | ||
985 | return 0; | ||
986 | |||
987 | /* only fall back when first event fails */ | ||
988 | if (evsel != perf_evlist__first(evlist)) | ||
989 | return 0; | ||
990 | |||
991 | evlist__for_each_entry(evlist, counter) | ||
992 | counter->attr.write_backward = false; | ||
993 | opts->overwrite = false; | ||
994 | pr_debug2("fall back to non-overwrite mode\n"); | ||
995 | return 1; | ||
882 | } | 996 | } |
883 | 997 | ||
884 | static int perf_top__start_counters(struct perf_top *top) | 998 | static int perf_top__start_counters(struct perf_top *top) |
@@ -888,12 +1002,33 @@ static int perf_top__start_counters(struct perf_top *top) | |||
888 | struct perf_evlist *evlist = top->evlist; | 1002 | struct perf_evlist *evlist = top->evlist; |
889 | struct record_opts *opts = &top->record_opts; | 1003 | struct record_opts *opts = &top->record_opts; |
890 | 1004 | ||
1005 | if (perf_top__overwrite_check(top)) { | ||
1006 | ui__error("perf top only support consistent per-event " | ||
1007 | "overwrite setting for all events\n"); | ||
1008 | goto out_err; | ||
1009 | } | ||
1010 | |||
891 | perf_evlist__config(evlist, opts, &callchain_param); | 1011 | perf_evlist__config(evlist, opts, &callchain_param); |
892 | 1012 | ||
893 | evlist__for_each_entry(evlist, counter) { | 1013 | evlist__for_each_entry(evlist, counter) { |
894 | try_again: | 1014 | try_again: |
895 | if (perf_evsel__open(counter, top->evlist->cpus, | 1015 | if (perf_evsel__open(counter, top->evlist->cpus, |
896 | top->evlist->threads) < 0) { | 1016 | top->evlist->threads) < 0) { |
1017 | |||
1018 | /* | ||
1019 | * Specially handle overwrite fall back. | ||
1020 | * Because perf top is the only tool which has | ||
1021 | * overwrite mode by default, support | ||
1022 | * both overwrite and non-overwrite mode, and | ||
1023 | * require consistent mode for all events. | ||
1024 | * | ||
1025 | * May move it to generic code with more tools | ||
1026 | * have similar attribute. | ||
1027 | */ | ||
1028 | if (perf_missing_features.write_backward && | ||
1029 | perf_top_overwrite_fallback(top, counter)) | ||
1030 | goto try_again; | ||
1031 | |||
897 | if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { | 1032 | if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { |
898 | if (verbose > 0) | 1033 | if (verbose > 0) |
899 | ui__warning("%s\n", msg); | 1034 | ui__warning("%s\n", msg); |
@@ -1033,7 +1168,7 @@ static int __cmd_top(struct perf_top *top) | |||
1033 | 1168 | ||
1034 | perf_top__mmap_read(top); | 1169 | perf_top__mmap_read(top); |
1035 | 1170 | ||
1036 | if (hits == top->samples) | 1171 | if (opts->overwrite || (hits == top->samples)) |
1037 | ret = perf_evlist__poll(top->evlist, 100); | 1172 | ret = perf_evlist__poll(top->evlist, 100); |
1038 | 1173 | ||
1039 | if (resize) { | 1174 | if (resize) { |
@@ -1127,6 +1262,7 @@ int cmd_top(int argc, const char **argv) | |||
1127 | .uses_mmap = true, | 1262 | .uses_mmap = true, |
1128 | }, | 1263 | }, |
1129 | .proc_map_timeout = 500, | 1264 | .proc_map_timeout = 500, |
1265 | .overwrite = 1, | ||
1130 | }, | 1266 | }, |
1131 | .max_stack = sysctl_perf_event_max_stack, | 1267 | .max_stack = sysctl_perf_event_max_stack, |
1132 | .sym_pcnt_filter = 5, | 1268 | .sym_pcnt_filter = 5, |
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 51abdb0a4047..790ec25919a0 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh | |||
@@ -33,7 +33,6 @@ arch/s390/include/uapi/asm/kvm.h | |||
33 | arch/s390/include/uapi/asm/kvm_perf.h | 33 | arch/s390/include/uapi/asm/kvm_perf.h |
34 | arch/s390/include/uapi/asm/ptrace.h | 34 | arch/s390/include/uapi/asm/ptrace.h |
35 | arch/s390/include/uapi/asm/sie.h | 35 | arch/s390/include/uapi/asm/sie.h |
36 | arch/s390/include/uapi/asm/unistd.h | ||
37 | arch/arm/include/uapi/asm/kvm.h | 36 | arch/arm/include/uapi/asm/kvm.h |
38 | arch/arm64/include/uapi/asm/kvm.h | 37 | arch/arm64/include/uapi/asm/kvm.h |
39 | arch/alpha/include/uapi/asm/errno.h | 38 | arch/alpha/include/uapi/asm/errno.h |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index cfe46236a5e5..57b9b342d533 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -61,6 +61,7 @@ struct record_opts { | |||
61 | bool tail_synthesize; | 61 | bool tail_synthesize; |
62 | bool overwrite; | 62 | bool overwrite; |
63 | bool ignore_missing_thread; | 63 | bool ignore_missing_thread; |
64 | bool sample_id; | ||
64 | unsigned int freq; | 65 | unsigned int freq; |
65 | unsigned int mmap_pages; | 66 | unsigned int mmap_pages; |
66 | unsigned int auxtrace_mmap_pages; | 67 | unsigned int auxtrace_mmap_pages; |
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json new file mode 100644 index 000000000000..3b6208763e50 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/branch.json | |||
@@ -0,0 +1,27 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0x7A", | ||
4 | "EventName": "BR_INDIRECT_SPEC", | ||
5 | "BriefDescription": "Branch speculatively executed - Indirect branch" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0xC9", | ||
9 | "EventName": "BR_COND", | ||
10 | "BriefDescription": "Conditional branch executed" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xCA", | ||
14 | "EventName": "BR_INDIRECT_MISPRED", | ||
15 | "BriefDescription": "Indirect branch mispredicted" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xCB", | ||
19 | "EventName": "BR_INDIRECT_MISPRED_ADDR", | ||
20 | "BriefDescription": "Indirect branch mispredicted because of address miscompare" | ||
21 | }, | ||
22 | {, | ||
23 | "EventCode": "0xCC", | ||
24 | "EventName": "BR_COND_MISPRED", | ||
25 | "BriefDescription": "Conditional branch mispredicted" | ||
26 | } | ||
27 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json new file mode 100644 index 000000000000..480d9f7460ab --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/bus.json | |||
@@ -0,0 +1,22 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0x60", | ||
4 | "EventName": "BUS_ACCESS_LD", | ||
5 | "BriefDescription": "Bus access - Read" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0x61", | ||
9 | "EventName": "BUS_ACCESS_ST", | ||
10 | "BriefDescription": "Bus access - Write" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xC0", | ||
14 | "EventName": "EXT_MEM_REQ", | ||
15 | "BriefDescription": "External memory request" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xC1", | ||
19 | "EventName": "EXT_MEM_REQ_NC", | ||
20 | "BriefDescription": "Non-cacheable external memory request" | ||
21 | } | ||
22 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json new file mode 100644 index 000000000000..11baad6344b9 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/cache.json | |||
@@ -0,0 +1,27 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0xC2", | ||
4 | "EventName": "PREFETCH_LINEFILL", | ||
5 | "BriefDescription": "Linefill because of prefetch" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0xC3", | ||
9 | "EventName": "PREFETCH_LINEFILL_DROP", | ||
10 | "BriefDescription": "Instruction Cache Throttle occurred" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xC4", | ||
14 | "EventName": "READ_ALLOC_ENTER", | ||
15 | "BriefDescription": "Entering read allocate mode" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xC5", | ||
19 | "EventName": "READ_ALLOC", | ||
20 | "BriefDescription": "Read allocate mode" | ||
21 | }, | ||
22 | {, | ||
23 | "EventCode": "0xC8", | ||
24 | "EventName": "EXT_SNOOP", | ||
25 | "BriefDescription": "SCU Snooped data from another CPU for this CPU" | ||
26 | } | ||
27 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json new file mode 100644 index 000000000000..480d9f7460ab --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/memory.json | |||
@@ -0,0 +1,22 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0x60", | ||
4 | "EventName": "BUS_ACCESS_LD", | ||
5 | "BriefDescription": "Bus access - Read" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0x61", | ||
9 | "EventName": "BUS_ACCESS_ST", | ||
10 | "BriefDescription": "Bus access - Write" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xC0", | ||
14 | "EventName": "EXT_MEM_REQ", | ||
15 | "BriefDescription": "External memory request" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xC1", | ||
19 | "EventName": "EXT_MEM_REQ_NC", | ||
20 | "BriefDescription": "Non-cacheable external memory request" | ||
21 | } | ||
22 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json new file mode 100644 index 000000000000..73a22402d003 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/other.json | |||
@@ -0,0 +1,32 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0x86", | ||
4 | "EventName": "EXC_IRQ", | ||
5 | "BriefDescription": "Exception taken, IRQ" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0x87", | ||
9 | "EventName": "EXC_FIQ", | ||
10 | "BriefDescription": "Exception taken, FIQ" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xC6", | ||
14 | "EventName": "PRE_DECODE_ERR", | ||
15 | "BriefDescription": "Pre-decode error" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xD0", | ||
19 | "EventName": "L1I_CACHE_ERR", | ||
20 | "BriefDescription": "L1 Instruction Cache (data or tag) memory error" | ||
21 | }, | ||
22 | {, | ||
23 | "EventCode": "0xD1", | ||
24 | "EventName": "L1D_CACHE_ERR", | ||
25 | "BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable" | ||
26 | }, | ||
27 | {, | ||
28 | "EventCode": "0xD2", | ||
29 | "EventName": "TLB_ERR", | ||
30 | "BriefDescription": "TLB memory error" | ||
31 | } | ||
32 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json b/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json new file mode 100644 index 000000000000..3149fb90555a --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/cortex-a53/pipeline.json | |||
@@ -0,0 +1,52 @@ | |||
1 | [ | ||
2 | {, | ||
3 | "EventCode": "0xC7", | ||
4 | "EventName": "STALL_SB_FULL", | ||
5 | "BriefDescription": "Data Write operation that stalls the pipeline because the store buffer is full" | ||
6 | }, | ||
7 | {, | ||
8 | "EventCode": "0xE0", | ||
9 | "EventName": "OTHER_IQ_DEP_STALL", | ||
10 | "BriefDescription": "Cycles that the DPU IQ is empty and that is not because of a recent micro-TLB miss, instruction cache miss or pre-decode error" | ||
11 | }, | ||
12 | {, | ||
13 | "EventCode": "0xE1", | ||
14 | "EventName": "IC_DEP_STALL", | ||
15 | "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction cache miss being processed" | ||
16 | }, | ||
17 | {, | ||
18 | "EventCode": "0xE2", | ||
19 | "EventName": "IUTLB_DEP_STALL", | ||
20 | "BriefDescription": "Cycles the DPU IQ is empty and there is an instruction micro-TLB miss being processed" | ||
21 | }, | ||
22 | {, | ||
23 | "EventCode": "0xE3", | ||
24 | "EventName": "DECODE_DEP_STALL", | ||
25 | "BriefDescription": "Cycles the DPU IQ is empty and there is a pre-decode error being processed" | ||
26 | }, | ||
27 | {, | ||
28 | "EventCode": "0xE4", | ||
29 | "EventName": "OTHER_INTERLOCK_STALL", | ||
30 | "BriefDescription": "Cycles there is an interlock other than Advanced SIMD/Floating-point instructions or load/store instruction" | ||
31 | }, | ||
32 | {, | ||
33 | "EventCode": "0xE5", | ||
34 | "EventName": "AGU_DEP_STALL", | ||
35 | "BriefDescription": "Cycles there is an interlock for a load/store instruction waiting for data to calculate the address in the AGU" | ||
36 | }, | ||
37 | {, | ||
38 | "EventCode": "0xE6", | ||
39 | "EventName": "SIMD_DEP_STALL", | ||
40 | "BriefDescription": "Cycles there is an interlock for an Advanced SIMD/Floating-point operation." | ||
41 | }, | ||
42 | {, | ||
43 | "EventCode": "0xE7", | ||
44 | "EventName": "LD_DEP_STALL", | ||
45 | "BriefDescription": "Cycles there is a stall in the Wr stage because of a load miss" | ||
46 | }, | ||
47 | {, | ||
48 | "EventCode": "0xE8", | ||
49 | "EventName": "ST_DEP_STALL", | ||
50 | "BriefDescription": "Cycles there is a stall in the Wr stage because of a store" | ||
51 | } | ||
52 | ] | ||
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv index 219d6756134e..e61c9ca6cf9e 100644 --- a/tools/perf/pmu-events/arch/arm64/mapfile.csv +++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv | |||
@@ -13,3 +13,4 @@ | |||
13 | # | 13 | # |
14 | #Family-model,Version,Filename,EventType | 14 | #Family-model,Version,Filename,EventType |
15 | 0x00000000420f5160,v1,cavium,core | 15 | 0x00000000420f5160,v1,cavium,core |
16 | 0x00000000410fd03[[:xdigit:]],v1,cortex-a53,core | ||
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 4035d43523c3..e0b1b414d466 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c | |||
@@ -31,10 +31,12 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, | |||
31 | int i; | 31 | int i; |
32 | 32 | ||
33 | for (i = 0; i < evlist->nr_mmaps; i++) { | 33 | for (i = 0; i < evlist->nr_mmaps; i++) { |
34 | struct perf_mmap *map = &evlist->overwrite_mmap[i]; | ||
34 | union perf_event *event; | 35 | union perf_event *event; |
36 | u64 start, end; | ||
35 | 37 | ||
36 | perf_mmap__read_catchup(&evlist->overwrite_mmap[i]); | 38 | perf_mmap__read_init(map, true, &start, &end); |
37 | while ((event = perf_mmap__read_backward(&evlist->overwrite_mmap[i])) != NULL) { | 39 | while ((event = perf_mmap__read_event(map, true, &start, end)) != NULL) { |
38 | const u32 type = event->header.type; | 40 | const u32 type = event->header.type; |
39 | 41 | ||
40 | switch (type) { | 42 | switch (type) { |
@@ -49,6 +51,7 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, | |||
49 | return TEST_FAIL; | 51 | return TEST_FAIL; |
50 | } | 52 | } |
51 | } | 53 | } |
54 | perf_mmap__read_done(map); | ||
52 | } | 55 | } |
53 | return TEST_OK; | 56 | return TEST_OK; |
54 | } | 57 | } |
diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh index 8b3da21a08f1..c446c894b297 100755 --- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | |||
@@ -22,10 +22,23 @@ trace_libc_inet_pton_backtrace() { | |||
22 | expected[4]="rtt min.*" | 22 | expected[4]="rtt min.*" |
23 | expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" | 23 | expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" |
24 | expected[6]=".*inet_pton[[:space:]]\($libc\)$" | 24 | expected[6]=".*inet_pton[[:space:]]\($libc\)$" |
25 | expected[7]="getaddrinfo[[:space:]]\($libc\)$" | 25 | case "$(uname -m)" in |
26 | expected[8]=".*\(.*/bin/ping.*\)$" | 26 | s390x) |
27 | 27 | eventattr='call-graph=dwarf' | |
28 | perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do | 28 | expected[7]="gaih_inet[[:space:]]\(inlined\)$" |
29 | expected[8]="__GI_getaddrinfo[[:space:]]\(inlined\)$" | ||
30 | expected[9]="main[[:space:]]\(.*/bin/ping.*\)$" | ||
31 | expected[10]="__libc_start_main[[:space:]]\($libc\)$" | ||
32 | expected[11]="_start[[:space:]]\(.*/bin/ping.*\)$" | ||
33 | ;; | ||
34 | *) | ||
35 | eventattr='max-stack=3' | ||
36 | expected[7]="getaddrinfo[[:space:]]\($libc\)$" | ||
37 | expected[8]=".*\(.*/bin/ping.*\)$" | ||
38 | ;; | ||
39 | esac | ||
40 | |||
41 | perf trace --no-syscalls -e probe_libc:inet_pton/$eventattr/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do | ||
29 | echo $line | 42 | echo $line |
30 | echo "$line" | egrep -q "${expected[$idx]}" | 43 | echo "$line" | egrep -q "${expected[$idx]}" |
31 | if [ $? -ne 0 ] ; then | 44 | if [ $? -ne 0 ] ; then |
@@ -33,7 +46,7 @@ trace_libc_inet_pton_backtrace() { | |||
33 | exit 1 | 46 | exit 1 |
34 | fi | 47 | fi |
35 | let idx+=1 | 48 | let idx+=1 |
36 | [ $idx -eq 9 ] && break | 49 | [ -z "${expected[$idx]}" ] && break |
37 | done | 50 | done |
38 | } | 51 | } |
39 | 52 | ||
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 286427975112..fbf927cf775d 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -327,7 +327,32 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) | |||
327 | if (!disasm_line__is_valid_jump(cursor, sym)) | 327 | if (!disasm_line__is_valid_jump(cursor, sym)) |
328 | return; | 328 | return; |
329 | 329 | ||
330 | /* | ||
331 | * This first was seen with a gcc function, _cpp_lex_token, that | ||
332 | * has the usual jumps: | ||
333 | * | ||
334 | * │1159e6c: ↓ jne 115aa32 <_cpp_lex_token@@Base+0xf92> | ||
335 | * | ||
336 | * I.e. jumps to a label inside that function (_cpp_lex_token), and | ||
337 | * those works, but also this kind: | ||
338 | * | ||
339 | * │1159e8b: ↓ jne c469be <cpp_named_operator2name@@Base+0xa72> | ||
340 | * | ||
341 | * I.e. jumps to another function, outside _cpp_lex_token, which | ||
342 | * are not being correctly handled generating as a side effect references | ||
343 | * to ab->offset[] entries that are set to NULL, so to make this code | ||
344 | * more robust, check that here. | ||
345 | * | ||
346 | * A proper fix for will be put in place, looking at the function | ||
347 | * name right after the '<' token and probably treating this like a | ||
348 | * 'call' instruction. | ||
349 | */ | ||
330 | target = ab->offsets[cursor->ops.target.offset]; | 350 | target = ab->offsets[cursor->ops.target.offset]; |
351 | if (target == NULL) { | ||
352 | ui_helpline__printf("WARN: jump target inconsistency, press 'o', ab->offsets[%#x] = NULL\n", | ||
353 | cursor->ops.target.offset); | ||
354 | return; | ||
355 | } | ||
331 | 356 | ||
332 | bcursor = browser_line(&cursor->al); | 357 | bcursor = browser_line(&cursor->al); |
333 | btarget = browser_line(target); | 358 | btarget = browser_line(target); |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 68146f4620a5..6495ee55d9c3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -608,7 +608,8 @@ static int hist_browser__title(struct hist_browser *browser, char *bf, size_t si | |||
608 | return browser->title ? browser->title(browser, bf, size) : 0; | 608 | return browser->title ? browser->title(browser, bf, size) : 0; |
609 | } | 609 | } |
610 | 610 | ||
611 | int hist_browser__run(struct hist_browser *browser, const char *help) | 611 | int hist_browser__run(struct hist_browser *browser, const char *help, |
612 | bool warn_lost_event) | ||
612 | { | 613 | { |
613 | int key; | 614 | int key; |
614 | char title[160]; | 615 | char title[160]; |
@@ -638,8 +639,9 @@ int hist_browser__run(struct hist_browser *browser, const char *help) | |||
638 | nr_entries = hist_browser__nr_entries(browser); | 639 | nr_entries = hist_browser__nr_entries(browser); |
639 | ui_browser__update_nr_entries(&browser->b, nr_entries); | 640 | ui_browser__update_nr_entries(&browser->b, nr_entries); |
640 | 641 | ||
641 | if (browser->hists->stats.nr_lost_warned != | 642 | if (warn_lost_event && |
642 | browser->hists->stats.nr_events[PERF_RECORD_LOST]) { | 643 | (browser->hists->stats.nr_lost_warned != |
644 | browser->hists->stats.nr_events[PERF_RECORD_LOST])) { | ||
643 | browser->hists->stats.nr_lost_warned = | 645 | browser->hists->stats.nr_lost_warned = |
644 | browser->hists->stats.nr_events[PERF_RECORD_LOST]; | 646 | browser->hists->stats.nr_events[PERF_RECORD_LOST]; |
645 | ui_browser__warn_lost_events(&browser->b); | 647 | ui_browser__warn_lost_events(&browser->b); |
@@ -2763,7 +2765,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
2763 | bool left_exits, | 2765 | bool left_exits, |
2764 | struct hist_browser_timer *hbt, | 2766 | struct hist_browser_timer *hbt, |
2765 | float min_pcnt, | 2767 | float min_pcnt, |
2766 | struct perf_env *env) | 2768 | struct perf_env *env, |
2769 | bool warn_lost_event) | ||
2767 | { | 2770 | { |
2768 | struct hists *hists = evsel__hists(evsel); | 2771 | struct hists *hists = evsel__hists(evsel); |
2769 | struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); | 2772 | struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); |
@@ -2844,7 +2847,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
2844 | 2847 | ||
2845 | nr_options = 0; | 2848 | nr_options = 0; |
2846 | 2849 | ||
2847 | key = hist_browser__run(browser, helpline); | 2850 | key = hist_browser__run(browser, helpline, |
2851 | warn_lost_event); | ||
2848 | 2852 | ||
2849 | if (browser->he_selection != NULL) { | 2853 | if (browser->he_selection != NULL) { |
2850 | thread = hist_browser__selected_thread(browser); | 2854 | thread = hist_browser__selected_thread(browser); |
@@ -3184,7 +3188,8 @@ static void perf_evsel_menu__write(struct ui_browser *browser, | |||
3184 | 3188 | ||
3185 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | 3189 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, |
3186 | int nr_events, const char *help, | 3190 | int nr_events, const char *help, |
3187 | struct hist_browser_timer *hbt) | 3191 | struct hist_browser_timer *hbt, |
3192 | bool warn_lost_event) | ||
3188 | { | 3193 | { |
3189 | struct perf_evlist *evlist = menu->b.priv; | 3194 | struct perf_evlist *evlist = menu->b.priv; |
3190 | struct perf_evsel *pos; | 3195 | struct perf_evsel *pos; |
@@ -3203,7 +3208,9 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | |||
3203 | case K_TIMER: | 3208 | case K_TIMER: |
3204 | hbt->timer(hbt->arg); | 3209 | hbt->timer(hbt->arg); |
3205 | 3210 | ||
3206 | if (!menu->lost_events_warned && menu->lost_events) { | 3211 | if (!menu->lost_events_warned && |
3212 | menu->lost_events && | ||
3213 | warn_lost_event) { | ||
3207 | ui_browser__warn_lost_events(&menu->b); | 3214 | ui_browser__warn_lost_events(&menu->b); |
3208 | menu->lost_events_warned = true; | 3215 | menu->lost_events_warned = true; |
3209 | } | 3216 | } |
@@ -3224,7 +3231,8 @@ browse_hists: | |||
3224 | key = perf_evsel__hists_browse(pos, nr_events, help, | 3231 | key = perf_evsel__hists_browse(pos, nr_events, help, |
3225 | true, hbt, | 3232 | true, hbt, |
3226 | menu->min_pcnt, | 3233 | menu->min_pcnt, |
3227 | menu->env); | 3234 | menu->env, |
3235 | warn_lost_event); | ||
3228 | ui_browser__show_title(&menu->b, title); | 3236 | ui_browser__show_title(&menu->b, title); |
3229 | switch (key) { | 3237 | switch (key) { |
3230 | case K_TAB: | 3238 | case K_TAB: |
@@ -3282,7 +3290,8 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
3282 | int nr_entries, const char *help, | 3290 | int nr_entries, const char *help, |
3283 | struct hist_browser_timer *hbt, | 3291 | struct hist_browser_timer *hbt, |
3284 | float min_pcnt, | 3292 | float min_pcnt, |
3285 | struct perf_env *env) | 3293 | struct perf_env *env, |
3294 | bool warn_lost_event) | ||
3286 | { | 3295 | { |
3287 | struct perf_evsel *pos; | 3296 | struct perf_evsel *pos; |
3288 | struct perf_evsel_menu menu = { | 3297 | struct perf_evsel_menu menu = { |
@@ -3309,13 +3318,15 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
3309 | menu.b.width = line_len; | 3318 | menu.b.width = line_len; |
3310 | } | 3319 | } |
3311 | 3320 | ||
3312 | return perf_evsel_menu__run(&menu, nr_entries, help, hbt); | 3321 | return perf_evsel_menu__run(&menu, nr_entries, help, |
3322 | hbt, warn_lost_event); | ||
3313 | } | 3323 | } |
3314 | 3324 | ||
3315 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 3325 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
3316 | struct hist_browser_timer *hbt, | 3326 | struct hist_browser_timer *hbt, |
3317 | float min_pcnt, | 3327 | float min_pcnt, |
3318 | struct perf_env *env) | 3328 | struct perf_env *env, |
3329 | bool warn_lost_event) | ||
3319 | { | 3330 | { |
3320 | int nr_entries = evlist->nr_entries; | 3331 | int nr_entries = evlist->nr_entries; |
3321 | 3332 | ||
@@ -3325,7 +3336,7 @@ single_entry: | |||
3325 | 3336 | ||
3326 | return perf_evsel__hists_browse(first, nr_entries, help, | 3337 | return perf_evsel__hists_browse(first, nr_entries, help, |
3327 | false, hbt, min_pcnt, | 3338 | false, hbt, min_pcnt, |
3328 | env); | 3339 | env, warn_lost_event); |
3329 | } | 3340 | } |
3330 | 3341 | ||
3331 | if (symbol_conf.event_group) { | 3342 | if (symbol_conf.event_group) { |
@@ -3342,5 +3353,6 @@ single_entry: | |||
3342 | } | 3353 | } |
3343 | 3354 | ||
3344 | return __perf_evlist__tui_browse_hists(evlist, nr_entries, help, | 3355 | return __perf_evlist__tui_browse_hists(evlist, nr_entries, help, |
3345 | hbt, min_pcnt, env); | 3356 | hbt, min_pcnt, env, |
3357 | warn_lost_event); | ||
3346 | } | 3358 | } |
diff --git a/tools/perf/ui/browsers/hists.h b/tools/perf/ui/browsers/hists.h index ba431777f559..9428bee076f2 100644 --- a/tools/perf/ui/browsers/hists.h +++ b/tools/perf/ui/browsers/hists.h | |||
@@ -28,7 +28,8 @@ struct hist_browser { | |||
28 | 28 | ||
29 | struct hist_browser *hist_browser__new(struct hists *hists); | 29 | struct hist_browser *hist_browser__new(struct hists *hists); |
30 | void hist_browser__delete(struct hist_browser *browser); | 30 | void hist_browser__delete(struct hist_browser *browser); |
31 | int hist_browser__run(struct hist_browser *browser, const char *help); | 31 | int hist_browser__run(struct hist_browser *browser, const char *help, |
32 | bool warn_lost_event); | ||
32 | void hist_browser__init(struct hist_browser *browser, | 33 | void hist_browser__init(struct hist_browser *browser, |
33 | struct hists *hists); | 34 | struct hists *hists); |
34 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ | 35 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ |
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 9faf3b5367db..6470ea2aa25e 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c | |||
@@ -60,6 +60,12 @@ | |||
60 | #include "sane_ctype.h" | 60 | #include "sane_ctype.h" |
61 | #include "symbol/kallsyms.h" | 61 | #include "symbol/kallsyms.h" |
62 | 62 | ||
63 | static bool auxtrace__dont_decode(struct perf_session *session) | ||
64 | { | ||
65 | return !session->itrace_synth_opts || | ||
66 | session->itrace_synth_opts->dont_decode; | ||
67 | } | ||
68 | |||
63 | int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, | 69 | int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, |
64 | struct auxtrace_mmap_params *mp, | 70 | struct auxtrace_mmap_params *mp, |
65 | void *userpg, int fd) | 71 | void *userpg, int fd) |
@@ -762,6 +768,9 @@ int auxtrace_queues__process_index(struct auxtrace_queues *queues, | |||
762 | size_t i; | 768 | size_t i; |
763 | int err; | 769 | int err; |
764 | 770 | ||
771 | if (auxtrace__dont_decode(session)) | ||
772 | return 0; | ||
773 | |||
765 | list_for_each_entry(auxtrace_index, &session->auxtrace_index, list) { | 774 | list_for_each_entry(auxtrace_index, &session->auxtrace_index, list) { |
766 | for (i = 0; i < auxtrace_index->nr; i++) { | 775 | for (i = 0; i < auxtrace_index->nr; i++) { |
767 | ent = &auxtrace_index->entries[i]; | 776 | ent = &auxtrace_index->entries[i]; |
@@ -892,12 +901,6 @@ out_free: | |||
892 | return err; | 901 | return err; |
893 | } | 902 | } |
894 | 903 | ||
895 | static bool auxtrace__dont_decode(struct perf_session *session) | ||
896 | { | ||
897 | return !session->itrace_synth_opts || | ||
898 | session->itrace_synth_opts->dont_decode; | ||
899 | } | ||
900 | |||
901 | int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, | 904 | int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, |
902 | union perf_event *event, | 905 | union perf_event *event, |
903 | struct perf_session *session) | 906 | struct perf_session *session) |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ac35cd214feb..e5fc14e53c05 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -715,28 +715,11 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int | |||
715 | return perf_mmap__read_forward(md); | 715 | return perf_mmap__read_forward(md); |
716 | } | 716 | } |
717 | 717 | ||
718 | union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx) | ||
719 | { | ||
720 | struct perf_mmap *md = &evlist->mmap[idx]; | ||
721 | |||
722 | /* | ||
723 | * No need to check messup for backward ring buffer: | ||
724 | * We can always read arbitrary long data from a backward | ||
725 | * ring buffer unless we forget to pause it before reading. | ||
726 | */ | ||
727 | return perf_mmap__read_backward(md); | ||
728 | } | ||
729 | |||
730 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) | 718 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) |
731 | { | 719 | { |
732 | return perf_evlist__mmap_read_forward(evlist, idx); | 720 | return perf_evlist__mmap_read_forward(evlist, idx); |
733 | } | 721 | } |
734 | 722 | ||
735 | void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx) | ||
736 | { | ||
737 | perf_mmap__read_catchup(&evlist->mmap[idx]); | ||
738 | } | ||
739 | |||
740 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) | 723 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) |
741 | { | 724 | { |
742 | perf_mmap__consume(&evlist->mmap[idx], false); | 725 | perf_mmap__consume(&evlist->mmap[idx], false); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 75f8e0ad5d76..336b838e6957 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -133,10 +133,6 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx); | |||
133 | 133 | ||
134 | union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, | 134 | union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, |
135 | int idx); | 135 | int idx); |
136 | union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, | ||
137 | int idx); | ||
138 | void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx); | ||
139 | |||
140 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); | 136 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); |
141 | 137 | ||
142 | int perf_evlist__open(struct perf_evlist *evlist); | 138 | int perf_evlist__open(struct perf_evlist *evlist); |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ff359c9ece2e..ef351688b797 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -41,17 +41,7 @@ | |||
41 | 41 | ||
42 | #include "sane_ctype.h" | 42 | #include "sane_ctype.h" |
43 | 43 | ||
44 | static struct { | 44 | struct perf_missing_features perf_missing_features; |
45 | bool sample_id_all; | ||
46 | bool exclude_guest; | ||
47 | bool mmap2; | ||
48 | bool cloexec; | ||
49 | bool clockid; | ||
50 | bool clockid_wrong; | ||
51 | bool lbr_flags; | ||
52 | bool write_backward; | ||
53 | bool group_read; | ||
54 | } perf_missing_features; | ||
55 | 45 | ||
56 | static clockid_t clockid; | 46 | static clockid_t clockid; |
57 | 47 | ||
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 846e41644525..a7487c6d1866 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -149,6 +149,20 @@ union u64_swap { | |||
149 | u32 val32[2]; | 149 | u32 val32[2]; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | struct perf_missing_features { | ||
153 | bool sample_id_all; | ||
154 | bool exclude_guest; | ||
155 | bool mmap2; | ||
156 | bool cloexec; | ||
157 | bool clockid; | ||
158 | bool clockid_wrong; | ||
159 | bool lbr_flags; | ||
160 | bool write_backward; | ||
161 | bool group_read; | ||
162 | }; | ||
163 | |||
164 | extern struct perf_missing_features perf_missing_features; | ||
165 | |||
152 | struct cpu_map; | 166 | struct cpu_map; |
153 | struct target; | 167 | struct target; |
154 | struct thread_map; | 168 | struct thread_map; |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index f6630cb95eff..02721b579746 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -430,7 +430,8 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, | |||
430 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 430 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
431 | struct hist_browser_timer *hbt, | 431 | struct hist_browser_timer *hbt, |
432 | float min_pcnt, | 432 | float min_pcnt, |
433 | struct perf_env *env); | 433 | struct perf_env *env, |
434 | bool warn_lost_event); | ||
434 | int script_browse(const char *script_opt); | 435 | int script_browse(const char *script_opt); |
435 | #else | 436 | #else |
436 | static inline | 437 | static inline |
@@ -438,7 +439,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, | |||
438 | const char *help __maybe_unused, | 439 | const char *help __maybe_unused, |
439 | struct hist_browser_timer *hbt __maybe_unused, | 440 | struct hist_browser_timer *hbt __maybe_unused, |
440 | float min_pcnt __maybe_unused, | 441 | float min_pcnt __maybe_unused, |
441 | struct perf_env *env __maybe_unused) | 442 | struct perf_env *env __maybe_unused, |
443 | bool warn_lost_event __maybe_unused) | ||
442 | { | 444 | { |
443 | return 0; | 445 | return 0; |
444 | } | 446 | } |
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 05076e683938..91531a7c8fbf 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c | |||
@@ -22,29 +22,27 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map) | |||
22 | 22 | ||
23 | /* When check_messup is true, 'end' must points to a good entry */ | 23 | /* When check_messup is true, 'end' must points to a good entry */ |
24 | static union perf_event *perf_mmap__read(struct perf_mmap *map, | 24 | static union perf_event *perf_mmap__read(struct perf_mmap *map, |
25 | u64 start, u64 end, u64 *prev) | 25 | u64 *startp, u64 end) |
26 | { | 26 | { |
27 | unsigned char *data = map->base + page_size; | 27 | unsigned char *data = map->base + page_size; |
28 | union perf_event *event = NULL; | 28 | union perf_event *event = NULL; |
29 | int diff = end - start; | 29 | int diff = end - *startp; |
30 | 30 | ||
31 | if (diff >= (int)sizeof(event->header)) { | 31 | if (diff >= (int)sizeof(event->header)) { |
32 | size_t size; | 32 | size_t size; |
33 | 33 | ||
34 | event = (union perf_event *)&data[start & map->mask]; | 34 | event = (union perf_event *)&data[*startp & map->mask]; |
35 | size = event->header.size; | 35 | size = event->header.size; |
36 | 36 | ||
37 | if (size < sizeof(event->header) || diff < (int)size) { | 37 | if (size < sizeof(event->header) || diff < (int)size) |
38 | event = NULL; | 38 | return NULL; |
39 | goto broken_event; | ||
40 | } | ||
41 | 39 | ||
42 | /* | 40 | /* |
43 | * Event straddles the mmap boundary -- header should always | 41 | * Event straddles the mmap boundary -- header should always |
44 | * be inside due to u64 alignment of output. | 42 | * be inside due to u64 alignment of output. |
45 | */ | 43 | */ |
46 | if ((start & map->mask) + size != ((start + size) & map->mask)) { | 44 | if ((*startp & map->mask) + size != ((*startp + size) & map->mask)) { |
47 | unsigned int offset = start; | 45 | unsigned int offset = *startp; |
48 | unsigned int len = min(sizeof(*event), size), cpy; | 46 | unsigned int len = min(sizeof(*event), size), cpy; |
49 | void *dst = map->event_copy; | 47 | void *dst = map->event_copy; |
50 | 48 | ||
@@ -59,20 +57,19 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map, | |||
59 | event = (union perf_event *)map->event_copy; | 57 | event = (union perf_event *)map->event_copy; |
60 | } | 58 | } |
61 | 59 | ||
62 | start += size; | 60 | *startp += size; |
63 | } | 61 | } |
64 | 62 | ||
65 | broken_event: | ||
66 | if (prev) | ||
67 | *prev = start; | ||
68 | |||
69 | return event; | 63 | return event; |
70 | } | 64 | } |
71 | 65 | ||
66 | /* | ||
67 | * legacy interface for mmap read. | ||
68 | * Don't use it. Use perf_mmap__read_event(). | ||
69 | */ | ||
72 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map) | 70 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map) |
73 | { | 71 | { |
74 | u64 head; | 72 | u64 head; |
75 | u64 old = map->prev; | ||
76 | 73 | ||
77 | /* | 74 | /* |
78 | * Check if event was unmapped due to a POLLHUP/POLLERR. | 75 | * Check if event was unmapped due to a POLLHUP/POLLERR. |
@@ -82,13 +79,26 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map) | |||
82 | 79 | ||
83 | head = perf_mmap__read_head(map); | 80 | head = perf_mmap__read_head(map); |
84 | 81 | ||
85 | return perf_mmap__read(map, old, head, &map->prev); | 82 | return perf_mmap__read(map, &map->prev, head); |
86 | } | 83 | } |
87 | 84 | ||
88 | union perf_event *perf_mmap__read_backward(struct perf_mmap *map) | 85 | /* |
86 | * Read event from ring buffer one by one. | ||
87 | * Return one event for each call. | ||
88 | * | ||
89 | * Usage: | ||
90 | * perf_mmap__read_init() | ||
91 | * while(event = perf_mmap__read_event()) { | ||
92 | * //process the event | ||
93 | * perf_mmap__consume() | ||
94 | * } | ||
95 | * perf_mmap__read_done() | ||
96 | */ | ||
97 | union perf_event *perf_mmap__read_event(struct perf_mmap *map, | ||
98 | bool overwrite, | ||
99 | u64 *startp, u64 end) | ||
89 | { | 100 | { |
90 | u64 head, end; | 101 | union perf_event *event; |
91 | u64 start = map->prev; | ||
92 | 102 | ||
93 | /* | 103 | /* |
94 | * Check if event was unmapped due to a POLLHUP/POLLERR. | 104 | * Check if event was unmapped due to a POLLHUP/POLLERR. |
@@ -96,40 +106,19 @@ union perf_event *perf_mmap__read_backward(struct perf_mmap *map) | |||
96 | if (!refcount_read(&map->refcnt)) | 106 | if (!refcount_read(&map->refcnt)) |
97 | return NULL; | 107 | return NULL; |
98 | 108 | ||
99 | head = perf_mmap__read_head(map); | 109 | if (startp == NULL) |
100 | if (!head) | ||
101 | return NULL; | 110 | return NULL; |
102 | 111 | ||
103 | /* | 112 | /* non-overwirte doesn't pause the ringbuffer */ |
104 | * 'head' pointer starts from 0. Kernel minus sizeof(record) form | 113 | if (!overwrite) |
105 | * it each time when kernel writes to it, so in fact 'head' is | 114 | end = perf_mmap__read_head(map); |
106 | * negative. 'end' pointer is made manually by adding the size of | ||
107 | * the ring buffer to 'head' pointer, means the validate data can | ||
108 | * read is the whole ring buffer. If 'end' is positive, the ring | ||
109 | * buffer has not fully filled, so we must adjust 'end' to 0. | ||
110 | * | ||
111 | * However, since both 'head' and 'end' is unsigned, we can't | ||
112 | * simply compare 'end' against 0. Here we compare '-head' and | ||
113 | * the size of the ring buffer, where -head is the number of bytes | ||
114 | * kernel write to the ring buffer. | ||
115 | */ | ||
116 | if (-head < (u64)(map->mask + 1)) | ||
117 | end = 0; | ||
118 | else | ||
119 | end = head + map->mask + 1; | ||
120 | |||
121 | return perf_mmap__read(map, start, end, &map->prev); | ||
122 | } | ||
123 | 115 | ||
124 | void perf_mmap__read_catchup(struct perf_mmap *map) | 116 | event = perf_mmap__read(map, startp, end); |
125 | { | ||
126 | u64 head; | ||
127 | 117 | ||
128 | if (!refcount_read(&map->refcnt)) | 118 | if (!overwrite) |
129 | return; | 119 | map->prev = *startp; |
130 | 120 | ||
131 | head = perf_mmap__read_head(map); | 121 | return event; |
132 | map->prev = head; | ||
133 | } | 122 | } |
134 | 123 | ||
135 | static bool perf_mmap__empty(struct perf_mmap *map) | 124 | static bool perf_mmap__empty(struct perf_mmap *map) |
@@ -267,41 +256,60 @@ static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u6 | |||
267 | return -1; | 256 | return -1; |
268 | } | 257 | } |
269 | 258 | ||
270 | int perf_mmap__push(struct perf_mmap *md, bool overwrite, | 259 | /* |
271 | void *to, int push(void *to, void *buf, size_t size)) | 260 | * Report the start and end of the available data in ringbuffer |
261 | */ | ||
262 | int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, | ||
263 | u64 *startp, u64 *endp) | ||
272 | { | 264 | { |
273 | u64 head = perf_mmap__read_head(md); | 265 | u64 head = perf_mmap__read_head(md); |
274 | u64 old = md->prev; | 266 | u64 old = md->prev; |
275 | u64 end = head, start = old; | ||
276 | unsigned char *data = md->base + page_size; | 267 | unsigned char *data = md->base + page_size; |
277 | unsigned long size; | 268 | unsigned long size; |
278 | void *buf; | ||
279 | int rc = 0; | ||
280 | 269 | ||
281 | start = overwrite ? head : old; | 270 | *startp = overwrite ? head : old; |
282 | end = overwrite ? old : head; | 271 | *endp = overwrite ? old : head; |
283 | 272 | ||
284 | if (start == end) | 273 | if (*startp == *endp) |
285 | return 0; | 274 | return -EAGAIN; |
286 | 275 | ||
287 | size = end - start; | 276 | size = *endp - *startp; |
288 | if (size > (unsigned long)(md->mask) + 1) { | 277 | if (size > (unsigned long)(md->mask) + 1) { |
289 | if (!overwrite) { | 278 | if (!overwrite) { |
290 | WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n"); | 279 | WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n"); |
291 | 280 | ||
292 | md->prev = head; | 281 | md->prev = head; |
293 | perf_mmap__consume(md, overwrite); | 282 | perf_mmap__consume(md, overwrite); |
294 | return 0; | 283 | return -EAGAIN; |
295 | } | 284 | } |
296 | 285 | ||
297 | /* | 286 | /* |
298 | * Backward ring buffer is full. We still have a chance to read | 287 | * Backward ring buffer is full. We still have a chance to read |
299 | * most of data from it. | 288 | * most of data from it. |
300 | */ | 289 | */ |
301 | if (overwrite_rb_find_range(data, md->mask, head, &start, &end)) | 290 | if (overwrite_rb_find_range(data, md->mask, head, startp, endp)) |
302 | return -1; | 291 | return -EINVAL; |
303 | } | 292 | } |
304 | 293 | ||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | int perf_mmap__push(struct perf_mmap *md, bool overwrite, | ||
298 | void *to, int push(void *to, void *buf, size_t size)) | ||
299 | { | ||
300 | u64 head = perf_mmap__read_head(md); | ||
301 | u64 end, start; | ||
302 | unsigned char *data = md->base + page_size; | ||
303 | unsigned long size; | ||
304 | void *buf; | ||
305 | int rc = 0; | ||
306 | |||
307 | rc = perf_mmap__read_init(md, overwrite, &start, &end); | ||
308 | if (rc < 0) | ||
309 | return (rc == -EAGAIN) ? 0 : -1; | ||
310 | |||
311 | size = end - start; | ||
312 | |||
305 | if ((start & md->mask) + size != (end & md->mask)) { | 313 | if ((start & md->mask) + size != (end & md->mask)) { |
306 | buf = &data[start & md->mask]; | 314 | buf = &data[start & md->mask]; |
307 | size = md->mask + 1 - (start & md->mask); | 315 | size = md->mask + 1 - (start & md->mask); |
@@ -327,3 +335,14 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite, | |||
327 | out: | 335 | out: |
328 | return rc; | 336 | return rc; |
329 | } | 337 | } |
338 | |||
339 | /* | ||
340 | * Mandatory for overwrite mode | ||
341 | * The direction of overwrite mode is backward. | ||
342 | * The last perf_mmap__read() will set tail to map->prev. | ||
343 | * Need to correct the map->prev to head which is the end of next read. | ||
344 | */ | ||
345 | void perf_mmap__read_done(struct perf_mmap *map) | ||
346 | { | ||
347 | map->prev = perf_mmap__read_head(map); | ||
348 | } | ||
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index e43d7b55a55f..ec7d3a24e276 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h | |||
@@ -65,8 +65,6 @@ void perf_mmap__put(struct perf_mmap *map); | |||
65 | 65 | ||
66 | void perf_mmap__consume(struct perf_mmap *map, bool overwrite); | 66 | void perf_mmap__consume(struct perf_mmap *map, bool overwrite); |
67 | 67 | ||
68 | void perf_mmap__read_catchup(struct perf_mmap *md); | ||
69 | |||
70 | static inline u64 perf_mmap__read_head(struct perf_mmap *mm) | 68 | static inline u64 perf_mmap__read_head(struct perf_mmap *mm) |
71 | { | 69 | { |
72 | struct perf_event_mmap_page *pc = mm->base; | 70 | struct perf_event_mmap_page *pc = mm->base; |
@@ -87,11 +85,17 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail) | |||
87 | } | 85 | } |
88 | 86 | ||
89 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map); | 87 | union perf_event *perf_mmap__read_forward(struct perf_mmap *map); |
90 | union perf_event *perf_mmap__read_backward(struct perf_mmap *map); | 88 | |
89 | union perf_event *perf_mmap__read_event(struct perf_mmap *map, | ||
90 | bool overwrite, | ||
91 | u64 *startp, u64 end); | ||
91 | 92 | ||
92 | int perf_mmap__push(struct perf_mmap *md, bool backward, | 93 | int perf_mmap__push(struct perf_mmap *md, bool backward, |
93 | void *to, int push(void *to, void *buf, size_t size)); | 94 | void *to, int push(void *to, void *buf, size_t size)); |
94 | 95 | ||
95 | size_t perf_mmap__mmap_len(struct perf_mmap *map); | 96 | size_t perf_mmap__mmap_len(struct perf_mmap *map); |
96 | 97 | ||
98 | int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, | ||
99 | u64 *startp, u64 *endp); | ||
100 | void perf_mmap__read_done(struct perf_mmap *map); | ||
97 | #endif /*__PERF_MMAP_H */ | 101 | #endif /*__PERF_MMAP_H */ |
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 1e97937b03a9..6f09e4962dad 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -137,6 +137,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, | |||
137 | struct perf_evsel *evsel; | 137 | struct perf_evsel *evsel; |
138 | bool use_sample_identifier = false; | 138 | bool use_sample_identifier = false; |
139 | bool use_comm_exec; | 139 | bool use_comm_exec; |
140 | bool sample_id = opts->sample_id; | ||
140 | 141 | ||
141 | /* | 142 | /* |
142 | * Set the evsel leader links before we configure attributes, | 143 | * Set the evsel leader links before we configure attributes, |
@@ -163,8 +164,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, | |||
163 | * match the id. | 164 | * match the id. |
164 | */ | 165 | */ |
165 | use_sample_identifier = perf_can_sample_identifier(); | 166 | use_sample_identifier = perf_can_sample_identifier(); |
166 | evlist__for_each_entry(evlist, evsel) | 167 | sample_id = true; |
167 | perf_evsel__set_sample_id(evsel, use_sample_identifier); | ||
168 | } else if (evlist->nr_entries > 1) { | 168 | } else if (evlist->nr_entries > 1) { |
169 | struct perf_evsel *first = perf_evlist__first(evlist); | 169 | struct perf_evsel *first = perf_evlist__first(evlist); |
170 | 170 | ||
@@ -174,6 +174,10 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, | |||
174 | use_sample_identifier = perf_can_sample_identifier(); | 174 | use_sample_identifier = perf_can_sample_identifier(); |
175 | break; | 175 | break; |
176 | } | 176 | } |
177 | sample_id = true; | ||
178 | } | ||
179 | |||
180 | if (sample_id) { | ||
177 | evlist__for_each_entry(evlist, evsel) | 181 | evlist__for_each_entry(evlist, evsel) |
178 | perf_evsel__set_sample_id(evsel, use_sample_identifier); | 182 | perf_evsel__set_sample_id(evsel, use_sample_identifier); |
179 | } | 183 | } |
diff --git a/tools/perf/util/trigger.h b/tools/perf/util/trigger.h index 370138e7e35c..88223bc7c82b 100644 --- a/tools/perf/util/trigger.h +++ b/tools/perf/util/trigger.h | |||
@@ -12,7 +12,7 @@ | |||
12 | * States and transits: | 12 | * States and transits: |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * OFF--(on)--> READY --(hit)--> HIT | 15 | * OFF--> ON --> READY --(hit)--> HIT |
16 | * ^ | | 16 | * ^ | |
17 | * | (ready) | 17 | * | (ready) |
18 | * | | | 18 | * | | |
@@ -27,8 +27,9 @@ struct trigger { | |||
27 | volatile enum { | 27 | volatile enum { |
28 | TRIGGER_ERROR = -2, | 28 | TRIGGER_ERROR = -2, |
29 | TRIGGER_OFF = -1, | 29 | TRIGGER_OFF = -1, |
30 | TRIGGER_READY = 0, | 30 | TRIGGER_ON = 0, |
31 | TRIGGER_HIT = 1, | 31 | TRIGGER_READY = 1, |
32 | TRIGGER_HIT = 2, | ||
32 | } state; | 33 | } state; |
33 | const char *name; | 34 | const char *name; |
34 | }; | 35 | }; |
@@ -50,7 +51,7 @@ static inline bool trigger_is_error(struct trigger *t) | |||
50 | static inline void trigger_on(struct trigger *t) | 51 | static inline void trigger_on(struct trigger *t) |
51 | { | 52 | { |
52 | TRIGGER_WARN_ONCE(t, TRIGGER_OFF); | 53 | TRIGGER_WARN_ONCE(t, TRIGGER_OFF); |
53 | t->state = TRIGGER_READY; | 54 | t->state = TRIGGER_ON; |
54 | } | 55 | } |
55 | 56 | ||
56 | static inline void trigger_ready(struct trigger *t) | 57 | static inline void trigger_ready(struct trigger *t) |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 443892dabedb..1019bbc5dbd8 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -340,35 +340,15 @@ size_t hex_width(u64 v) | |||
340 | return n; | 340 | return n; |
341 | } | 341 | } |
342 | 342 | ||
343 | static int hex(char ch) | ||
344 | { | ||
345 | if ((ch >= '0') && (ch <= '9')) | ||
346 | return ch - '0'; | ||
347 | if ((ch >= 'a') && (ch <= 'f')) | ||
348 | return ch - 'a' + 10; | ||
349 | if ((ch >= 'A') && (ch <= 'F')) | ||
350 | return ch - 'A' + 10; | ||
351 | return -1; | ||
352 | } | ||
353 | |||
354 | /* | 343 | /* |
355 | * While we find nice hex chars, build a long_val. | 344 | * While we find nice hex chars, build a long_val. |
356 | * Return number of chars processed. | 345 | * Return number of chars processed. |
357 | */ | 346 | */ |
358 | int hex2u64(const char *ptr, u64 *long_val) | 347 | int hex2u64(const char *ptr, u64 *long_val) |
359 | { | 348 | { |
360 | const char *p = ptr; | 349 | char *p; |
361 | *long_val = 0; | ||
362 | |||
363 | while (*p) { | ||
364 | const int hex_val = hex(*p); | ||
365 | 350 | ||
366 | if (hex_val < 0) | 351 | *long_val = strtoull(ptr, &p, 16); |
367 | break; | ||
368 | |||
369 | *long_val = (*long_val << 4) | hex_val; | ||
370 | p++; | ||
371 | } | ||
372 | 352 | ||
373 | return p - ptr; | 353 | return p - ptr; |
374 | } | 354 | } |
diff --git a/tools/power/acpi/Makefile.config b/tools/power/acpi/Makefile.config index a1883bbb0144..2cccbba64418 100644 --- a/tools/power/acpi/Makefile.config +++ b/tools/power/acpi/Makefile.config | |||
@@ -56,9 +56,6 @@ INSTALL_SCRIPT = ${INSTALL_PROGRAM} | |||
56 | # to compile vs uClibc, that can be done here as well. | 56 | # to compile vs uClibc, that can be done here as well. |
57 | CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- | 57 | CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- |
58 | CROSS_COMPILE ?= $(CROSS) | 58 | CROSS_COMPILE ?= $(CROSS) |
59 | CC = $(CROSS_COMPILE)gcc | ||
60 | LD = $(CROSS_COMPILE)gcc | ||
61 | STRIP = $(CROSS_COMPILE)strip | ||
62 | HOSTCC = gcc | 59 | HOSTCC = gcc |
63 | 60 | ||
64 | # check if compiler option is supported | 61 | # check if compiler option is supported |
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index fcb3ed0be5f8..dd614463d4d6 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include | |||
@@ -42,6 +42,24 @@ EXTRA_WARNINGS += -Wformat | |||
42 | 42 | ||
43 | CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) | 43 | CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) |
44 | 44 | ||
45 | # Makefiles suck: This macro sets a default value of $(2) for the | ||
46 | # variable named by $(1), unless the variable has been set by | ||
47 | # environment or command line. This is necessary for CC and AR | ||
48 | # because make sets default values, so the simpler ?= approach | ||
49 | # won't work as expected. | ||
50 | define allow-override | ||
51 | $(if $(or $(findstring environment,$(origin $(1))),\ | ||
52 | $(findstring command line,$(origin $(1)))),,\ | ||
53 | $(eval $(1) = $(2))) | ||
54 | endef | ||
55 | |||
56 | # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. | ||
57 | $(call allow-override,CC,$(CROSS_COMPILE)gcc) | ||
58 | $(call allow-override,AR,$(CROSS_COMPILE)ar) | ||
59 | $(call allow-override,LD,$(CROSS_COMPILE)ld) | ||
60 | $(call allow-override,CXX,$(CROSS_COMPILE)g++) | ||
61 | $(call allow-override,STRIP,$(CROSS_COMPILE)strip) | ||
62 | |||
45 | ifeq ($(CC_NO_CLANG), 1) | 63 | ifeq ($(CC_NO_CLANG), 1) |
46 | EXTRA_WARNINGS += -Wstrict-aliasing=3 | 64 | EXTRA_WARNINGS += -Wstrict-aliasing=3 |
47 | endif | 65 | endif |
diff --git a/tools/spi/Makefile b/tools/spi/Makefile index 90615e10c79a..815d15589177 100644 --- a/tools/spi/Makefile +++ b/tools/spi/Makefile | |||
@@ -11,8 +11,6 @@ endif | |||
11 | # (this improves performance and avoids hard-to-debug behaviour); | 11 | # (this improves performance and avoids hard-to-debug behaviour); |
12 | MAKEFLAGS += -r | 12 | MAKEFLAGS += -r |
13 | 13 | ||
14 | CC = $(CROSS_COMPILE)gcc | ||
15 | LD = $(CROSS_COMPILE)ld | ||
16 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 14 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
17 | 15 | ||
18 | ALL_TARGETS := spidev_test spidev_fdx | 16 | ALL_TARGETS := spidev_test spidev_fdx |
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index 44ef9eba5a7a..6c645eb77d42 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c | |||
@@ -178,6 +178,55 @@ void idr_get_next_test(int base) | |||
178 | idr_destroy(&idr); | 178 | idr_destroy(&idr); |
179 | } | 179 | } |
180 | 180 | ||
181 | int idr_u32_cb(int id, void *ptr, void *data) | ||
182 | { | ||
183 | BUG_ON(id < 0); | ||
184 | BUG_ON(ptr != DUMMY_PTR); | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | void idr_u32_test1(struct idr *idr, u32 handle) | ||
189 | { | ||
190 | static bool warned = false; | ||
191 | u32 id = handle; | ||
192 | int sid = 0; | ||
193 | void *ptr; | ||
194 | |||
195 | BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL)); | ||
196 | BUG_ON(id != handle); | ||
197 | BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL) != -ENOSPC); | ||
198 | BUG_ON(id != handle); | ||
199 | if (!warned && id > INT_MAX) | ||
200 | printk("vvv Ignore these warnings\n"); | ||
201 | ptr = idr_get_next(idr, &sid); | ||
202 | if (id > INT_MAX) { | ||
203 | BUG_ON(ptr != NULL); | ||
204 | BUG_ON(sid != 0); | ||
205 | } else { | ||
206 | BUG_ON(ptr != DUMMY_PTR); | ||
207 | BUG_ON(sid != id); | ||
208 | } | ||
209 | idr_for_each(idr, idr_u32_cb, NULL); | ||
210 | if (!warned && id > INT_MAX) { | ||
211 | printk("^^^ Warnings over\n"); | ||
212 | warned = true; | ||
213 | } | ||
214 | BUG_ON(idr_remove(idr, id) != DUMMY_PTR); | ||
215 | BUG_ON(!idr_is_empty(idr)); | ||
216 | } | ||
217 | |||
218 | void idr_u32_test(int base) | ||
219 | { | ||
220 | DEFINE_IDR(idr); | ||
221 | idr_init_base(&idr, base); | ||
222 | idr_u32_test1(&idr, 10); | ||
223 | idr_u32_test1(&idr, 0x7fffffff); | ||
224 | idr_u32_test1(&idr, 0x80000000); | ||
225 | idr_u32_test1(&idr, 0x80000001); | ||
226 | idr_u32_test1(&idr, 0xffe00000); | ||
227 | idr_u32_test1(&idr, 0xffffffff); | ||
228 | } | ||
229 | |||
181 | void idr_checks(void) | 230 | void idr_checks(void) |
182 | { | 231 | { |
183 | unsigned long i; | 232 | unsigned long i; |
@@ -248,6 +297,9 @@ void idr_checks(void) | |||
248 | idr_get_next_test(0); | 297 | idr_get_next_test(0); |
249 | idr_get_next_test(1); | 298 | idr_get_next_test(1); |
250 | idr_get_next_test(4); | 299 | idr_get_next_test(4); |
300 | idr_u32_test(4); | ||
301 | idr_u32_test(1); | ||
302 | idr_u32_test(0); | ||
251 | } | 303 | } |
252 | 304 | ||
253 | /* | 305 | /* |
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c index 6903ccf35595..44a0d1ad4408 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/radix-tree/linux.c | |||
@@ -29,7 +29,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, int flags) | |||
29 | { | 29 | { |
30 | struct radix_tree_node *node; | 30 | struct radix_tree_node *node; |
31 | 31 | ||
32 | if (flags & __GFP_NOWARN) | 32 | if (!(flags & __GFP_DIRECT_RECLAIM)) |
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | pthread_mutex_lock(&cachep->lock); | 35 | pthread_mutex_lock(&cachep->lock); |
@@ -73,10 +73,17 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp) | |||
73 | 73 | ||
74 | void *kmalloc(size_t size, gfp_t gfp) | 74 | void *kmalloc(size_t size, gfp_t gfp) |
75 | { | 75 | { |
76 | void *ret = malloc(size); | 76 | void *ret; |
77 | |||
78 | if (!(gfp & __GFP_DIRECT_RECLAIM)) | ||
79 | return NULL; | ||
80 | |||
81 | ret = malloc(size); | ||
77 | uatomic_inc(&nr_allocated); | 82 | uatomic_inc(&nr_allocated); |
78 | if (kmalloc_verbose) | 83 | if (kmalloc_verbose) |
79 | printf("Allocating %p from malloc\n", ret); | 84 | printf("Allocating %p from malloc\n", ret); |
85 | if (gfp & __GFP_ZERO) | ||
86 | memset(ret, 0, size); | ||
80 | return ret; | 87 | return ret; |
81 | } | 88 | } |
82 | 89 | ||
diff --git a/tools/testing/radix-tree/linux/compiler_types.h b/tools/testing/radix-tree/linux/compiler_types.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/tools/testing/radix-tree/linux/compiler_types.h | |||
diff --git a/tools/testing/radix-tree/linux/gfp.h b/tools/testing/radix-tree/linux/gfp.h index e9fff59dfd8a..e3201ccf54c3 100644 --- a/tools/testing/radix-tree/linux/gfp.h +++ b/tools/testing/radix-tree/linux/gfp.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #define __GFP_IO 0x40u | 11 | #define __GFP_IO 0x40u |
12 | #define __GFP_FS 0x80u | 12 | #define __GFP_FS 0x80u |
13 | #define __GFP_NOWARN 0x200u | 13 | #define __GFP_NOWARN 0x200u |
14 | #define __GFP_ZERO 0x8000u | ||
14 | #define __GFP_ATOMIC 0x80000u | 15 | #define __GFP_ATOMIC 0x80000u |
15 | #define __GFP_ACCOUNT 0x100000u | 16 | #define __GFP_ACCOUNT 0x100000u |
16 | #define __GFP_DIRECT_RECLAIM 0x400000u | 17 | #define __GFP_DIRECT_RECLAIM 0x400000u |
diff --git a/tools/testing/radix-tree/linux/slab.h b/tools/testing/radix-tree/linux/slab.h index 979baeec7e70..a037def0dec6 100644 --- a/tools/testing/radix-tree/linux/slab.h +++ b/tools/testing/radix-tree/linux/slab.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #define SLAB_H | 3 | #define SLAB_H |
4 | 4 | ||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/gfp.h> | ||
6 | 7 | ||
7 | #define SLAB_HWCACHE_ALIGN 1 | 8 | #define SLAB_HWCACHE_ALIGN 1 |
8 | #define SLAB_PANIC 2 | 9 | #define SLAB_PANIC 2 |
@@ -11,6 +12,11 @@ | |||
11 | void *kmalloc(size_t size, gfp_t); | 12 | void *kmalloc(size_t size, gfp_t); |
12 | void kfree(void *); | 13 | void kfree(void *); |
13 | 14 | ||
15 | static inline void *kzalloc(size_t size, gfp_t gfp) | ||
16 | { | ||
17 | return kmalloc(size, gfp | __GFP_ZERO); | ||
18 | } | ||
19 | |||
14 | void *kmem_cache_alloc(struct kmem_cache *cachep, int flags); | 20 | void *kmem_cache_alloc(struct kmem_cache *cachep, int flags); |
15 | void kmem_cache_free(struct kmem_cache *cachep, void *objp); | 21 | void kmem_cache_free(struct kmem_cache *cachep, void *objp); |
16 | 22 | ||
diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 1a7492268993..f6304d2be90c 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile | |||
@@ -11,11 +11,11 @@ all: | |||
11 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ | 11 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ |
12 | mkdir $$BUILD_TARGET -p; \ | 12 | mkdir $$BUILD_TARGET -p; \ |
13 | make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ | 13 | make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ |
14 | #SUBDIR test prog name should be in the form: SUBDIR_test.sh | 14 | #SUBDIR test prog name should be in the form: SUBDIR_test.sh \ |
15 | TEST=$$DIR"_test.sh"; \ | 15 | TEST=$$DIR"_test.sh"; \ |
16 | if [ -e $$DIR/$$TEST ]; then | 16 | if [ -e $$DIR/$$TEST ]; then \ |
17 | rsync -a $$DIR/$$TEST $$BUILD_TARGET/; | 17 | rsync -a $$DIR/$$TEST $$BUILD_TARGET/; \ |
18 | fi | 18 | fi \ |
19 | done | 19 | done |
20 | 20 | ||
21 | override define RUN_TESTS | 21 | override define RUN_TESTS |
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore index cc15af2e54fe..9cf83f895d98 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore | |||
@@ -11,3 +11,4 @@ test_progs | |||
11 | test_tcpbpf_user | 11 | test_tcpbpf_user |
12 | test_verifier_log | 12 | test_verifier_log |
13 | feature | 13 | feature |
14 | test_libbpf_open | ||
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 436c4c72414f..9e03a4c356a4 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c | |||
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data) | |||
126 | fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, | 126 | fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, |
127 | 2, map_flags); | 127 | 2, map_flags); |
128 | if (fd < 0) { | 128 | if (fd < 0) { |
129 | if (errno == ENOMEM) | ||
130 | return; | ||
129 | printf("Failed to create hashmap key=%d value=%d '%s'\n", | 131 | printf("Failed to create hashmap key=%d value=%d '%s'\n", |
130 | i, j, strerror(errno)); | 132 | i, j, strerror(errno)); |
131 | exit(1); | 133 | exit(1); |
diff --git a/tools/testing/selftests/bpf/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/test_tcpbpf_kern.c index 57119ad57a3f..3e645ee41ed5 100644 --- a/tools/testing/selftests/bpf/test_tcpbpf_kern.c +++ b/tools/testing/selftests/bpf/test_tcpbpf_kern.c | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <linux/if_ether.h> | 5 | #include <linux/if_ether.h> |
6 | #include <linux/if_packet.h> | 6 | #include <linux/if_packet.h> |
7 | #include <linux/ip.h> | 7 | #include <linux/ip.h> |
8 | #include <linux/in6.h> | ||
9 | #include <linux/types.h> | 8 | #include <linux/types.h> |
10 | #include <linux/socket.h> | 9 | #include <linux/socket.h> |
11 | #include <linux/tcp.h> | 10 | #include <linux/tcp.h> |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index c0f16e93f9bd..437c0b1c9d21 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -2587,6 +2587,32 @@ static struct bpf_test tests[] = { | |||
2587 | .result = ACCEPT, | 2587 | .result = ACCEPT, |
2588 | }, | 2588 | }, |
2589 | { | 2589 | { |
2590 | "runtime/jit: pass negative index to tail_call", | ||
2591 | .insns = { | ||
2592 | BPF_MOV64_IMM(BPF_REG_3, -1), | ||
2593 | BPF_LD_MAP_FD(BPF_REG_2, 0), | ||
2594 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
2595 | BPF_FUNC_tail_call), | ||
2596 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
2597 | BPF_EXIT_INSN(), | ||
2598 | }, | ||
2599 | .fixup_prog = { 1 }, | ||
2600 | .result = ACCEPT, | ||
2601 | }, | ||
2602 | { | ||
2603 | "runtime/jit: pass > 32bit index to tail_call", | ||
2604 | .insns = { | ||
2605 | BPF_LD_IMM64(BPF_REG_3, 0x100000000ULL), | ||
2606 | BPF_LD_MAP_FD(BPF_REG_2, 0), | ||
2607 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
2608 | BPF_FUNC_tail_call), | ||
2609 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
2610 | BPF_EXIT_INSN(), | ||
2611 | }, | ||
2612 | .fixup_prog = { 2 }, | ||
2613 | .result = ACCEPT, | ||
2614 | }, | ||
2615 | { | ||
2590 | "stack pointer arithmetic", | 2616 | "stack pointer arithmetic", |
2591 | .insns = { | 2617 | .insns = { |
2592 | BPF_MOV64_IMM(BPF_REG_1, 4), | 2618 | BPF_MOV64_IMM(BPF_REG_1, 4), |
@@ -11137,6 +11163,64 @@ static struct bpf_test tests[] = { | |||
11137 | .result = REJECT, | 11163 | .result = REJECT, |
11138 | .prog_type = BPF_PROG_TYPE_TRACEPOINT, | 11164 | .prog_type = BPF_PROG_TYPE_TRACEPOINT, |
11139 | }, | 11165 | }, |
11166 | { | ||
11167 | "xadd/w check unaligned stack", | ||
11168 | .insns = { | ||
11169 | BPF_MOV64_IMM(BPF_REG_0, 1), | ||
11170 | BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8), | ||
11171 | BPF_STX_XADD(BPF_W, BPF_REG_10, BPF_REG_0, -7), | ||
11172 | BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8), | ||
11173 | BPF_EXIT_INSN(), | ||
11174 | }, | ||
11175 | .result = REJECT, | ||
11176 | .errstr = "misaligned stack access off", | ||
11177 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
11178 | }, | ||
11179 | { | ||
11180 | "xadd/w check unaligned map", | ||
11181 | .insns = { | ||
11182 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
11183 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
11184 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
11185 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
11186 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
11187 | BPF_FUNC_map_lookup_elem), | ||
11188 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
11189 | BPF_EXIT_INSN(), | ||
11190 | BPF_MOV64_IMM(BPF_REG_1, 1), | ||
11191 | BPF_STX_XADD(BPF_W, BPF_REG_0, BPF_REG_1, 3), | ||
11192 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 3), | ||
11193 | BPF_EXIT_INSN(), | ||
11194 | }, | ||
11195 | .fixup_map1 = { 3 }, | ||
11196 | .result = REJECT, | ||
11197 | .errstr = "misaligned value access off", | ||
11198 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
11199 | }, | ||
11200 | { | ||
11201 | "xadd/w check unaligned pkt", | ||
11202 | .insns = { | ||
11203 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, | ||
11204 | offsetof(struct xdp_md, data)), | ||
11205 | BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, | ||
11206 | offsetof(struct xdp_md, data_end)), | ||
11207 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_2), | ||
11208 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8), | ||
11209 | BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 2), | ||
11210 | BPF_MOV64_IMM(BPF_REG_0, 99), | ||
11211 | BPF_JMP_IMM(BPF_JA, 0, 0, 6), | ||
11212 | BPF_MOV64_IMM(BPF_REG_0, 1), | ||
11213 | BPF_ST_MEM(BPF_W, BPF_REG_2, 0, 0), | ||
11214 | BPF_ST_MEM(BPF_W, BPF_REG_2, 3, 0), | ||
11215 | BPF_STX_XADD(BPF_W, BPF_REG_2, BPF_REG_0, 1), | ||
11216 | BPF_STX_XADD(BPF_W, BPF_REG_2, BPF_REG_0, 2), | ||
11217 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 1), | ||
11218 | BPF_EXIT_INSN(), | ||
11219 | }, | ||
11220 | .result = REJECT, | ||
11221 | .errstr = "BPF_XADD stores into R2 packet", | ||
11222 | .prog_type = BPF_PROG_TYPE_XDP, | ||
11223 | }, | ||
11140 | }; | 11224 | }; |
11141 | 11225 | ||
11142 | static int probe_filter_length(const struct bpf_insn *fp) | 11226 | static int probe_filter_length(const struct bpf_insn *fp) |
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/futex/Makefile b/tools/testing/selftests/futex/Makefile index cea4adcd42b8..a63e8453984d 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile | |||
@@ -12,9 +12,9 @@ all: | |||
12 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ | 12 | BUILD_TARGET=$(OUTPUT)/$$DIR; \ |
13 | mkdir $$BUILD_TARGET -p; \ | 13 | mkdir $$BUILD_TARGET -p; \ |
14 | make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ | 14 | make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ |
15 | if [ -e $$DIR/$(TEST_PROGS) ]; then | 15 | if [ -e $$DIR/$(TEST_PROGS) ]; then \ |
16 | rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; | 16 | rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \ |
17 | fi | 17 | fi \ |
18 | done | 18 | done |
19 | 19 | ||
20 | override define RUN_TESTS | 20 | override define RUN_TESTS |
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index a5276a91dfbf..0862e6f47a38 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile | |||
@@ -5,6 +5,7 @@ CFLAGS += -I../../../../include/ | |||
5 | CFLAGS += -I../../../../usr/include/ | 5 | CFLAGS += -I../../../../usr/include/ |
6 | 6 | ||
7 | TEST_PROGS := run_tests.sh | 7 | TEST_PROGS := run_tests.sh |
8 | TEST_FILES := run_fuse_test.sh | ||
8 | TEST_GEN_FILES := memfd_test fuse_mnt fuse_test | 9 | TEST_GEN_FILES := memfd_test fuse_mnt fuse_test |
9 | 10 | ||
10 | fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) | 11 | fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) |
diff --git a/tools/testing/selftests/memfd/config b/tools/testing/selftests/memfd/config new file mode 100644 index 000000000000..835c7f4dadcd --- /dev/null +++ b/tools/testing/selftests/memfd/config | |||
@@ -0,0 +1 @@ | |||
CONFIG_FUSE_FS=m | |||
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile index 86636d207adf..686da510f989 100644 --- a/tools/testing/selftests/memory-hotplug/Makefile +++ b/tools/testing/selftests/memory-hotplug/Makefile | |||
@@ -4,8 +4,9 @@ all: | |||
4 | include ../lib.mk | 4 | include ../lib.mk |
5 | 5 | ||
6 | TEST_PROGS := mem-on-off-test.sh | 6 | TEST_PROGS := mem-on-off-test.sh |
7 | override RUN_TESTS := ./mem-on-off-test.sh -r 2 && echo "selftests: memory-hotplug [PASS]" || echo "selftests: memory-hotplug [FAIL]" | 7 | override RUN_TESTS := @./mem-on-off-test.sh -r 2 && echo "selftests: memory-hotplug [PASS]" || echo "selftests: memory-hotplug [FAIL]" |
8 | override EMIT_TESTS := echo "$(RUN_TESTS)" | 8 | |
9 | override EMIT_TESTS := echo "$(subst @,,$(RUN_TESTS))" | ||
9 | 10 | ||
10 | run_full_test: | 11 | run_full_test: |
11 | @/bin/bash ./mem-on-off-test.sh && echo "memory-hotplug selftests: [PASS]" || echo "memory-hotplug selftests: [FAIL]" | 12 | @/bin/bash ./mem-on-off-test.sh && echo "memory-hotplug selftests: [PASS]" || echo "memory-hotplug selftests: [FAIL]" |
diff --git a/tools/testing/selftests/powerpc/alignment/alignment_handler.c b/tools/testing/selftests/powerpc/alignment/alignment_handler.c index 39fd362415cf..0f2698f9fd6d 100644 --- a/tools/testing/selftests/powerpc/alignment/alignment_handler.c +++ b/tools/testing/selftests/powerpc/alignment/alignment_handler.c | |||
@@ -57,7 +57,7 @@ volatile int gotsig; | |||
57 | 57 | ||
58 | void sighandler(int sig, siginfo_t *info, void *ctx) | 58 | void sighandler(int sig, siginfo_t *info, void *ctx) |
59 | { | 59 | { |
60 | struct ucontext *ucp = ctx; | 60 | ucontext_t *ucp = ctx; |
61 | 61 | ||
62 | if (!testing) { | 62 | if (!testing) { |
63 | signal(sig, SIG_DFL); | 63 | signal(sig, SIG_DFL); |
diff --git a/tools/testing/selftests/powerpc/mm/subpage_prot.c b/tools/testing/selftests/powerpc/mm/subpage_prot.c index 35ade7406dcd..3ae77ba93208 100644 --- a/tools/testing/selftests/powerpc/mm/subpage_prot.c +++ b/tools/testing/selftests/powerpc/mm/subpage_prot.c | |||
@@ -135,6 +135,16 @@ static int run_test(void *addr, unsigned long size) | |||
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | static int syscall_available(void) | ||
139 | { | ||
140 | int rc; | ||
141 | |||
142 | errno = 0; | ||
143 | rc = syscall(__NR_subpage_prot, 0, 0, 0); | ||
144 | |||
145 | return rc == 0 || (errno != ENOENT && errno != ENOSYS); | ||
146 | } | ||
147 | |||
138 | int test_anon(void) | 148 | int test_anon(void) |
139 | { | 149 | { |
140 | unsigned long align; | 150 | unsigned long align; |
@@ -145,6 +155,8 @@ int test_anon(void) | |||
145 | void *mallocblock; | 155 | void *mallocblock; |
146 | unsigned long mallocsize; | 156 | unsigned long mallocsize; |
147 | 157 | ||
158 | SKIP_IF(!syscall_available()); | ||
159 | |||
148 | if (getpagesize() != 0x10000) { | 160 | if (getpagesize() != 0x10000) { |
149 | fprintf(stderr, "Kernel page size must be 64K!\n"); | 161 | fprintf(stderr, "Kernel page size must be 64K!\n"); |
150 | return 1; | 162 | return 1; |
@@ -180,6 +192,8 @@ int test_file(void) | |||
180 | off_t filesize; | 192 | off_t filesize; |
181 | int fd; | 193 | int fd; |
182 | 194 | ||
195 | SKIP_IF(!syscall_available()); | ||
196 | |||
183 | fd = open(file_name, O_RDWR); | 197 | fd = open(file_name, O_RDWR); |
184 | if (fd == -1) { | 198 | if (fd == -1) { |
185 | perror("failed to open file"); | 199 | perror("failed to open file"); |
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile index a23453943ad2..5c72ff978f27 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile | |||
@@ -16,7 +16,7 @@ $(OUTPUT)/tm-syscall: tm-syscall-asm.S | |||
16 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include | 16 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include |
17 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread | 17 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread |
18 | $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 | 18 | $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 |
19 | $(OUTPUT)/tm-resched-dscr: ../pmu/lib.o | 19 | $(OUTPUT)/tm-resched-dscr: ../pmu/lib.c |
20 | $(OUTPUT)/tm-unavailable: CFLAGS += -O0 -pthread -m64 -Wno-error=uninitialized -mvsx | 20 | $(OUTPUT)/tm-unavailable: CFLAGS += -O0 -pthread -m64 -Wno-error=uninitialized -mvsx |
21 | $(OUTPUT)/tm-trap: CFLAGS += -O0 -pthread -m64 | 21 | $(OUTPUT)/tm-trap: CFLAGS += -O0 -pthread -m64 |
22 | 22 | ||
diff --git a/tools/testing/selftests/powerpc/tm/tm-trap.c b/tools/testing/selftests/powerpc/tm/tm-trap.c index 5d92c23ee6cb..179d592f0073 100644 --- a/tools/testing/selftests/powerpc/tm/tm-trap.c +++ b/tools/testing/selftests/powerpc/tm/tm-trap.c | |||
@@ -255,6 +255,8 @@ int tm_trap_test(void) | |||
255 | 255 | ||
256 | struct sigaction trap_sa; | 256 | struct sigaction trap_sa; |
257 | 257 | ||
258 | SKIP_IF(!have_htm()); | ||
259 | |||
258 | trap_sa.sa_flags = SA_SIGINFO; | 260 | trap_sa.sa_flags = SA_SIGINFO; |
259 | trap_sa.sa_sigaction = trap_signal_handler; | 261 | trap_sa.sa_sigaction = trap_signal_handler; |
260 | sigaction(SIGTRAP, &trap_sa, NULL); | 262 | sigaction(SIGTRAP, &trap_sa, NULL); |
diff --git a/tools/testing/selftests/pstore/config b/tools/testing/selftests/pstore/config index 6a8e5a9bfc10..d148f9f89fb6 100644 --- a/tools/testing/selftests/pstore/config +++ b/tools/testing/selftests/pstore/config | |||
@@ -2,3 +2,4 @@ CONFIG_MISC_FILESYSTEMS=y | |||
2 | CONFIG_PSTORE=y | 2 | CONFIG_PSTORE=y |
3 | CONFIG_PSTORE_PMSG=y | 3 | CONFIG_PSTORE_PMSG=y |
4 | CONFIG_PSTORE_CONSOLE=y | 4 | CONFIG_PSTORE_CONSOLE=y |
5 | CONFIG_PSTORE_RAM=m | ||
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 0b457e8e0f0c..5df609950a66 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
@@ -141,6 +141,15 @@ struct seccomp_data { | |||
141 | #define SECCOMP_FILTER_FLAG_LOG 2 | 141 | #define SECCOMP_FILTER_FLAG_LOG 2 |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | #ifndef PTRACE_SECCOMP_GET_METADATA | ||
145 | #define PTRACE_SECCOMP_GET_METADATA 0x420d | ||
146 | |||
147 | struct seccomp_metadata { | ||
148 | __u64 filter_off; /* Input: which filter */ | ||
149 | __u64 flags; /* Output: filter's flags */ | ||
150 | }; | ||
151 | #endif | ||
152 | |||
144 | #ifndef seccomp | 153 | #ifndef seccomp |
145 | int seccomp(unsigned int op, unsigned int flags, void *args) | 154 | int seccomp(unsigned int op, unsigned int flags, void *args) |
146 | { | 155 | { |
@@ -2845,6 +2854,58 @@ TEST(get_action_avail) | |||
2845 | EXPECT_EQ(errno, EOPNOTSUPP); | 2854 | EXPECT_EQ(errno, EOPNOTSUPP); |
2846 | } | 2855 | } |
2847 | 2856 | ||
2857 | TEST(get_metadata) | ||
2858 | { | ||
2859 | pid_t pid; | ||
2860 | int pipefd[2]; | ||
2861 | char buf; | ||
2862 | struct seccomp_metadata md; | ||
2863 | |||
2864 | ASSERT_EQ(0, pipe(pipefd)); | ||
2865 | |||
2866 | pid = fork(); | ||
2867 | ASSERT_GE(pid, 0); | ||
2868 | if (pid == 0) { | ||
2869 | struct sock_filter filter[] = { | ||
2870 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), | ||
2871 | }; | ||
2872 | struct sock_fprog prog = { | ||
2873 | .len = (unsigned short)ARRAY_SIZE(filter), | ||
2874 | .filter = filter, | ||
2875 | }; | ||
2876 | |||
2877 | /* one with log, one without */ | ||
2878 | ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, | ||
2879 | SECCOMP_FILTER_FLAG_LOG, &prog)); | ||
2880 | ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); | ||
2881 | |||
2882 | ASSERT_EQ(0, close(pipefd[0])); | ||
2883 | ASSERT_EQ(1, write(pipefd[1], "1", 1)); | ||
2884 | ASSERT_EQ(0, close(pipefd[1])); | ||
2885 | |||
2886 | while (1) | ||
2887 | sleep(100); | ||
2888 | } | ||
2889 | |||
2890 | ASSERT_EQ(0, close(pipefd[1])); | ||
2891 | ASSERT_EQ(1, read(pipefd[0], &buf, 1)); | ||
2892 | |||
2893 | ASSERT_EQ(0, ptrace(PTRACE_ATTACH, pid)); | ||
2894 | ASSERT_EQ(pid, waitpid(pid, NULL, 0)); | ||
2895 | |||
2896 | md.filter_off = 0; | ||
2897 | ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); | ||
2898 | EXPECT_EQ(md.flags, SECCOMP_FILTER_FLAG_LOG); | ||
2899 | EXPECT_EQ(md.filter_off, 0); | ||
2900 | |||
2901 | md.filter_off = 1; | ||
2902 | ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); | ||
2903 | EXPECT_EQ(md.flags, 0); | ||
2904 | EXPECT_EQ(md.filter_off, 1); | ||
2905 | |||
2906 | ASSERT_EQ(0, kill(pid, SIGKILL)); | ||
2907 | } | ||
2908 | |||
2848 | /* | 2909 | /* |
2849 | * TODO: | 2910 | * TODO: |
2850 | * - add microbenchmarks | 2911 | * - add microbenchmarks |
diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile index b3c8ba3cb668..d0121a8a3523 100644 --- a/tools/testing/selftests/sync/Makefile +++ b/tools/testing/selftests/sync/Makefile | |||
@@ -30,7 +30,7 @@ $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS) | |||
30 | $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS) | 30 | $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS) |
31 | 31 | ||
32 | $(OBJS): $(OUTPUT)/%.o: %.c | 32 | $(OBJS): $(OUTPUT)/%.o: %.c |
33 | $(CC) -c $^ -o $@ | 33 | $(CC) -c $^ -o $@ $(CFLAGS) |
34 | 34 | ||
35 | $(TESTS): $(OUTPUT)/%.o: %.c | 35 | $(TESTS): $(OUTPUT)/%.o: %.c |
36 | $(CC) -c $^ -o $@ | 36 | $(CC) -c $^ -o $@ |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json b/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json index e34075059c26..90bba48c3f07 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json | |||
@@ -315,7 +315,7 @@ | |||
315 | "cmdUnderTest": "$TC actions ls action skbmod", | 315 | "cmdUnderTest": "$TC actions ls action skbmod", |
316 | "expExitCode": "0", | 316 | "expExitCode": "0", |
317 | "verifyCmd": "$TC actions get action skbmod index 4", | 317 | "verifyCmd": "$TC actions get action skbmod index 4", |
318 | "matchPattern": "action order [0-9]*: skbmod pipe set etype 0x0031", | 318 | "matchPattern": "action order [0-9]*: skbmod pipe set etype 0x31", |
319 | "matchCount": "1", | 319 | "matchCount": "1", |
320 | "teardown": [ | 320 | "teardown": [ |
321 | "$TC actions flush action skbmod" | 321 | "$TC actions flush action skbmod" |
diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index 3d5a62ff7d31..f5d7a7851e21 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile | |||
@@ -1,4 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | include ../lib.mk | ||
3 | |||
2 | ifndef CROSS_COMPILE | 4 | ifndef CROSS_COMPILE |
3 | CFLAGS := -std=gnu99 | 5 | CFLAGS := -std=gnu99 |
4 | CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector | 6 | CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector |
@@ -6,16 +8,14 @@ ifeq ($(CONFIG_X86_32),y) | |||
6 | LDLIBS += -lgcc_s | 8 | LDLIBS += -lgcc_s |
7 | endif | 9 | endif |
8 | 10 | ||
9 | TEST_PROGS := vdso_test vdso_standalone_test_x86 | 11 | TEST_PROGS := $(OUTPUT)/vdso_test $(OUTPUT)/vdso_standalone_test_x86 |
10 | 12 | ||
11 | all: $(TEST_PROGS) | 13 | all: $(TEST_PROGS) |
12 | vdso_test: parse_vdso.c vdso_test.c | 14 | $(OUTPUT)/vdso_test: parse_vdso.c vdso_test.c |
13 | vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c | 15 | $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c |
14 | $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ | 16 | $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ |
15 | vdso_standalone_test_x86.c parse_vdso.c \ | 17 | vdso_standalone_test_x86.c parse_vdso.c \ |
16 | -o vdso_standalone_test_x86 | 18 | -o $@ |
17 | 19 | ||
18 | include ../lib.mk | 20 | EXTRA_CLEAN := $(TEST_PROGS) |
19 | clean: | ||
20 | rm -fr $(TEST_PROGS) | ||
21 | endif | 21 | endif |
diff --git a/tools/testing/selftests/vm/.gitignore b/tools/testing/selftests/vm/.gitignore index 63c94d776e89..342c7bc9dc8c 100644 --- a/tools/testing/selftests/vm/.gitignore +++ b/tools/testing/selftests/vm/.gitignore | |||
@@ -11,3 +11,4 @@ mlock-intersect-test | |||
11 | mlock-random-test | 11 | mlock-random-test |
12 | virtual_address_range | 12 | virtual_address_range |
13 | gup_benchmark | 13 | gup_benchmark |
14 | va_128TBswitch | ||
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index d2561895a021..22d564673830 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests | |||
@@ -2,25 +2,33 @@ | |||
2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
3 | #please run as root | 3 | #please run as root |
4 | 4 | ||
5 | #we need 256M, below is the size in kB | ||
6 | needmem=262144 | ||
7 | mnt=./huge | 5 | mnt=./huge |
8 | exitcode=0 | 6 | exitcode=0 |
9 | 7 | ||
10 | #get pagesize and freepages from /proc/meminfo | 8 | #get huge pagesize and freepages from /proc/meminfo |
11 | while read name size unit; do | 9 | while read name size unit; do |
12 | if [ "$name" = "HugePages_Free:" ]; then | 10 | if [ "$name" = "HugePages_Free:" ]; then |
13 | freepgs=$size | 11 | freepgs=$size |
14 | fi | 12 | fi |
15 | if [ "$name" = "Hugepagesize:" ]; then | 13 | if [ "$name" = "Hugepagesize:" ]; then |
16 | pgsize=$size | 14 | hpgsize_KB=$size |
17 | fi | 15 | fi |
18 | done < /proc/meminfo | 16 | done < /proc/meminfo |
19 | 17 | ||
18 | # Simple hugetlbfs tests have a hardcoded minimum requirement of | ||
19 | # huge pages totaling 256MB (262144KB) in size. The userfaultfd | ||
20 | # hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take | ||
21 | # both of these requirements into account and attempt to increase | ||
22 | # number of huge pages available. | ||
23 | nr_cpus=$(nproc) | ||
24 | hpgsize_MB=$((hpgsize_KB / 1024)) | ||
25 | half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128)) | ||
26 | needmem_KB=$((half_ufd_size_MB * 2 * 1024)) | ||
27 | |||
20 | #set proper nr_hugepages | 28 | #set proper nr_hugepages |
21 | if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then | 29 | if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then |
22 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` | 30 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` |
23 | needpgs=`expr $needmem / $pgsize` | 31 | needpgs=$((needmem_KB / hpgsize_KB)) |
24 | tries=2 | 32 | tries=2 |
25 | while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do | 33 | while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do |
26 | lackpgs=$(( $needpgs - $freepgs )) | 34 | lackpgs=$(( $needpgs - $freepgs )) |
@@ -107,8 +115,9 @@ fi | |||
107 | echo "---------------------------" | 115 | echo "---------------------------" |
108 | echo "running userfaultfd_hugetlb" | 116 | echo "running userfaultfd_hugetlb" |
109 | echo "---------------------------" | 117 | echo "---------------------------" |
110 | # 256MB total huge pages == 128MB src and 128MB dst | 118 | # Test requires source and destination huge pages. Size of source |
111 | ./userfaultfd hugetlb 128 32 $mnt/ufd_test_file | 119 | # (half_ufd_size_MB) is passed as argument to test. |
120 | ./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file | ||
112 | if [ $? -ne 0 ]; then | 121 | if [ $? -ne 0 ]; then |
113 | echo "[FAIL]" | 122 | echo "[FAIL]" |
114 | exitcode=1 | 123 | exitcode=1 |
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index 10ca46df1449..d744991c0f4f 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile | |||
@@ -5,16 +5,26 @@ include ../lib.mk | |||
5 | 5 | ||
6 | .PHONY: all all_32 all_64 warn_32bit_failure clean | 6 | .PHONY: all all_32 all_64 warn_32bit_failure clean |
7 | 7 | ||
8 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall test_mremap_vdso \ | 8 | UNAME_M := $(shell uname -m) |
9 | check_initial_reg_state sigreturn ldt_gdt iopl mpx-mini-test ioperm \ | 9 | CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) |
10 | CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) | ||
11 | |||
12 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ | ||
13 | check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \ | ||
10 | protection_keys test_vdso test_vsyscall | 14 | protection_keys test_vdso test_vsyscall |
11 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ | 15 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ |
12 | test_FCMOV test_FCOMI test_FISTTP \ | 16 | test_FCMOV test_FCOMI test_FISTTP \ |
13 | vdso_restorer | 17 | vdso_restorer |
14 | TARGETS_C_64BIT_ONLY := fsgsbase sysret_rip 5lvl | 18 | TARGETS_C_64BIT_ONLY := fsgsbase sysret_rip |
19 | # Some selftests require 32bit support enabled also on 64bit systems | ||
20 | TARGETS_C_32BIT_NEEDED := ldt_gdt ptrace_syscall | ||
15 | 21 | ||
16 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) | 22 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) $(TARGETS_C_32BIT_NEEDED) |
17 | TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY) | 23 | TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY) |
24 | ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),11) | ||
25 | TARGETS_C_64BIT_ALL += $(TARGETS_C_32BIT_NEEDED) | ||
26 | endif | ||
27 | |||
18 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) | 28 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) |
19 | BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) | 29 | BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) |
20 | 30 | ||
@@ -23,10 +33,6 @@ BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) | |||
23 | 33 | ||
24 | CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie | 34 | CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie |
25 | 35 | ||
26 | UNAME_M := $(shell uname -m) | ||
27 | CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) | ||
28 | CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) | ||
29 | |||
30 | define gen-target-rule-32 | 36 | define gen-target-rule-32 |
31 | $(1) $(1)_32: $(OUTPUT)/$(1)_32 | 37 | $(1) $(1)_32: $(OUTPUT)/$(1)_32 |
32 | .PHONY: $(1) $(1)_32 | 38 | .PHONY: $(1) $(1)_32 |
@@ -40,12 +46,14 @@ endef | |||
40 | ifeq ($(CAN_BUILD_I386),1) | 46 | ifeq ($(CAN_BUILD_I386),1) |
41 | all: all_32 | 47 | all: all_32 |
42 | TEST_PROGS += $(BINARIES_32) | 48 | TEST_PROGS += $(BINARIES_32) |
49 | EXTRA_CFLAGS += -DCAN_BUILD_32 | ||
43 | $(foreach t,$(TARGETS_C_32BIT_ALL),$(eval $(call gen-target-rule-32,$(t)))) | 50 | $(foreach t,$(TARGETS_C_32BIT_ALL),$(eval $(call gen-target-rule-32,$(t)))) |
44 | endif | 51 | endif |
45 | 52 | ||
46 | ifeq ($(CAN_BUILD_X86_64),1) | 53 | ifeq ($(CAN_BUILD_X86_64),1) |
47 | all: all_64 | 54 | all: all_64 |
48 | TEST_PROGS += $(BINARIES_64) | 55 | TEST_PROGS += $(BINARIES_64) |
56 | EXTRA_CFLAGS += -DCAN_BUILD_64 | ||
49 | $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(call gen-target-rule-64,$(t)))) | 57 | $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(call gen-target-rule-64,$(t)))) |
50 | endif | 58 | endif |
51 | 59 | ||
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/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c index ec0f6b45ce8b..9c0325e1ea68 100644 --- a/tools/testing/selftests/x86/mpx-mini-test.c +++ b/tools/testing/selftests/x86/mpx-mini-test.c | |||
@@ -315,11 +315,39 @@ static inline void *__si_bounds_upper(siginfo_t *si) | |||
315 | return si->si_upper; | 315 | return si->si_upper; |
316 | } | 316 | } |
317 | #else | 317 | #else |
318 | |||
319 | /* | ||
320 | * This deals with old version of _sigfault in some distros: | ||
321 | * | ||
322 | |||
323 | old _sigfault: | ||
324 | struct { | ||
325 | void *si_addr; | ||
326 | } _sigfault; | ||
327 | |||
328 | new _sigfault: | ||
329 | struct { | ||
330 | void __user *_addr; | ||
331 | int _trapno; | ||
332 | short _addr_lsb; | ||
333 | union { | ||
334 | struct { | ||
335 | void __user *_lower; | ||
336 | void __user *_upper; | ||
337 | } _addr_bnd; | ||
338 | __u32 _pkey; | ||
339 | }; | ||
340 | } _sigfault; | ||
341 | * | ||
342 | */ | ||
343 | |||
318 | static inline void **__si_bounds_hack(siginfo_t *si) | 344 | static inline void **__si_bounds_hack(siginfo_t *si) |
319 | { | 345 | { |
320 | void *sigfault = &si->_sifields._sigfault; | 346 | void *sigfault = &si->_sifields._sigfault; |
321 | void *end_sigfault = sigfault + sizeof(si->_sifields._sigfault); | 347 | void *end_sigfault = sigfault + sizeof(si->_sifields._sigfault); |
322 | void **__si_lower = end_sigfault; | 348 | int *trapno = (int*)end_sigfault; |
349 | /* skip _trapno and _addr_lsb */ | ||
350 | void **__si_lower = (void**)(trapno + 2); | ||
323 | 351 | ||
324 | return __si_lower; | 352 | return __si_lower; |
325 | } | 353 | } |
@@ -331,7 +359,7 @@ static inline void *__si_bounds_lower(siginfo_t *si) | |||
331 | 359 | ||
332 | static inline void *__si_bounds_upper(siginfo_t *si) | 360 | static inline void *__si_bounds_upper(siginfo_t *si) |
333 | { | 361 | { |
334 | return (*__si_bounds_hack(si)) + sizeof(void *); | 362 | return *(__si_bounds_hack(si) + 1); |
335 | } | 363 | } |
336 | #endif | 364 | #endif |
337 | 365 | ||
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index bc1b0735bb50..f15aa5a76fe3 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c | |||
@@ -393,34 +393,6 @@ pid_t fork_lazy_child(void) | |||
393 | return forkret; | 393 | return forkret; |
394 | } | 394 | } |
395 | 395 | ||
396 | void davecmp(void *_a, void *_b, int len) | ||
397 | { | ||
398 | int i; | ||
399 | unsigned long *a = _a; | ||
400 | unsigned long *b = _b; | ||
401 | |||
402 | for (i = 0; i < len / sizeof(*a); i++) { | ||
403 | if (a[i] == b[i]) | ||
404 | continue; | ||
405 | |||
406 | dprintf3("[%3d]: a: %016lx b: %016lx\n", i, a[i], b[i]); | ||
407 | } | ||
408 | } | ||
409 | |||
410 | void dumpit(char *f) | ||
411 | { | ||
412 | int fd = open(f, O_RDONLY); | ||
413 | char buf[100]; | ||
414 | int nr_read; | ||
415 | |||
416 | dprintf2("maps fd: %d\n", fd); | ||
417 | do { | ||
418 | nr_read = read(fd, &buf[0], sizeof(buf)); | ||
419 | write(1, buf, nr_read); | ||
420 | } while (nr_read > 0); | ||
421 | close(fd); | ||
422 | } | ||
423 | |||
424 | #define PKEY_DISABLE_ACCESS 0x1 | 396 | #define PKEY_DISABLE_ACCESS 0x1 |
425 | #define PKEY_DISABLE_WRITE 0x2 | 397 | #define PKEY_DISABLE_WRITE 0x2 |
426 | 398 | ||
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); |
diff --git a/tools/testing/selftests/x86/single_step_syscall.c b/tools/testing/selftests/x86/single_step_syscall.c index a48da95c18fd..ddfdd635de16 100644 --- a/tools/testing/selftests/x86/single_step_syscall.c +++ b/tools/testing/selftests/x86/single_step_syscall.c | |||
@@ -119,7 +119,9 @@ static void check_result(void) | |||
119 | 119 | ||
120 | int main() | 120 | int main() |
121 | { | 121 | { |
122 | #ifdef CAN_BUILD_32 | ||
122 | int tmp; | 123 | int tmp; |
124 | #endif | ||
123 | 125 | ||
124 | sethandler(SIGTRAP, sigtrap, 0); | 126 | sethandler(SIGTRAP, sigtrap, 0); |
125 | 127 | ||
@@ -139,12 +141,13 @@ int main() | |||
139 | : : "c" (post_nop) : "r11"); | 141 | : : "c" (post_nop) : "r11"); |
140 | check_result(); | 142 | check_result(); |
141 | #endif | 143 | #endif |
142 | 144 | #ifdef CAN_BUILD_32 | |
143 | printf("[RUN]\tSet TF and check int80\n"); | 145 | printf("[RUN]\tSet TF and check int80\n"); |
144 | set_eflags(get_eflags() | X86_EFLAGS_TF); | 146 | set_eflags(get_eflags() | X86_EFLAGS_TF); |
145 | asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) | 147 | asm volatile ("int $0x80" : "=a" (tmp) : "a" (SYS_getpid) |
146 | : INT80_CLOBBERS); | 148 | : INT80_CLOBBERS); |
147 | check_result(); | 149 | check_result(); |
150 | #endif | ||
148 | 151 | ||
149 | /* | 152 | /* |
150 | * This test is particularly interesting if fast syscalls use | 153 | * This test is particularly interesting if fast syscalls use |
diff --git a/tools/testing/selftests/x86/test_mremap_vdso.c b/tools/testing/selftests/x86/test_mremap_vdso.c index bf0d687c7db7..64f11c8d9b76 100644 --- a/tools/testing/selftests/x86/test_mremap_vdso.c +++ b/tools/testing/selftests/x86/test_mremap_vdso.c | |||
@@ -90,8 +90,12 @@ int main(int argc, char **argv, char **envp) | |||
90 | vdso_size += PAGE_SIZE; | 90 | vdso_size += PAGE_SIZE; |
91 | } | 91 | } |
92 | 92 | ||
93 | #ifdef __i386__ | ||
93 | /* Glibc is likely to explode now - exit with raw syscall */ | 94 | /* Glibc is likely to explode now - exit with raw syscall */ |
94 | asm volatile ("int $0x80" : : "a" (__NR_exit), "b" (!!ret)); | 95 | asm volatile ("int $0x80" : : "a" (__NR_exit), "b" (!!ret)); |
96 | #else /* __x86_64__ */ | ||
97 | syscall(SYS_exit, ret); | ||
98 | #endif | ||
95 | } else { | 99 | } else { |
96 | int status; | 100 | int status; |
97 | 101 | ||
diff --git a/tools/testing/selftests/x86/test_vdso.c b/tools/testing/selftests/x86/test_vdso.c index 29973cde06d3..235259011704 100644 --- a/tools/testing/selftests/x86/test_vdso.c +++ b/tools/testing/selftests/x86/test_vdso.c | |||
@@ -26,20 +26,59 @@ | |||
26 | # endif | 26 | # endif |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | /* max length of lines in /proc/self/maps - anything longer is skipped here */ | ||
30 | #define MAPS_LINE_LEN 128 | ||
31 | |||
29 | int nerrs = 0; | 32 | int nerrs = 0; |
30 | 33 | ||
34 | typedef long (*getcpu_t)(unsigned *, unsigned *, void *); | ||
35 | |||
36 | getcpu_t vgetcpu; | ||
37 | getcpu_t vdso_getcpu; | ||
38 | |||
39 | static void *vsyscall_getcpu(void) | ||
40 | { | ||
31 | #ifdef __x86_64__ | 41 | #ifdef __x86_64__ |
32 | # define VSYS(x) (x) | 42 | FILE *maps; |
43 | char line[MAPS_LINE_LEN]; | ||
44 | bool found = false; | ||
45 | |||
46 | maps = fopen("/proc/self/maps", "r"); | ||
47 | if (!maps) /* might still be present, but ignore it here, as we test vDSO not vsyscall */ | ||
48 | return NULL; | ||
49 | |||
50 | while (fgets(line, MAPS_LINE_LEN, maps)) { | ||
51 | char r, x; | ||
52 | void *start, *end; | ||
53 | char name[MAPS_LINE_LEN]; | ||
54 | |||
55 | /* sscanf() is safe here as strlen(name) >= strlen(line) */ | ||
56 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", | ||
57 | &start, &end, &r, &x, name) != 5) | ||
58 | continue; | ||
59 | |||
60 | if (strcmp(name, "[vsyscall]")) | ||
61 | continue; | ||
62 | |||
63 | /* assume entries are OK, as we test vDSO here not vsyscall */ | ||
64 | found = true; | ||
65 | break; | ||
66 | } | ||
67 | |||
68 | fclose(maps); | ||
69 | |||
70 | if (!found) { | ||
71 | printf("Warning: failed to find vsyscall getcpu\n"); | ||
72 | return NULL; | ||
73 | } | ||
74 | return (void *) (0xffffffffff600800); | ||
33 | #else | 75 | #else |
34 | # define VSYS(x) 0 | 76 | return NULL; |
35 | #endif | 77 | #endif |
78 | } | ||
36 | 79 | ||
37 | typedef long (*getcpu_t)(unsigned *, unsigned *, void *); | ||
38 | |||
39 | const getcpu_t vgetcpu = (getcpu_t)VSYS(0xffffffffff600800); | ||
40 | getcpu_t vdso_getcpu; | ||
41 | 80 | ||
42 | void fill_function_pointers() | 81 | static void fill_function_pointers() |
43 | { | 82 | { |
44 | void *vdso = dlopen("linux-vdso.so.1", | 83 | void *vdso = dlopen("linux-vdso.so.1", |
45 | RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); | 84 | RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); |
@@ -54,6 +93,8 @@ void fill_function_pointers() | |||
54 | vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); | 93 | vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); |
55 | if (!vdso_getcpu) | 94 | if (!vdso_getcpu) |
56 | printf("Warning: failed to find getcpu in vDSO\n"); | 95 | printf("Warning: failed to find getcpu in vDSO\n"); |
96 | |||
97 | vgetcpu = (getcpu_t) vsyscall_getcpu(); | ||
57 | } | 98 | } |
58 | 99 | ||
59 | static long sys_getcpu(unsigned * cpu, unsigned * node, | 100 | static long sys_getcpu(unsigned * cpu, unsigned * node, |
diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c index 7a744fa7b786..0b4f1cc2291c 100644 --- a/tools/testing/selftests/x86/test_vsyscall.c +++ b/tools/testing/selftests/x86/test_vsyscall.c | |||
@@ -33,6 +33,9 @@ | |||
33 | # endif | 33 | # endif |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | /* max length of lines in /proc/self/maps - anything longer is skipped here */ | ||
37 | #define MAPS_LINE_LEN 128 | ||
38 | |||
36 | static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), | 39 | static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), |
37 | int flags) | 40 | int flags) |
38 | { | 41 | { |
@@ -98,7 +101,7 @@ static int init_vsys(void) | |||
98 | #ifdef __x86_64__ | 101 | #ifdef __x86_64__ |
99 | int nerrs = 0; | 102 | int nerrs = 0; |
100 | FILE *maps; | 103 | FILE *maps; |
101 | char line[128]; | 104 | char line[MAPS_LINE_LEN]; |
102 | bool found = false; | 105 | bool found = false; |
103 | 106 | ||
104 | maps = fopen("/proc/self/maps", "r"); | 107 | maps = fopen("/proc/self/maps", "r"); |
@@ -108,10 +111,12 @@ static int init_vsys(void) | |||
108 | return 0; | 111 | return 0; |
109 | } | 112 | } |
110 | 113 | ||
111 | while (fgets(line, sizeof(line), maps)) { | 114 | while (fgets(line, MAPS_LINE_LEN, maps)) { |
112 | char r, x; | 115 | char r, x; |
113 | void *start, *end; | 116 | void *start, *end; |
114 | char name[128]; | 117 | char name[MAPS_LINE_LEN]; |
118 | |||
119 | /* sscanf() is safe here as strlen(name) >= strlen(line) */ | ||
115 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", | 120 | if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", |
116 | &start, &end, &r, &x, name) != 5) | 121 | &start, &end, &r, &x, name) != 5) |
117 | continue; | 122 | continue; |
@@ -445,7 +450,7 @@ static void sigtrap(int sig, siginfo_t *info, void *ctx_void) | |||
445 | num_vsyscall_traps++; | 450 | num_vsyscall_traps++; |
446 | } | 451 | } |
447 | 452 | ||
448 | static int test_native_vsyscall(void) | 453 | static int test_emulation(void) |
449 | { | 454 | { |
450 | time_t tmp; | 455 | time_t tmp; |
451 | bool is_native; | 456 | bool is_native; |
@@ -453,7 +458,7 @@ static int test_native_vsyscall(void) | |||
453 | if (!vtime) | 458 | if (!vtime) |
454 | return 0; | 459 | return 0; |
455 | 460 | ||
456 | printf("[RUN]\tchecking for native vsyscall\n"); | 461 | printf("[RUN]\tchecking that vsyscalls are emulated\n"); |
457 | sethandler(SIGTRAP, sigtrap, 0); | 462 | sethandler(SIGTRAP, sigtrap, 0); |
458 | set_eflags(get_eflags() | X86_EFLAGS_TF); | 463 | set_eflags(get_eflags() | X86_EFLAGS_TF); |
459 | vtime(&tmp); | 464 | vtime(&tmp); |
@@ -469,11 +474,12 @@ static int test_native_vsyscall(void) | |||
469 | */ | 474 | */ |
470 | is_native = (num_vsyscall_traps > 1); | 475 | is_native = (num_vsyscall_traps > 1); |
471 | 476 | ||
472 | printf("\tvsyscalls are %s (%d instructions in vsyscall page)\n", | 477 | printf("[%s]\tvsyscalls are %s (%d instructions in vsyscall page)\n", |
478 | (is_native ? "FAIL" : "OK"), | ||
473 | (is_native ? "native" : "emulated"), | 479 | (is_native ? "native" : "emulated"), |
474 | (int)num_vsyscall_traps); | 480 | (int)num_vsyscall_traps); |
475 | 481 | ||
476 | return 0; | 482 | return is_native; |
477 | } | 483 | } |
478 | #endif | 484 | #endif |
479 | 485 | ||
@@ -493,7 +499,7 @@ int main(int argc, char **argv) | |||
493 | nerrs += test_vsys_r(); | 499 | nerrs += test_vsys_r(); |
494 | 500 | ||
495 | #ifdef __x86_64__ | 501 | #ifdef __x86_64__ |
496 | nerrs += test_native_vsyscall(); | 502 | nerrs += test_emulation(); |
497 | #endif | 503 | #endif |
498 | 504 | ||
499 | return nerrs ? 1 : 0; | 505 | return nerrs ? 1 : 0; |
diff --git a/tools/usb/Makefile b/tools/usb/Makefile index 4e6506078494..01d758d73b6d 100644 --- a/tools/usb/Makefile +++ b/tools/usb/Makefile | |||
@@ -1,7 +1,6 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for USB tools | 2 | # Makefile for USB tools |
3 | 3 | ||
4 | CC = $(CROSS_COMPILE)gcc | ||
5 | PTHREAD_LIBS = -lpthread | 4 | PTHREAD_LIBS = -lpthread |
6 | WARNINGS = -Wall -Wextra | 5 | WARNINGS = -Wall -Wextra |
7 | CFLAGS = $(WARNINGS) -g -I../include | 6 | CFLAGS = $(WARNINGS) -g -I../include |
diff --git a/tools/vm/Makefile b/tools/vm/Makefile index be320b905ea7..20f6cf04377f 100644 --- a/tools/vm/Makefile +++ b/tools/vm/Makefile | |||
@@ -6,7 +6,6 @@ TARGETS=page-types slabinfo page_owner_sort | |||
6 | LIB_DIR = ../lib/api | 6 | LIB_DIR = ../lib/api |
7 | LIBS = $(LIB_DIR)/libapi.a | 7 | LIBS = $(LIB_DIR)/libapi.a |
8 | 8 | ||
9 | CC = $(CROSS_COMPILE)gcc | ||
10 | CFLAGS = -Wall -Wextra -I../lib/ | 9 | CFLAGS = -Wall -Wextra -I../lib/ |
11 | LDFLAGS = $(LIBS) | 10 | LDFLAGS = $(LIBS) |
12 | 11 | ||
diff --git a/tools/wmi/Makefile b/tools/wmi/Makefile index e664f1167388..e0e87239126b 100644 --- a/tools/wmi/Makefile +++ b/tools/wmi/Makefile | |||
@@ -2,7 +2,6 @@ PREFIX ?= /usr | |||
2 | SBINDIR ?= sbin | 2 | SBINDIR ?= sbin |
3 | INSTALL ?= install | 3 | INSTALL ?= install |
4 | CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include | 4 | CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include |
5 | CC = $(CROSS_COMPILE)gcc | ||
6 | 5 | ||
7 | TARGET = dell-smbios-example | 6 | TARGET = dell-smbios-example |
8 | 7 | ||