aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/powerpc/include/uapi/asm/perf_regs.h1
-rw-r--r--tools/arch/powerpc/include/uapi/asm/unistd.h404
-rw-r--r--tools/arch/riscv/include/uapi/asm/bitsperlong.h25
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/arch/x86/include/asm/disabled-features.h8
-rw-r--r--tools/bpf/bpftool/Makefile9
-rw-r--r--tools/bpf/bpftool/btf_dumper.c13
-rw-r--r--tools/bpf/bpftool/common.c6
-rw-r--r--tools/bpf/bpftool/json_writer.c7
-rw-r--r--tools/bpf/bpftool/json_writer.h5
-rw-r--r--tools/bpf/bpftool/map.c33
-rw-r--r--tools/bpf/bpftool/prog.c5
-rw-r--r--tools/iio/iio_generic_buffer.c2
-rw-r--r--tools/include/uapi/asm-generic/unistd.h4
-rw-r--r--tools/include/uapi/asm/bitsperlong.h4
-rw-r--r--tools/include/uapi/drm/i915_drm.h8
-rw-r--r--tools/include/uapi/linux/fs.h60
-rw-r--r--tools/include/uapi/linux/if_link.h19
-rw-r--r--tools/include/uapi/linux/in.h10
-rw-r--r--tools/include/uapi/linux/kvm.h19
-rw-r--r--tools/include/uapi/linux/mount.h58
-rw-r--r--tools/include/uapi/linux/pkt_sched.h1163
-rw-r--r--tools/include/uapi/linux/prctl.h8
-rw-r--r--tools/include/uapi/linux/vhost.h113
-rw-r--r--tools/lib/bpf/.gitignore1
-rw-r--r--tools/lib/bpf/README.rst14
-rw-r--r--tools/lib/bpf/bpf.c19
-rw-r--r--tools/lib/traceevent/event-parse-api.c4
-rw-r--r--tools/lib/traceevent/event-parse-local.h4
-rw-r--r--tools/lib/traceevent/event-parse.c129
-rw-r--r--tools/lib/traceevent/event-parse.h17
-rw-r--r--tools/lib/traceevent/plugin_kvm.c2
-rw-r--r--tools/lib/traceevent/trace-seq.c17
-rw-r--r--tools/perf/Documentation/perf-c2c.txt16
-rw-r--r--tools/perf/Documentation/perf-mem.txt2
-rw-r--r--tools/perf/Makefile.perf8
-rw-r--r--tools/perf/arch/arm/tests/Build1
-rw-r--r--tools/perf/arch/arm/tests/arch-tests.c4
-rw-r--r--tools/perf/arch/arm/tests/vectors-page.c24
-rw-r--r--tools/perf/arch/powerpc/Makefile15
-rwxr-xr-xtools/perf/arch/powerpc/entry/syscalls/mksyscalltbl22
-rw-r--r--tools/perf/arch/powerpc/entry/syscalls/syscall.tbl427
-rw-r--r--tools/perf/arch/powerpc/include/perf_regs.h3
-rw-r--r--tools/perf/arch/powerpc/util/Build1
-rw-r--r--tools/perf/arch/powerpc/util/mem-events.c11
-rw-r--r--tools/perf/arch/powerpc/util/perf_regs.c1
-rw-r--r--tools/perf/builtin-script.c9
-rw-r--r--tools/perf/builtin-stat.c3
-rw-r--r--tools/perf/builtin-top.c7
-rw-r--r--tools/perf/builtin-trace.c40
-rwxr-xr-xtools/perf/check-headers.sh2
-rw-r--r--tools/perf/perf-read-vdso.c6
-rw-r--r--tools/perf/tests/attr.py32
-rw-r--r--tools/perf/tests/evsel-tp-sched.c2
-rw-r--r--tools/perf/tests/shell/lib/probe_vfs_getname.sh3
-rw-r--r--tools/perf/tests/tests.h5
-rwxr-xr-xtools/perf/trace/beauty/mount_flags.sh4
-rwxr-xr-xtools/perf/trace/beauty/prctl_option.sh2
-rw-r--r--tools/perf/ui/browsers/annotate.c16
-rw-r--r--tools/perf/util/annotate.c8
-rw-r--r--tools/perf/util/c++/clang.cpp2
-rw-r--r--tools/perf/util/callchain.c32
-rw-r--r--tools/perf/util/callchain.h1
-rw-r--r--tools/perf/util/cpumap.c11
-rw-r--r--tools/perf/util/find-map.c (renamed from tools/perf/util/find-vdso-map.c)7
-rw-r--r--tools/perf/util/machine.c2
-rw-r--r--tools/perf/util/mem-events.c2
-rw-r--r--tools/perf/util/ordered-events.c6
-rw-r--r--tools/perf/util/setup.py2
-rw-r--r--tools/perf/util/strbuf.c1
-rw-r--r--tools/perf/util/symbol-elf.c23
-rw-r--r--tools/perf/util/symbol.c1
-rw-r--r--tools/perf/util/vdso.c6
-rw-r--r--tools/testing/nvdimm/dimm_devs.c4
-rw-r--r--tools/testing/selftests/Makefile1
-rw-r--r--tools/testing/selftests/bpf/.gitignore1
-rw-r--r--tools/testing/selftests/bpf/Makefile5
-rw-r--r--tools/testing/selftests/bpf/bpf_util.h30
-rw-r--r--tools/testing/selftests/bpf/cgroup_helpers.c6
-rw-r--r--tools/testing/selftests/bpf/test_btf.c38
-rw-r--r--tools/testing/selftests/bpf/test_cgroup_storage.c2
-rw-r--r--tools/testing/selftests/bpf/test_dev_cgroup.c2
-rw-r--r--tools/testing/selftests/bpf/test_lpm_map.c10
-rw-r--r--tools/testing/selftests/bpf/test_netcnt.c2
-rw-r--r--tools/testing/selftests/bpf/test_progs.c30
-rw-r--r--tools/testing/selftests/bpf/test_skb_cgroup_id_user.c2
-rw-r--r--tools/testing/selftests/bpf/test_sock.c2
-rw-r--r--tools/testing/selftests/bpf/test_sock_addr.c55
-rw-r--r--tools/testing/selftests/bpf/test_socket_cookie.c2
-rw-r--r--tools/testing/selftests/bpf/test_tcpbpf_user.c2
-rw-r--r--tools/testing/selftests/bpf/test_tcpnotify_user.c2
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c120
-rwxr-xr-xtools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh13
-rwxr-xr-xtools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh20
-rwxr-xr-xtools/testing/selftests/drivers/net/mlxsw/vxlan.sh18
-rw-r--r--tools/testing/selftests/filesystems/binderfs/.gitignore1
-rw-r--r--tools/testing/selftests/filesystems/binderfs/Makefile6
-rw-r--r--tools/testing/selftests/filesystems/binderfs/binderfs_test.c275
-rw-r--r--tools/testing/selftests/filesystems/binderfs/config3
-rw-r--r--tools/testing/selftests/gpio/gpio-mockup-chardev.c9
-rw-r--r--tools/testing/selftests/ir/Makefile2
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c9
-rw-r--r--tools/testing/selftests/kvm/x86_64/evmcs_test.c6
-rw-r--r--tools/testing/selftests/net/Makefile2
-rwxr-xr-xtools/testing/selftests/net/fib_tests.sh1
-rwxr-xr-xtools/testing/selftests/net/forwarding/bridge_vlan_aware.sh47
-rwxr-xr-xtools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh2
-rw-r--r--tools/testing/selftests/net/ip_defrag.c96
-rwxr-xr-xtools/testing/selftests/net/ip_defrag.sh9
-rwxr-xr-xtools/testing/selftests/net/xfrm_policy.sh153
-rw-r--r--tools/testing/selftests/netfilter/Makefile2
-rw-r--r--tools/testing/selftests/netfilter/config2
-rwxr-xr-xtools/testing/selftests/netfilter/nft_nat.sh762
-rw-r--r--tools/testing/selftests/networking/timestamping/Makefile3
-rw-r--r--tools/testing/selftests/networking/timestamping/txtimestamp.c2
-rw-r--r--tools/testing/selftests/proc/.gitignore1
-rw-r--r--tools/testing/selftests/proc/Makefile1
-rw-r--r--tools/testing/selftests/proc/setns-dcache.c129
-rw-r--r--tools/testing/selftests/rtc/rtctest.c109
-rw-r--r--tools/testing/selftests/seccomp/Makefile2
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c82
-rw-r--r--tools/testing/selftests/tc-testing/tc-tests/actions/ife.json88
-rw-r--r--tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json31
-rw-r--r--tools/testing/selftests/timers/Makefile2
-rw-r--r--tools/testing/selftests/vm/gup_benchmark.c1
-rw-r--r--tools/testing/selftests/x86/mpx-mini-test.c2
-rw-r--r--tools/testing/selftests/x86/protection_keys.c41
-rw-r--r--tools/testing/selftests/x86/unwind_vdso.c1
-rw-r--r--tools/thermal/tmon/Makefile2
-rw-r--r--tools/vm/page_owner_sort.c4
130 files changed, 4226 insertions, 992 deletions
diff --git a/tools/arch/powerpc/include/uapi/asm/perf_regs.h b/tools/arch/powerpc/include/uapi/asm/perf_regs.h
index ff91192407d1..f599064dd8dc 100644
--- a/tools/arch/powerpc/include/uapi/asm/perf_regs.h
+++ b/tools/arch/powerpc/include/uapi/asm/perf_regs.h
@@ -47,6 +47,7 @@ enum perf_event_powerpc_regs {
47 PERF_REG_POWERPC_DAR, 47 PERF_REG_POWERPC_DAR,
48 PERF_REG_POWERPC_DSISR, 48 PERF_REG_POWERPC_DSISR,
49 PERF_REG_POWERPC_SIER, 49 PERF_REG_POWERPC_SIER,
50 PERF_REG_POWERPC_MMCRA,
50 PERF_REG_POWERPC_MAX, 51 PERF_REG_POWERPC_MAX,
51}; 52};
52#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */ 53#endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
diff --git a/tools/arch/powerpc/include/uapi/asm/unistd.h b/tools/arch/powerpc/include/uapi/asm/unistd.h
deleted file mode 100644
index 985534d0b448..000000000000
--- a/tools/arch/powerpc/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,404 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2/*
3 * This file contains the system call numbers.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10#ifndef _UAPI_ASM_POWERPC_UNISTD_H_
11#define _UAPI_ASM_POWERPC_UNISTD_H_
12
13
14#define __NR_restart_syscall 0
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_waitpid 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_time 13
28#define __NR_mknod 14
29#define __NR_chmod 15
30#define __NR_lchown 16
31#define __NR_break 17
32#define __NR_oldstat 18
33#define __NR_lseek 19
34#define __NR_getpid 20
35#define __NR_mount 21
36#define __NR_umount 22
37#define __NR_setuid 23
38#define __NR_getuid 24
39#define __NR_stime 25
40#define __NR_ptrace 26
41#define __NR_alarm 27
42#define __NR_oldfstat 28
43#define __NR_pause 29
44#define __NR_utime 30
45#define __NR_stty 31
46#define __NR_gtty 32
47#define __NR_access 33
48#define __NR_nice 34
49#define __NR_ftime 35
50#define __NR_sync 36
51#define __NR_kill 37
52#define __NR_rename 38
53#define __NR_mkdir 39
54#define __NR_rmdir 40
55#define __NR_dup 41
56#define __NR_pipe 42
57#define __NR_times 43
58#define __NR_prof 44
59#define __NR_brk 45
60#define __NR_setgid 46
61#define __NR_getgid 47
62#define __NR_signal 48
63#define __NR_geteuid 49
64#define __NR_getegid 50
65#define __NR_acct 51
66#define __NR_umount2 52
67#define __NR_lock 53
68#define __NR_ioctl 54
69#define __NR_fcntl 55
70#define __NR_mpx 56
71#define __NR_setpgid 57
72#define __NR_ulimit 58
73#define __NR_oldolduname 59
74#define __NR_umask 60
75#define __NR_chroot 61
76#define __NR_ustat 62
77#define __NR_dup2 63
78#define __NR_getppid 64
79#define __NR_getpgrp 65
80#define __NR_setsid 66
81#define __NR_sigaction 67
82#define __NR_sgetmask 68
83#define __NR_ssetmask 69
84#define __NR_setreuid 70
85#define __NR_setregid 71
86#define __NR_sigsuspend 72
87#define __NR_sigpending 73
88#define __NR_sethostname 74
89#define __NR_setrlimit 75
90#define __NR_getrlimit 76
91#define __NR_getrusage 77
92#define __NR_gettimeofday 78
93#define __NR_settimeofday 79
94#define __NR_getgroups 80
95#define __NR_setgroups 81
96#define __NR_select 82
97#define __NR_symlink 83
98#define __NR_oldlstat 84
99#define __NR_readlink 85
100#define __NR_uselib 86
101#define __NR_swapon 87
102#define __NR_reboot 88
103#define __NR_readdir 89
104#define __NR_mmap 90
105#define __NR_munmap 91
106#define __NR_truncate 92
107#define __NR_ftruncate 93
108#define __NR_fchmod 94
109#define __NR_fchown 95
110#define __NR_getpriority 96
111#define __NR_setpriority 97
112#define __NR_profil 98
113#define __NR_statfs 99
114#define __NR_fstatfs 100
115#define __NR_ioperm 101
116#define __NR_socketcall 102
117#define __NR_syslog 103
118#define __NR_setitimer 104
119#define __NR_getitimer 105
120#define __NR_stat 106
121#define __NR_lstat 107
122#define __NR_fstat 108
123#define __NR_olduname 109
124#define __NR_iopl 110
125#define __NR_vhangup 111
126#define __NR_idle 112
127#define __NR_vm86 113
128#define __NR_wait4 114
129#define __NR_swapoff 115
130#define __NR_sysinfo 116
131#define __NR_ipc 117
132#define __NR_fsync 118
133#define __NR_sigreturn 119
134#define __NR_clone 120
135#define __NR_setdomainname 121
136#define __NR_uname 122
137#define __NR_modify_ldt 123
138#define __NR_adjtimex 124
139#define __NR_mprotect 125
140#define __NR_sigprocmask 126
141#define __NR_create_module 127
142#define __NR_init_module 128
143#define __NR_delete_module 129
144#define __NR_get_kernel_syms 130
145#define __NR_quotactl 131
146#define __NR_getpgid 132
147#define __NR_fchdir 133
148#define __NR_bdflush 134
149#define __NR_sysfs 135
150#define __NR_personality 136
151#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
152#define __NR_setfsuid 138
153#define __NR_setfsgid 139
154#define __NR__llseek 140
155#define __NR_getdents 141
156#define __NR__newselect 142
157#define __NR_flock 143
158#define __NR_msync 144
159#define __NR_readv 145
160#define __NR_writev 146
161#define __NR_getsid 147
162#define __NR_fdatasync 148
163#define __NR__sysctl 149
164#define __NR_mlock 150
165#define __NR_munlock 151
166#define __NR_mlockall 152
167#define __NR_munlockall 153
168#define __NR_sched_setparam 154
169#define __NR_sched_getparam 155
170#define __NR_sched_setscheduler 156
171#define __NR_sched_getscheduler 157
172#define __NR_sched_yield 158
173#define __NR_sched_get_priority_max 159
174#define __NR_sched_get_priority_min 160
175#define __NR_sched_rr_get_interval 161
176#define __NR_nanosleep 162
177#define __NR_mremap 163
178#define __NR_setresuid 164
179#define __NR_getresuid 165
180#define __NR_query_module 166
181#define __NR_poll 167
182#define __NR_nfsservctl 168
183#define __NR_setresgid 169
184#define __NR_getresgid 170
185#define __NR_prctl 171
186#define __NR_rt_sigreturn 172
187#define __NR_rt_sigaction 173
188#define __NR_rt_sigprocmask 174
189#define __NR_rt_sigpending 175
190#define __NR_rt_sigtimedwait 176
191#define __NR_rt_sigqueueinfo 177
192#define __NR_rt_sigsuspend 178
193#define __NR_pread64 179
194#define __NR_pwrite64 180
195#define __NR_chown 181
196#define __NR_getcwd 182
197#define __NR_capget 183
198#define __NR_capset 184
199#define __NR_sigaltstack 185
200#define __NR_sendfile 186
201#define __NR_getpmsg 187 /* some people actually want streams */
202#define __NR_putpmsg 188 /* some people actually want streams */
203#define __NR_vfork 189
204#define __NR_ugetrlimit 190 /* SuS compliant getrlimit */
205#define __NR_readahead 191
206#ifndef __powerpc64__ /* these are 32-bit only */
207#define __NR_mmap2 192
208#define __NR_truncate64 193
209#define __NR_ftruncate64 194
210#define __NR_stat64 195
211#define __NR_lstat64 196
212#define __NR_fstat64 197
213#endif
214#define __NR_pciconfig_read 198
215#define __NR_pciconfig_write 199
216#define __NR_pciconfig_iobase 200
217#define __NR_multiplexer 201
218#define __NR_getdents64 202
219#define __NR_pivot_root 203
220#ifndef __powerpc64__
221#define __NR_fcntl64 204
222#endif
223#define __NR_madvise 205
224#define __NR_mincore 206
225#define __NR_gettid 207
226#define __NR_tkill 208
227#define __NR_setxattr 209
228#define __NR_lsetxattr 210
229#define __NR_fsetxattr 211
230#define __NR_getxattr 212
231#define __NR_lgetxattr 213
232#define __NR_fgetxattr 214
233#define __NR_listxattr 215
234#define __NR_llistxattr 216
235#define __NR_flistxattr 217
236#define __NR_removexattr 218
237#define __NR_lremovexattr 219
238#define __NR_fremovexattr 220
239#define __NR_futex 221
240#define __NR_sched_setaffinity 222
241#define __NR_sched_getaffinity 223
242/* 224 currently unused */
243#define __NR_tuxcall 225
244#ifndef __powerpc64__
245#define __NR_sendfile64 226
246#endif
247#define __NR_io_setup 227
248#define __NR_io_destroy 228
249#define __NR_io_getevents 229
250#define __NR_io_submit 230
251#define __NR_io_cancel 231
252#define __NR_set_tid_address 232
253#define __NR_fadvise64 233
254#define __NR_exit_group 234
255#define __NR_lookup_dcookie 235
256#define __NR_epoll_create 236
257#define __NR_epoll_ctl 237
258#define __NR_epoll_wait 238
259#define __NR_remap_file_pages 239
260#define __NR_timer_create 240
261#define __NR_timer_settime 241
262#define __NR_timer_gettime 242
263#define __NR_timer_getoverrun 243
264#define __NR_timer_delete 244
265#define __NR_clock_settime 245
266#define __NR_clock_gettime 246
267#define __NR_clock_getres 247
268#define __NR_clock_nanosleep 248
269#define __NR_swapcontext 249
270#define __NR_tgkill 250
271#define __NR_utimes 251
272#define __NR_statfs64 252
273#define __NR_fstatfs64 253
274#ifndef __powerpc64__
275#define __NR_fadvise64_64 254
276#endif
277#define __NR_rtas 255
278#define __NR_sys_debug_setcontext 256
279/* Number 257 is reserved for vserver */
280#define __NR_migrate_pages 258
281#define __NR_mbind 259
282#define __NR_get_mempolicy 260
283#define __NR_set_mempolicy 261
284#define __NR_mq_open 262
285#define __NR_mq_unlink 263
286#define __NR_mq_timedsend 264
287#define __NR_mq_timedreceive 265
288#define __NR_mq_notify 266
289#define __NR_mq_getsetattr 267
290#define __NR_kexec_load 268
291#define __NR_add_key 269
292#define __NR_request_key 270
293#define __NR_keyctl 271
294#define __NR_waitid 272
295#define __NR_ioprio_set 273
296#define __NR_ioprio_get 274
297#define __NR_inotify_init 275
298#define __NR_inotify_add_watch 276
299#define __NR_inotify_rm_watch 277
300#define __NR_spu_run 278
301#define __NR_spu_create 279
302#define __NR_pselect6 280
303#define __NR_ppoll 281
304#define __NR_unshare 282
305#define __NR_splice 283
306#define __NR_tee 284
307#define __NR_vmsplice 285
308#define __NR_openat 286
309#define __NR_mkdirat 287
310#define __NR_mknodat 288
311#define __NR_fchownat 289
312#define __NR_futimesat 290
313#ifdef __powerpc64__
314#define __NR_newfstatat 291
315#else
316#define __NR_fstatat64 291
317#endif
318#define __NR_unlinkat 292
319#define __NR_renameat 293
320#define __NR_linkat 294
321#define __NR_symlinkat 295
322#define __NR_readlinkat 296
323#define __NR_fchmodat 297
324#define __NR_faccessat 298
325#define __NR_get_robust_list 299
326#define __NR_set_robust_list 300
327#define __NR_move_pages 301
328#define __NR_getcpu 302
329#define __NR_epoll_pwait 303
330#define __NR_utimensat 304
331#define __NR_signalfd 305
332#define __NR_timerfd_create 306
333#define __NR_eventfd 307
334#define __NR_sync_file_range2 308
335#define __NR_fallocate 309
336#define __NR_subpage_prot 310
337#define __NR_timerfd_settime 311
338#define __NR_timerfd_gettime 312
339#define __NR_signalfd4 313
340#define __NR_eventfd2 314
341#define __NR_epoll_create1 315
342#define __NR_dup3 316
343#define __NR_pipe2 317
344#define __NR_inotify_init1 318
345#define __NR_perf_event_open 319
346#define __NR_preadv 320
347#define __NR_pwritev 321
348#define __NR_rt_tgsigqueueinfo 322
349#define __NR_fanotify_init 323
350#define __NR_fanotify_mark 324
351#define __NR_prlimit64 325
352#define __NR_socket 326
353#define __NR_bind 327
354#define __NR_connect 328
355#define __NR_listen 329
356#define __NR_accept 330
357#define __NR_getsockname 331
358#define __NR_getpeername 332
359#define __NR_socketpair 333
360#define __NR_send 334
361#define __NR_sendto 335
362#define __NR_recv 336
363#define __NR_recvfrom 337
364#define __NR_shutdown 338
365#define __NR_setsockopt 339
366#define __NR_getsockopt 340
367#define __NR_sendmsg 341
368#define __NR_recvmsg 342
369#define __NR_recvmmsg 343
370#define __NR_accept4 344
371#define __NR_name_to_handle_at 345
372#define __NR_open_by_handle_at 346
373#define __NR_clock_adjtime 347
374#define __NR_syncfs 348
375#define __NR_sendmmsg 349
376#define __NR_setns 350
377#define __NR_process_vm_readv 351
378#define __NR_process_vm_writev 352
379#define __NR_finit_module 353
380#define __NR_kcmp 354
381#define __NR_sched_setattr 355
382#define __NR_sched_getattr 356
383#define __NR_renameat2 357
384#define __NR_seccomp 358
385#define __NR_getrandom 359
386#define __NR_memfd_create 360
387#define __NR_bpf 361
388#define __NR_execveat 362
389#define __NR_switch_endian 363
390#define __NR_userfaultfd 364
391#define __NR_membarrier 365
392#define __NR_mlock2 378
393#define __NR_copy_file_range 379
394#define __NR_preadv2 380
395#define __NR_pwritev2 381
396#define __NR_kexec_file_load 382
397#define __NR_statx 383
398#define __NR_pkey_alloc 384
399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387
402#define __NR_io_pgetevents 388
403
404#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/tools/arch/riscv/include/uapi/asm/bitsperlong.h b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
new file mode 100644
index 000000000000..0b3cb52fd29d
--- /dev/null
+++ b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 * Copyright (C) 2015 Regents of the University of California
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _UAPI_ASM_RISCV_BITSPERLONG_H
19#define _UAPI_ASM_RISCV_BITSPERLONG_H
20
21#define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8)
22
23#include <asm-generic/bitsperlong.h>
24
25#endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 28c4a502b419..6d6122524711 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -281,9 +281,11 @@
281#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ 281#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
282#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ 282#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
283#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */ 283#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
284#define X86_FEATURE_WBNOINVD (13*32+ 9) /* WBNOINVD instruction */
284#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */ 285#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */
285#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */ 286#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */
286#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */ 287#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */
288#define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* "" Single Thread Indirect Branch Predictors always-on preferred */
287#define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */ 289#define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */
288#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ 290#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */
289#define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */ 291#define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */
diff --git a/tools/arch/x86/include/asm/disabled-features.h b/tools/arch/x86/include/asm/disabled-features.h
index 33833d1909af..a5ea841cc6d2 100644
--- a/tools/arch/x86/include/asm/disabled-features.h
+++ b/tools/arch/x86/include/asm/disabled-features.h
@@ -16,6 +16,12 @@
16# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31)) 16# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31))
17#endif 17#endif
18 18
19#ifdef CONFIG_X86_SMAP
20# define DISABLE_SMAP 0
21#else
22# define DISABLE_SMAP (1<<(X86_FEATURE_SMAP & 31))
23#endif
24
19#ifdef CONFIG_X86_INTEL_UMIP 25#ifdef CONFIG_X86_INTEL_UMIP
20# define DISABLE_UMIP 0 26# define DISABLE_UMIP 0
21#else 27#else
@@ -68,7 +74,7 @@
68#define DISABLED_MASK6 0 74#define DISABLED_MASK6 0
69#define DISABLED_MASK7 (DISABLE_PTI) 75#define DISABLED_MASK7 (DISABLE_PTI)
70#define DISABLED_MASK8 0 76#define DISABLED_MASK8 0
71#define DISABLED_MASK9 (DISABLE_MPX) 77#define DISABLED_MASK9 (DISABLE_MPX|DISABLE_SMAP)
72#define DISABLED_MASK10 0 78#define DISABLED_MASK10 0
73#define DISABLED_MASK11 0 79#define DISABLED_MASK11 0
74#define DISABLED_MASK12 0 80#define DISABLED_MASK12 0
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 492f0f24e2d3..4ad1f0894d53 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -93,9 +93,16 @@ BFD_SRCS = jit_disasm.c
93SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c)) 93SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
94 94
95ifeq ($(feature-libbfd),1) 95ifeq ($(feature-libbfd),1)
96 LIBS += -lbfd -ldl -lopcodes
97else ifeq ($(feature-libbfd-liberty),1)
98 LIBS += -lbfd -ldl -lopcodes -liberty
99else ifeq ($(feature-libbfd-liberty-z),1)
100 LIBS += -lbfd -ldl -lopcodes -liberty -lz
101endif
102
103ifneq ($(filter -lbfd,$(LIBS)),)
96CFLAGS += -DHAVE_LIBBFD_SUPPORT 104CFLAGS += -DHAVE_LIBBFD_SUPPORT
97SRCS += $(BFD_SRCS) 105SRCS += $(BFD_SRCS)
98LIBS += -lbfd -lopcodes
99endif 106endif
100 107
101OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o 108OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
diff --git a/tools/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c
index 3f0629edbca5..6ba5f567a9d8 100644
--- a/tools/bpf/bpftool/btf_dumper.c
+++ b/tools/bpf/bpftool/btf_dumper.c
@@ -82,8 +82,6 @@ static void btf_dumper_bitfield(__u32 nr_bits, __u8 bit_offset,
82 int bits_to_copy; 82 int bits_to_copy;
83 __u64 print_num; 83 __u64 print_num;
84 84
85 data += BITS_ROUNDDOWN_BYTES(bit_offset);
86 bit_offset = BITS_PER_BYTE_MASKED(bit_offset);
87 bits_to_copy = bit_offset + nr_bits; 85 bits_to_copy = bit_offset + nr_bits;
88 bytes_to_copy = BITS_ROUNDUP_BYTES(bits_to_copy); 86 bytes_to_copy = BITS_ROUNDUP_BYTES(bits_to_copy);
89 87
@@ -118,7 +116,9 @@ static void btf_dumper_int_bits(__u32 int_type, __u8 bit_offset,
118 * BTF_INT_OFFSET() cannot exceed 64 bits. 116 * BTF_INT_OFFSET() cannot exceed 64 bits.
119 */ 117 */
120 total_bits_offset = bit_offset + BTF_INT_OFFSET(int_type); 118 total_bits_offset = bit_offset + BTF_INT_OFFSET(int_type);
121 btf_dumper_bitfield(nr_bits, total_bits_offset, data, jw, 119 data += BITS_ROUNDDOWN_BYTES(total_bits_offset);
120 bit_offset = BITS_PER_BYTE_MASKED(total_bits_offset);
121 btf_dumper_bitfield(nr_bits, bit_offset, data, jw,
122 is_plain_text); 122 is_plain_text);
123} 123}
124 124
@@ -216,11 +216,12 @@ static int btf_dumper_struct(const struct btf_dumper *d, __u32 type_id,
216 } 216 }
217 217
218 jsonw_name(d->jw, btf__name_by_offset(d->btf, m[i].name_off)); 218 jsonw_name(d->jw, btf__name_by_offset(d->btf, m[i].name_off));
219 data_off = data + BITS_ROUNDDOWN_BYTES(bit_offset);
219 if (bitfield_size) { 220 if (bitfield_size) {
220 btf_dumper_bitfield(bitfield_size, bit_offset, 221 btf_dumper_bitfield(bitfield_size,
221 data, d->jw, d->is_plain_text); 222 BITS_PER_BYTE_MASKED(bit_offset),
223 data_off, d->jw, d->is_plain_text);
222 } else { 224 } else {
223 data_off = data + BITS_ROUNDDOWN_BYTES(bit_offset);
224 ret = btf_dumper_do_type(d, m[i].type, 225 ret = btf_dumper_do_type(d, m[i].type,
225 BITS_PER_BYTE_MASKED(bit_offset), 226 BITS_PER_BYTE_MASKED(bit_offset),
226 data_off); 227 data_off);
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 897483457bf0..f7261fad45c1 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -297,10 +297,8 @@ char *get_fdinfo(int fd, const char *key)
297 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); 297 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd);
298 298
299 fdi = fopen(path, "r"); 299 fdi = fopen(path, "r");
300 if (!fdi) { 300 if (!fdi)
301 p_err("can't open fdinfo: %s", strerror(errno));
302 return NULL; 301 return NULL;
303 }
304 302
305 while ((n = getline(&line, &line_n, fdi)) > 0) { 303 while ((n = getline(&line, &line_n, fdi)) > 0) {
306 char *value; 304 char *value;
@@ -313,7 +311,6 @@ char *get_fdinfo(int fd, const char *key)
313 311
314 value = strchr(line, '\t'); 312 value = strchr(line, '\t');
315 if (!value || !value[1]) { 313 if (!value || !value[1]) {
316 p_err("malformed fdinfo!?");
317 free(line); 314 free(line);
318 return NULL; 315 return NULL;
319 } 316 }
@@ -326,7 +323,6 @@ char *get_fdinfo(int fd, const char *key)
326 return line; 323 return line;
327 } 324 }
328 325
329 p_err("key '%s' not found in fdinfo", key);
330 free(line); 326 free(line);
331 fclose(fdi); 327 fclose(fdi);
332 return NULL; 328 return NULL;
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c
index bff7ee026680..6046dcab51cc 100644
--- a/tools/bpf/bpftool/json_writer.c
+++ b/tools/bpf/bpftool/json_writer.c
@@ -1,15 +1,10 @@
1// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 1// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
2/* 2/*
3 * Simple streaming JSON writer 3 * Simple streaming JSON writer
4 * 4 *
5 * This takes care of the annoying bits of JSON syntax like the commas 5 * This takes care of the annoying bits of JSON syntax like the commas
6 * after elements 6 * after elements
7 * 7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * Authors: Stephen Hemminger <stephen@networkplumber.org> 8 * Authors: Stephen Hemminger <stephen@networkplumber.org>
14 */ 9 */
15 10
diff --git a/tools/bpf/bpftool/json_writer.h b/tools/bpf/bpftool/json_writer.h
index c1ab51aed99c..cb9a1993681c 100644
--- a/tools/bpf/bpftool/json_writer.h
+++ b/tools/bpf/bpftool/json_writer.h
@@ -5,11 +5,6 @@
5 * This takes care of the annoying bits of JSON syntax like the commas 5 * This takes care of the annoying bits of JSON syntax like the commas
6 * after elements 6 * after elements
7 * 7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * Authors: Stephen Hemminger <stephen@networkplumber.org> 8 * Authors: Stephen Hemminger <stephen@networkplumber.org>
14 */ 9 */
15 10
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 2037e3dc864b..1ef1ee2280a2 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -347,6 +347,20 @@ static char **parse_bytes(char **argv, const char *name, unsigned char *val,
347 return argv + i; 347 return argv + i;
348} 348}
349 349
350/* on per cpu maps we must copy the provided value on all value instances */
351static void fill_per_cpu_value(struct bpf_map_info *info, void *value)
352{
353 unsigned int i, n, step;
354
355 if (!map_is_per_cpu(info->type))
356 return;
357
358 n = get_possible_cpus();
359 step = round_up(info->value_size, 8);
360 for (i = 1; i < n; i++)
361 memcpy(value + i * step, value, info->value_size);
362}
363
350static int parse_elem(char **argv, struct bpf_map_info *info, 364static int parse_elem(char **argv, struct bpf_map_info *info,
351 void *key, void *value, __u32 key_size, __u32 value_size, 365 void *key, void *value, __u32 key_size, __u32 value_size,
352 __u32 *flags, __u32 **value_fd) 366 __u32 *flags, __u32 **value_fd)
@@ -426,6 +440,8 @@ static int parse_elem(char **argv, struct bpf_map_info *info,
426 argv = parse_bytes(argv, "value", value, value_size); 440 argv = parse_bytes(argv, "value", value, value_size);
427 if (!argv) 441 if (!argv)
428 return -1; 442 return -1;
443
444 fill_per_cpu_value(info, value);
429 } 445 }
430 446
431 return parse_elem(argv, info, key, NULL, key_size, value_size, 447 return parse_elem(argv, info, key, NULL, key_size, value_size,
@@ -497,10 +513,9 @@ static int show_map_close_json(int fd, struct bpf_map_info *info)
497 jsonw_uint_field(json_wtr, "owner_prog_type", 513 jsonw_uint_field(json_wtr, "owner_prog_type",
498 prog_type); 514 prog_type);
499 } 515 }
500 if (atoi(owner_jited)) 516 if (owner_jited)
501 jsonw_bool_field(json_wtr, "owner_jited", true); 517 jsonw_bool_field(json_wtr, "owner_jited",
502 else 518 !!atoi(owner_jited));
503 jsonw_bool_field(json_wtr, "owner_jited", false);
504 519
505 free(owner_prog_type); 520 free(owner_prog_type);
506 free(owner_jited); 521 free(owner_jited);
@@ -553,7 +568,8 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
553 char *owner_prog_type = get_fdinfo(fd, "owner_prog_type"); 568 char *owner_prog_type = get_fdinfo(fd, "owner_prog_type");
554 char *owner_jited = get_fdinfo(fd, "owner_jited"); 569 char *owner_jited = get_fdinfo(fd, "owner_jited");
555 570
556 printf("\n\t"); 571 if (owner_prog_type || owner_jited)
572 printf("\n\t");
557 if (owner_prog_type) { 573 if (owner_prog_type) {
558 unsigned int prog_type = atoi(owner_prog_type); 574 unsigned int prog_type = atoi(owner_prog_type);
559 575
@@ -563,10 +579,9 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
563 else 579 else
564 printf("owner_prog_type %d ", prog_type); 580 printf("owner_prog_type %d ", prog_type);
565 } 581 }
566 if (atoi(owner_jited)) 582 if (owner_jited)
567 printf("owner jited"); 583 printf("owner%s jited",
568 else 584 atoi(owner_jited) ? "" : " not");
569 printf("owner not jited");
570 585
571 free(owner_prog_type); 586 free(owner_prog_type);
572 free(owner_jited); 587 free(owner_jited);
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 2d1bb7d6ff51..b54ed82b9589 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -78,13 +78,14 @@ static void print_boot_time(__u64 nsecs, char *buf, unsigned int size)
78 78
79static int prog_fd_by_tag(unsigned char *tag) 79static int prog_fd_by_tag(unsigned char *tag)
80{ 80{
81 struct bpf_prog_info info = {};
82 __u32 len = sizeof(info);
83 unsigned int id = 0; 81 unsigned int id = 0;
84 int err; 82 int err;
85 int fd; 83 int fd;
86 84
87 while (true) { 85 while (true) {
86 struct bpf_prog_info info = {};
87 __u32 len = sizeof(info);
88
88 err = bpf_prog_get_next_id(id, &id); 89 err = bpf_prog_get_next_id(id, &id);
89 if (err) { 90 if (err) {
90 p_err("%s", strerror(errno)); 91 p_err("%s", strerror(errno));
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 3040830d7797..84545666a09c 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -330,7 +330,7 @@ static const struct option longopts[] = {
330 330
331int main(int argc, char **argv) 331int main(int argc, char **argv)
332{ 332{
333 unsigned long long num_loops = 2; 333 long long num_loops = 2;
334 unsigned long timedelay = 1000000; 334 unsigned long timedelay = 1000000;
335 unsigned long buf_len = 128; 335 unsigned long buf_len = 128;
336 336
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index c7f3321fbe43..d90127298f12 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -738,9 +738,11 @@ __SYSCALL(__NR_statx, sys_statx)
738__SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents) 738__SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents)
739#define __NR_rseq 293 739#define __NR_rseq 293
740__SYSCALL(__NR_rseq, sys_rseq) 740__SYSCALL(__NR_rseq, sys_rseq)
741#define __NR_kexec_file_load 294
742__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)
741 743
742#undef __NR_syscalls 744#undef __NR_syscalls
743#define __NR_syscalls 294 745#define __NR_syscalls 295
744 746
745/* 747/*
746 * 32 bit systems traditionally used different 748 * 32 bit systems traditionally used different
diff --git a/tools/include/uapi/asm/bitsperlong.h b/tools/include/uapi/asm/bitsperlong.h
index 8dd6aefdafa4..57aaeaf8e192 100644
--- a/tools/include/uapi/asm/bitsperlong.h
+++ b/tools/include/uapi/asm/bitsperlong.h
@@ -13,6 +13,10 @@
13#include "../../arch/mips/include/uapi/asm/bitsperlong.h" 13#include "../../arch/mips/include/uapi/asm/bitsperlong.h"
14#elif defined(__ia64__) 14#elif defined(__ia64__)
15#include "../../arch/ia64/include/uapi/asm/bitsperlong.h" 15#include "../../arch/ia64/include/uapi/asm/bitsperlong.h"
16#elif defined(__riscv)
17#include "../../arch/riscv/include/uapi/asm/bitsperlong.h"
18#elif defined(__alpha__)
19#include "../../arch/alpha/include/uapi/asm/bitsperlong.h"
16#else 20#else
17#include <asm-generic/bitsperlong.h> 21#include <asm-generic/bitsperlong.h>
18#endif 22#endif
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index a4446f452040..298b2e197744 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -412,6 +412,14 @@ typedef struct drm_i915_irq_wait {
412 int irq_seq; 412 int irq_seq;
413} drm_i915_irq_wait_t; 413} drm_i915_irq_wait_t;
414 414
415/*
416 * Different modes of per-process Graphics Translation Table,
417 * see I915_PARAM_HAS_ALIASING_PPGTT
418 */
419#define I915_GEM_PPGTT_NONE 0
420#define I915_GEM_PPGTT_ALIASING 1
421#define I915_GEM_PPGTT_FULL 2
422
415/* Ioctl to query kernel params: 423/* Ioctl to query kernel params:
416 */ 424 */
417#define I915_PARAM_IRQ_ACTIVE 1 425#define I915_PARAM_IRQ_ACTIVE 1
diff --git a/tools/include/uapi/linux/fs.h b/tools/include/uapi/linux/fs.h
index a441ea1bfe6d..121e82ce296b 100644
--- a/tools/include/uapi/linux/fs.h
+++ b/tools/include/uapi/linux/fs.h
@@ -14,6 +14,11 @@
14#include <linux/ioctl.h> 14#include <linux/ioctl.h>
15#include <linux/types.h> 15#include <linux/types.h>
16 16
17/* Use of MS_* flags within the kernel is restricted to core mount(2) code. */
18#if !defined(__KERNEL__)
19#include <linux/mount.h>
20#endif
21
17/* 22/*
18 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change 23 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
19 * the file limit at runtime and only root can increase the per-process 24 * the file limit at runtime and only root can increase the per-process
@@ -101,57 +106,6 @@ struct inodes_stat_t {
101 106
102#define NR_FILE 8192 /* this can well be larger on a larger system */ 107#define NR_FILE 8192 /* this can well be larger on a larger system */
103 108
104
105/*
106 * These are the fs-independent mount-flags: up to 32 flags are supported
107 */
108#define MS_RDONLY 1 /* Mount read-only */
109#define MS_NOSUID 2 /* Ignore suid and sgid bits */
110#define MS_NODEV 4 /* Disallow access to device special files */
111#define MS_NOEXEC 8 /* Disallow program execution */
112#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
113#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
114#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
115#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
116#define MS_NOATIME 1024 /* Do not update access times. */
117#define MS_NODIRATIME 2048 /* Do not update directory access times */
118#define MS_BIND 4096
119#define MS_MOVE 8192
120#define MS_REC 16384
121#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
122 MS_VERBOSE is deprecated. */
123#define MS_SILENT 32768
124#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
125#define MS_UNBINDABLE (1<<17) /* change to unbindable */
126#define MS_PRIVATE (1<<18) /* change to private */
127#define MS_SLAVE (1<<19) /* change to slave */
128#define MS_SHARED (1<<20) /* change to shared */
129#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
130#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
131#define MS_I_VERSION (1<<23) /* Update inode I_version field */
132#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
133#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
134
135/* These sb flags are internal to the kernel */
136#define MS_SUBMOUNT (1<<26)
137#define MS_NOREMOTELOCK (1<<27)
138#define MS_NOSEC (1<<28)
139#define MS_BORN (1<<29)
140#define MS_ACTIVE (1<<30)
141#define MS_NOUSER (1<<31)
142
143/*
144 * Superblock flags that can be altered by MS_REMOUNT
145 */
146#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
147 MS_LAZYTIME)
148
149/*
150 * Old magic mount flag and mask
151 */
152#define MS_MGC_VAL 0xC0ED0000
153#define MS_MGC_MSK 0xffff0000
154
155/* 109/*
156 * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR. 110 * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR.
157 */ 111 */
@@ -269,7 +223,8 @@ struct fsxattr {
269#define FS_POLICY_FLAGS_PAD_16 0x02 223#define FS_POLICY_FLAGS_PAD_16 0x02
270#define FS_POLICY_FLAGS_PAD_32 0x03 224#define FS_POLICY_FLAGS_PAD_32 0x03
271#define FS_POLICY_FLAGS_PAD_MASK 0x03 225#define FS_POLICY_FLAGS_PAD_MASK 0x03
272#define FS_POLICY_FLAGS_VALID 0x03 226#define FS_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */
227#define FS_POLICY_FLAGS_VALID 0x07
273 228
274/* Encryption algorithms */ 229/* Encryption algorithms */
275#define FS_ENCRYPTION_MODE_INVALID 0 230#define FS_ENCRYPTION_MODE_INVALID 0
@@ -281,6 +236,7 @@ struct fsxattr {
281#define FS_ENCRYPTION_MODE_AES_128_CTS 6 236#define FS_ENCRYPTION_MODE_AES_128_CTS 6
282#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* Removed, do not use. */ 237#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* Removed, do not use. */
283#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* Removed, do not use. */ 238#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* Removed, do not use. */
239#define FS_ENCRYPTION_MODE_ADIANTUM 9
284 240
285struct fscrypt_policy { 241struct fscrypt_policy {
286 __u8 version; 242 __u8 version;
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 1debfa42cba1..d6533828123a 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -288,6 +288,7 @@ enum {
288 IFLA_BR_MCAST_IGMP_VERSION, 288 IFLA_BR_MCAST_IGMP_VERSION,
289 IFLA_BR_MCAST_MLD_VERSION, 289 IFLA_BR_MCAST_MLD_VERSION,
290 IFLA_BR_VLAN_STATS_PER_PORT, 290 IFLA_BR_VLAN_STATS_PER_PORT,
291 IFLA_BR_MULTI_BOOLOPT,
291 __IFLA_BR_MAX, 292 __IFLA_BR_MAX,
292}; 293};
293 294
@@ -533,6 +534,7 @@ enum {
533 IFLA_VXLAN_LABEL, 534 IFLA_VXLAN_LABEL,
534 IFLA_VXLAN_GPE, 535 IFLA_VXLAN_GPE,
535 IFLA_VXLAN_TTL_INHERIT, 536 IFLA_VXLAN_TTL_INHERIT,
537 IFLA_VXLAN_DF,
536 __IFLA_VXLAN_MAX 538 __IFLA_VXLAN_MAX
537}; 539};
538#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) 540#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
@@ -542,6 +544,14 @@ struct ifla_vxlan_port_range {
542 __be16 high; 544 __be16 high;
543}; 545};
544 546
547enum ifla_vxlan_df {
548 VXLAN_DF_UNSET = 0,
549 VXLAN_DF_SET,
550 VXLAN_DF_INHERIT,
551 __VXLAN_DF_END,
552 VXLAN_DF_MAX = __VXLAN_DF_END - 1,
553};
554
545/* GENEVE section */ 555/* GENEVE section */
546enum { 556enum {
547 IFLA_GENEVE_UNSPEC, 557 IFLA_GENEVE_UNSPEC,
@@ -557,10 +567,19 @@ enum {
557 IFLA_GENEVE_UDP_ZERO_CSUM6_RX, 567 IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
558 IFLA_GENEVE_LABEL, 568 IFLA_GENEVE_LABEL,
559 IFLA_GENEVE_TTL_INHERIT, 569 IFLA_GENEVE_TTL_INHERIT,
570 IFLA_GENEVE_DF,
560 __IFLA_GENEVE_MAX 571 __IFLA_GENEVE_MAX
561}; 572};
562#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1) 573#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
563 574
575enum ifla_geneve_df {
576 GENEVE_DF_UNSET = 0,
577 GENEVE_DF_SET,
578 GENEVE_DF_INHERIT,
579 __GENEVE_DF_END,
580 GENEVE_DF_MAX = __GENEVE_DF_END - 1,
581};
582
564/* PPP section */ 583/* PPP section */
565enum { 584enum {
566 IFLA_PPP_UNSPEC, 585 IFLA_PPP_UNSPEC,
diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
index 48e8a225b985..a55cb8b10165 100644
--- a/tools/include/uapi/linux/in.h
+++ b/tools/include/uapi/linux/in.h
@@ -266,10 +266,14 @@ struct sockaddr_in {
266 266
267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
268#define IN_MULTICAST(a) IN_CLASSD(a) 268#define IN_MULTICAST(a) IN_CLASSD(a)
269#define IN_MULTICAST_NET 0xF0000000 269#define IN_MULTICAST_NET 0xe0000000
270 270
271#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 271#define IN_BADCLASS(a) (((long int) (a) ) == (long int)0xffffffff)
272#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) 272#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
273
274#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
275#define IN_CLASSE_NET 0xffffffff
276#define IN_CLASSE_NSHIFT 0
273 277
274/* Address to accept any incoming messages. */ 278/* Address to accept any incoming messages. */
275#define INADDR_ANY ((unsigned long int) 0x00000000) 279#define INADDR_ANY ((unsigned long int) 0x00000000)
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 2b7a652c9fa4..6d4ea4b6c922 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -492,6 +492,17 @@ struct kvm_dirty_log {
492 }; 492 };
493}; 493};
494 494
495/* for KVM_CLEAR_DIRTY_LOG */
496struct kvm_clear_dirty_log {
497 __u32 slot;
498 __u32 num_pages;
499 __u64 first_page;
500 union {
501 void __user *dirty_bitmap; /* one bit per page */
502 __u64 padding2;
503 };
504};
505
495/* for KVM_SET_SIGNAL_MASK */ 506/* for KVM_SET_SIGNAL_MASK */
496struct kvm_signal_mask { 507struct kvm_signal_mask {
497 __u32 len; 508 __u32 len;
@@ -975,6 +986,8 @@ struct kvm_ppc_resize_hpt {
975#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 986#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
976#define KVM_CAP_EXCEPTION_PAYLOAD 164 987#define KVM_CAP_EXCEPTION_PAYLOAD 164
977#define KVM_CAP_ARM_VM_IPA_SIZE 165 988#define KVM_CAP_ARM_VM_IPA_SIZE 165
989#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166
990#define KVM_CAP_HYPERV_CPUID 167
978 991
979#ifdef KVM_CAP_IRQ_ROUTING 992#ifdef KVM_CAP_IRQ_ROUTING
980 993
@@ -1421,6 +1434,12 @@ struct kvm_enc_region {
1421#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1434#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1422#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 1435#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state)
1423 1436
1437/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT */
1438#define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1439
1440/* Available with KVM_CAP_HYPERV_CPUID */
1441#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1442
1424/* Secure Encrypted Virtualization command */ 1443/* Secure Encrypted Virtualization command */
1425enum sev_cmd_id { 1444enum sev_cmd_id {
1426 /* Guest initialization commands */ 1445 /* Guest initialization commands */
diff --git a/tools/include/uapi/linux/mount.h b/tools/include/uapi/linux/mount.h
new file mode 100644
index 000000000000..3f9ec42510b0
--- /dev/null
+++ b/tools/include/uapi/linux/mount.h
@@ -0,0 +1,58 @@
1#ifndef _UAPI_LINUX_MOUNT_H
2#define _UAPI_LINUX_MOUNT_H
3
4/*
5 * These are the fs-independent mount-flags: up to 32 flags are supported
6 *
7 * Usage of these is restricted within the kernel to core mount(2) code and
8 * callers of sys_mount() only. Filesystems should be using the SB_*
9 * equivalent instead.
10 */
11#define MS_RDONLY 1 /* Mount read-only */
12#define MS_NOSUID 2 /* Ignore suid and sgid bits */
13#define MS_NODEV 4 /* Disallow access to device special files */
14#define MS_NOEXEC 8 /* Disallow program execution */
15#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
16#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
17#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
18#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
19#define MS_NOATIME 1024 /* Do not update access times. */
20#define MS_NODIRATIME 2048 /* Do not update directory access times */
21#define MS_BIND 4096
22#define MS_MOVE 8192
23#define MS_REC 16384
24#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
25 MS_VERBOSE is deprecated. */
26#define MS_SILENT 32768
27#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
28#define MS_UNBINDABLE (1<<17) /* change to unbindable */
29#define MS_PRIVATE (1<<18) /* change to private */
30#define MS_SLAVE (1<<19) /* change to slave */
31#define MS_SHARED (1<<20) /* change to shared */
32#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
33#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
34#define MS_I_VERSION (1<<23) /* Update inode I_version field */
35#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
36#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
37
38/* These sb flags are internal to the kernel */
39#define MS_SUBMOUNT (1<<26)
40#define MS_NOREMOTELOCK (1<<27)
41#define MS_NOSEC (1<<28)
42#define MS_BORN (1<<29)
43#define MS_ACTIVE (1<<30)
44#define MS_NOUSER (1<<31)
45
46/*
47 * Superblock flags that can be altered by MS_REMOUNT
48 */
49#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
50 MS_LAZYTIME)
51
52/*
53 * Old magic mount flag and mask
54 */
55#define MS_MGC_VAL 0xC0ED0000
56#define MS_MGC_MSK 0xffff0000
57
58#endif /* _UAPI_LINUX_MOUNT_H */
diff --git a/tools/include/uapi/linux/pkt_sched.h b/tools/include/uapi/linux/pkt_sched.h
new file mode 100644
index 000000000000..0d18b1d1fbbc
--- /dev/null
+++ b/tools/include/uapi/linux/pkt_sched.h
@@ -0,0 +1,1163 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef __LINUX_PKT_SCHED_H
3#define __LINUX_PKT_SCHED_H
4
5#include <linux/types.h>
6
7/* Logical priority bands not depending on specific packet scheduler.
8 Every scheduler will map them to real traffic classes, if it has
9 no more precise mechanism to classify packets.
10
11 These numbers have no special meaning, though their coincidence
12 with obsolete IPv6 values is not occasional :-). New IPv6 drafts
13 preferred full anarchy inspired by diffserv group.
14
15 Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
16 class, actually, as rule it will be handled with more care than
17 filler or even bulk.
18 */
19
20#define TC_PRIO_BESTEFFORT 0
21#define TC_PRIO_FILLER 1
22#define TC_PRIO_BULK 2
23#define TC_PRIO_INTERACTIVE_BULK 4
24#define TC_PRIO_INTERACTIVE 6
25#define TC_PRIO_CONTROL 7
26
27#define TC_PRIO_MAX 15
28
29/* Generic queue statistics, available for all the elements.
30 Particular schedulers may have also their private records.
31 */
32
33struct tc_stats {
34 __u64 bytes; /* Number of enqueued bytes */
35 __u32 packets; /* Number of enqueued packets */
36 __u32 drops; /* Packets dropped because of lack of resources */
37 __u32 overlimits; /* Number of throttle events when this
38 * flow goes out of allocated bandwidth */
39 __u32 bps; /* Current flow byte rate */
40 __u32 pps; /* Current flow packet rate */
41 __u32 qlen;
42 __u32 backlog;
43};
44
45struct tc_estimator {
46 signed char interval;
47 unsigned char ewma_log;
48};
49
50/* "Handles"
51 ---------
52
53 All the traffic control objects have 32bit identifiers, or "handles".
54
55 They can be considered as opaque numbers from user API viewpoint,
56 but actually they always consist of two fields: major and
57 minor numbers, which are interpreted by kernel specially,
58 that may be used by applications, though not recommended.
59
60 F.e. qdisc handles always have minor number equal to zero,
61 classes (or flows) have major equal to parent qdisc major, and
62 minor uniquely identifying class inside qdisc.
63
64 Macros to manipulate handles:
65 */
66
67#define TC_H_MAJ_MASK (0xFFFF0000U)
68#define TC_H_MIN_MASK (0x0000FFFFU)
69#define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
70#define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
71#define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
72
73#define TC_H_UNSPEC (0U)
74#define TC_H_ROOT (0xFFFFFFFFU)
75#define TC_H_INGRESS (0xFFFFFFF1U)
76#define TC_H_CLSACT TC_H_INGRESS
77
78#define TC_H_MIN_PRIORITY 0xFFE0U
79#define TC_H_MIN_INGRESS 0xFFF2U
80#define TC_H_MIN_EGRESS 0xFFF3U
81
82/* Need to corrospond to iproute2 tc/tc_core.h "enum link_layer" */
83enum tc_link_layer {
84 TC_LINKLAYER_UNAWARE, /* Indicate unaware old iproute2 util */
85 TC_LINKLAYER_ETHERNET,
86 TC_LINKLAYER_ATM,
87};
88#define TC_LINKLAYER_MASK 0x0F /* limit use to lower 4 bits */
89
90struct tc_ratespec {
91 unsigned char cell_log;
92 __u8 linklayer; /* lower 4 bits */
93 unsigned short overhead;
94 short cell_align;
95 unsigned short mpu;
96 __u32 rate;
97};
98
99#define TC_RTAB_SIZE 1024
100
101struct tc_sizespec {
102 unsigned char cell_log;
103 unsigned char size_log;
104 short cell_align;
105 int overhead;
106 unsigned int linklayer;
107 unsigned int mpu;
108 unsigned int mtu;
109 unsigned int tsize;
110};
111
112enum {
113 TCA_STAB_UNSPEC,
114 TCA_STAB_BASE,
115 TCA_STAB_DATA,
116 __TCA_STAB_MAX
117};
118
119#define TCA_STAB_MAX (__TCA_STAB_MAX - 1)
120
121/* FIFO section */
122
123struct tc_fifo_qopt {
124 __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
125};
126
127/* SKBPRIO section */
128
129/*
130 * Priorities go from zero to (SKBPRIO_MAX_PRIORITY - 1).
131 * SKBPRIO_MAX_PRIORITY should be at least 64 in order for skbprio to be able
132 * to map one to one the DS field of IPV4 and IPV6 headers.
133 * Memory allocation grows linearly with SKBPRIO_MAX_PRIORITY.
134 */
135
136#define SKBPRIO_MAX_PRIORITY 64
137
138struct tc_skbprio_qopt {
139 __u32 limit; /* Queue length in packets. */
140};
141
142/* PRIO section */
143
144#define TCQ_PRIO_BANDS 16
145#define TCQ_MIN_PRIO_BANDS 2
146
147struct tc_prio_qopt {
148 int bands; /* Number of bands */
149 __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
150};
151
152/* MULTIQ section */
153
154struct tc_multiq_qopt {
155 __u16 bands; /* Number of bands */
156 __u16 max_bands; /* Maximum number of queues */
157};
158
159/* PLUG section */
160
161#define TCQ_PLUG_BUFFER 0
162#define TCQ_PLUG_RELEASE_ONE 1
163#define TCQ_PLUG_RELEASE_INDEFINITE 2
164#define TCQ_PLUG_LIMIT 3
165
166struct tc_plug_qopt {
167 /* TCQ_PLUG_BUFFER: Inset a plug into the queue and
168 * buffer any incoming packets
169 * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head
170 * to beginning of the next plug.
171 * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue.
172 * Stop buffering packets until the next TCQ_PLUG_BUFFER
173 * command is received (just act as a pass-thru queue).
174 * TCQ_PLUG_LIMIT: Increase/decrease queue size
175 */
176 int action;
177 __u32 limit;
178};
179
180/* TBF section */
181
182struct tc_tbf_qopt {
183 struct tc_ratespec rate;
184 struct tc_ratespec peakrate;
185 __u32 limit;
186 __u32 buffer;
187 __u32 mtu;
188};
189
190enum {
191 TCA_TBF_UNSPEC,
192 TCA_TBF_PARMS,
193 TCA_TBF_RTAB,
194 TCA_TBF_PTAB,
195 TCA_TBF_RATE64,
196 TCA_TBF_PRATE64,
197 TCA_TBF_BURST,
198 TCA_TBF_PBURST,
199 TCA_TBF_PAD,
200 __TCA_TBF_MAX,
201};
202
203#define TCA_TBF_MAX (__TCA_TBF_MAX - 1)
204
205
206/* TEQL section */
207
208/* TEQL does not require any parameters */
209
210/* SFQ section */
211
212struct tc_sfq_qopt {
213 unsigned quantum; /* Bytes per round allocated to flow */
214 int perturb_period; /* Period of hash perturbation */
215 __u32 limit; /* Maximal packets in queue */
216 unsigned divisor; /* Hash divisor */
217 unsigned flows; /* Maximal number of flows */
218};
219
220struct tc_sfqred_stats {
221 __u32 prob_drop; /* Early drops, below max threshold */
222 __u32 forced_drop; /* Early drops, after max threshold */
223 __u32 prob_mark; /* Marked packets, below max threshold */
224 __u32 forced_mark; /* Marked packets, after max threshold */
225 __u32 prob_mark_head; /* Marked packets, below max threshold */
226 __u32 forced_mark_head;/* Marked packets, after max threshold */
227};
228
229struct tc_sfq_qopt_v1 {
230 struct tc_sfq_qopt v0;
231 unsigned int depth; /* max number of packets per flow */
232 unsigned int headdrop;
233/* SFQRED parameters */
234 __u32 limit; /* HARD maximal flow queue length (bytes) */
235 __u32 qth_min; /* Min average length threshold (bytes) */
236 __u32 qth_max; /* Max average length threshold (bytes) */
237 unsigned char Wlog; /* log(W) */
238 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
239 unsigned char Scell_log; /* cell size for idle damping */
240 unsigned char flags;
241 __u32 max_P; /* probability, high resolution */
242/* SFQRED stats */
243 struct tc_sfqred_stats stats;
244};
245
246
247struct tc_sfq_xstats {
248 __s32 allot;
249};
250
251/* RED section */
252
253enum {
254 TCA_RED_UNSPEC,
255 TCA_RED_PARMS,
256 TCA_RED_STAB,
257 TCA_RED_MAX_P,
258 __TCA_RED_MAX,
259};
260
261#define TCA_RED_MAX (__TCA_RED_MAX - 1)
262
263struct tc_red_qopt {
264 __u32 limit; /* HARD maximal queue length (bytes) */
265 __u32 qth_min; /* Min average length threshold (bytes) */
266 __u32 qth_max; /* Max average length threshold (bytes) */
267 unsigned char Wlog; /* log(W) */
268 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
269 unsigned char Scell_log; /* cell size for idle damping */
270 unsigned char flags;
271#define TC_RED_ECN 1
272#define TC_RED_HARDDROP 2
273#define TC_RED_ADAPTATIVE 4
274};
275
276struct tc_red_xstats {
277 __u32 early; /* Early drops */
278 __u32 pdrop; /* Drops due to queue limits */
279 __u32 other; /* Drops due to drop() calls */
280 __u32 marked; /* Marked packets */
281};
282
283/* GRED section */
284
285#define MAX_DPs 16
286
287enum {
288 TCA_GRED_UNSPEC,
289 TCA_GRED_PARMS,
290 TCA_GRED_STAB,
291 TCA_GRED_DPS,
292 TCA_GRED_MAX_P,
293 TCA_GRED_LIMIT,
294 TCA_GRED_VQ_LIST, /* nested TCA_GRED_VQ_ENTRY */
295 __TCA_GRED_MAX,
296};
297
298#define TCA_GRED_MAX (__TCA_GRED_MAX - 1)
299
300enum {
301 TCA_GRED_VQ_ENTRY_UNSPEC,
302 TCA_GRED_VQ_ENTRY, /* nested TCA_GRED_VQ_* */
303 __TCA_GRED_VQ_ENTRY_MAX,
304};
305#define TCA_GRED_VQ_ENTRY_MAX (__TCA_GRED_VQ_ENTRY_MAX - 1)
306
307enum {
308 TCA_GRED_VQ_UNSPEC,
309 TCA_GRED_VQ_PAD,
310 TCA_GRED_VQ_DP, /* u32 */
311 TCA_GRED_VQ_STAT_BYTES, /* u64 */
312 TCA_GRED_VQ_STAT_PACKETS, /* u32 */
313 TCA_GRED_VQ_STAT_BACKLOG, /* u32 */
314 TCA_GRED_VQ_STAT_PROB_DROP, /* u32 */
315 TCA_GRED_VQ_STAT_PROB_MARK, /* u32 */
316 TCA_GRED_VQ_STAT_FORCED_DROP, /* u32 */
317 TCA_GRED_VQ_STAT_FORCED_MARK, /* u32 */
318 TCA_GRED_VQ_STAT_PDROP, /* u32 */
319 TCA_GRED_VQ_STAT_OTHER, /* u32 */
320 TCA_GRED_VQ_FLAGS, /* u32 */
321 __TCA_GRED_VQ_MAX
322};
323
324#define TCA_GRED_VQ_MAX (__TCA_GRED_VQ_MAX - 1)
325
326struct tc_gred_qopt {
327 __u32 limit; /* HARD maximal queue length (bytes) */
328 __u32 qth_min; /* Min average length threshold (bytes) */
329 __u32 qth_max; /* Max average length threshold (bytes) */
330 __u32 DP; /* up to 2^32 DPs */
331 __u32 backlog;
332 __u32 qave;
333 __u32 forced;
334 __u32 early;
335 __u32 other;
336 __u32 pdrop;
337 __u8 Wlog; /* log(W) */
338 __u8 Plog; /* log(P_max/(qth_max-qth_min)) */
339 __u8 Scell_log; /* cell size for idle damping */
340 __u8 prio; /* prio of this VQ */
341 __u32 packets;
342 __u32 bytesin;
343};
344
345/* gred setup */
346struct tc_gred_sopt {
347 __u32 DPs;
348 __u32 def_DP;
349 __u8 grio;
350 __u8 flags;
351 __u16 pad1;
352};
353
354/* CHOKe section */
355
356enum {
357 TCA_CHOKE_UNSPEC,
358 TCA_CHOKE_PARMS,
359 TCA_CHOKE_STAB,
360 TCA_CHOKE_MAX_P,
361 __TCA_CHOKE_MAX,
362};
363
364#define TCA_CHOKE_MAX (__TCA_CHOKE_MAX - 1)
365
366struct tc_choke_qopt {
367 __u32 limit; /* Hard queue length (packets) */
368 __u32 qth_min; /* Min average threshold (packets) */
369 __u32 qth_max; /* Max average threshold (packets) */
370 unsigned char Wlog; /* log(W) */
371 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
372 unsigned char Scell_log; /* cell size for idle damping */
373 unsigned char flags; /* see RED flags */
374};
375
376struct tc_choke_xstats {
377 __u32 early; /* Early drops */
378 __u32 pdrop; /* Drops due to queue limits */
379 __u32 other; /* Drops due to drop() calls */
380 __u32 marked; /* Marked packets */
381 __u32 matched; /* Drops due to flow match */
382};
383
384/* HTB section */
385#define TC_HTB_NUMPRIO 8
386#define TC_HTB_MAXDEPTH 8
387#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */
388
389struct tc_htb_opt {
390 struct tc_ratespec rate;
391 struct tc_ratespec ceil;
392 __u32 buffer;
393 __u32 cbuffer;
394 __u32 quantum;
395 __u32 level; /* out only */
396 __u32 prio;
397};
398struct tc_htb_glob {
399 __u32 version; /* to match HTB/TC */
400 __u32 rate2quantum; /* bps->quantum divisor */
401 __u32 defcls; /* default class number */
402 __u32 debug; /* debug flags */
403
404 /* stats */
405 __u32 direct_pkts; /* count of non shaped packets */
406};
407enum {
408 TCA_HTB_UNSPEC,
409 TCA_HTB_PARMS,
410 TCA_HTB_INIT,
411 TCA_HTB_CTAB,
412 TCA_HTB_RTAB,
413 TCA_HTB_DIRECT_QLEN,
414 TCA_HTB_RATE64,
415 TCA_HTB_CEIL64,
416 TCA_HTB_PAD,
417 __TCA_HTB_MAX,
418};
419
420#define TCA_HTB_MAX (__TCA_HTB_MAX - 1)
421
422struct tc_htb_xstats {
423 __u32 lends;
424 __u32 borrows;
425 __u32 giants; /* unused since 'Make HTB scheduler work with TSO.' */
426 __s32 tokens;
427 __s32 ctokens;
428};
429
430/* HFSC section */
431
432struct tc_hfsc_qopt {
433 __u16 defcls; /* default class */
434};
435
436struct tc_service_curve {
437 __u32 m1; /* slope of the first segment in bps */
438 __u32 d; /* x-projection of the first segment in us */
439 __u32 m2; /* slope of the second segment in bps */
440};
441
442struct tc_hfsc_stats {
443 __u64 work; /* total work done */
444 __u64 rtwork; /* work done by real-time criteria */
445 __u32 period; /* current period */
446 __u32 level; /* class level in hierarchy */
447};
448
449enum {
450 TCA_HFSC_UNSPEC,
451 TCA_HFSC_RSC,
452 TCA_HFSC_FSC,
453 TCA_HFSC_USC,
454 __TCA_HFSC_MAX,
455};
456
457#define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1)
458
459
460/* CBQ section */
461
462#define TC_CBQ_MAXPRIO 8
463#define TC_CBQ_MAXLEVEL 8
464#define TC_CBQ_DEF_EWMA 5
465
466struct tc_cbq_lssopt {
467 unsigned char change;
468 unsigned char flags;
469#define TCF_CBQ_LSS_BOUNDED 1
470#define TCF_CBQ_LSS_ISOLATED 2
471 unsigned char ewma_log;
472 unsigned char level;
473#define TCF_CBQ_LSS_FLAGS 1
474#define TCF_CBQ_LSS_EWMA 2
475#define TCF_CBQ_LSS_MAXIDLE 4
476#define TCF_CBQ_LSS_MINIDLE 8
477#define TCF_CBQ_LSS_OFFTIME 0x10
478#define TCF_CBQ_LSS_AVPKT 0x20
479 __u32 maxidle;
480 __u32 minidle;
481 __u32 offtime;
482 __u32 avpkt;
483};
484
485struct tc_cbq_wrropt {
486 unsigned char flags;
487 unsigned char priority;
488 unsigned char cpriority;
489 unsigned char __reserved;
490 __u32 allot;
491 __u32 weight;
492};
493
494struct tc_cbq_ovl {
495 unsigned char strategy;
496#define TC_CBQ_OVL_CLASSIC 0
497#define TC_CBQ_OVL_DELAY 1
498#define TC_CBQ_OVL_LOWPRIO 2
499#define TC_CBQ_OVL_DROP 3
500#define TC_CBQ_OVL_RCLASSIC 4
501 unsigned char priority2;
502 __u16 pad;
503 __u32 penalty;
504};
505
506struct tc_cbq_police {
507 unsigned char police;
508 unsigned char __res1;
509 unsigned short __res2;
510};
511
512struct tc_cbq_fopt {
513 __u32 split;
514 __u32 defmap;
515 __u32 defchange;
516};
517
518struct tc_cbq_xstats {
519 __u32 borrows;
520 __u32 overactions;
521 __s32 avgidle;
522 __s32 undertime;
523};
524
525enum {
526 TCA_CBQ_UNSPEC,
527 TCA_CBQ_LSSOPT,
528 TCA_CBQ_WRROPT,
529 TCA_CBQ_FOPT,
530 TCA_CBQ_OVL_STRATEGY,
531 TCA_CBQ_RATE,
532 TCA_CBQ_RTAB,
533 TCA_CBQ_POLICE,
534 __TCA_CBQ_MAX,
535};
536
537#define TCA_CBQ_MAX (__TCA_CBQ_MAX - 1)
538
539/* dsmark section */
540
541enum {
542 TCA_DSMARK_UNSPEC,
543 TCA_DSMARK_INDICES,
544 TCA_DSMARK_DEFAULT_INDEX,
545 TCA_DSMARK_SET_TC_INDEX,
546 TCA_DSMARK_MASK,
547 TCA_DSMARK_VALUE,
548 __TCA_DSMARK_MAX,
549};
550
551#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1)
552
553/* ATM section */
554
555enum {
556 TCA_ATM_UNSPEC,
557 TCA_ATM_FD, /* file/socket descriptor */
558 TCA_ATM_PTR, /* pointer to descriptor - later */
559 TCA_ATM_HDR, /* LL header */
560 TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
561 TCA_ATM_ADDR, /* PVC address (for output only) */
562 TCA_ATM_STATE, /* VC state (ATM_VS_*; for output only) */
563 __TCA_ATM_MAX,
564};
565
566#define TCA_ATM_MAX (__TCA_ATM_MAX - 1)
567
568/* Network emulator */
569
570enum {
571 TCA_NETEM_UNSPEC,
572 TCA_NETEM_CORR,
573 TCA_NETEM_DELAY_DIST,
574 TCA_NETEM_REORDER,
575 TCA_NETEM_CORRUPT,
576 TCA_NETEM_LOSS,
577 TCA_NETEM_RATE,
578 TCA_NETEM_ECN,
579 TCA_NETEM_RATE64,
580 TCA_NETEM_PAD,
581 TCA_NETEM_LATENCY64,
582 TCA_NETEM_JITTER64,
583 TCA_NETEM_SLOT,
584 TCA_NETEM_SLOT_DIST,
585 __TCA_NETEM_MAX,
586};
587
588#define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1)
589
590struct tc_netem_qopt {
591 __u32 latency; /* added delay (us) */
592 __u32 limit; /* fifo limit (packets) */
593 __u32 loss; /* random packet loss (0=none ~0=100%) */
594 __u32 gap; /* re-ordering gap (0 for none) */
595 __u32 duplicate; /* random packet dup (0=none ~0=100%) */
596 __u32 jitter; /* random jitter in latency (us) */
597};
598
599struct tc_netem_corr {
600 __u32 delay_corr; /* delay correlation */
601 __u32 loss_corr; /* packet loss correlation */
602 __u32 dup_corr; /* duplicate correlation */
603};
604
605struct tc_netem_reorder {
606 __u32 probability;
607 __u32 correlation;
608};
609
610struct tc_netem_corrupt {
611 __u32 probability;
612 __u32 correlation;
613};
614
615struct tc_netem_rate {
616 __u32 rate; /* byte/s */
617 __s32 packet_overhead;
618 __u32 cell_size;
619 __s32 cell_overhead;
620};
621
622struct tc_netem_slot {
623 __s64 min_delay; /* nsec */
624 __s64 max_delay;
625 __s32 max_packets;
626 __s32 max_bytes;
627 __s64 dist_delay; /* nsec */
628 __s64 dist_jitter; /* nsec */
629};
630
631enum {
632 NETEM_LOSS_UNSPEC,
633 NETEM_LOSS_GI, /* General Intuitive - 4 state model */
634 NETEM_LOSS_GE, /* Gilbert Elliot models */
635 __NETEM_LOSS_MAX
636};
637#define NETEM_LOSS_MAX (__NETEM_LOSS_MAX - 1)
638
639/* State transition probabilities for 4 state model */
640struct tc_netem_gimodel {
641 __u32 p13;
642 __u32 p31;
643 __u32 p32;
644 __u32 p14;
645 __u32 p23;
646};
647
648/* Gilbert-Elliot models */
649struct tc_netem_gemodel {
650 __u32 p;
651 __u32 r;
652 __u32 h;
653 __u32 k1;
654};
655
656#define NETEM_DIST_SCALE 8192
657#define NETEM_DIST_MAX 16384
658
659/* DRR */
660
661enum {
662 TCA_DRR_UNSPEC,
663 TCA_DRR_QUANTUM,
664 __TCA_DRR_MAX
665};
666
667#define TCA_DRR_MAX (__TCA_DRR_MAX - 1)
668
669struct tc_drr_stats {
670 __u32 deficit;
671};
672
673/* MQPRIO */
674#define TC_QOPT_BITMASK 15
675#define TC_QOPT_MAX_QUEUE 16
676
677enum {
678 TC_MQPRIO_HW_OFFLOAD_NONE, /* no offload requested */
679 TC_MQPRIO_HW_OFFLOAD_TCS, /* offload TCs, no queue counts */
680 __TC_MQPRIO_HW_OFFLOAD_MAX
681};
682
683#define TC_MQPRIO_HW_OFFLOAD_MAX (__TC_MQPRIO_HW_OFFLOAD_MAX - 1)
684
685enum {
686 TC_MQPRIO_MODE_DCB,
687 TC_MQPRIO_MODE_CHANNEL,
688 __TC_MQPRIO_MODE_MAX
689};
690
691#define __TC_MQPRIO_MODE_MAX (__TC_MQPRIO_MODE_MAX - 1)
692
693enum {
694 TC_MQPRIO_SHAPER_DCB,
695 TC_MQPRIO_SHAPER_BW_RATE, /* Add new shapers below */
696 __TC_MQPRIO_SHAPER_MAX
697};
698
699#define __TC_MQPRIO_SHAPER_MAX (__TC_MQPRIO_SHAPER_MAX - 1)
700
701struct tc_mqprio_qopt {
702 __u8 num_tc;
703 __u8 prio_tc_map[TC_QOPT_BITMASK + 1];
704 __u8 hw;
705 __u16 count[TC_QOPT_MAX_QUEUE];
706 __u16 offset[TC_QOPT_MAX_QUEUE];
707};
708
709#define TC_MQPRIO_F_MODE 0x1
710#define TC_MQPRIO_F_SHAPER 0x2
711#define TC_MQPRIO_F_MIN_RATE 0x4
712#define TC_MQPRIO_F_MAX_RATE 0x8
713
714enum {
715 TCA_MQPRIO_UNSPEC,
716 TCA_MQPRIO_MODE,
717 TCA_MQPRIO_SHAPER,
718 TCA_MQPRIO_MIN_RATE64,
719 TCA_MQPRIO_MAX_RATE64,
720 __TCA_MQPRIO_MAX,
721};
722
723#define TCA_MQPRIO_MAX (__TCA_MQPRIO_MAX - 1)
724
725/* SFB */
726
727enum {
728 TCA_SFB_UNSPEC,
729 TCA_SFB_PARMS,
730 __TCA_SFB_MAX,
731};
732
733#define TCA_SFB_MAX (__TCA_SFB_MAX - 1)
734
735/*
736 * Note: increment, decrement are Q0.16 fixed-point values.
737 */
738struct tc_sfb_qopt {
739 __u32 rehash_interval; /* delay between hash move, in ms */
740 __u32 warmup_time; /* double buffering warmup time in ms (warmup_time < rehash_interval) */
741 __u32 max; /* max len of qlen_min */
742 __u32 bin_size; /* maximum queue length per bin */
743 __u32 increment; /* probability increment, (d1 in Blue) */
744 __u32 decrement; /* probability decrement, (d2 in Blue) */
745 __u32 limit; /* max SFB queue length */
746 __u32 penalty_rate; /* inelastic flows are rate limited to 'rate' pps */
747 __u32 penalty_burst;
748};
749
750struct tc_sfb_xstats {
751 __u32 earlydrop;
752 __u32 penaltydrop;
753 __u32 bucketdrop;
754 __u32 queuedrop;
755 __u32 childdrop; /* drops in child qdisc */
756 __u32 marked;
757 __u32 maxqlen;
758 __u32 maxprob;
759 __u32 avgprob;
760};
761
762#define SFB_MAX_PROB 0xFFFF
763
764/* QFQ */
765enum {
766 TCA_QFQ_UNSPEC,
767 TCA_QFQ_WEIGHT,
768 TCA_QFQ_LMAX,
769 __TCA_QFQ_MAX
770};
771
772#define TCA_QFQ_MAX (__TCA_QFQ_MAX - 1)
773
774struct tc_qfq_stats {
775 __u32 weight;
776 __u32 lmax;
777};
778
779/* CODEL */
780
781enum {
782 TCA_CODEL_UNSPEC,
783 TCA_CODEL_TARGET,
784 TCA_CODEL_LIMIT,
785 TCA_CODEL_INTERVAL,
786 TCA_CODEL_ECN,
787 TCA_CODEL_CE_THRESHOLD,
788 __TCA_CODEL_MAX
789};
790
791#define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1)
792
793struct tc_codel_xstats {
794 __u32 maxpacket; /* largest packet we've seen so far */
795 __u32 count; /* how many drops we've done since the last time we
796 * entered dropping state
797 */
798 __u32 lastcount; /* count at entry to dropping state */
799 __u32 ldelay; /* in-queue delay seen by most recently dequeued packet */
800 __s32 drop_next; /* time to drop next packet */
801 __u32 drop_overlimit; /* number of time max qdisc packet limit was hit */
802 __u32 ecn_mark; /* number of packets we ECN marked instead of dropped */
803 __u32 dropping; /* are we in dropping state ? */
804 __u32 ce_mark; /* number of CE marked packets because of ce_threshold */
805};
806
807/* FQ_CODEL */
808
809enum {
810 TCA_FQ_CODEL_UNSPEC,
811 TCA_FQ_CODEL_TARGET,
812 TCA_FQ_CODEL_LIMIT,
813 TCA_FQ_CODEL_INTERVAL,
814 TCA_FQ_CODEL_ECN,
815 TCA_FQ_CODEL_FLOWS,
816 TCA_FQ_CODEL_QUANTUM,
817 TCA_FQ_CODEL_CE_THRESHOLD,
818 TCA_FQ_CODEL_DROP_BATCH_SIZE,
819 TCA_FQ_CODEL_MEMORY_LIMIT,
820 __TCA_FQ_CODEL_MAX
821};
822
823#define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1)
824
825enum {
826 TCA_FQ_CODEL_XSTATS_QDISC,
827 TCA_FQ_CODEL_XSTATS_CLASS,
828};
829
830struct tc_fq_codel_qd_stats {
831 __u32 maxpacket; /* largest packet we've seen so far */
832 __u32 drop_overlimit; /* number of time max qdisc
833 * packet limit was hit
834 */
835 __u32 ecn_mark; /* number of packets we ECN marked
836 * instead of being dropped
837 */
838 __u32 new_flow_count; /* number of time packets
839 * created a 'new flow'
840 */
841 __u32 new_flows_len; /* count of flows in new list */
842 __u32 old_flows_len; /* count of flows in old list */
843 __u32 ce_mark; /* packets above ce_threshold */
844 __u32 memory_usage; /* in bytes */
845 __u32 drop_overmemory;
846};
847
848struct tc_fq_codel_cl_stats {
849 __s32 deficit;
850 __u32 ldelay; /* in-queue delay seen by most recently
851 * dequeued packet
852 */
853 __u32 count;
854 __u32 lastcount;
855 __u32 dropping;
856 __s32 drop_next;
857};
858
859struct tc_fq_codel_xstats {
860 __u32 type;
861 union {
862 struct tc_fq_codel_qd_stats qdisc_stats;
863 struct tc_fq_codel_cl_stats class_stats;
864 };
865};
866
867/* FQ */
868
869enum {
870 TCA_FQ_UNSPEC,
871
872 TCA_FQ_PLIMIT, /* limit of total number of packets in queue */
873
874 TCA_FQ_FLOW_PLIMIT, /* limit of packets per flow */
875
876 TCA_FQ_QUANTUM, /* RR quantum */
877
878 TCA_FQ_INITIAL_QUANTUM, /* RR quantum for new flow */
879
880 TCA_FQ_RATE_ENABLE, /* enable/disable rate limiting */
881
882 TCA_FQ_FLOW_DEFAULT_RATE,/* obsolete, do not use */
883
884 TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */
885
886 TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */
887
888 TCA_FQ_FLOW_REFILL_DELAY, /* flow credit refill delay in usec */
889
890 TCA_FQ_ORPHAN_MASK, /* mask applied to orphaned skb hashes */
891
892 TCA_FQ_LOW_RATE_THRESHOLD, /* per packet delay under this rate */
893
894 TCA_FQ_CE_THRESHOLD, /* DCTCP-like CE-marking threshold */
895
896 __TCA_FQ_MAX
897};
898
899#define TCA_FQ_MAX (__TCA_FQ_MAX - 1)
900
901struct tc_fq_qd_stats {
902 __u64 gc_flows;
903 __u64 highprio_packets;
904 __u64 tcp_retrans;
905 __u64 throttled;
906 __u64 flows_plimit;
907 __u64 pkts_too_long;
908 __u64 allocation_errors;
909 __s64 time_next_delayed_flow;
910 __u32 flows;
911 __u32 inactive_flows;
912 __u32 throttled_flows;
913 __u32 unthrottle_latency_ns;
914 __u64 ce_mark; /* packets above ce_threshold */
915};
916
917/* Heavy-Hitter Filter */
918
919enum {
920 TCA_HHF_UNSPEC,
921 TCA_HHF_BACKLOG_LIMIT,
922 TCA_HHF_QUANTUM,
923 TCA_HHF_HH_FLOWS_LIMIT,
924 TCA_HHF_RESET_TIMEOUT,
925 TCA_HHF_ADMIT_BYTES,
926 TCA_HHF_EVICT_TIMEOUT,
927 TCA_HHF_NON_HH_WEIGHT,
928 __TCA_HHF_MAX
929};
930
931#define TCA_HHF_MAX (__TCA_HHF_MAX - 1)
932
933struct tc_hhf_xstats {
934 __u32 drop_overlimit; /* number of times max qdisc packet limit
935 * was hit
936 */
937 __u32 hh_overlimit; /* number of times max heavy-hitters was hit */
938 __u32 hh_tot_count; /* number of captured heavy-hitters so far */
939 __u32 hh_cur_count; /* number of current heavy-hitters */
940};
941
942/* PIE */
943enum {
944 TCA_PIE_UNSPEC,
945 TCA_PIE_TARGET,
946 TCA_PIE_LIMIT,
947 TCA_PIE_TUPDATE,
948 TCA_PIE_ALPHA,
949 TCA_PIE_BETA,
950 TCA_PIE_ECN,
951 TCA_PIE_BYTEMODE,
952 __TCA_PIE_MAX
953};
954#define TCA_PIE_MAX (__TCA_PIE_MAX - 1)
955
956struct tc_pie_xstats {
957 __u32 prob; /* current probability */
958 __u32 delay; /* current delay in ms */
959 __u32 avg_dq_rate; /* current average dq_rate in bits/pie_time */
960 __u32 packets_in; /* total number of packets enqueued */
961 __u32 dropped; /* packets dropped due to pie_action */
962 __u32 overlimit; /* dropped due to lack of space in queue */
963 __u32 maxq; /* maximum queue size */
964 __u32 ecn_mark; /* packets marked with ecn*/
965};
966
967/* CBS */
968struct tc_cbs_qopt {
969 __u8 offload;
970 __u8 _pad[3];
971 __s32 hicredit;
972 __s32 locredit;
973 __s32 idleslope;
974 __s32 sendslope;
975};
976
977enum {
978 TCA_CBS_UNSPEC,
979 TCA_CBS_PARMS,
980 __TCA_CBS_MAX,
981};
982
983#define TCA_CBS_MAX (__TCA_CBS_MAX - 1)
984
985
986/* ETF */
987struct tc_etf_qopt {
988 __s32 delta;
989 __s32 clockid;
990 __u32 flags;
991#define TC_ETF_DEADLINE_MODE_ON BIT(0)
992#define TC_ETF_OFFLOAD_ON BIT(1)
993};
994
995enum {
996 TCA_ETF_UNSPEC,
997 TCA_ETF_PARMS,
998 __TCA_ETF_MAX,
999};
1000
1001#define TCA_ETF_MAX (__TCA_ETF_MAX - 1)
1002
1003
1004/* CAKE */
1005enum {
1006 TCA_CAKE_UNSPEC,
1007 TCA_CAKE_PAD,
1008 TCA_CAKE_BASE_RATE64,
1009 TCA_CAKE_DIFFSERV_MODE,
1010 TCA_CAKE_ATM,
1011 TCA_CAKE_FLOW_MODE,
1012 TCA_CAKE_OVERHEAD,
1013 TCA_CAKE_RTT,
1014 TCA_CAKE_TARGET,
1015 TCA_CAKE_AUTORATE,
1016 TCA_CAKE_MEMORY,
1017 TCA_CAKE_NAT,
1018 TCA_CAKE_RAW,
1019 TCA_CAKE_WASH,
1020 TCA_CAKE_MPU,
1021 TCA_CAKE_INGRESS,
1022 TCA_CAKE_ACK_FILTER,
1023 TCA_CAKE_SPLIT_GSO,
1024 __TCA_CAKE_MAX
1025};
1026#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
1027
1028enum {
1029 __TCA_CAKE_STATS_INVALID,
1030 TCA_CAKE_STATS_PAD,
1031 TCA_CAKE_STATS_CAPACITY_ESTIMATE64,
1032 TCA_CAKE_STATS_MEMORY_LIMIT,
1033 TCA_CAKE_STATS_MEMORY_USED,
1034 TCA_CAKE_STATS_AVG_NETOFF,
1035 TCA_CAKE_STATS_MIN_NETLEN,
1036 TCA_CAKE_STATS_MAX_NETLEN,
1037 TCA_CAKE_STATS_MIN_ADJLEN,
1038 TCA_CAKE_STATS_MAX_ADJLEN,
1039 TCA_CAKE_STATS_TIN_STATS,
1040 TCA_CAKE_STATS_DEFICIT,
1041 TCA_CAKE_STATS_COBALT_COUNT,
1042 TCA_CAKE_STATS_DROPPING,
1043 TCA_CAKE_STATS_DROP_NEXT_US,
1044 TCA_CAKE_STATS_P_DROP,
1045 TCA_CAKE_STATS_BLUE_TIMER_US,
1046 __TCA_CAKE_STATS_MAX
1047};
1048#define TCA_CAKE_STATS_MAX (__TCA_CAKE_STATS_MAX - 1)
1049
1050enum {
1051 __TCA_CAKE_TIN_STATS_INVALID,
1052 TCA_CAKE_TIN_STATS_PAD,
1053 TCA_CAKE_TIN_STATS_SENT_PACKETS,
1054 TCA_CAKE_TIN_STATS_SENT_BYTES64,
1055 TCA_CAKE_TIN_STATS_DROPPED_PACKETS,
1056 TCA_CAKE_TIN_STATS_DROPPED_BYTES64,
1057 TCA_CAKE_TIN_STATS_ACKS_DROPPED_PACKETS,
1058 TCA_CAKE_TIN_STATS_ACKS_DROPPED_BYTES64,
1059 TCA_CAKE_TIN_STATS_ECN_MARKED_PACKETS,
1060 TCA_CAKE_TIN_STATS_ECN_MARKED_BYTES64,
1061 TCA_CAKE_TIN_STATS_BACKLOG_PACKETS,
1062 TCA_CAKE_TIN_STATS_BACKLOG_BYTES,
1063 TCA_CAKE_TIN_STATS_THRESHOLD_RATE64,
1064 TCA_CAKE_TIN_STATS_TARGET_US,
1065 TCA_CAKE_TIN_STATS_INTERVAL_US,
1066 TCA_CAKE_TIN_STATS_WAY_INDIRECT_HITS,
1067 TCA_CAKE_TIN_STATS_WAY_MISSES,
1068 TCA_CAKE_TIN_STATS_WAY_COLLISIONS,
1069 TCA_CAKE_TIN_STATS_PEAK_DELAY_US,
1070 TCA_CAKE_TIN_STATS_AVG_DELAY_US,
1071 TCA_CAKE_TIN_STATS_BASE_DELAY_US,
1072 TCA_CAKE_TIN_STATS_SPARSE_FLOWS,
1073 TCA_CAKE_TIN_STATS_BULK_FLOWS,
1074 TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS,
1075 TCA_CAKE_TIN_STATS_MAX_SKBLEN,
1076 TCA_CAKE_TIN_STATS_FLOW_QUANTUM,
1077 __TCA_CAKE_TIN_STATS_MAX
1078};
1079#define TCA_CAKE_TIN_STATS_MAX (__TCA_CAKE_TIN_STATS_MAX - 1)
1080#define TC_CAKE_MAX_TINS (8)
1081
1082enum {
1083 CAKE_FLOW_NONE = 0,
1084 CAKE_FLOW_SRC_IP,
1085 CAKE_FLOW_DST_IP,
1086 CAKE_FLOW_HOSTS, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_DST_IP */
1087 CAKE_FLOW_FLOWS,
1088 CAKE_FLOW_DUAL_SRC, /* = CAKE_FLOW_SRC_IP | CAKE_FLOW_FLOWS */
1089 CAKE_FLOW_DUAL_DST, /* = CAKE_FLOW_DST_IP | CAKE_FLOW_FLOWS */
1090 CAKE_FLOW_TRIPLE, /* = CAKE_FLOW_HOSTS | CAKE_FLOW_FLOWS */
1091 CAKE_FLOW_MAX,
1092};
1093
1094enum {
1095 CAKE_DIFFSERV_DIFFSERV3 = 0,
1096 CAKE_DIFFSERV_DIFFSERV4,
1097 CAKE_DIFFSERV_DIFFSERV8,
1098 CAKE_DIFFSERV_BESTEFFORT,
1099 CAKE_DIFFSERV_PRECEDENCE,
1100 CAKE_DIFFSERV_MAX
1101};
1102
1103enum {
1104 CAKE_ACK_NONE = 0,
1105 CAKE_ACK_FILTER,
1106 CAKE_ACK_AGGRESSIVE,
1107 CAKE_ACK_MAX
1108};
1109
1110enum {
1111 CAKE_ATM_NONE = 0,
1112 CAKE_ATM_ATM,
1113 CAKE_ATM_PTM,
1114 CAKE_ATM_MAX
1115};
1116
1117
1118/* TAPRIO */
1119enum {
1120 TC_TAPRIO_CMD_SET_GATES = 0x00,
1121 TC_TAPRIO_CMD_SET_AND_HOLD = 0x01,
1122 TC_TAPRIO_CMD_SET_AND_RELEASE = 0x02,
1123};
1124
1125enum {
1126 TCA_TAPRIO_SCHED_ENTRY_UNSPEC,
1127 TCA_TAPRIO_SCHED_ENTRY_INDEX, /* u32 */
1128 TCA_TAPRIO_SCHED_ENTRY_CMD, /* u8 */
1129 TCA_TAPRIO_SCHED_ENTRY_GATE_MASK, /* u32 */
1130 TCA_TAPRIO_SCHED_ENTRY_INTERVAL, /* u32 */
1131 __TCA_TAPRIO_SCHED_ENTRY_MAX,
1132};
1133#define TCA_TAPRIO_SCHED_ENTRY_MAX (__TCA_TAPRIO_SCHED_ENTRY_MAX - 1)
1134
1135/* The format for schedule entry list is:
1136 * [TCA_TAPRIO_SCHED_ENTRY_LIST]
1137 * [TCA_TAPRIO_SCHED_ENTRY]
1138 * [TCA_TAPRIO_SCHED_ENTRY_CMD]
1139 * [TCA_TAPRIO_SCHED_ENTRY_GATES]
1140 * [TCA_TAPRIO_SCHED_ENTRY_INTERVAL]
1141 */
1142enum {
1143 TCA_TAPRIO_SCHED_UNSPEC,
1144 TCA_TAPRIO_SCHED_ENTRY,
1145 __TCA_TAPRIO_SCHED_MAX,
1146};
1147
1148#define TCA_TAPRIO_SCHED_MAX (__TCA_TAPRIO_SCHED_MAX - 1)
1149
1150enum {
1151 TCA_TAPRIO_ATTR_UNSPEC,
1152 TCA_TAPRIO_ATTR_PRIOMAP, /* struct tc_mqprio_qopt */
1153 TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, /* nested of entry */
1154 TCA_TAPRIO_ATTR_SCHED_BASE_TIME, /* s64 */
1155 TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY, /* single entry */
1156 TCA_TAPRIO_ATTR_SCHED_CLOCKID, /* s32 */
1157 TCA_TAPRIO_PAD,
1158 __TCA_TAPRIO_ATTR_MAX,
1159};
1160
1161#define TCA_TAPRIO_ATTR_MAX (__TCA_TAPRIO_ATTR_MAX - 1)
1162
1163#endif
diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index b17201edfa09..b4875a93363a 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -220,4 +220,12 @@ struct prctl_mm_map {
220# define PR_SPEC_DISABLE (1UL << 2) 220# define PR_SPEC_DISABLE (1UL << 2)
221# define PR_SPEC_FORCE_DISABLE (1UL << 3) 221# define PR_SPEC_FORCE_DISABLE (1UL << 3)
222 222
223/* Reset arm64 pointer authentication keys */
224#define PR_PAC_RESET_KEYS 54
225# define PR_PAC_APIAKEY (1UL << 0)
226# define PR_PAC_APIBKEY (1UL << 1)
227# define PR_PAC_APDAKEY (1UL << 2)
228# define PR_PAC_APDBKEY (1UL << 3)
229# define PR_PAC_APGAKEY (1UL << 4)
230
223#endif /* _LINUX_PRCTL_H */ 231#endif /* _LINUX_PRCTL_H */
diff --git a/tools/include/uapi/linux/vhost.h b/tools/include/uapi/linux/vhost.h
index 84c3de89696a..40d028eed645 100644
--- a/tools/include/uapi/linux/vhost.h
+++ b/tools/include/uapi/linux/vhost.h
@@ -11,94 +11,9 @@
11 * device configuration. 11 * device configuration.
12 */ 12 */
13 13
14#include <linux/vhost_types.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <linux/compiler.h>
16#include <linux/ioctl.h> 16#include <linux/ioctl.h>
17#include <linux/virtio_config.h>
18#include <linux/virtio_ring.h>
19
20struct vhost_vring_state {
21 unsigned int index;
22 unsigned int num;
23};
24
25struct vhost_vring_file {
26 unsigned int index;
27 int fd; /* Pass -1 to unbind from file. */
28
29};
30
31struct vhost_vring_addr {
32 unsigned int index;
33 /* Option flags. */
34 unsigned int flags;
35 /* Flag values: */
36 /* Whether log address is valid. If set enables logging. */
37#define VHOST_VRING_F_LOG 0
38
39 /* Start of array of descriptors (virtually contiguous) */
40 __u64 desc_user_addr;
41 /* Used structure address. Must be 32 bit aligned */
42 __u64 used_user_addr;
43 /* Available structure address. Must be 16 bit aligned */
44 __u64 avail_user_addr;
45 /* Logging support. */
46 /* Log writes to used structure, at offset calculated from specified
47 * address. Address must be 32 bit aligned. */
48 __u64 log_guest_addr;
49};
50
51/* no alignment requirement */
52struct vhost_iotlb_msg {
53 __u64 iova;
54 __u64 size;
55 __u64 uaddr;
56#define VHOST_ACCESS_RO 0x1
57#define VHOST_ACCESS_WO 0x2
58#define VHOST_ACCESS_RW 0x3
59 __u8 perm;
60#define VHOST_IOTLB_MISS 1
61#define VHOST_IOTLB_UPDATE 2
62#define VHOST_IOTLB_INVALIDATE 3
63#define VHOST_IOTLB_ACCESS_FAIL 4
64 __u8 type;
65};
66
67#define VHOST_IOTLB_MSG 0x1
68#define VHOST_IOTLB_MSG_V2 0x2
69
70struct vhost_msg {
71 int type;
72 union {
73 struct vhost_iotlb_msg iotlb;
74 __u8 padding[64];
75 };
76};
77
78struct vhost_msg_v2 {
79 __u32 type;
80 __u32 reserved;
81 union {
82 struct vhost_iotlb_msg iotlb;
83 __u8 padding[64];
84 };
85};
86
87struct vhost_memory_region {
88 __u64 guest_phys_addr;
89 __u64 memory_size; /* bytes */
90 __u64 userspace_addr;
91 __u64 flags_padding; /* No flags are currently specified. */
92};
93
94/* All region addresses and sizes must be 4K aligned. */
95#define VHOST_PAGE_SIZE 0x1000
96
97struct vhost_memory {
98 __u32 nregions;
99 __u32 padding;
100 struct vhost_memory_region regions[0];
101};
102 17
103/* ioctls */ 18/* ioctls */
104 19
@@ -186,31 +101,7 @@ struct vhost_memory {
186 * device. This can be used to stop the ring (e.g. for migration). */ 101 * device. This can be used to stop the ring (e.g. for migration). */
187#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file) 102#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
188 103
189/* Feature bits */ 104/* VHOST_SCSI specific defines */
190/* Log all write descriptors. Can be changed while device is active. */
191#define VHOST_F_LOG_ALL 26
192/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
193#define VHOST_NET_F_VIRTIO_NET_HDR 27
194
195/* VHOST_SCSI specific definitions */
196
197/*
198 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
199 *
200 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
201 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
202 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
203 * All the targets under vhost_wwpn can be seen and used by guset.
204 */
205
206#define VHOST_SCSI_ABI_VERSION 1
207
208struct vhost_scsi_target {
209 int abi_version;
210 char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
211 unsigned short vhost_tpgt;
212 unsigned short reserved;
213};
214 105
215#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target) 106#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
216#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target) 107#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
diff --git a/tools/lib/bpf/.gitignore b/tools/lib/bpf/.gitignore
index f81e549ddfdb..4db74758c674 100644
--- a/tools/lib/bpf/.gitignore
+++ b/tools/lib/bpf/.gitignore
@@ -1,2 +1,3 @@
1libbpf_version.h 1libbpf_version.h
2FEATURE-DUMP.libbpf 2FEATURE-DUMP.libbpf
3test_libbpf
diff --git a/tools/lib/bpf/README.rst b/tools/lib/bpf/README.rst
index 056f38310722..607aae40f4ed 100644
--- a/tools/lib/bpf/README.rst
+++ b/tools/lib/bpf/README.rst
@@ -132,6 +132,20 @@ For example, if current state of ``libbpf.map`` is:
132Format of version script and ways to handle ABI changes, including 132Format of version script and ways to handle ABI changes, including
133incompatible ones, described in details in [1]. 133incompatible ones, described in details in [1].
134 134
135Stand-alone build
136=================
137
138Under https://github.com/libbpf/libbpf there is a (semi-)automated
139mirror of the mainline's version of libbpf for a stand-alone build.
140
141However, all changes to libbpf's code base must be upstreamed through
142the mainline kernel tree.
143
144License
145=======
146
147libbpf is dual-licensed under LGPL 2.1 and BSD 2-Clause.
148
135Links 149Links
136===== 150=====
137 151
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 3caaa3428774..88cbd110ae58 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -65,6 +65,17 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
65 return syscall(__NR_bpf, cmd, attr, size); 65 return syscall(__NR_bpf, cmd, attr, size);
66} 66}
67 67
68static inline int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size)
69{
70 int fd;
71
72 do {
73 fd = sys_bpf(BPF_PROG_LOAD, attr, size);
74 } while (fd < 0 && errno == EAGAIN);
75
76 return fd;
77}
78
68int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr) 79int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
69{ 80{
70 __u32 name_len = create_attr->name ? strlen(create_attr->name) : 0; 81 __u32 name_len = create_attr->name ? strlen(create_attr->name) : 0;
@@ -232,7 +243,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
232 memcpy(attr.prog_name, load_attr->name, 243 memcpy(attr.prog_name, load_attr->name,
233 min(name_len, BPF_OBJ_NAME_LEN - 1)); 244 min(name_len, BPF_OBJ_NAME_LEN - 1));
234 245
235 fd = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); 246 fd = sys_bpf_prog_load(&attr, sizeof(attr));
236 if (fd >= 0) 247 if (fd >= 0)
237 return fd; 248 return fd;
238 249
@@ -269,7 +280,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
269 break; 280 break;
270 } 281 }
271 282
272 fd = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); 283 fd = sys_bpf_prog_load(&attr, sizeof(attr));
273 284
274 if (fd >= 0) 285 if (fd >= 0)
275 goto done; 286 goto done;
@@ -283,7 +294,7 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
283 attr.log_size = log_buf_sz; 294 attr.log_size = log_buf_sz;
284 attr.log_level = 1; 295 attr.log_level = 1;
285 log_buf[0] = 0; 296 log_buf[0] = 0;
286 fd = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); 297 fd = sys_bpf_prog_load(&attr, sizeof(attr));
287done: 298done:
288 free(finfo); 299 free(finfo);
289 free(linfo); 300 free(linfo);
@@ -328,7 +339,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
328 attr.kern_version = kern_version; 339 attr.kern_version = kern_version;
329 attr.prog_flags = prog_flags; 340 attr.prog_flags = prog_flags;
330 341
331 return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); 342 return sys_bpf_prog_load(&attr, sizeof(attr));
332} 343}
333 344
334int bpf_map_update_elem(int fd, const void *key, const void *value, 345int bpf_map_update_elem(int fd, const void *key, const void *value,
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 8b31c0e00ba3..d463761a58f4 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -194,13 +194,13 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size)
194} 194}
195 195
196/** 196/**
197 * tep_is_file_bigendian - get if the file is in big endian order 197 * tep_file_bigendian - get if the file is in big endian order
198 * @pevent: a handle to the tep_handle 198 * @pevent: a handle to the tep_handle
199 * 199 *
200 * This returns if the file is in big endian order 200 * This returns if the file is in big endian order
201 * If @pevent is NULL, 0 is returned. 201 * If @pevent is NULL, 0 is returned.
202 */ 202 */
203int tep_is_file_bigendian(struct tep_handle *pevent) 203int tep_file_bigendian(struct tep_handle *pevent)
204{ 204{
205 if(pevent) 205 if(pevent)
206 return pevent->file_bigendian; 206 return pevent->file_bigendian;
diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h
index 9a092dd4a86d..35833ee32d6c 100644
--- a/tools/lib/traceevent/event-parse-local.h
+++ b/tools/lib/traceevent/event-parse-local.h
@@ -7,7 +7,7 @@
7#ifndef _PARSE_EVENTS_INT_H 7#ifndef _PARSE_EVENTS_INT_H
8#define _PARSE_EVENTS_INT_H 8#define _PARSE_EVENTS_INT_H
9 9
10struct cmdline; 10struct tep_cmdline;
11struct cmdline_list; 11struct cmdline_list;
12struct func_map; 12struct func_map;
13struct func_list; 13struct func_list;
@@ -36,7 +36,7 @@ struct tep_handle {
36 int long_size; 36 int long_size;
37 int page_size; 37 int page_size;
38 38
39 struct cmdline *cmdlines; 39 struct tep_cmdline *cmdlines;
40 struct cmdline_list *cmdlist; 40 struct cmdline_list *cmdlist;
41 int cmdline_count; 41 int cmdline_count;
42 42
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 69a96e39f0ab..abd4fa5d3088 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -124,15 +124,15 @@ struct tep_print_arg *alloc_arg(void)
124 return calloc(1, sizeof(struct tep_print_arg)); 124 return calloc(1, sizeof(struct tep_print_arg));
125} 125}
126 126
127struct cmdline { 127struct tep_cmdline {
128 char *comm; 128 char *comm;
129 int pid; 129 int pid;
130}; 130};
131 131
132static int cmdline_cmp(const void *a, const void *b) 132static int cmdline_cmp(const void *a, const void *b)
133{ 133{
134 const struct cmdline *ca = a; 134 const struct tep_cmdline *ca = a;
135 const struct cmdline *cb = b; 135 const struct tep_cmdline *cb = b;
136 136
137 if (ca->pid < cb->pid) 137 if (ca->pid < cb->pid)
138 return -1; 138 return -1;
@@ -152,7 +152,7 @@ static int cmdline_init(struct tep_handle *pevent)
152{ 152{
153 struct cmdline_list *cmdlist = pevent->cmdlist; 153 struct cmdline_list *cmdlist = pevent->cmdlist;
154 struct cmdline_list *item; 154 struct cmdline_list *item;
155 struct cmdline *cmdlines; 155 struct tep_cmdline *cmdlines;
156 int i; 156 int i;
157 157
158 cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count); 158 cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count);
@@ -179,8 +179,8 @@ static int cmdline_init(struct tep_handle *pevent)
179 179
180static const char *find_cmdline(struct tep_handle *pevent, int pid) 180static const char *find_cmdline(struct tep_handle *pevent, int pid)
181{ 181{
182 const struct cmdline *comm; 182 const struct tep_cmdline *comm;
183 struct cmdline key; 183 struct tep_cmdline key;
184 184
185 if (!pid) 185 if (!pid)
186 return "<idle>"; 186 return "<idle>";
@@ -208,8 +208,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)
208 */ 208 */
209int tep_pid_is_registered(struct tep_handle *pevent, int pid) 209int tep_pid_is_registered(struct tep_handle *pevent, int pid)
210{ 210{
211 const struct cmdline *comm; 211 const struct tep_cmdline *comm;
212 struct cmdline key; 212 struct tep_cmdline key;
213 213
214 if (!pid) 214 if (!pid)
215 return 1; 215 return 1;
@@ -232,11 +232,13 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)
232 * we must add this pid. This is much slower than when cmdlines 232 * we must add this pid. This is much slower than when cmdlines
233 * are added before the array is initialized. 233 * are added before the array is initialized.
234 */ 234 */
235static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) 235static int add_new_comm(struct tep_handle *pevent,
236 const char *comm, int pid, bool override)
236{ 237{
237 struct cmdline *cmdlines = pevent->cmdlines; 238 struct tep_cmdline *cmdlines = pevent->cmdlines;
238 const struct cmdline *cmdline; 239 struct tep_cmdline *cmdline;
239 struct cmdline key; 240 struct tep_cmdline key;
241 char *new_comm;
240 242
241 if (!pid) 243 if (!pid)
242 return 0; 244 return 0;
@@ -247,8 +249,19 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
247 cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count, 249 cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count,
248 sizeof(*pevent->cmdlines), cmdline_cmp); 250 sizeof(*pevent->cmdlines), cmdline_cmp);
249 if (cmdline) { 251 if (cmdline) {
250 errno = EEXIST; 252 if (!override) {
251 return -1; 253 errno = EEXIST;
254 return -1;
255 }
256 new_comm = strdup(comm);
257 if (!new_comm) {
258 errno = ENOMEM;
259 return -1;
260 }
261 free(cmdline->comm);
262 cmdline->comm = new_comm;
263
264 return 0;
252 } 265 }
253 266
254 cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1)); 267 cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1));
@@ -275,21 +288,13 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
275 return 0; 288 return 0;
276} 289}
277 290
278/** 291static int _tep_register_comm(struct tep_handle *pevent,
279 * tep_register_comm - register a pid / comm mapping 292 const char *comm, int pid, bool override)
280 * @pevent: handle for the pevent
281 * @comm: the command line to register
282 * @pid: the pid to map the command line to
283 *
284 * This adds a mapping to search for command line names with
285 * a given pid. The comm is duplicated.
286 */
287int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
288{ 293{
289 struct cmdline_list *item; 294 struct cmdline_list *item;
290 295
291 if (pevent->cmdlines) 296 if (pevent->cmdlines)
292 return add_new_comm(pevent, comm, pid); 297 return add_new_comm(pevent, comm, pid, override);
293 298
294 item = malloc(sizeof(*item)); 299 item = malloc(sizeof(*item));
295 if (!item) 300 if (!item)
@@ -312,6 +317,40 @@ int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
312 return 0; 317 return 0;
313} 318}
314 319
320/**
321 * tep_register_comm - register a pid / comm mapping
322 * @pevent: handle for the pevent
323 * @comm: the command line to register
324 * @pid: the pid to map the command line to
325 *
326 * This adds a mapping to search for command line names with
327 * a given pid. The comm is duplicated. If a command with the same pid
328 * already exist, -1 is returned and errno is set to EEXIST
329 */
330int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
331{
332 return _tep_register_comm(pevent, comm, pid, false);
333}
334
335/**
336 * tep_override_comm - register a pid / comm mapping
337 * @pevent: handle for the pevent
338 * @comm: the command line to register
339 * @pid: the pid to map the command line to
340 *
341 * This adds a mapping to search for command line names with
342 * a given pid. The comm is duplicated. If a command with the same pid
343 * already exist, the command string is udapted with the new one
344 */
345int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid)
346{
347 if (!pevent->cmdlines && cmdline_init(pevent)) {
348 errno = ENOMEM;
349 return -1;
350 }
351 return _tep_register_comm(pevent, comm, pid, true);
352}
353
315int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock) 354int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock)
316{ 355{
317 pevent->trace_clock = strdup(trace_clock); 356 pevent->trace_clock = strdup(trace_clock);
@@ -5227,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
5227} 5266}
5228 5267
5229/** 5268/**
5230 * tep_data_event_from_type - find the event by a given type
5231 * @pevent: a handle to the pevent
5232 * @type: the type of the event.
5233 *
5234 * This returns the event form a given @type;
5235 */
5236struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type)
5237{
5238 return tep_find_event(pevent, type);
5239}
5240
5241/**
5242 * tep_data_pid - parse the PID from record 5269 * tep_data_pid - parse the PID from record
5243 * @pevent: a handle to the pevent 5270 * @pevent: a handle to the pevent
5244 * @rec: the record to parse 5271 * @rec: the record to parse
@@ -5292,8 +5319,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)
5292 return comm; 5319 return comm;
5293} 5320}
5294 5321
5295static struct cmdline * 5322static struct tep_cmdline *
5296pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next) 5323pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct tep_cmdline *next)
5297{ 5324{
5298 struct cmdline_list *cmdlist = (struct cmdline_list *)next; 5325 struct cmdline_list *cmdlist = (struct cmdline_list *)next;
5299 5326
@@ -5305,7 +5332,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
5305 while (cmdlist && strcmp(cmdlist->comm, comm) != 0) 5332 while (cmdlist && strcmp(cmdlist->comm, comm) != 0)
5306 cmdlist = cmdlist->next; 5333 cmdlist = cmdlist->next;
5307 5334
5308 return (struct cmdline *)cmdlist; 5335 return (struct tep_cmdline *)cmdlist;
5309} 5336}
5310 5337
5311/** 5338/**
@@ -5321,10 +5348,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne
5321 * next pid. 5348 * next pid.
5322 * Also, it does a linear search, so it may be slow. 5349 * Also, it does a linear search, so it may be slow.
5323 */ 5350 */
5324struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, 5351struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
5325 struct cmdline *next) 5352 struct tep_cmdline *next)
5326{ 5353{
5327 struct cmdline *cmdline; 5354 struct tep_cmdline *cmdline;
5328 5355
5329 /* 5356 /*
5330 * If the cmdlines have not been converted yet, then use 5357 * If the cmdlines have not been converted yet, then use
@@ -5363,7 +5390,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co
5363 * Returns the pid for a give cmdline. If @cmdline is NULL, then 5390 * Returns the pid for a give cmdline. If @cmdline is NULL, then
5364 * -1 is returned. 5391 * -1 is returned.
5365 */ 5392 */
5366int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) 5393int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline)
5367{ 5394{
5368 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; 5395 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
5369 5396
@@ -6593,6 +6620,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id,
6593 * 6620 *
6594 * If @id is >= 0, then it is used to find the event. 6621 * If @id is >= 0, then it is used to find the event.
6595 * else @sys_name and @event_name are used. 6622 * else @sys_name and @event_name are used.
6623 *
6624 * Returns:
6625 * TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten
6626 * TEP_REGISTER_SUCCESS if a new handler is registered successfully
6627 * negative TEP_ERRNO_... in case of an error
6628 *
6596 */ 6629 */
6597int tep_register_event_handler(struct tep_handle *pevent, int id, 6630int tep_register_event_handler(struct tep_handle *pevent, int id,
6598 const char *sys_name, const char *event_name, 6631 const char *sys_name, const char *event_name,
@@ -6610,7 +6643,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
6610 6643
6611 event->handler = func; 6644 event->handler = func;
6612 event->context = context; 6645 event->context = context;
6613 return 0; 6646 return TEP_REGISTER_SUCCESS_OVERWRITE;
6614 6647
6615 not_found: 6648 not_found:
6616 /* Save for later use. */ 6649 /* Save for later use. */
@@ -6640,7 +6673,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
6640 pevent->handlers = handle; 6673 pevent->handlers = handle;
6641 handle->context = context; 6674 handle->context = context;
6642 6675
6643 return -1; 6676 return TEP_REGISTER_SUCCESS;
6644} 6677}
6645 6678
6646static int handle_matches(struct event_handler *handler, int id, 6679static int handle_matches(struct event_handler *handler, int id,
@@ -6723,8 +6756,10 @@ struct tep_handle *tep_alloc(void)
6723{ 6756{
6724 struct tep_handle *pevent = calloc(1, sizeof(*pevent)); 6757 struct tep_handle *pevent = calloc(1, sizeof(*pevent));
6725 6758
6726 if (pevent) 6759 if (pevent) {
6727 pevent->ref_count = 1; 6760 pevent->ref_count = 1;
6761 pevent->host_bigendian = tep_host_bigendian();
6762 }
6728 6763
6729 return pevent; 6764 return pevent;
6730} 6765}
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 35d37087d3c5..aec48f2aea8a 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -432,6 +432,7 @@ int tep_set_function_resolver(struct tep_handle *pevent,
432 tep_func_resolver_t *func, void *priv); 432 tep_func_resolver_t *func, void *priv);
433void tep_reset_function_resolver(struct tep_handle *pevent); 433void tep_reset_function_resolver(struct tep_handle *pevent);
434int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); 434int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid);
435int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid);
435int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); 436int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock);
436int tep_register_function(struct tep_handle *pevent, char *name, 437int tep_register_function(struct tep_handle *pevent, char *name,
437 unsigned long long addr, char *mod); 438 unsigned long long addr, char *mod);
@@ -484,6 +485,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt,
484 struct tep_event *event, const char *name, 485 struct tep_event *event, const char *name,
485 struct tep_record *record, int err); 486 struct tep_record *record, int err);
486 487
488enum tep_reg_handler {
489 TEP_REGISTER_SUCCESS = 0,
490 TEP_REGISTER_SUCCESS_OVERWRITE,
491};
492
487int tep_register_event_handler(struct tep_handle *pevent, int id, 493int tep_register_event_handler(struct tep_handle *pevent, int id,
488 const char *sys_name, const char *event_name, 494 const char *sys_name, const char *event_name,
489 tep_event_handler_func func, void *context); 495 tep_event_handler_func func, void *context);
@@ -520,15 +526,14 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
520void tep_data_lat_fmt(struct tep_handle *pevent, 526void tep_data_lat_fmt(struct tep_handle *pevent,
521 struct trace_seq *s, struct tep_record *record); 527 struct trace_seq *s, struct tep_record *record);
522int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); 528int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
523struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type);
524int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); 529int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
525int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); 530int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
526int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); 531int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
527const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid); 532const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
528struct cmdline; 533struct tep_cmdline;
529struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, 534struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
530 struct cmdline *next); 535 struct tep_cmdline *next);
531int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); 536int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline);
532 537
533void tep_print_field(struct trace_seq *s, void *data, 538void tep_print_field(struct trace_seq *s, void *data,
534 struct tep_format_field *field); 539 struct tep_format_field *field);
@@ -553,7 +558,7 @@ int tep_get_long_size(struct tep_handle *pevent);
553void tep_set_long_size(struct tep_handle *pevent, int long_size); 558void tep_set_long_size(struct tep_handle *pevent, int long_size);
554int tep_get_page_size(struct tep_handle *pevent); 559int tep_get_page_size(struct tep_handle *pevent);
555void tep_set_page_size(struct tep_handle *pevent, int _page_size); 560void tep_set_page_size(struct tep_handle *pevent, int _page_size);
556int tep_is_file_bigendian(struct tep_handle *pevent); 561int tep_file_bigendian(struct tep_handle *pevent);
557void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); 562void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian);
558int tep_is_host_bigendian(struct tep_handle *pevent); 563int tep_is_host_bigendian(struct tep_handle *pevent);
559void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); 564void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian);
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 754050eea467..64b9c25a1fd3 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,7 +389,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
389 * We can only use the structure if file is of the same 389 * We can only use the structure if file is of the same
390 * endianness. 390 * endianness.
391 */ 391 */
392 if (tep_is_file_bigendian(event->pevent) == 392 if (tep_file_bigendian(event->pevent) ==
393 tep_is_host_bigendian(event->pevent)) { 393 tep_is_host_bigendian(event->pevent)) {
394 394
395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", 395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 8ff1d55954d1..8d5ecd2bf877 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s)
100 * @fmt: printf format string 100 * @fmt: printf format string
101 * 101 *
102 * It returns 0 if the trace oversizes the buffer's free 102 * It returns 0 if the trace oversizes the buffer's free
103 * space, 1 otherwise. 103 * space, the number of characters printed, or a negative
104 * value in case of an error.
104 * 105 *
105 * The tracer may use either sequence operations or its own 106 * The tracer may use either sequence operations or its own
106 * copy to user routines. To simplify formating of a trace 107 * copy to user routines. To simplify formating of a trace
@@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
129 goto try_again; 130 goto try_again;
130 } 131 }
131 132
132 s->len += ret; 133 if (ret > 0)
134 s->len += ret;
133 135
134 return 1; 136 return ret;
135} 137}
136 138
137/** 139/**
@@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
139 * @s: trace sequence descriptor 141 * @s: trace sequence descriptor
140 * @fmt: printf format string 142 * @fmt: printf format string
141 * 143 *
144 * It returns 0 if the trace oversizes the buffer's free
145 * space, the number of characters printed, or a negative
146 * value in case of an error.
147 * *
142 * The tracer may use either sequence operations or its own 148 * The tracer may use either sequence operations or its own
143 * copy to user routines. To simplify formating of a trace 149 * copy to user routines. To simplify formating of a trace
144 * trace_seq_printf is used to store strings into a special 150 * trace_seq_printf is used to store strings into a special
@@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
163 goto try_again; 169 goto try_again;
164 } 170 }
165 171
166 s->len += ret; 172 if (ret > 0)
173 s->len += ret;
167 174
168 return len; 175 return ret;
169} 176}
170 177
171/** 178/**
diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt
index 095aebdc5bb7..e6150f21267d 100644
--- a/tools/perf/Documentation/perf-c2c.txt
+++ b/tools/perf/Documentation/perf-c2c.txt
@@ -19,8 +19,11 @@ C2C stands for Cache To Cache.
19The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows 19The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows
20you to track down the cacheline contentions. 20you to track down the cacheline contentions.
21 21
22The tool is based on x86's load latency and precise store facility events 22On x86, the tool is based on load latency and precise store facility events
23provided by Intel CPUs. These events provide: 23provided by Intel CPUs. On PowerPC, the tool uses random instruction sampling
24with thresholding feature.
25
26These events provide:
24 - memory address of the access 27 - memory address of the access
25 - type of the access (load and store details) 28 - type of the access (load and store details)
26 - latency (in cycles) of the load access 29 - latency (in cycles) of the load access
@@ -46,7 +49,7 @@ RECORD OPTIONS
46 49
47-l:: 50-l::
48--ldlat:: 51--ldlat::
49 Configure mem-loads latency. 52 Configure mem-loads latency. (x86 only)
50 53
51-k:: 54-k::
52--all-kernel:: 55--all-kernel::
@@ -119,11 +122,16 @@ Following perf record options are configured by default:
119 -W,-d,--phys-data,--sample-cpu 122 -W,-d,--phys-data,--sample-cpu
120 123
121Unless specified otherwise with '-e' option, following events are monitored by 124Unless specified otherwise with '-e' option, following events are monitored by
122default: 125default on x86:
123 126
124 cpu/mem-loads,ldlat=30/P 127 cpu/mem-loads,ldlat=30/P
125 cpu/mem-stores/P 128 cpu/mem-stores/P
126 129
130and following on PowerPC:
131
132 cpu/mem-loads/
133 cpu/mem-stores/
134
127User can pass any 'perf record' option behind '--' mark, like (to enable 135User can pass any 'perf record' option behind '--' mark, like (to enable
128callchains and system wide monitoring): 136callchains and system wide monitoring):
129 137
diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index f8d2167cf3e7..199ea0f0a6c0 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -82,7 +82,7 @@ RECORD OPTIONS
82 Be more verbose (show counter open errors, etc) 82 Be more verbose (show counter open errors, etc)
83 83
84--ldlat <n>:: 84--ldlat <n>::
85 Specify desired latency for loads event. 85 Specify desired latency for loads event. (x86 only)
86 86
87In addition, for report all perf report options are valid, and for record 87In addition, for report all perf report options are valid, and for record
88all perf record options. 88all perf record options.
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ff29c3372ec3..0ee6795d82cc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -524,12 +524,14 @@ $(arch_errno_name_array): $(arch_errno_tbl)
524 524
525all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) 525all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
526 526
527# Create python binding output directory if not already present
528_dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
529
527$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) 530$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
528 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ 531 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
529 CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \ 532 CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
530 $(PYTHON_WORD) util/setup.py \ 533 $(PYTHON_WORD) util/setup.py \
531 --quiet build_ext; \ 534 --quiet build_ext; \
532 mkdir -p $(OUTPUT)python && \
533 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/ 535 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
534 536
535please_set_SHELL_PATH_to_a_more_modern_shell: 537please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -660,12 +662,12 @@ $(OUTPUT)perf-%: %.o $(PERFLIBS)
660 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) 662 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
661 663
662ifndef NO_PERF_READ_VDSO32 664ifndef NO_PERF_READ_VDSO32
663$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-vdso-map.c 665$(OUTPUT)perf-read-vdso32: perf-read-vdso.c util/find-map.c
664 $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c 666 $(QUIET_CC)$(CC) -m32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
665endif 667endif
666 668
667ifndef NO_PERF_READ_VDSOX32 669ifndef NO_PERF_READ_VDSOX32
668$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c 670$(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-map.c
669 $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c 671 $(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
670endif 672endif
671 673
diff --git a/tools/perf/arch/arm/tests/Build b/tools/perf/arch/arm/tests/Build
index 883c57ff0c08..d9ae2733f9cc 100644
--- a/tools/perf/arch/arm/tests/Build
+++ b/tools/perf/arch/arm/tests/Build
@@ -1,4 +1,5 @@
1libperf-y += regs_load.o 1libperf-y += regs_load.o
2libperf-y += dwarf-unwind.o 2libperf-y += dwarf-unwind.o
3libperf-y += vectors-page.o
3 4
4libperf-y += arch-tests.o 5libperf-y += arch-tests.o
diff --git a/tools/perf/arch/arm/tests/arch-tests.c b/tools/perf/arch/arm/tests/arch-tests.c
index 5b1543c98022..6848101a855f 100644
--- a/tools/perf/arch/arm/tests/arch-tests.c
+++ b/tools/perf/arch/arm/tests/arch-tests.c
@@ -11,6 +11,10 @@ struct test arch_tests[] = {
11 }, 11 },
12#endif 12#endif
13 { 13 {
14 .desc = "Vectors page",
15 .func = test__vectors_page,
16 },
17 {
14 .func = NULL, 18 .func = NULL,
15 }, 19 },
16}; 20};
diff --git a/tools/perf/arch/arm/tests/vectors-page.c b/tools/perf/arch/arm/tests/vectors-page.c
new file mode 100644
index 000000000000..7ffdd79971c8
--- /dev/null
+++ b/tools/perf/arch/arm/tests/vectors-page.c
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <stdio.h>
3#include <string.h>
4#include <linux/compiler.h>
5
6#include "debug.h"
7#include "tests/tests.h"
8#include "util/find-map.c"
9
10#define VECTORS__MAP_NAME "[vectors]"
11
12int test__vectors_page(struct test *test __maybe_unused,
13 int subtest __maybe_unused)
14{
15 void *start, *end;
16
17 if (find_map(&start, &end, VECTORS__MAP_NAME)) {
18 pr_err("%s not found, is CONFIG_KUSER_HELPERS enabled?\n",
19 VECTORS__MAP_NAME);
20 return TEST_FAIL;
21 }
22
23 return TEST_OK;
24}
diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index a111239df182..e58d00d62f02 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -14,18 +14,25 @@ PERF_HAVE_JITDUMP := 1
14out := $(OUTPUT)arch/powerpc/include/generated/asm 14out := $(OUTPUT)arch/powerpc/include/generated/asm
15header32 := $(out)/syscalls_32.c 15header32 := $(out)/syscalls_32.c
16header64 := $(out)/syscalls_64.c 16header64 := $(out)/syscalls_64.c
17sysdef := $(srctree)/tools/arch/powerpc/include/uapi/asm/unistd.h 17syskrn := $(srctree)/arch/powerpc/kernel/syscalls/syscall.tbl
18sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls/ 18sysprf := $(srctree)/tools/perf/arch/powerpc/entry/syscalls
19sysdef := $(sysprf)/syscall.tbl
19systbl := $(sysprf)/mksyscalltbl 20systbl := $(sysprf)/mksyscalltbl
20 21
21# Create output directory if not already present 22# Create output directory if not already present
22_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') 23_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
23 24
24$(header64): $(sysdef) $(systbl) 25$(header64): $(sysdef) $(systbl)
25 $(Q)$(SHELL) '$(systbl)' '64' '$(CC)' $(sysdef) > $@ 26 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
27 (diff -B $(sysdef) $(syskrn) >/dev/null) \
28 || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true
29 $(Q)$(SHELL) '$(systbl)' '64' $(sysdef) > $@
26 30
27$(header32): $(sysdef) $(systbl) 31$(header32): $(sysdef) $(systbl)
28 $(Q)$(SHELL) '$(systbl)' '32' '$(CC)' $(sysdef) > $@ 32 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
33 (diff -B $(sysdef) $(syskrn) >/dev/null) \
34 || echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest version at '$(syskrn)'" >&2 )) || true
35 $(Q)$(SHELL) '$(systbl)' '32' $(sysdef) > $@
29 36
30clean:: 37clean::
31 $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64) 38 $(call QUIET_CLEAN, powerpc) $(RM) $(header32) $(header64)
diff --git a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
index ef52e1dd694b..6c58060aa03b 100755
--- a/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
@@ -9,10 +9,9 @@
9# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> 9# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
10 10
11wordsize=$1 11wordsize=$1
12gcc=$2 12SYSCALL_TBL=$2
13input=$3
14 13
15if ! test -r $input; then 14if ! test -r $SYSCALL_TBL; then
16 echo "Could not read input file" >&2 15 echo "Could not read input file" >&2
17 exit 1 16 exit 1
18fi 17fi
@@ -20,18 +19,21 @@ fi
20create_table() 19create_table()
21{ 20{
22 local wordsize=$1 21 local wordsize=$1
23 local max_nr 22 local max_nr nr abi sc discard
23 max_nr=-1
24 nr=0
24 25
25 echo "static const char *syscalltbl_powerpc_${wordsize}[] = {" 26 echo "static const char *syscalltbl_powerpc_${wordsize}[] = {"
26 while read sc nr; do 27 while read nr abi sc discard; do
27 printf '\t[%d] = "%s",\n' $nr $sc 28 if [ "$max_nr" -lt "$nr" ]; then
28 max_nr=$nr 29 printf '\t[%d] = "%s",\n' $nr $sc
30 max_nr=$nr
31 fi
29 done 32 done
30 echo '};' 33 echo '};'
31 echo "#define SYSCALLTBL_POWERPC_${wordsize}_MAX_ID $max_nr" 34 echo "#define SYSCALLTBL_POWERPC_${wordsize}_MAX_ID $max_nr"
32} 35}
33 36
34$gcc -m${wordsize} -E -dM -x c $input \ 37grep -E "^[[:digit:]]+[[:space:]]+(common|spu|nospu|${wordsize})" $SYSCALL_TBL \
35 |sed -ne 's/^#define __NR_//p' \ 38 |sort -k1 -n \
36 |sort -t' ' -k2 -nu \
37 |create_table ${wordsize} 39 |create_table ${wordsize}
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
new file mode 100644
index 000000000000..db3bbb8744af
--- /dev/null
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -0,0 +1,427 @@
1# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2#
3# system call numbers and entry vectors for powerpc
4#
5# The format is:
6# <number> <abi> <name> <entry point> <compat entry point>
7#
8# The <abi> can be common, spu, nospu, 64, or 32 for this file.
9#
100 nospu restart_syscall sys_restart_syscall
111 nospu exit sys_exit
122 nospu fork ppc_fork
133 common read sys_read
144 common write sys_write
155 common open sys_open compat_sys_open
166 common close sys_close
177 common waitpid sys_waitpid
188 common creat sys_creat
199 common link sys_link
2010 common unlink sys_unlink
2111 nospu execve sys_execve compat_sys_execve
2212 common chdir sys_chdir
2313 common time sys_time compat_sys_time
2414 common mknod sys_mknod
2515 common chmod sys_chmod
2616 common lchown sys_lchown
2717 common break sys_ni_syscall
2818 32 oldstat sys_stat sys_ni_syscall
2918 64 oldstat sys_ni_syscall
3018 spu oldstat sys_ni_syscall
3119 common lseek sys_lseek compat_sys_lseek
3220 common getpid sys_getpid
3321 nospu mount sys_mount compat_sys_mount
3422 32 umount sys_oldumount
3522 64 umount sys_ni_syscall
3622 spu umount sys_ni_syscall
3723 common setuid sys_setuid
3824 common getuid sys_getuid
3925 common stime sys_stime compat_sys_stime
4026 nospu ptrace sys_ptrace compat_sys_ptrace
4127 common alarm sys_alarm
4228 32 oldfstat sys_fstat sys_ni_syscall
4328 64 oldfstat sys_ni_syscall
4428 spu oldfstat sys_ni_syscall
4529 nospu pause sys_pause
4630 nospu utime sys_utime compat_sys_utime
4731 common stty sys_ni_syscall
4832 common gtty sys_ni_syscall
4933 common access sys_access
5034 common nice sys_nice
5135 common ftime sys_ni_syscall
5236 common sync sys_sync
5337 common kill sys_kill
5438 common rename sys_rename
5539 common mkdir sys_mkdir
5640 common rmdir sys_rmdir
5741 common dup sys_dup
5842 common pipe sys_pipe
5943 common times sys_times compat_sys_times
6044 common prof sys_ni_syscall
6145 common brk sys_brk
6246 common setgid sys_setgid
6347 common getgid sys_getgid
6448 nospu signal sys_signal
6549 common geteuid sys_geteuid
6650 common getegid sys_getegid
6751 nospu acct sys_acct
6852 nospu umount2 sys_umount
6953 common lock sys_ni_syscall
7054 common ioctl sys_ioctl compat_sys_ioctl
7155 common fcntl sys_fcntl compat_sys_fcntl
7256 common mpx sys_ni_syscall
7357 common setpgid sys_setpgid
7458 common ulimit sys_ni_syscall
7559 32 oldolduname sys_olduname
7659 64 oldolduname sys_ni_syscall
7759 spu oldolduname sys_ni_syscall
7860 common umask sys_umask
7961 common chroot sys_chroot
8062 nospu ustat sys_ustat compat_sys_ustat
8163 common dup2 sys_dup2
8264 common getppid sys_getppid
8365 common getpgrp sys_getpgrp
8466 common setsid sys_setsid
8567 32 sigaction sys_sigaction compat_sys_sigaction
8667 64 sigaction sys_ni_syscall
8767 spu sigaction sys_ni_syscall
8868 common sgetmask sys_sgetmask
8969 common ssetmask sys_ssetmask
9070 common setreuid sys_setreuid
9171 common setregid sys_setregid
9272 32 sigsuspend sys_sigsuspend
9372 64 sigsuspend sys_ni_syscall
9472 spu sigsuspend sys_ni_syscall
9573 32 sigpending sys_sigpending compat_sys_sigpending
9673 64 sigpending sys_ni_syscall
9773 spu sigpending sys_ni_syscall
9874 common sethostname sys_sethostname
9975 common setrlimit sys_setrlimit compat_sys_setrlimit
10076 32 getrlimit sys_old_getrlimit compat_sys_old_getrlimit
10176 64 getrlimit sys_ni_syscall
10276 spu getrlimit sys_ni_syscall
10377 common getrusage sys_getrusage compat_sys_getrusage
10478 common gettimeofday sys_gettimeofday compat_sys_gettimeofday
10579 common settimeofday sys_settimeofday compat_sys_settimeofday
10680 common getgroups sys_getgroups
10781 common setgroups sys_setgroups
10882 32 select ppc_select sys_ni_syscall
10982 64 select sys_ni_syscall
11082 spu select sys_ni_syscall
11183 common symlink sys_symlink
11284 32 oldlstat sys_lstat sys_ni_syscall
11384 64 oldlstat sys_ni_syscall
11484 spu oldlstat sys_ni_syscall
11585 common readlink sys_readlink
11686 nospu uselib sys_uselib
11787 nospu swapon sys_swapon
11888 nospu reboot sys_reboot
11989 32 readdir sys_old_readdir compat_sys_old_readdir
12089 64 readdir sys_ni_syscall
12189 spu readdir sys_ni_syscall
12290 common mmap sys_mmap
12391 common munmap sys_munmap
12492 common truncate sys_truncate compat_sys_truncate
12593 common ftruncate sys_ftruncate compat_sys_ftruncate
12694 common fchmod sys_fchmod
12795 common fchown sys_fchown
12896 common getpriority sys_getpriority
12997 common setpriority sys_setpriority
13098 common profil sys_ni_syscall
13199 nospu statfs sys_statfs compat_sys_statfs
132100 nospu fstatfs sys_fstatfs compat_sys_fstatfs
133101 common ioperm sys_ni_syscall
134102 common socketcall sys_socketcall compat_sys_socketcall
135103 common syslog sys_syslog
136104 common setitimer sys_setitimer compat_sys_setitimer
137105 common getitimer sys_getitimer compat_sys_getitimer
138106 common stat sys_newstat compat_sys_newstat
139107 common lstat sys_newlstat compat_sys_newlstat
140108 common fstat sys_newfstat compat_sys_newfstat
141109 32 olduname sys_uname
142109 64 olduname sys_ni_syscall
143109 spu olduname sys_ni_syscall
144110 common iopl sys_ni_syscall
145111 common vhangup sys_vhangup
146112 common idle sys_ni_syscall
147113 common vm86 sys_ni_syscall
148114 common wait4 sys_wait4 compat_sys_wait4
149115 nospu swapoff sys_swapoff
150116 common sysinfo sys_sysinfo compat_sys_sysinfo
151117 nospu ipc sys_ipc compat_sys_ipc
152118 common fsync sys_fsync
153119 32 sigreturn sys_sigreturn compat_sys_sigreturn
154119 64 sigreturn sys_ni_syscall
155119 spu sigreturn sys_ni_syscall
156120 nospu clone ppc_clone
157121 common setdomainname sys_setdomainname
158122 common uname sys_newuname
159123 common modify_ldt sys_ni_syscall
160124 common adjtimex sys_adjtimex compat_sys_adjtimex
161125 common mprotect sys_mprotect
162126 32 sigprocmask sys_sigprocmask compat_sys_sigprocmask
163126 64 sigprocmask sys_ni_syscall
164126 spu sigprocmask sys_ni_syscall
165127 common create_module sys_ni_syscall
166128 nospu init_module sys_init_module
167129 nospu delete_module sys_delete_module
168130 common get_kernel_syms sys_ni_syscall
169131 nospu quotactl sys_quotactl
170132 common getpgid sys_getpgid
171133 common fchdir sys_fchdir
172134 common bdflush sys_bdflush
173135 common sysfs sys_sysfs
174136 32 personality sys_personality ppc64_personality
175136 64 personality ppc64_personality
176136 spu personality ppc64_personality
177137 common afs_syscall sys_ni_syscall
178138 common setfsuid sys_setfsuid
179139 common setfsgid sys_setfsgid
180140 common _llseek sys_llseek
181141 common getdents sys_getdents compat_sys_getdents
182142 common _newselect sys_select compat_sys_select
183143 common flock sys_flock
184144 common msync sys_msync
185145 common readv sys_readv compat_sys_readv
186146 common writev sys_writev compat_sys_writev
187147 common getsid sys_getsid
188148 common fdatasync sys_fdatasync
189149 nospu _sysctl sys_sysctl compat_sys_sysctl
190150 common mlock sys_mlock
191151 common munlock sys_munlock
192152 common mlockall sys_mlockall
193153 common munlockall sys_munlockall
194154 common sched_setparam sys_sched_setparam
195155 common sched_getparam sys_sched_getparam
196156 common sched_setscheduler sys_sched_setscheduler
197157 common sched_getscheduler sys_sched_getscheduler
198158 common sched_yield sys_sched_yield
199159 common sched_get_priority_max sys_sched_get_priority_max
200160 common sched_get_priority_min sys_sched_get_priority_min
201161 common sched_rr_get_interval sys_sched_rr_get_interval compat_sys_sched_rr_get_interval
202162 common nanosleep sys_nanosleep compat_sys_nanosleep
203163 common mremap sys_mremap
204164 common setresuid sys_setresuid
205165 common getresuid sys_getresuid
206166 common query_module sys_ni_syscall
207167 common poll sys_poll
208168 common nfsservctl sys_ni_syscall
209169 common setresgid sys_setresgid
210170 common getresgid sys_getresgid
211171 common prctl sys_prctl
212172 nospu rt_sigreturn sys_rt_sigreturn compat_sys_rt_sigreturn
213173 nospu rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction
214174 nospu rt_sigprocmask sys_rt_sigprocmask compat_sys_rt_sigprocmask
215175 nospu rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending
216176 nospu rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
217177 nospu rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
218178 nospu rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend
219179 common pread64 sys_pread64 compat_sys_pread64
220180 common pwrite64 sys_pwrite64 compat_sys_pwrite64
221181 common chown sys_chown
222182 common getcwd sys_getcwd
223183 common capget sys_capget
224184 common capset sys_capset
225185 nospu sigaltstack sys_sigaltstack compat_sys_sigaltstack
226186 32 sendfile sys_sendfile compat_sys_sendfile
227186 64 sendfile sys_sendfile64
228186 spu sendfile sys_sendfile64
229187 common getpmsg sys_ni_syscall
230188 common putpmsg sys_ni_syscall
231189 nospu vfork ppc_vfork
232190 common ugetrlimit sys_getrlimit compat_sys_getrlimit
233191 common readahead sys_readahead compat_sys_readahead
234192 32 mmap2 sys_mmap2 compat_sys_mmap2
235193 32 truncate64 sys_truncate64 compat_sys_truncate64
236194 32 ftruncate64 sys_ftruncate64 compat_sys_ftruncate64
237195 32 stat64 sys_stat64
238196 32 lstat64 sys_lstat64
239197 32 fstat64 sys_fstat64
240198 nospu pciconfig_read sys_pciconfig_read
241199 nospu pciconfig_write sys_pciconfig_write
242200 nospu pciconfig_iobase sys_pciconfig_iobase
243201 common multiplexer sys_ni_syscall
244202 common getdents64 sys_getdents64
245203 common pivot_root sys_pivot_root
246204 32 fcntl64 sys_fcntl64 compat_sys_fcntl64
247205 common madvise sys_madvise
248206 common mincore sys_mincore
249207 common gettid sys_gettid
250208 common tkill sys_tkill
251209 common setxattr sys_setxattr
252210 common lsetxattr sys_lsetxattr
253211 common fsetxattr sys_fsetxattr
254212 common getxattr sys_getxattr
255213 common lgetxattr sys_lgetxattr
256214 common fgetxattr sys_fgetxattr
257215 common listxattr sys_listxattr
258216 common llistxattr sys_llistxattr
259217 common flistxattr sys_flistxattr
260218 common removexattr sys_removexattr
261219 common lremovexattr sys_lremovexattr
262220 common fremovexattr sys_fremovexattr
263221 common futex sys_futex compat_sys_futex
264222 common sched_setaffinity sys_sched_setaffinity compat_sys_sched_setaffinity
265223 common sched_getaffinity sys_sched_getaffinity compat_sys_sched_getaffinity
266# 224 unused
267225 common tuxcall sys_ni_syscall
268226 32 sendfile64 sys_sendfile64 compat_sys_sendfile64
269227 common io_setup sys_io_setup compat_sys_io_setup
270228 common io_destroy sys_io_destroy
271229 common io_getevents sys_io_getevents compat_sys_io_getevents
272230 common io_submit sys_io_submit compat_sys_io_submit
273231 common io_cancel sys_io_cancel
274232 nospu set_tid_address sys_set_tid_address
275233 common fadvise64 sys_fadvise64 ppc32_fadvise64
276234 nospu exit_group sys_exit_group
277235 nospu lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie
278236 common epoll_create sys_epoll_create
279237 common epoll_ctl sys_epoll_ctl
280238 common epoll_wait sys_epoll_wait
281239 common remap_file_pages sys_remap_file_pages
282240 common timer_create sys_timer_create compat_sys_timer_create
283241 common timer_settime sys_timer_settime compat_sys_timer_settime
284242 common timer_gettime sys_timer_gettime compat_sys_timer_gettime
285243 common timer_getoverrun sys_timer_getoverrun
286244 common timer_delete sys_timer_delete
287245 common clock_settime sys_clock_settime compat_sys_clock_settime
288246 common clock_gettime sys_clock_gettime compat_sys_clock_gettime
289247 common clock_getres sys_clock_getres compat_sys_clock_getres
290248 common clock_nanosleep sys_clock_nanosleep compat_sys_clock_nanosleep
291249 32 swapcontext ppc_swapcontext ppc32_swapcontext
292249 64 swapcontext ppc64_swapcontext
293249 spu swapcontext sys_ni_syscall
294250 common tgkill sys_tgkill
295251 common utimes sys_utimes compat_sys_utimes
296252 common statfs64 sys_statfs64 compat_sys_statfs64
297253 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64
298254 32 fadvise64_64 ppc_fadvise64_64
299254 spu fadvise64_64 sys_ni_syscall
300255 common rtas sys_rtas
301256 32 sys_debug_setcontext sys_debug_setcontext sys_ni_syscall
302256 64 sys_debug_setcontext sys_ni_syscall
303256 spu sys_debug_setcontext sys_ni_syscall
304# 257 reserved for vserver
305258 nospu migrate_pages sys_migrate_pages compat_sys_migrate_pages
306259 nospu mbind sys_mbind compat_sys_mbind
307260 nospu get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
308261 nospu set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy
309262 nospu mq_open sys_mq_open compat_sys_mq_open
310263 nospu mq_unlink sys_mq_unlink
311264 nospu mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend
312265 nospu mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive
313266 nospu mq_notify sys_mq_notify compat_sys_mq_notify
314267 nospu mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr
315268 nospu kexec_load sys_kexec_load compat_sys_kexec_load
316269 nospu add_key sys_add_key
317270 nospu request_key sys_request_key
318271 nospu keyctl sys_keyctl compat_sys_keyctl
319272 nospu waitid sys_waitid compat_sys_waitid
320273 nospu ioprio_set sys_ioprio_set
321274 nospu ioprio_get sys_ioprio_get
322275 nospu inotify_init sys_inotify_init
323276 nospu inotify_add_watch sys_inotify_add_watch
324277 nospu inotify_rm_watch sys_inotify_rm_watch
325278 nospu spu_run sys_spu_run
326279 nospu spu_create sys_spu_create
327280 nospu pselect6 sys_pselect6 compat_sys_pselect6
328281 nospu ppoll sys_ppoll compat_sys_ppoll
329282 common unshare sys_unshare
330283 common splice sys_splice
331284 common tee sys_tee
332285 common vmsplice sys_vmsplice compat_sys_vmsplice
333286 common openat sys_openat compat_sys_openat
334287 common mkdirat sys_mkdirat
335288 common mknodat sys_mknodat
336289 common fchownat sys_fchownat
337290 common futimesat sys_futimesat compat_sys_futimesat
338291 32 fstatat64 sys_fstatat64
339291 64 newfstatat sys_newfstatat
340291 spu newfstatat sys_newfstatat
341292 common unlinkat sys_unlinkat
342293 common renameat sys_renameat
343294 common linkat sys_linkat
344295 common symlinkat sys_symlinkat
345296 common readlinkat sys_readlinkat
346297 common fchmodat sys_fchmodat
347298 common faccessat sys_faccessat
348299 common get_robust_list sys_get_robust_list compat_sys_get_robust_list
349300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list
350301 common move_pages sys_move_pages compat_sys_move_pages
351302 common getcpu sys_getcpu
352303 nospu epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
353304 common utimensat sys_utimensat compat_sys_utimensat
354305 common signalfd sys_signalfd compat_sys_signalfd
355306 common timerfd_create sys_timerfd_create
356307 common eventfd sys_eventfd
357308 common sync_file_range2 sys_sync_file_range2 compat_sys_sync_file_range2
358309 nospu fallocate sys_fallocate compat_sys_fallocate
359310 nospu subpage_prot sys_subpage_prot
360311 common timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime
361312 common timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime
362313 common signalfd4 sys_signalfd4 compat_sys_signalfd4
363314 common eventfd2 sys_eventfd2
364315 common epoll_create1 sys_epoll_create1
365316 common dup3 sys_dup3
366317 common pipe2 sys_pipe2
367318 nospu inotify_init1 sys_inotify_init1
368319 common perf_event_open sys_perf_event_open
369320 common preadv sys_preadv compat_sys_preadv
370321 common pwritev sys_pwritev compat_sys_pwritev
371322 nospu rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
372323 nospu fanotify_init sys_fanotify_init
373324 nospu fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark
374325 common prlimit64 sys_prlimit64
375326 common socket sys_socket
376327 common bind sys_bind
377328 common connect sys_connect
378329 common listen sys_listen
379330 common accept sys_accept
380331 common getsockname sys_getsockname
381332 common getpeername sys_getpeername
382333 common socketpair sys_socketpair
383334 common send sys_send
384335 common sendto sys_sendto
385336 common recv sys_recv compat_sys_recv
386337 common recvfrom sys_recvfrom compat_sys_recvfrom
387338 common shutdown sys_shutdown
388339 common setsockopt sys_setsockopt compat_sys_setsockopt
389340 common getsockopt sys_getsockopt compat_sys_getsockopt
390341 common sendmsg sys_sendmsg compat_sys_sendmsg
391342 common recvmsg sys_recvmsg compat_sys_recvmsg
392343 common recvmmsg sys_recvmmsg compat_sys_recvmmsg
393344 common accept4 sys_accept4
394345 common name_to_handle_at sys_name_to_handle_at
395346 common open_by_handle_at sys_open_by_handle_at compat_sys_open_by_handle_at
396347 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime
397348 common syncfs sys_syncfs
398349 common sendmmsg sys_sendmmsg compat_sys_sendmmsg
399350 common setns sys_setns
400351 nospu process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv
401352 nospu process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev
402353 nospu finit_module sys_finit_module
403354 nospu kcmp sys_kcmp
404355 common sched_setattr sys_sched_setattr
405356 common sched_getattr sys_sched_getattr
406357 common renameat2 sys_renameat2
407358 common seccomp sys_seccomp
408359 common getrandom sys_getrandom
409360 common memfd_create sys_memfd_create
410361 common bpf sys_bpf
411362 nospu execveat sys_execveat compat_sys_execveat
412363 32 switch_endian sys_ni_syscall
413363 64 switch_endian ppc_switch_endian
414363 spu switch_endian sys_ni_syscall
415364 common userfaultfd sys_userfaultfd
416365 common membarrier sys_membarrier
417378 nospu mlock2 sys_mlock2
418379 nospu copy_file_range sys_copy_file_range
419380 common preadv2 sys_preadv2 compat_sys_preadv2
420381 common pwritev2 sys_pwritev2 compat_sys_pwritev2
421382 nospu kexec_file_load sys_kexec_file_load
422383 nospu statx sys_statx
423384 nospu pkey_alloc sys_pkey_alloc
424385 nospu pkey_free sys_pkey_free
425386 nospu pkey_mprotect sys_pkey_mprotect
426387 nospu rseq sys_rseq
427388 nospu io_pgetevents sys_io_pgetevents compat_sys_io_pgetevents
diff --git a/tools/perf/arch/powerpc/include/perf_regs.h b/tools/perf/arch/powerpc/include/perf_regs.h
index 1076393e6f43..e18a3556f5e3 100644
--- a/tools/perf/arch/powerpc/include/perf_regs.h
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -63,7 +63,8 @@ static const char *reg_names[] = {
63 [PERF_REG_POWERPC_TRAP] = "trap", 63 [PERF_REG_POWERPC_TRAP] = "trap",
64 [PERF_REG_POWERPC_DAR] = "dar", 64 [PERF_REG_POWERPC_DAR] = "dar",
65 [PERF_REG_POWERPC_DSISR] = "dsisr", 65 [PERF_REG_POWERPC_DSISR] = "dsisr",
66 [PERF_REG_POWERPC_SIER] = "sier" 66 [PERF_REG_POWERPC_SIER] = "sier",
67 [PERF_REG_POWERPC_MMCRA] = "mmcra"
67}; 68};
68 69
69static inline const char *perf_reg_name(int id) 70static inline const char *perf_reg_name(int id)
diff --git a/tools/perf/arch/powerpc/util/Build b/tools/perf/arch/powerpc/util/Build
index 2e6595310420..ba98bd006488 100644
--- a/tools/perf/arch/powerpc/util/Build
+++ b/tools/perf/arch/powerpc/util/Build
@@ -2,6 +2,7 @@ libperf-y += header.o
2libperf-y += sym-handling.o 2libperf-y += sym-handling.o
3libperf-y += kvm-stat.o 3libperf-y += kvm-stat.o
4libperf-y += perf_regs.o 4libperf-y += perf_regs.o
5libperf-y += mem-events.o
5 6
6libperf-$(CONFIG_DWARF) += dwarf-regs.o 7libperf-$(CONFIG_DWARF) += dwarf-regs.o
7libperf-$(CONFIG_DWARF) += skip-callchain-idx.o 8libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
new file mode 100644
index 000000000000..d08311f04e95
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/mem-events.c
@@ -0,0 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0
2#include "mem-events.h"
3
4/* PowerPC does not support 'ldlat' parameter. */
5char *perf_mem_events__name(int i)
6{
7 if (i == PERF_MEM_EVENTS__LOAD)
8 return (char *) "cpu/mem-loads/";
9
10 return (char *) "cpu/mem-stores/";
11}
diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c
index 07fcd977d93e..34d5134681d9 100644
--- a/tools/perf/arch/powerpc/util/perf_regs.c
+++ b/tools/perf/arch/powerpc/util/perf_regs.c
@@ -53,6 +53,7 @@ const struct sample_reg sample_reg_masks[] = {
53 SMPL_REG(dar, PERF_REG_POWERPC_DAR), 53 SMPL_REG(dar, PERF_REG_POWERPC_DAR),
54 SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR), 54 SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR),
55 SMPL_REG(sier, PERF_REG_POWERPC_SIER), 55 SMPL_REG(sier, PERF_REG_POWERPC_SIER),
56 SMPL_REG(mmcra, PERF_REG_POWERPC_MMCRA),
56 SMPL_REG_END 57 SMPL_REG_END
57}; 58};
58 59
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index d079f36d342d..ac221f137ed2 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1681,13 +1681,8 @@ static void perf_sample__fprint_metric(struct perf_script *script,
1681 .force_header = false, 1681 .force_header = false,
1682 }; 1682 };
1683 struct perf_evsel *ev2; 1683 struct perf_evsel *ev2;
1684 static bool init;
1685 u64 val; 1684 u64 val;
1686 1685
1687 if (!init) {
1688 perf_stat__init_shadow_stats();
1689 init = true;
1690 }
1691 if (!evsel->stats) 1686 if (!evsel->stats)
1692 perf_evlist__alloc_stats(script->session->evlist, false); 1687 perf_evlist__alloc_stats(script->session->evlist, false);
1693 if (evsel_script(evsel->leader)->gnum++ == 0) 1688 if (evsel_script(evsel->leader)->gnum++ == 0)
@@ -1794,7 +1789,7 @@ static void process_event(struct perf_script *script,
1794 return; 1789 return;
1795 } 1790 }
1796 1791
1797 if (PRINT_FIELD(TRACE)) { 1792 if (PRINT_FIELD(TRACE) && sample->raw_data) {
1798 event_format__fprintf(evsel->tp_format, sample->cpu, 1793 event_format__fprintf(evsel->tp_format, sample->cpu,
1799 sample->raw_data, sample->raw_size, fp); 1794 sample->raw_data, sample->raw_size, fp);
1800 } 1795 }
@@ -2359,6 +2354,8 @@ static int __cmd_script(struct perf_script *script)
2359 2354
2360 signal(SIGINT, sig_handler); 2355 signal(SIGINT, sig_handler);
2361 2356
2357 perf_stat__init_shadow_stats();
2358
2362 /* override event processing functions */ 2359 /* override event processing functions */
2363 if (script->show_task_events) { 2360 if (script->show_task_events) {
2364 script->tool.comm = process_comm_event; 2361 script->tool.comm = process_comm_event;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1410d66192f7..63a3afc7f32b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -561,7 +561,8 @@ try_again:
561 break; 561 break;
562 } 562 }
563 } 563 }
564 wait4(child_pid, &status, 0, &stat_config.ru_data); 564 if (child_pid != -1)
565 wait4(child_pid, &status, 0, &stat_config.ru_data);
565 566
566 if (workload_exec_errno) { 567 if (workload_exec_errno) {
567 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); 568 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index fe3ecfb2e64b..f64e312db787 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1028,12 +1028,7 @@ out_err:
1028 1028
1029static int callchain_param__setup_sample_type(struct callchain_param *callchain) 1029static int callchain_param__setup_sample_type(struct callchain_param *callchain)
1030{ 1030{
1031 if (!perf_hpp_list.sym) { 1031 if (callchain->mode != CHAIN_NONE) {
1032 if (callchain->enabled) {
1033 ui__error("Selected -g but \"sym\" not present in --sort/-s.");
1034 return -EINVAL;
1035 }
1036 } else if (callchain->mode != CHAIN_NONE) {
1037 if (callchain_register_param(callchain) < 0) { 1032 if (callchain_register_param(callchain) < 0) {
1038 ui__error("Can't register callchain params.\n"); 1033 ui__error("Can't register callchain params.\n");
1039 return -EINVAL; 1034 return -EINVAL;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index adbf28183560..b36061cd1ab8 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1758,6 +1758,7 @@ static int trace__printf_interrupted_entry(struct trace *trace)
1758{ 1758{
1759 struct thread_trace *ttrace; 1759 struct thread_trace *ttrace;
1760 size_t printed; 1760 size_t printed;
1761 int len;
1761 1762
1762 if (trace->failure_only || trace->current == NULL) 1763 if (trace->failure_only || trace->current == NULL)
1763 return 0; 1764 return 0;
@@ -1768,9 +1769,14 @@ static int trace__printf_interrupted_entry(struct trace *trace)
1768 return 0; 1769 return 0;
1769 1770
1770 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output); 1771 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output);
1771 printed += fprintf(trace->output, ")%-*s ...\n", trace->args_alignment, ttrace->entry_str); 1772 printed += len = fprintf(trace->output, "%s)", ttrace->entry_str);
1772 ttrace->entry_pending = false; 1773
1774 if (len < trace->args_alignment - 4)
1775 printed += fprintf(trace->output, "%-*s", trace->args_alignment - 4 - len, " ");
1776
1777 printed += fprintf(trace->output, " ...\n");
1773 1778
1779 ttrace->entry_pending = false;
1774 ++trace->nr_events_printed; 1780 ++trace->nr_events_printed;
1775 1781
1776 return printed; 1782 return printed;
@@ -2026,9 +2032,10 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
2026 if (ttrace->entry_pending) { 2032 if (ttrace->entry_pending) {
2027 printed = fprintf(trace->output, "%s", ttrace->entry_str); 2033 printed = fprintf(trace->output, "%s", ttrace->entry_str);
2028 } else { 2034 } else {
2029 fprintf(trace->output, " ... ["); 2035 printed += fprintf(trace->output, " ... [");
2030 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued"); 2036 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued");
2031 fprintf(trace->output, "]: %s()", sc->name); 2037 printed += 9;
2038 printed += fprintf(trace->output, "]: %s()", sc->name);
2032 } 2039 }
2033 2040
2034 printed++; /* the closing ')' */ 2041 printed++; /* the closing ')' */
@@ -2507,19 +2514,30 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);
2507 2514
2508static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist) 2515static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist)
2509{ 2516{
2510 struct perf_evsel *evsel = perf_evsel__newtp("probe", "vfs_getname"); 2517 bool found = false;
2518 struct perf_evsel *evsel, *tmp;
2519 struct parse_events_error err = { .idx = 0, };
2520 int ret = parse_events(evlist, "probe:vfs_getname*", &err);
2511 2521
2512 if (IS_ERR(evsel)) 2522 if (ret)
2513 return false; 2523 return false;
2514 2524
2515 if (perf_evsel__field(evsel, "pathname") == NULL) { 2525 evlist__for_each_entry_safe(evlist, evsel, tmp) {
2526 if (!strstarts(perf_evsel__name(evsel), "probe:vfs_getname"))
2527 continue;
2528
2529 if (perf_evsel__field(evsel, "pathname")) {
2530 evsel->handler = trace__vfs_getname;
2531 found = true;
2532 continue;
2533 }
2534
2535 list_del_init(&evsel->node);
2536 evsel->evlist = NULL;
2516 perf_evsel__delete(evsel); 2537 perf_evsel__delete(evsel);
2517 return false;
2518 } 2538 }
2519 2539
2520 evsel->handler = trace__vfs_getname; 2540 return found;
2521 perf_evlist__add(evlist, evsel);
2522 return true;
2523} 2541}
2524 2542
2525static struct perf_evsel *perf_evsel__new_pgfault(u64 config) 2543static struct perf_evsel *perf_evsel__new_pgfault(u64 config)
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 6cb98f8570a2..7b55613924de 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -10,6 +10,7 @@ include/uapi/linux/fs.h
10include/uapi/linux/kcmp.h 10include/uapi/linux/kcmp.h
11include/uapi/linux/kvm.h 11include/uapi/linux/kvm.h
12include/uapi/linux/in.h 12include/uapi/linux/in.h
13include/uapi/linux/mount.h
13include/uapi/linux/perf_event.h 14include/uapi/linux/perf_event.h
14include/uapi/linux/prctl.h 15include/uapi/linux/prctl.h
15include/uapi/linux/sched.h 16include/uapi/linux/sched.h
@@ -49,7 +50,6 @@ arch/parisc/include/uapi/asm/errno.h
49arch/powerpc/include/uapi/asm/errno.h 50arch/powerpc/include/uapi/asm/errno.h
50arch/sparc/include/uapi/asm/errno.h 51arch/sparc/include/uapi/asm/errno.h
51arch/x86/include/uapi/asm/errno.h 52arch/x86/include/uapi/asm/errno.h
52arch/powerpc/include/uapi/asm/unistd.h
53include/asm-generic/bitops/arch_hweight.h 53include/asm-generic/bitops/arch_hweight.h
54include/asm-generic/bitops/const_hweight.h 54include/asm-generic/bitops/const_hweight.h
55include/asm-generic/bitops/__fls.h 55include/asm-generic/bitops/__fls.h
diff --git a/tools/perf/perf-read-vdso.c b/tools/perf/perf-read-vdso.c
index 8c0ca0cc428f..aaa5210ea84a 100644
--- a/tools/perf/perf-read-vdso.c
+++ b/tools/perf/perf-read-vdso.c
@@ -5,17 +5,17 @@
5#define VDSO__MAP_NAME "[vdso]" 5#define VDSO__MAP_NAME "[vdso]"
6 6
7/* 7/*
8 * Include definition of find_vdso_map() also used in util/vdso.c for 8 * Include definition of find_map() also used in util/vdso.c for
9 * building perf. 9 * building perf.
10 */ 10 */
11#include "util/find-vdso-map.c" 11#include "util/find-map.c"
12 12
13int main(void) 13int main(void)
14{ 14{
15 void *start, *end; 15 void *start, *end;
16 size_t size, written; 16 size_t size, written;
17 17
18 if (find_vdso_map(&start, &end)) 18 if (find_map(&start, &end, VDSO__MAP_NAME))
19 return 1; 19 return 1;
20 20
21 size = end - start; 21 size = end - start;
diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index 44090a9a19f3..e952127e4fb0 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -1,6 +1,8 @@
1#! /usr/bin/python 1#! /usr/bin/python
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3 3
4from __future__ import print_function
5
4import os 6import os
5import sys 7import sys
6import glob 8import glob
@@ -8,7 +10,11 @@ import optparse
8import tempfile 10import tempfile
9import logging 11import logging
10import shutil 12import shutil
11import ConfigParser 13
14try:
15 import configparser
16except ImportError:
17 import ConfigParser as configparser
12 18
13def data_equal(a, b): 19def data_equal(a, b):
14 # Allow multiple values in assignment separated by '|' 20 # Allow multiple values in assignment separated by '|'
@@ -100,20 +106,20 @@ class Event(dict):
100 def equal(self, other): 106 def equal(self, other):
101 for t in Event.terms: 107 for t in Event.terms:
102 log.debug(" [%s] %s %s" % (t, self[t], other[t])); 108 log.debug(" [%s] %s %s" % (t, self[t], other[t]));
103 if not self.has_key(t) or not other.has_key(t): 109 if t not in self or t not in other:
104 return False 110 return False
105 if not data_equal(self[t], other[t]): 111 if not data_equal(self[t], other[t]):
106 return False 112 return False
107 return True 113 return True
108 114
109 def optional(self): 115 def optional(self):
110 if self.has_key('optional') and self['optional'] == '1': 116 if 'optional' in self and self['optional'] == '1':
111 return True 117 return True
112 return False 118 return False
113 119
114 def diff(self, other): 120 def diff(self, other):
115 for t in Event.terms: 121 for t in Event.terms:
116 if not self.has_key(t) or not other.has_key(t): 122 if t not in self or t not in other:
117 continue 123 continue
118 if not data_equal(self[t], other[t]): 124 if not data_equal(self[t], other[t]):
119 log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) 125 log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
@@ -134,7 +140,7 @@ class Event(dict):
134# - expected values assignments 140# - expected values assignments
135class Test(object): 141class Test(object):
136 def __init__(self, path, options): 142 def __init__(self, path, options):
137 parser = ConfigParser.SafeConfigParser() 143 parser = configparser.SafeConfigParser()
138 parser.read(path) 144 parser.read(path)
139 145
140 log.warning("running '%s'" % path) 146 log.warning("running '%s'" % path)
@@ -193,7 +199,7 @@ class Test(object):
193 return True 199 return True
194 200
195 def load_events(self, path, events): 201 def load_events(self, path, events):
196 parser_event = ConfigParser.SafeConfigParser() 202 parser_event = configparser.SafeConfigParser()
197 parser_event.read(path) 203 parser_event.read(path)
198 204
199 # The event record section header contains 'event' word, 205 # The event record section header contains 'event' word,
@@ -207,7 +213,7 @@ class Test(object):
207 # Read parent event if there's any 213 # Read parent event if there's any
208 if (':' in section): 214 if (':' in section):
209 base = section[section.index(':') + 1:] 215 base = section[section.index(':') + 1:]
210 parser_base = ConfigParser.SafeConfigParser() 216 parser_base = configparser.SafeConfigParser()
211 parser_base.read(self.test_dir + '/' + base) 217 parser_base.read(self.test_dir + '/' + base)
212 base_items = parser_base.items('event') 218 base_items = parser_base.items('event')
213 219
@@ -322,9 +328,9 @@ def run_tests(options):
322 for f in glob.glob(options.test_dir + '/' + options.test): 328 for f in glob.glob(options.test_dir + '/' + options.test):
323 try: 329 try:
324 Test(f, options).run() 330 Test(f, options).run()
325 except Unsup, obj: 331 except Unsup as obj:
326 log.warning("unsupp %s" % obj.getMsg()) 332 log.warning("unsupp %s" % obj.getMsg())
327 except Notest, obj: 333 except Notest as obj:
328 log.warning("skipped %s" % obj.getMsg()) 334 log.warning("skipped %s" % obj.getMsg())
329 335
330def setup_log(verbose): 336def setup_log(verbose):
@@ -363,7 +369,7 @@ def main():
363 parser.add_option("-p", "--perf", 369 parser.add_option("-p", "--perf",
364 action="store", type="string", dest="perf") 370 action="store", type="string", dest="perf")
365 parser.add_option("-v", "--verbose", 371 parser.add_option("-v", "--verbose",
366 action="count", dest="verbose") 372 default=0, action="count", dest="verbose")
367 373
368 options, args = parser.parse_args() 374 options, args = parser.parse_args()
369 if args: 375 if args:
@@ -373,7 +379,7 @@ def main():
373 setup_log(options.verbose) 379 setup_log(options.verbose)
374 380
375 if not options.test_dir: 381 if not options.test_dir:
376 print 'FAILED no -d option specified' 382 print('FAILED no -d option specified')
377 sys.exit(-1) 383 sys.exit(-1)
378 384
379 if not options.test: 385 if not options.test:
@@ -382,8 +388,8 @@ def main():
382 try: 388 try:
383 run_tests(options) 389 run_tests(options)
384 390
385 except Fail, obj: 391 except Fail as obj:
386 print "FAILED %s" % obj.getMsg(); 392 print("FAILED %s" % obj.getMsg())
387 sys.exit(-1) 393 sys.exit(-1)
388 394
389 sys.exit(0) 395 sys.exit(0)
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 5f8501c68da4..5cbba70bcdd0 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
17 return -1; 17 return -1;
18 } 18 }
19 19
20 is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED); 20 is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
21 if (should_be_signed && !is_signed) { 21 if (should_be_signed && !is_signed) {
22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", 22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
23 evsel->name, name, is_signed, should_be_signed); 23 evsel->name, name, is_signed, should_be_signed);
diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
index 1c16e56cd93e..7cb99b433888 100644
--- a/tools/perf/tests/shell/lib/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
@@ -13,7 +13,8 @@ add_probe_vfs_getname() {
13 local verbose=$1 13 local verbose=$1
14 if [ $had_vfs_getname -eq 1 ] ; then 14 if [ $had_vfs_getname -eq 1 ] ; then
15 line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') 15 line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/')
16 perf probe $verbose "vfs_getname=getname_flags:${line} pathname=result->name:string" 16 perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \
17 perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string"
17 fi 18 fi
18} 19}
19 20
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index b82f55fcc294..399f18ca71a3 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -119,4 +119,9 @@ int test__arch_unwind_sample(struct perf_sample *sample,
119 struct thread *thread); 119 struct thread *thread);
120#endif 120#endif
121#endif 121#endif
122
123#if defined(__arm__)
124int test__vectors_page(struct test *test, int subtest);
125#endif
126
122#endif /* TESTS_H */ 127#endif /* TESTS_H */
diff --git a/tools/perf/trace/beauty/mount_flags.sh b/tools/perf/trace/beauty/mount_flags.sh
index 45547573a1db..847850b2ef6c 100755
--- a/tools/perf/trace/beauty/mount_flags.sh
+++ b/tools/perf/trace/beauty/mount_flags.sh
@@ -5,11 +5,11 @@
5 5
6printf "static const char *mount_flags[] = {\n" 6printf "static const char *mount_flags[] = {\n"
7regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*' 7regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*'
8egrep $regex ${header_dir}/fs.h | egrep -v '(MSK|VERBOSE|MGC_VAL)\>' | \ 8egrep $regex ${header_dir}/mount.h | egrep -v '(MSK|VERBOSE|MGC_VAL)\>' | \
9 sed -r "s/$regex/\2 \2 \1/g" | sort -n | \ 9 sed -r "s/$regex/\2 \2 \1/g" | sort -n | \
10 xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n" 10 xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n"
11regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*' 11regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*'
12egrep $regex ${header_dir}/fs.h | \ 12egrep $regex ${header_dir}/mount.h | \
13 sed -r "s/$regex/\2 \1/g" | \ 13 sed -r "s/$regex/\2 \1/g" | \
14 xargs printf "\t[%s + 1] = \"%s\",\n" 14 xargs printf "\t[%s + 1] = \"%s\",\n"
15printf "};\n" 15printf "};\n"
diff --git a/tools/perf/trace/beauty/prctl_option.sh b/tools/perf/trace/beauty/prctl_option.sh
index d32f8f1124af..3109d7b05e11 100755
--- a/tools/perf/trace/beauty/prctl_option.sh
+++ b/tools/perf/trace/beauty/prctl_option.sh
@@ -4,7 +4,7 @@
4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/ 4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
5 5
6printf "static const char *prctl_options[] = {\n" 6printf "static const char *prctl_options[] = {\n"
7regex='^#define[[:space:]]+PR_([GS]ET\w+)[[:space:]]*([[:xdigit:]]+).*' 7regex='^#define[[:space:]]+PR_(\w+)[[:space:]]*([[:xdigit:]]+).*'
8egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \ 8egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \
9 sed -r "s/$regex/\2 \1/g" | \ 9 sed -r "s/$regex/\2 \1/g" | \
10 sort -n | xargs printf "\t[%s] = \"%s\",\n" 10 sort -n | xargs printf "\t[%s] = \"%s\",\n"
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 1d00e5ec7906..82e16bf84466 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -224,20 +224,24 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
224 return ret; 224 return ret;
225} 225}
226 226
227static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) 227static double disasm__cmp(struct annotation_line *a, struct annotation_line *b,
228 int percent_type)
228{ 229{
229 int i; 230 int i;
230 231
231 for (i = 0; i < a->data_nr; i++) { 232 for (i = 0; i < a->data_nr; i++) {
232 if (a->data[i].percent == b->data[i].percent) 233 if (a->data[i].percent[percent_type] == b->data[i].percent[percent_type])
233 continue; 234 continue;
234 return a->data[i].percent < b->data[i].percent; 235 return a->data[i].percent[percent_type] -
236 b->data[i].percent[percent_type];
235 } 237 }
236 return 0; 238 return 0;
237} 239}
238 240
239static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al) 241static void disasm_rb_tree__insert(struct annotate_browser *browser,
242 struct annotation_line *al)
240{ 243{
244 struct rb_root *root = &browser->entries;
241 struct rb_node **p = &root->rb_node; 245 struct rb_node **p = &root->rb_node;
242 struct rb_node *parent = NULL; 246 struct rb_node *parent = NULL;
243 struct annotation_line *l; 247 struct annotation_line *l;
@@ -246,7 +250,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line
246 parent = *p; 250 parent = *p;
247 l = rb_entry(parent, struct annotation_line, rb_node); 251 l = rb_entry(parent, struct annotation_line, rb_node);
248 252
249 if (disasm__cmp(al, l)) 253 if (disasm__cmp(al, l, browser->opts->percent_type) < 0)
250 p = &(*p)->rb_left; 254 p = &(*p)->rb_left;
251 else 255 else
252 p = &(*p)->rb_right; 256 p = &(*p)->rb_right;
@@ -329,7 +333,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
329 RB_CLEAR_NODE(&pos->al.rb_node); 333 RB_CLEAR_NODE(&pos->al.rb_node);
330 continue; 334 continue;
331 } 335 }
332 disasm_rb_tree__insert(&browser->entries, &pos->al); 336 disasm_rb_tree__insert(browser, &pos->al);
333 } 337 }
334 pthread_mutex_unlock(&notes->lock); 338 pthread_mutex_unlock(&notes->lock);
335 339
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ac9805e0bc76..70de8f6b3aee 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1723,15 +1723,14 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1723 err = asprintf(&command, 1723 err = asprintf(&command,
1724 "%s %s%s --start-address=0x%016" PRIx64 1724 "%s %s%s --start-address=0x%016" PRIx64
1725 " --stop-address=0x%016" PRIx64 1725 " --stop-address=0x%016" PRIx64
1726 " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand", 1726 " -l -d %s %s -C \"$1\" 2>/dev/null|grep -v \"$1:\"|expand",
1727 opts->objdump_path ?: "objdump", 1727 opts->objdump_path ?: "objdump",
1728 opts->disassembler_style ? "-M " : "", 1728 opts->disassembler_style ? "-M " : "",
1729 opts->disassembler_style ?: "", 1729 opts->disassembler_style ?: "",
1730 map__rip_2objdump(map, sym->start), 1730 map__rip_2objdump(map, sym->start),
1731 map__rip_2objdump(map, sym->end), 1731 map__rip_2objdump(map, sym->end),
1732 opts->show_asm_raw ? "" : "--no-show-raw", 1732 opts->show_asm_raw ? "" : "--no-show-raw",
1733 opts->annotate_src ? "-S" : "", 1733 opts->annotate_src ? "-S" : "");
1734 symfs_filename, symfs_filename);
1735 1734
1736 if (err < 0) { 1735 if (err < 0) {
1737 pr_err("Failure allocating memory for the command to run\n"); 1736 pr_err("Failure allocating memory for the command to run\n");
@@ -1756,7 +1755,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1756 close(stdout_fd[0]); 1755 close(stdout_fd[0]);
1757 dup2(stdout_fd[1], 1); 1756 dup2(stdout_fd[1], 1);
1758 close(stdout_fd[1]); 1757 close(stdout_fd[1]);
1759 execl("/bin/sh", "sh", "-c", command, NULL); 1758 execl("/bin/sh", "sh", "-c", command, "--", symfs_filename,
1759 NULL);
1760 perror(command); 1760 perror(command);
1761 exit(-1); 1761 exit(-1);
1762 } 1762 }
diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
index 89512504551b..39c0004f2886 100644
--- a/tools/perf/util/c++/clang.cpp
+++ b/tools/perf/util/c++/clang.cpp
@@ -160,7 +160,7 @@ getBPFObjectFromModule(llvm::Module *Module)
160 } 160 }
161 PM.run(*Module); 161 PM.run(*Module);
162 162
163 return std::move(Buffer); 163 return Buffer;
164} 164}
165 165
166} 166}
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 32ef7bdca1cf..dc2212e12184 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -766,6 +766,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
766 cnode->cycles_count += node->branch_flags.cycles; 766 cnode->cycles_count += node->branch_flags.cycles;
767 cnode->iter_count += node->nr_loop_iter; 767 cnode->iter_count += node->nr_loop_iter;
768 cnode->iter_cycles += node->iter_cycles; 768 cnode->iter_cycles += node->iter_cycles;
769 cnode->from_count++;
769 } 770 }
770 } 771 }
771 772
@@ -1345,10 +1346,10 @@ static int branch_to_str(char *bf, int bfsize,
1345static int branch_from_str(char *bf, int bfsize, 1346static int branch_from_str(char *bf, int bfsize,
1346 u64 branch_count, 1347 u64 branch_count,
1347 u64 cycles_count, u64 iter_count, 1348 u64 cycles_count, u64 iter_count,
1348 u64 iter_cycles) 1349 u64 iter_cycles, u64 from_count)
1349{ 1350{
1350 int printed = 0, i = 0; 1351 int printed = 0, i = 0;
1351 u64 cycles; 1352 u64 cycles, v = 0;
1352 1353
1353 cycles = cycles_count / branch_count; 1354 cycles = cycles_count / branch_count;
1354 if (cycles) { 1355 if (cycles) {
@@ -1357,14 +1358,16 @@ static int branch_from_str(char *bf, int bfsize,
1357 bf + printed, bfsize - printed); 1358 bf + printed, bfsize - printed);
1358 } 1359 }
1359 1360
1360 if (iter_count) { 1361 if (iter_count && from_count) {
1361 printed += count_pri64_printf(i++, "iter", 1362 v = iter_count / from_count;
1362 iter_count, 1363 if (v) {
1363 bf + printed, bfsize - printed); 1364 printed += count_pri64_printf(i++, "iter",
1365 v, bf + printed, bfsize - printed);
1364 1366
1365 printed += count_pri64_printf(i++, "avg_cycles", 1367 printed += count_pri64_printf(i++, "avg_cycles",
1366 iter_cycles / iter_count, 1368 iter_cycles / iter_count,
1367 bf + printed, bfsize - printed); 1369 bf + printed, bfsize - printed);
1370 }
1368 } 1371 }
1369 1372
1370 if (i) 1373 if (i)
@@ -1377,6 +1380,7 @@ static int counts_str_build(char *bf, int bfsize,
1377 u64 branch_count, u64 predicted_count, 1380 u64 branch_count, u64 predicted_count,
1378 u64 abort_count, u64 cycles_count, 1381 u64 abort_count, u64 cycles_count,
1379 u64 iter_count, u64 iter_cycles, 1382 u64 iter_count, u64 iter_cycles,
1383 u64 from_count,
1380 struct branch_type_stat *brtype_stat) 1384 struct branch_type_stat *brtype_stat)
1381{ 1385{
1382 int printed; 1386 int printed;
@@ -1389,7 +1393,8 @@ static int counts_str_build(char *bf, int bfsize,
1389 predicted_count, abort_count, brtype_stat); 1393 predicted_count, abort_count, brtype_stat);
1390 } else { 1394 } else {
1391 printed = branch_from_str(bf, bfsize, branch_count, 1395 printed = branch_from_str(bf, bfsize, branch_count,
1392 cycles_count, iter_count, iter_cycles); 1396 cycles_count, iter_count, iter_cycles,
1397 from_count);
1393 } 1398 }
1394 1399
1395 if (!printed) 1400 if (!printed)
@@ -1402,13 +1407,14 @@ static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
1402 u64 branch_count, u64 predicted_count, 1407 u64 branch_count, u64 predicted_count,
1403 u64 abort_count, u64 cycles_count, 1408 u64 abort_count, u64 cycles_count,
1404 u64 iter_count, u64 iter_cycles, 1409 u64 iter_count, u64 iter_cycles,
1410 u64 from_count,
1405 struct branch_type_stat *brtype_stat) 1411 struct branch_type_stat *brtype_stat)
1406{ 1412{
1407 char str[256]; 1413 char str[256];
1408 1414
1409 counts_str_build(str, sizeof(str), branch_count, 1415 counts_str_build(str, sizeof(str), branch_count,
1410 predicted_count, abort_count, cycles_count, 1416 predicted_count, abort_count, cycles_count,
1411 iter_count, iter_cycles, brtype_stat); 1417 iter_count, iter_cycles, from_count, brtype_stat);
1412 1418
1413 if (fp) 1419 if (fp)
1414 return fprintf(fp, "%s", str); 1420 return fprintf(fp, "%s", str);
@@ -1422,6 +1428,7 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
1422 u64 branch_count, predicted_count; 1428 u64 branch_count, predicted_count;
1423 u64 abort_count, cycles_count; 1429 u64 abort_count, cycles_count;
1424 u64 iter_count, iter_cycles; 1430 u64 iter_count, iter_cycles;
1431 u64 from_count;
1425 1432
1426 branch_count = clist->branch_count; 1433 branch_count = clist->branch_count;
1427 predicted_count = clist->predicted_count; 1434 predicted_count = clist->predicted_count;
@@ -1429,11 +1436,12 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
1429 cycles_count = clist->cycles_count; 1436 cycles_count = clist->cycles_count;
1430 iter_count = clist->iter_count; 1437 iter_count = clist->iter_count;
1431 iter_cycles = clist->iter_cycles; 1438 iter_cycles = clist->iter_cycles;
1439 from_count = clist->from_count;
1432 1440
1433 return callchain_counts_printf(fp, bf, bfsize, branch_count, 1441 return callchain_counts_printf(fp, bf, bfsize, branch_count,
1434 predicted_count, abort_count, 1442 predicted_count, abort_count,
1435 cycles_count, iter_count, iter_cycles, 1443 cycles_count, iter_count, iter_cycles,
1436 &clist->brtype_stat); 1444 from_count, &clist->brtype_stat);
1437} 1445}
1438 1446
1439static void free_callchain_node(struct callchain_node *node) 1447static void free_callchain_node(struct callchain_node *node)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 154560b1eb65..99d38ac019b8 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -118,6 +118,7 @@ struct callchain_list {
118 bool has_children; 118 bool has_children;
119 }; 119 };
120 u64 branch_count; 120 u64 branch_count;
121 u64 from_count;
121 u64 predicted_count; 122 u64 predicted_count;
122 u64 abort_count; 123 u64 abort_count;
123 u64 cycles_count; 124 u64 cycles_count;
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 1ccbd3342069..383674f448fc 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
134 if (!cpu_list) 134 if (!cpu_list)
135 return cpu_map__read_all_cpu_map(); 135 return cpu_map__read_all_cpu_map();
136 136
137 if (!isdigit(*cpu_list)) 137 /*
138 * must handle the case of empty cpumap to cover
139 * TOPOLOGY header for NUMA nodes with no CPU
140 * ( e.g., because of CPU hotplug)
141 */
142 if (!isdigit(*cpu_list) && *cpu_list != '\0')
138 goto out; 143 goto out;
139 144
140 while (isdigit(*cpu_list)) { 145 while (isdigit(*cpu_list)) {
@@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
181 186
182 if (nr_cpus > 0) 187 if (nr_cpus > 0)
183 cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); 188 cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
184 else 189 else if (*cpu_list != '\0')
185 cpus = cpu_map__default_new(); 190 cpus = cpu_map__default_new();
191 else
192 cpus = cpu_map__dummy_new();
186invalid: 193invalid:
187 free(tmp_cpus); 194 free(tmp_cpus);
188out: 195out:
diff --git a/tools/perf/util/find-vdso-map.c b/tools/perf/util/find-map.c
index d7823e3508fc..7b2300588ece 100644
--- a/tools/perf/util/find-vdso-map.c
+++ b/tools/perf/util/find-map.c
@@ -1,5 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2static int find_vdso_map(void **start, void **end) 2static int find_map(void **start, void **end, const char *name)
3{ 3{
4 FILE *maps; 4 FILE *maps;
5 char line[128]; 5 char line[128];
@@ -7,7 +7,7 @@ static int find_vdso_map(void **start, void **end)
7 7
8 maps = fopen("/proc/self/maps", "r"); 8 maps = fopen("/proc/self/maps", "r");
9 if (!maps) { 9 if (!maps) {
10 fprintf(stderr, "vdso: cannot open maps\n"); 10 fprintf(stderr, "cannot open maps\n");
11 return -1; 11 return -1;
12 } 12 }
13 13
@@ -21,8 +21,7 @@ static int find_vdso_map(void **start, void **end)
21 if (m < 0) 21 if (m < 0)
22 continue; 22 continue;
23 23
24 if (!strncmp(&line[m], VDSO__MAP_NAME, 24 if (!strncmp(&line[m], name, strlen(name)))
25 sizeof(VDSO__MAP_NAME) - 1))
26 found = 1; 25 found = 1;
27 } 26 }
28 27
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 6fcb3bce0442..143f7057d581 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2005,7 +2005,7 @@ static void save_iterations(struct iterations *iter,
2005{ 2005{
2006 int i; 2006 int i;
2007 2007
2008 iter->nr_loop_iter = nr; 2008 iter->nr_loop_iter++;
2009 iter->cycles = 0; 2009 iter->cycles = 0;
2010 2010
2011 for (i = 0; i < nr; i++) 2011 for (i = 0; i < nr; i++)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 93f74d8d3cdd..42c3e5a229d2 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -28,7 +28,7 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
28static char mem_loads_name[100]; 28static char mem_loads_name[100];
29static bool mem_loads_name__init; 29static bool mem_loads_name__init;
30 30
31char *perf_mem_events__name(int i) 31char * __weak perf_mem_events__name(int i)
32{ 32{
33 if (i == PERF_MEM_EVENTS__LOAD) { 33 if (i == PERF_MEM_EVENTS__LOAD) {
34 if (!mem_loads_name__init) { 34 if (!mem_loads_name__init) {
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index 897589507d97..ea523d3b248f 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe)
391 * Current buffer might not have all the events allocated 391 * Current buffer might not have all the events allocated
392 * yet, we need to free only allocated ones ... 392 * yet, we need to free only allocated ones ...
393 */ 393 */
394 list_del(&oe->buffer->list); 394 if (oe->buffer) {
395 ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); 395 list_del(&oe->buffer->list);
396 ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
397 }
396 398
397 /* ... and continue with the rest */ 399 /* ... and continue with the rest */
398 list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) { 400 list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 63f758c655d5..64d1f36dee99 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -17,6 +17,8 @@ if cc == "clang":
17 vars[var] = sub("-mcet", "", vars[var]) 17 vars[var] = sub("-mcet", "", vars[var])
18 if not clang_has_option("-fcf-protection"): 18 if not clang_has_option("-fcf-protection"):
19 vars[var] = sub("-fcf-protection", "", vars[var]) 19 vars[var] = sub("-fcf-protection", "", vars[var])
20 if not clang_has_option("-fstack-clash-protection"):
21 vars[var] = sub("-fstack-clash-protection", "", vars[var])
20 22
21from distutils.core import setup, Extension 23from distutils.core import setup, Extension
22 24
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 9005fbe0780e..23092fd6451d 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -109,7 +109,6 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
109 return ret; 109 return ret;
110 } 110 }
111 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved); 111 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
112 va_end(ap_saved);
113 if (len > strbuf_avail(sb)) { 112 if (len > strbuf_avail(sb)) {
114 pr_debug("this should not happen, your vsnprintf is broken"); 113 pr_debug("this should not happen, your vsnprintf is broken");
115 va_end(ap_saved); 114 va_end(ap_saved);
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 66a84d5846c8..dca7dfae69ad 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -19,6 +19,20 @@
19#define EM_AARCH64 183 /* ARM 64 bit */ 19#define EM_AARCH64 183 /* ARM 64 bit */
20#endif 20#endif
21 21
22#ifndef ELF32_ST_VISIBILITY
23#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
24#endif
25
26/* For ELF64 the definitions are the same. */
27#ifndef ELF64_ST_VISIBILITY
28#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
29#endif
30
31/* How to extract information held in the st_other field. */
32#ifndef GELF_ST_VISIBILITY
33#define GELF_ST_VISIBILITY(val) ELF64_ST_VISIBILITY (val)
34#endif
35
22typedef Elf64_Nhdr GElf_Nhdr; 36typedef Elf64_Nhdr GElf_Nhdr;
23 37
24#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT 38#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
@@ -87,6 +101,11 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym)
87 return GELF_ST_TYPE(sym->st_info); 101 return GELF_ST_TYPE(sym->st_info);
88} 102}
89 103
104static inline uint8_t elf_sym__visibility(const GElf_Sym *sym)
105{
106 return GELF_ST_VISIBILITY(sym->st_other);
107}
108
90#ifndef STT_GNU_IFUNC 109#ifndef STT_GNU_IFUNC
91#define STT_GNU_IFUNC 10 110#define STT_GNU_IFUNC 10
92#endif 111#endif
@@ -111,7 +130,9 @@ static inline int elf_sym__is_label(const GElf_Sym *sym)
111 return elf_sym__type(sym) == STT_NOTYPE && 130 return elf_sym__type(sym) == STT_NOTYPE &&
112 sym->st_name != 0 && 131 sym->st_name != 0 &&
113 sym->st_shndx != SHN_UNDEF && 132 sym->st_shndx != SHN_UNDEF &&
114 sym->st_shndx != SHN_ABS; 133 sym->st_shndx != SHN_ABS &&
134 elf_sym__visibility(sym) != STV_HIDDEN &&
135 elf_sym__visibility(sym) != STV_INTERNAL;
115} 136}
116 137
117static bool elf_sym__filter(GElf_Sym *sym) 138static bool elf_sym__filter(GElf_Sym *sym)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 01f2c7385e38..48efad6d0f90 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -614,6 +614,7 @@ out:
614static bool symbol__is_idle(const char *name) 614static bool symbol__is_idle(const char *name)
615{ 615{
616 const char * const idle_symbols[] = { 616 const char * const idle_symbols[] = {
617 "arch_cpu_idle",
617 "cpu_idle", 618 "cpu_idle",
618 "cpu_startup_entry", 619 "cpu_startup_entry",
619 "intel_idle", 620 "intel_idle",
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 741af209b19d..3702cba11d7d 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -18,10 +18,10 @@
18#include "debug.h" 18#include "debug.h"
19 19
20/* 20/*
21 * Include definition of find_vdso_map() also used in perf-read-vdso.c for 21 * Include definition of find_map() also used in perf-read-vdso.c for
22 * building perf-read-vdso32 and perf-read-vdsox32. 22 * building perf-read-vdso32 and perf-read-vdsox32.
23 */ 23 */
24#include "find-vdso-map.c" 24#include "find-map.c"
25 25
26#define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX" 26#define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX"
27 27
@@ -76,7 +76,7 @@ static char *get_file(struct vdso_file *vdso_file)
76 if (vdso_file->found) 76 if (vdso_file->found)
77 return vdso_file->temp_file_name; 77 return vdso_file->temp_file_name;
78 78
79 if (vdso_file->error || find_vdso_map(&start, &end)) 79 if (vdso_file->error || find_map(&start, &end, VDSO__MAP_NAME))
80 return NULL; 80 return NULL;
81 81
82 size = end - start; 82 size = end - start;
diff --git a/tools/testing/nvdimm/dimm_devs.c b/tools/testing/nvdimm/dimm_devs.c
index e75238404555..2d4baf57822f 100644
--- a/tools/testing/nvdimm/dimm_devs.c
+++ b/tools/testing/nvdimm/dimm_devs.c
@@ -18,8 +18,8 @@ ssize_t security_show(struct device *dev,
18 * For the test version we need to poll the "hardware" in order 18 * For the test version we need to poll the "hardware" in order
19 * to get the updated status for unlock testing. 19 * to get the updated status for unlock testing.
20 */ 20 */
21 nvdimm->sec.state = nvdimm_security_state(nvdimm, false); 21 nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
22 nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, true); 22 nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, NVDIMM_MASTER);
23 23
24 switch (nvdimm->sec.state) { 24 switch (nvdimm->sec.state) {
25 case NVDIMM_SECURITY_DISABLED: 25 case NVDIMM_SECURITY_DISABLED:
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 1a2bd15c5b6e..400ee81a3043 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
10TARGETS += efivarfs 10TARGETS += efivarfs
11TARGETS += exec 11TARGETS += exec
12TARGETS += filesystems 12TARGETS += filesystems
13TARGETS += filesystems/binderfs
13TARGETS += firmware 14TARGETS += firmware
14TARGETS += ftrace 15TARGETS += ftrace
15TARGETS += futex 16TARGETS += futex
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
index 4a9785043a39..dd093bd91aa9 100644
--- a/tools/testing/selftests/bpf/.gitignore
+++ b/tools/testing/selftests/bpf/.gitignore
@@ -28,3 +28,4 @@ flow_dissector_load
28test_netcnt 28test_netcnt
29test_section_names 29test_section_names
30test_tcpnotify_user 30test_tcpnotify_user
31test_libbpf
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 73aa6d8f4a2f..41ab7a3668b3 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -55,7 +55,10 @@ TEST_PROGS := test_kmod.sh \
55 test_flow_dissector.sh \ 55 test_flow_dissector.sh \
56 test_xdp_vlan.sh 56 test_xdp_vlan.sh
57 57
58TEST_PROGS_EXTENDED := with_addr.sh 58TEST_PROGS_EXTENDED := with_addr.sh \
59 with_tunnels.sh \
60 tcp_client.py \
61 tcp_server.py
59 62
60# Compile but not part of 'make run_tests' 63# Compile but not part of 'make run_tests'
61TEST_GEN_PROGS_EXTENDED = test_libbpf_open test_sock_addr test_skb_cgroup_id_user \ 64TEST_GEN_PROGS_EXTENDED = test_libbpf_open test_sock_addr test_skb_cgroup_id_user \
diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
index 315a44fa32af..84fd6f1bf33e 100644
--- a/tools/testing/selftests/bpf/bpf_util.h
+++ b/tools/testing/selftests/bpf/bpf_util.h
@@ -13,7 +13,7 @@ static inline unsigned int bpf_num_possible_cpus(void)
13 unsigned int start, end, possible_cpus = 0; 13 unsigned int start, end, possible_cpus = 0;
14 char buff[128]; 14 char buff[128];
15 FILE *fp; 15 FILE *fp;
16 int n; 16 int len, n, i, j = 0;
17 17
18 fp = fopen(fcpu, "r"); 18 fp = fopen(fcpu, "r");
19 if (!fp) { 19 if (!fp) {
@@ -21,17 +21,27 @@ static inline unsigned int bpf_num_possible_cpus(void)
21 exit(1); 21 exit(1);
22 } 22 }
23 23
24 while (fgets(buff, sizeof(buff), fp)) { 24 if (!fgets(buff, sizeof(buff), fp)) {
25 n = sscanf(buff, "%u-%u", &start, &end); 25 printf("Failed to read %s!\n", fcpu);
26 if (n == 0) { 26 exit(1);
27 printf("Failed to retrieve # possible CPUs!\n"); 27 }
28 exit(1); 28
29 } else if (n == 1) { 29 len = strlen(buff);
30 end = start; 30 for (i = 0; i <= len; i++) {
31 if (buff[i] == ',' || buff[i] == '\0') {
32 buff[i] = '\0';
33 n = sscanf(&buff[j], "%u-%u", &start, &end);
34 if (n <= 0) {
35 printf("Failed to retrieve # possible CPUs!\n");
36 exit(1);
37 } else if (n == 1) {
38 end = start;
39 }
40 possible_cpus += end - start + 1;
41 j = i + 1;
31 } 42 }
32 possible_cpus = start == 0 ? end + 1 : 0;
33 break;
34 } 43 }
44
35 fclose(fp); 45 fclose(fp);
36 46
37 return possible_cpus; 47 return possible_cpus;
diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
index cf16948aad4a..6692a40a6979 100644
--- a/tools/testing/selftests/bpf/cgroup_helpers.c
+++ b/tools/testing/selftests/bpf/cgroup_helpers.c
@@ -155,7 +155,7 @@ void cleanup_cgroup_environment(void)
155 * This function creates a cgroup under the top level workdir and returns the 155 * This function creates a cgroup under the top level workdir and returns the
156 * file descriptor. It is idempotent. 156 * file descriptor. It is idempotent.
157 * 157 *
158 * On success, it returns the file descriptor. On failure it returns 0. 158 * On success, it returns the file descriptor. On failure it returns -1.
159 * If there is a failure, it prints the error to stderr. 159 * If there is a failure, it prints the error to stderr.
160 */ 160 */
161int create_and_get_cgroup(const char *path) 161int create_and_get_cgroup(const char *path)
@@ -166,13 +166,13 @@ int create_and_get_cgroup(const char *path)
166 format_cgroup_path(cgroup_path, path); 166 format_cgroup_path(cgroup_path, path);
167 if (mkdir(cgroup_path, 0777) && errno != EEXIST) { 167 if (mkdir(cgroup_path, 0777) && errno != EEXIST) {
168 log_err("mkdiring cgroup %s .. %s", path, cgroup_path); 168 log_err("mkdiring cgroup %s .. %s", path, cgroup_path);
169 return 0; 169 return -1;
170 } 170 }
171 171
172 fd = open(cgroup_path, O_RDONLY); 172 fd = open(cgroup_path, O_RDONLY);
173 if (fd < 0) { 173 if (fd < 0) {
174 log_err("Opening Cgroup"); 174 log_err("Opening Cgroup");
175 return 0; 175 return -1;
176 } 176 }
177 177
178 return fd; 178 return fd;
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
index 8bcd38010582..91420fa83b08 100644
--- a/tools/testing/selftests/bpf/test_btf.c
+++ b/tools/testing/selftests/bpf/test_btf.c
@@ -1881,13 +1881,12 @@ static struct btf_raw_test raw_tests[] = {
1881}, 1881},
1882 1882
1883{ 1883{
1884 .descr = "func proto (CONST=>TYPEDEF=>FUNC_PROTO)", 1884 .descr = "func proto (TYPEDEF=>FUNC_PROTO)",
1885 .raw_types = { 1885 .raw_types = {
1886 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */ 1886 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
1887 BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */ 1887 BTF_TYPE_INT_ENC(0, 0, 0, 32, 4), /* [2] */
1888 BTF_CONST_ENC(4), /* [3] */ 1888 BTF_TYPEDEF_ENC(NAME_TBD, 4), /* [3] */
1889 BTF_TYPEDEF_ENC(NAME_TBD, 5), /* [4] */ 1889 BTF_FUNC_PROTO_ENC(0, 2), /* [4] */
1890 BTF_FUNC_PROTO_ENC(0, 2), /* [5] */
1891 BTF_FUNC_PROTO_ARG_ENC(0, 1), 1890 BTF_FUNC_PROTO_ARG_ENC(0, 1),
1892 BTF_FUNC_PROTO_ARG_ENC(0, 2), 1891 BTF_FUNC_PROTO_ARG_ENC(0, 2),
1893 BTF_END_RAW, 1892 BTF_END_RAW,
@@ -1901,8 +1900,6 @@ static struct btf_raw_test raw_tests[] = {
1901 .key_type_id = 1, 1900 .key_type_id = 1,
1902 .value_type_id = 1, 1901 .value_type_id = 1,
1903 .max_entries = 4, 1902 .max_entries = 4,
1904 .btf_load_err = true,
1905 .err_str = "Invalid type_id",
1906}, 1903},
1907 1904
1908{ 1905{
@@ -3526,6 +3523,8 @@ struct pprint_mapv {
3526 ENUM_TWO, 3523 ENUM_TWO,
3527 ENUM_THREE, 3524 ENUM_THREE,
3528 } aenum; 3525 } aenum;
3526 uint32_t ui32b;
3527 uint32_t bits2c:2;
3529}; 3528};
3530 3529
3531static struct btf_raw_test pprint_test_template[] = { 3530static struct btf_raw_test pprint_test_template[] = {
@@ -3568,7 +3567,7 @@ static struct btf_raw_test pprint_test_template[] = {
3568 BTF_ENUM_ENC(NAME_TBD, 2), 3567 BTF_ENUM_ENC(NAME_TBD, 2),
3569 BTF_ENUM_ENC(NAME_TBD, 3), 3568 BTF_ENUM_ENC(NAME_TBD, 3),
3570 /* struct pprint_mapv */ /* [16] */ 3569 /* struct pprint_mapv */ /* [16] */
3571 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 8), 32), 3570 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 10), 40),
3572 BTF_MEMBER_ENC(NAME_TBD, 11, 0), /* uint32_t ui32 */ 3571 BTF_MEMBER_ENC(NAME_TBD, 11, 0), /* uint32_t ui32 */
3573 BTF_MEMBER_ENC(NAME_TBD, 10, 32), /* uint16_t ui16 */ 3572 BTF_MEMBER_ENC(NAME_TBD, 10, 32), /* uint16_t ui16 */
3574 BTF_MEMBER_ENC(NAME_TBD, 12, 64), /* int32_t si32 */ 3573 BTF_MEMBER_ENC(NAME_TBD, 12, 64), /* int32_t si32 */
@@ -3577,9 +3576,11 @@ static struct btf_raw_test pprint_test_template[] = {
3577 BTF_MEMBER_ENC(NAME_TBD, 6, 126), /* unused_bits2b */ 3576 BTF_MEMBER_ENC(NAME_TBD, 6, 126), /* unused_bits2b */
3578 BTF_MEMBER_ENC(0, 14, 128), /* union (anon) */ 3577 BTF_MEMBER_ENC(0, 14, 128), /* union (anon) */
3579 BTF_MEMBER_ENC(NAME_TBD, 15, 192), /* aenum */ 3578 BTF_MEMBER_ENC(NAME_TBD, 15, 192), /* aenum */
3579 BTF_MEMBER_ENC(NAME_TBD, 11, 224), /* uint32_t ui32b */
3580 BTF_MEMBER_ENC(NAME_TBD, 6, 256), /* bits2c */
3580 BTF_END_RAW, 3581 BTF_END_RAW,
3581 }, 3582 },
3582 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum"), 3583 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum\0ui32b\0bits2c"),
3583 .key_size = sizeof(unsigned int), 3584 .key_size = sizeof(unsigned int),
3584 .value_size = sizeof(struct pprint_mapv), 3585 .value_size = sizeof(struct pprint_mapv),
3585 .key_type_id = 3, /* unsigned int */ 3586 .key_type_id = 3, /* unsigned int */
@@ -3628,7 +3629,7 @@ static struct btf_raw_test pprint_test_template[] = {
3628 BTF_ENUM_ENC(NAME_TBD, 2), 3629 BTF_ENUM_ENC(NAME_TBD, 2),
3629 BTF_ENUM_ENC(NAME_TBD, 3), 3630 BTF_ENUM_ENC(NAME_TBD, 3),
3630 /* struct pprint_mapv */ /* [16] */ 3631 /* struct pprint_mapv */ /* [16] */
3631 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 8), 32), 3632 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 10), 40),
3632 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 0)), /* uint32_t ui32 */ 3633 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 0)), /* uint32_t ui32 */
3633 BTF_MEMBER_ENC(NAME_TBD, 10, BTF_MEMBER_OFFSET(0, 32)), /* uint16_t ui16 */ 3634 BTF_MEMBER_ENC(NAME_TBD, 10, BTF_MEMBER_OFFSET(0, 32)), /* uint16_t ui16 */
3634 BTF_MEMBER_ENC(NAME_TBD, 12, BTF_MEMBER_OFFSET(0, 64)), /* int32_t si32 */ 3635 BTF_MEMBER_ENC(NAME_TBD, 12, BTF_MEMBER_OFFSET(0, 64)), /* int32_t si32 */
@@ -3637,9 +3638,11 @@ static struct btf_raw_test pprint_test_template[] = {
3637 BTF_MEMBER_ENC(NAME_TBD, 6, BTF_MEMBER_OFFSET(2, 126)), /* unused_bits2b */ 3638 BTF_MEMBER_ENC(NAME_TBD, 6, BTF_MEMBER_OFFSET(2, 126)), /* unused_bits2b */
3638 BTF_MEMBER_ENC(0, 14, BTF_MEMBER_OFFSET(0, 128)), /* union (anon) */ 3639 BTF_MEMBER_ENC(0, 14, BTF_MEMBER_OFFSET(0, 128)), /* union (anon) */
3639 BTF_MEMBER_ENC(NAME_TBD, 15, BTF_MEMBER_OFFSET(0, 192)), /* aenum */ 3640 BTF_MEMBER_ENC(NAME_TBD, 15, BTF_MEMBER_OFFSET(0, 192)), /* aenum */
3641 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 224)), /* uint32_t ui32b */
3642 BTF_MEMBER_ENC(NAME_TBD, 6, BTF_MEMBER_OFFSET(2, 256)), /* bits2c */
3640 BTF_END_RAW, 3643 BTF_END_RAW,
3641 }, 3644 },
3642 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum"), 3645 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum\0ui32b\0bits2c"),
3643 .key_size = sizeof(unsigned int), 3646 .key_size = sizeof(unsigned int),
3644 .value_size = sizeof(struct pprint_mapv), 3647 .value_size = sizeof(struct pprint_mapv),
3645 .key_type_id = 3, /* unsigned int */ 3648 .key_type_id = 3, /* unsigned int */
@@ -3690,7 +3693,7 @@ static struct btf_raw_test pprint_test_template[] = {
3690 BTF_ENUM_ENC(NAME_TBD, 2), 3693 BTF_ENUM_ENC(NAME_TBD, 2),
3691 BTF_ENUM_ENC(NAME_TBD, 3), 3694 BTF_ENUM_ENC(NAME_TBD, 3),
3692 /* struct pprint_mapv */ /* [16] */ 3695 /* struct pprint_mapv */ /* [16] */
3693 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 8), 32), 3696 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 1, 10), 40),
3694 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 0)), /* uint32_t ui32 */ 3697 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 0)), /* uint32_t ui32 */
3695 BTF_MEMBER_ENC(NAME_TBD, 10, BTF_MEMBER_OFFSET(0, 32)), /* uint16_t ui16 */ 3698 BTF_MEMBER_ENC(NAME_TBD, 10, BTF_MEMBER_OFFSET(0, 32)), /* uint16_t ui16 */
3696 BTF_MEMBER_ENC(NAME_TBD, 12, BTF_MEMBER_OFFSET(0, 64)), /* int32_t si32 */ 3699 BTF_MEMBER_ENC(NAME_TBD, 12, BTF_MEMBER_OFFSET(0, 64)), /* int32_t si32 */
@@ -3699,13 +3702,15 @@ static struct btf_raw_test pprint_test_template[] = {
3699 BTF_MEMBER_ENC(NAME_TBD, 19, BTF_MEMBER_OFFSET(2, 126)),/* unused_bits2b */ 3702 BTF_MEMBER_ENC(NAME_TBD, 19, BTF_MEMBER_OFFSET(2, 126)),/* unused_bits2b */
3700 BTF_MEMBER_ENC(0, 14, BTF_MEMBER_OFFSET(0, 128)), /* union (anon) */ 3703 BTF_MEMBER_ENC(0, 14, BTF_MEMBER_OFFSET(0, 128)), /* union (anon) */
3701 BTF_MEMBER_ENC(NAME_TBD, 15, BTF_MEMBER_OFFSET(0, 192)), /* aenum */ 3704 BTF_MEMBER_ENC(NAME_TBD, 15, BTF_MEMBER_OFFSET(0, 192)), /* aenum */
3705 BTF_MEMBER_ENC(NAME_TBD, 11, BTF_MEMBER_OFFSET(0, 224)), /* uint32_t ui32b */
3706 BTF_MEMBER_ENC(NAME_TBD, 17, BTF_MEMBER_OFFSET(2, 256)), /* bits2c */
3702 /* typedef unsigned int ___int */ /* [17] */ 3707 /* typedef unsigned int ___int */ /* [17] */
3703 BTF_TYPEDEF_ENC(NAME_TBD, 18), 3708 BTF_TYPEDEF_ENC(NAME_TBD, 18),
3704 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_VOLATILE, 0, 0), 6), /* [18] */ 3709 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_VOLATILE, 0, 0), 6), /* [18] */
3705 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 15), /* [19] */ 3710 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 15), /* [19] */
3706 BTF_END_RAW, 3711 BTF_END_RAW,
3707 }, 3712 },
3708 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum\0___int"), 3713 BTF_STR_SEC("\0unsigned char\0unsigned short\0unsigned int\0int\0unsigned long long\0uint8_t\0uint16_t\0uint32_t\0int32_t\0uint64_t\0ui64\0ui8a\0ENUM_ZERO\0ENUM_ONE\0ENUM_TWO\0ENUM_THREE\0pprint_mapv\0ui32\0ui16\0si32\0unused_bits2a\0bits28\0unused_bits2b\0aenum\0ui32b\0bits2c\0___int"),
3709 .key_size = sizeof(unsigned int), 3714 .key_size = sizeof(unsigned int),
3710 .value_size = sizeof(struct pprint_mapv), 3715 .value_size = sizeof(struct pprint_mapv),
3711 .key_type_id = 3, /* unsigned int */ 3716 .key_type_id = 3, /* unsigned int */
@@ -3793,6 +3798,8 @@ static void set_pprint_mapv(struct pprint_mapv *v, uint32_t i,
3793 v->unused_bits2b = 3; 3798 v->unused_bits2b = 3;
3794 v->ui64 = i; 3799 v->ui64 = i;
3795 v->aenum = i & 0x03; 3800 v->aenum = i & 0x03;
3801 v->ui32b = 4;
3802 v->bits2c = 1;
3796 v = (void *)v + rounded_value_size; 3803 v = (void *)v + rounded_value_size;
3797 } 3804 }
3798} 3805}
@@ -3955,7 +3962,8 @@ static int do_test_pprint(int test_num)
3955 3962
3956 nexpected_line = snprintf(expected_line, sizeof(expected_line), 3963 nexpected_line = snprintf(expected_line, sizeof(expected_line),
3957 "%s%u: {%u,0,%d,0x%x,0x%x,0x%x," 3964 "%s%u: {%u,0,%d,0x%x,0x%x,0x%x,"
3958 "{%lu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s}\n", 3965 "{%lu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s,"
3966 "%u,0x%x}\n",
3959 percpu_map ? "\tcpu" : "", 3967 percpu_map ? "\tcpu" : "",
3960 percpu_map ? cpu : next_key, 3968 percpu_map ? cpu : next_key,
3961 cmapv->ui32, cmapv->si32, 3969 cmapv->ui32, cmapv->si32,
@@ -3967,7 +3975,9 @@ static int do_test_pprint(int test_num)
3967 cmapv->ui8a[2], cmapv->ui8a[3], 3975 cmapv->ui8a[2], cmapv->ui8a[3],
3968 cmapv->ui8a[4], cmapv->ui8a[5], 3976 cmapv->ui8a[4], cmapv->ui8a[5],
3969 cmapv->ui8a[6], cmapv->ui8a[7], 3977 cmapv->ui8a[6], cmapv->ui8a[7],
3970 pprint_enum_str[cmapv->aenum]); 3978 pprint_enum_str[cmapv->aenum],
3979 cmapv->ui32b,
3980 cmapv->bits2c);
3971 3981
3972 err = check_line(expected_line, nexpected_line, 3982 err = check_line(expected_line, nexpected_line,
3973 sizeof(expected_line), line); 3983 sizeof(expected_line), line);
diff --git a/tools/testing/selftests/bpf/test_cgroup_storage.c b/tools/testing/selftests/bpf/test_cgroup_storage.c
index f44834155f25..2fc4625c1a15 100644
--- a/tools/testing/selftests/bpf/test_cgroup_storage.c
+++ b/tools/testing/selftests/bpf/test_cgroup_storage.c
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
81 81
82 /* Create a cgroup, get fd, and join it */ 82 /* Create a cgroup, get fd, and join it */
83 cgroup_fd = create_and_get_cgroup(TEST_CGROUP); 83 cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
84 if (!cgroup_fd) { 84 if (cgroup_fd < 0) {
85 printf("Failed to create test cgroup\n"); 85 printf("Failed to create test cgroup\n");
86 goto err; 86 goto err;
87 } 87 }
diff --git a/tools/testing/selftests/bpf/test_dev_cgroup.c b/tools/testing/selftests/bpf/test_dev_cgroup.c
index 9c8b50bac7e0..76e4993b7c16 100644
--- a/tools/testing/selftests/bpf/test_dev_cgroup.c
+++ b/tools/testing/selftests/bpf/test_dev_cgroup.c
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
43 43
44 /* Create a cgroup, get fd, and join it */ 44 /* Create a cgroup, get fd, and join it */
45 cgroup_fd = create_and_get_cgroup(TEST_CGROUP); 45 cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
46 if (!cgroup_fd) { 46 if (cgroup_fd < 0) {
47 printf("Failed to create test cgroup\n"); 47 printf("Failed to create test cgroup\n");
48 goto err; 48 goto err;
49 } 49 }
diff --git a/tools/testing/selftests/bpf/test_lpm_map.c b/tools/testing/selftests/bpf/test_lpm_map.c
index 147e34cfceb7..02d7c871862a 100644
--- a/tools/testing/selftests/bpf/test_lpm_map.c
+++ b/tools/testing/selftests/bpf/test_lpm_map.c
@@ -474,6 +474,16 @@ static void test_lpm_delete(void)
474 assert(bpf_map_lookup_elem(map_fd, key, &value) == -1 && 474 assert(bpf_map_lookup_elem(map_fd, key, &value) == -1 &&
475 errno == ENOENT); 475 errno == ENOENT);
476 476
477 key->prefixlen = 30; // unused prefix so far
478 inet_pton(AF_INET, "192.255.0.0", key->data);
479 assert(bpf_map_delete_elem(map_fd, key) == -1 &&
480 errno == ENOENT);
481
482 key->prefixlen = 16; // same prefix as the root node
483 inet_pton(AF_INET, "192.255.0.0", key->data);
484 assert(bpf_map_delete_elem(map_fd, key) == -1 &&
485 errno == ENOENT);
486
477 /* assert initial lookup */ 487 /* assert initial lookup */
478 key->prefixlen = 32; 488 key->prefixlen = 32;
479 inet_pton(AF_INET, "192.168.0.1", key->data); 489 inet_pton(AF_INET, "192.168.0.1", key->data);
diff --git a/tools/testing/selftests/bpf/test_netcnt.c b/tools/testing/selftests/bpf/test_netcnt.c
index 44ed7f29f8ab..c1da5404454a 100644
--- a/tools/testing/selftests/bpf/test_netcnt.c
+++ b/tools/testing/selftests/bpf/test_netcnt.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
65 65
66 /* Create a cgroup, get fd, and join it */ 66 /* Create a cgroup, get fd, and join it */
67 cgroup_fd = create_and_get_cgroup(TEST_CGROUP); 67 cgroup_fd = create_and_get_cgroup(TEST_CGROUP);
68 if (!cgroup_fd) { 68 if (cgroup_fd < 0) {
69 printf("Failed to create test cgroup\n"); 69 printf("Failed to create test cgroup\n");
70 goto err; 70 goto err;
71 } 71 }
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 126fc624290d..25f0083a9b2e 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -1188,7 +1188,9 @@ static void test_stacktrace_build_id(void)
1188 int i, j; 1188 int i, j;
1189 struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH]; 1189 struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH];
1190 int build_id_matches = 0; 1190 int build_id_matches = 0;
1191 int retry = 1;
1191 1192
1193retry:
1192 err = bpf_prog_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj, &prog_fd); 1194 err = bpf_prog_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj, &prog_fd);
1193 if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno)) 1195 if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno))
1194 goto out; 1196 goto out;
@@ -1301,6 +1303,19 @@ static void test_stacktrace_build_id(void)
1301 previous_key = key; 1303 previous_key = key;
1302 } while (bpf_map_get_next_key(stackmap_fd, &previous_key, &key) == 0); 1304 } while (bpf_map_get_next_key(stackmap_fd, &previous_key, &key) == 0);
1303 1305
1306 /* stack_map_get_build_id_offset() is racy and sometimes can return
1307 * BPF_STACK_BUILD_ID_IP instead of BPF_STACK_BUILD_ID_VALID;
1308 * try it one more time.
1309 */
1310 if (build_id_matches < 1 && retry--) {
1311 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
1312 close(pmu_fd);
1313 bpf_object__close(obj);
1314 printf("%s:WARN:Didn't find expected build ID from the map, retrying\n",
1315 __func__);
1316 goto retry;
1317 }
1318
1304 if (CHECK(build_id_matches < 1, "build id match", 1319 if (CHECK(build_id_matches < 1, "build id match",
1305 "Didn't find expected build ID from the map\n")) 1320 "Didn't find expected build ID from the map\n"))
1306 goto disable_pmu; 1321 goto disable_pmu;
@@ -1341,7 +1356,9 @@ static void test_stacktrace_build_id_nmi(void)
1341 int i, j; 1356 int i, j;
1342 struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH]; 1357 struct bpf_stack_build_id id_offs[PERF_MAX_STACK_DEPTH];
1343 int build_id_matches = 0; 1358 int build_id_matches = 0;
1359 int retry = 1;
1344 1360
1361retry:
1345 err = bpf_prog_load(file, BPF_PROG_TYPE_PERF_EVENT, &obj, &prog_fd); 1362 err = bpf_prog_load(file, BPF_PROG_TYPE_PERF_EVENT, &obj, &prog_fd);
1346 if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno)) 1363 if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno))
1347 return; 1364 return;
@@ -1436,6 +1453,19 @@ static void test_stacktrace_build_id_nmi(void)
1436 previous_key = key; 1453 previous_key = key;
1437 } while (bpf_map_get_next_key(stackmap_fd, &previous_key, &key) == 0); 1454 } while (bpf_map_get_next_key(stackmap_fd, &previous_key, &key) == 0);
1438 1455
1456 /* stack_map_get_build_id_offset() is racy and sometimes can return
1457 * BPF_STACK_BUILD_ID_IP instead of BPF_STACK_BUILD_ID_VALID;
1458 * try it one more time.
1459 */
1460 if (build_id_matches < 1 && retry--) {
1461 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
1462 close(pmu_fd);
1463 bpf_object__close(obj);
1464 printf("%s:WARN:Didn't find expected build ID from the map, retrying\n",
1465 __func__);
1466 goto retry;
1467 }
1468
1439 if (CHECK(build_id_matches < 1, "build id match", 1469 if (CHECK(build_id_matches < 1, "build id match",
1440 "Didn't find expected build ID from the map\n")) 1470 "Didn't find expected build ID from the map\n"))
1441 goto disable_pmu; 1471 goto disable_pmu;
diff --git a/tools/testing/selftests/bpf/test_skb_cgroup_id_user.c b/tools/testing/selftests/bpf/test_skb_cgroup_id_user.c
index c121cc59f314..9220747c069d 100644
--- a/tools/testing/selftests/bpf/test_skb_cgroup_id_user.c
+++ b/tools/testing/selftests/bpf/test_skb_cgroup_id_user.c
@@ -164,7 +164,7 @@ int main(int argc, char **argv)
164 goto err; 164 goto err;
165 165
166 cgfd = create_and_get_cgroup(CGROUP_PATH); 166 cgfd = create_and_get_cgroup(CGROUP_PATH);
167 if (!cgfd) 167 if (cgfd < 0)
168 goto err; 168 goto err;
169 169
170 if (join_cgroup(CGROUP_PATH)) 170 if (join_cgroup(CGROUP_PATH))
diff --git a/tools/testing/selftests/bpf/test_sock.c b/tools/testing/selftests/bpf/test_sock.c
index b8ebe2f58074..561ffb6d6433 100644
--- a/tools/testing/selftests/bpf/test_sock.c
+++ b/tools/testing/selftests/bpf/test_sock.c
@@ -458,7 +458,7 @@ int main(int argc, char **argv)
458 goto err; 458 goto err;
459 459
460 cgfd = create_and_get_cgroup(CG_PATH); 460 cgfd = create_and_get_cgroup(CG_PATH);
461 if (!cgfd) 461 if (cgfd < 0)
462 goto err; 462 goto err;
463 463
464 if (join_cgroup(CG_PATH)) 464 if (join_cgroup(CG_PATH))
diff --git a/tools/testing/selftests/bpf/test_sock_addr.c b/tools/testing/selftests/bpf/test_sock_addr.c
index 73b7493d4120..3f110eaaf29c 100644
--- a/tools/testing/selftests/bpf/test_sock_addr.c
+++ b/tools/testing/selftests/bpf/test_sock_addr.c
@@ -44,6 +44,7 @@
44#define SERV6_V4MAPPED_IP "::ffff:192.168.0.4" 44#define SERV6_V4MAPPED_IP "::ffff:192.168.0.4"
45#define SRC6_IP "::1" 45#define SRC6_IP "::1"
46#define SRC6_REWRITE_IP "::6" 46#define SRC6_REWRITE_IP "::6"
47#define WILDCARD6_IP "::"
47#define SERV6_PORT 6060 48#define SERV6_PORT 6060
48#define SERV6_REWRITE_PORT 6666 49#define SERV6_REWRITE_PORT 6666
49 50
@@ -85,12 +86,14 @@ static int bind4_prog_load(const struct sock_addr_test *test);
85static int bind6_prog_load(const struct sock_addr_test *test); 86static int bind6_prog_load(const struct sock_addr_test *test);
86static int connect4_prog_load(const struct sock_addr_test *test); 87static int connect4_prog_load(const struct sock_addr_test *test);
87static int connect6_prog_load(const struct sock_addr_test *test); 88static int connect6_prog_load(const struct sock_addr_test *test);
89static int sendmsg_allow_prog_load(const struct sock_addr_test *test);
88static int sendmsg_deny_prog_load(const struct sock_addr_test *test); 90static int sendmsg_deny_prog_load(const struct sock_addr_test *test);
89static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test); 91static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test);
90static int sendmsg4_rw_c_prog_load(const struct sock_addr_test *test); 92static int sendmsg4_rw_c_prog_load(const struct sock_addr_test *test);
91static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test); 93static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test);
92static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test); 94static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test);
93static int sendmsg6_rw_v4mapped_prog_load(const struct sock_addr_test *test); 95static int sendmsg6_rw_v4mapped_prog_load(const struct sock_addr_test *test);
96static int sendmsg6_rw_wildcard_prog_load(const struct sock_addr_test *test);
94 97
95static struct sock_addr_test tests[] = { 98static struct sock_addr_test tests[] = {
96 /* bind */ 99 /* bind */
@@ -463,6 +466,34 @@ static struct sock_addr_test tests[] = {
463 SYSCALL_ENOTSUPP, 466 SYSCALL_ENOTSUPP,
464 }, 467 },
465 { 468 {
469 "sendmsg6: set dst IP = [::] (BSD'ism)",
470 sendmsg6_rw_wildcard_prog_load,
471 BPF_CGROUP_UDP6_SENDMSG,
472 BPF_CGROUP_UDP6_SENDMSG,
473 AF_INET6,
474 SOCK_DGRAM,
475 SERV6_IP,
476 SERV6_PORT,
477 SERV6_REWRITE_IP,
478 SERV6_REWRITE_PORT,
479 SRC6_REWRITE_IP,
480 SUCCESS,
481 },
482 {
483 "sendmsg6: preserve dst IP = [::] (BSD'ism)",
484 sendmsg_allow_prog_load,
485 BPF_CGROUP_UDP6_SENDMSG,
486 BPF_CGROUP_UDP6_SENDMSG,
487 AF_INET6,
488 SOCK_DGRAM,
489 WILDCARD6_IP,
490 SERV6_PORT,
491 SERV6_REWRITE_IP,
492 SERV6_PORT,
493 SRC6_IP,
494 SUCCESS,
495 },
496 {
466 "sendmsg6: deny call", 497 "sendmsg6: deny call",
467 sendmsg_deny_prog_load, 498 sendmsg_deny_prog_load,
468 BPF_CGROUP_UDP6_SENDMSG, 499 BPF_CGROUP_UDP6_SENDMSG,
@@ -734,16 +765,27 @@ static int connect6_prog_load(const struct sock_addr_test *test)
734 return load_path(test, CONNECT6_PROG_PATH); 765 return load_path(test, CONNECT6_PROG_PATH);
735} 766}
736 767
737static int sendmsg_deny_prog_load(const struct sock_addr_test *test) 768static int sendmsg_ret_only_prog_load(const struct sock_addr_test *test,
769 int32_t rc)
738{ 770{
739 struct bpf_insn insns[] = { 771 struct bpf_insn insns[] = {
740 /* return 0 */ 772 /* return rc */
741 BPF_MOV64_IMM(BPF_REG_0, 0), 773 BPF_MOV64_IMM(BPF_REG_0, rc),
742 BPF_EXIT_INSN(), 774 BPF_EXIT_INSN(),
743 }; 775 };
744 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); 776 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn));
745} 777}
746 778
779static int sendmsg_allow_prog_load(const struct sock_addr_test *test)
780{
781 return sendmsg_ret_only_prog_load(test, /*rc*/ 1);
782}
783
784static int sendmsg_deny_prog_load(const struct sock_addr_test *test)
785{
786 return sendmsg_ret_only_prog_load(test, /*rc*/ 0);
787}
788
747static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test) 789static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test)
748{ 790{
749 struct sockaddr_in dst4_rw_addr; 791 struct sockaddr_in dst4_rw_addr;
@@ -864,6 +906,11 @@ static int sendmsg6_rw_v4mapped_prog_load(const struct sock_addr_test *test)
864 return sendmsg6_rw_dst_asm_prog_load(test, SERV6_V4MAPPED_IP); 906 return sendmsg6_rw_dst_asm_prog_load(test, SERV6_V4MAPPED_IP);
865} 907}
866 908
909static int sendmsg6_rw_wildcard_prog_load(const struct sock_addr_test *test)
910{
911 return sendmsg6_rw_dst_asm_prog_load(test, WILDCARD6_IP);
912}
913
867static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test) 914static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test)
868{ 915{
869 return load_path(test, SENDMSG6_PROG_PATH); 916 return load_path(test, SENDMSG6_PROG_PATH);
@@ -1395,7 +1442,7 @@ int main(int argc, char **argv)
1395 goto err; 1442 goto err;
1396 1443
1397 cgfd = create_and_get_cgroup(CG_PATH); 1444 cgfd = create_and_get_cgroup(CG_PATH);
1398 if (!cgfd) 1445 if (cgfd < 0)
1399 goto err; 1446 goto err;
1400 1447
1401 if (join_cgroup(CG_PATH)) 1448 if (join_cgroup(CG_PATH))
diff --git a/tools/testing/selftests/bpf/test_socket_cookie.c b/tools/testing/selftests/bpf/test_socket_cookie.c
index b6c2c605d8c0..fc7832ee566b 100644
--- a/tools/testing/selftests/bpf/test_socket_cookie.c
+++ b/tools/testing/selftests/bpf/test_socket_cookie.c
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
202 goto err; 202 goto err;
203 203
204 cgfd = create_and_get_cgroup(CG_PATH); 204 cgfd = create_and_get_cgroup(CG_PATH);
205 if (!cgfd) 205 if (cgfd < 0)
206 goto err; 206 goto err;
207 207
208 if (join_cgroup(CG_PATH)) 208 if (join_cgroup(CG_PATH))
diff --git a/tools/testing/selftests/bpf/test_tcpbpf_user.c b/tools/testing/selftests/bpf/test_tcpbpf_user.c
index e6eebda7d112..716b4e3be581 100644
--- a/tools/testing/selftests/bpf/test_tcpbpf_user.c
+++ b/tools/testing/selftests/bpf/test_tcpbpf_user.c
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
103 goto err; 103 goto err;
104 104
105 cg_fd = create_and_get_cgroup(cg_path); 105 cg_fd = create_and_get_cgroup(cg_path);
106 if (!cg_fd) 106 if (cg_fd < 0)
107 goto err; 107 goto err;
108 108
109 if (join_cgroup(cg_path)) 109 if (join_cgroup(cg_path))
diff --git a/tools/testing/selftests/bpf/test_tcpnotify_user.c b/tools/testing/selftests/bpf/test_tcpnotify_user.c
index ff3c4522aed6..4e4353711a86 100644
--- a/tools/testing/selftests/bpf/test_tcpnotify_user.c
+++ b/tools/testing/selftests/bpf/test_tcpnotify_user.c
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
115 goto err; 115 goto err;
116 116
117 cg_fd = create_and_get_cgroup(cg_path); 117 cg_fd = create_and_get_cgroup(cg_path);
118 if (!cg_fd) 118 if (cg_fd < 0)
119 goto err; 119 goto err;
120 120
121 if (join_cgroup(cg_path)) 121 if (join_cgroup(cg_path))
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 10d44446e801..2fd90d456892 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -6934,6 +6934,126 @@ static struct bpf_test tests[] = {
6934 .retval = 1, 6934 .retval = 1,
6935 }, 6935 },
6936 { 6936 {
6937 "map access: mixing value pointer and scalar, 1",
6938 .insns = {
6939 // load map value pointer into r0 and r2
6940 BPF_MOV64_IMM(BPF_REG_0, 1),
6941 BPF_LD_MAP_FD(BPF_REG_ARG1, 0),
6942 BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP),
6943 BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16),
6944 BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0),
6945 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
6946 BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
6947 BPF_EXIT_INSN(),
6948 // load some number from the map into r1
6949 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6950 // depending on r1, branch:
6951 BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 3),
6952 // branch A
6953 BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
6954 BPF_MOV64_IMM(BPF_REG_3, 0),
6955 BPF_JMP_A(2),
6956 // branch B
6957 BPF_MOV64_IMM(BPF_REG_2, 0),
6958 BPF_MOV64_IMM(BPF_REG_3, 0x100000),
6959 // common instruction
6960 BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
6961 // depending on r1, branch:
6962 BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 1),
6963 // branch A
6964 BPF_JMP_A(4),
6965 // branch B
6966 BPF_MOV64_IMM(BPF_REG_0, 0x13371337),
6967 // verifier follows fall-through
6968 BPF_JMP_IMM(BPF_JNE, BPF_REG_2, 0x100000, 2),
6969 BPF_MOV64_IMM(BPF_REG_0, 0),
6970 BPF_EXIT_INSN(),
6971 // fake-dead code; targeted from branch A to
6972 // prevent dead code sanitization
6973 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_0, 0),
6974 BPF_MOV64_IMM(BPF_REG_0, 0),
6975 BPF_EXIT_INSN(),
6976 },
6977 .fixup_map_array_48b = { 1 },
6978 .result = ACCEPT,
6979 .result_unpriv = REJECT,
6980 .errstr_unpriv = "R2 tried to add from different pointers or scalars",
6981 .retval = 0,
6982 },
6983 {
6984 "map access: mixing value pointer and scalar, 2",
6985 .insns = {
6986 // load map value pointer into r0 and r2
6987 BPF_MOV64_IMM(BPF_REG_0, 1),
6988 BPF_LD_MAP_FD(BPF_REG_ARG1, 0),
6989 BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP),
6990 BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16),
6991 BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0),
6992 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
6993 BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
6994 BPF_EXIT_INSN(),
6995 // load some number from the map into r1
6996 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6997 // depending on r1, branch:
6998 BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3),
6999 // branch A
7000 BPF_MOV64_IMM(BPF_REG_2, 0),
7001 BPF_MOV64_IMM(BPF_REG_3, 0x100000),
7002 BPF_JMP_A(2),
7003 // branch B
7004 BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
7005 BPF_MOV64_IMM(BPF_REG_3, 0),
7006 // common instruction
7007 BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
7008 // depending on r1, branch:
7009 BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 1),
7010 // branch A
7011 BPF_JMP_A(4),
7012 // branch B
7013 BPF_MOV64_IMM(BPF_REG_0, 0x13371337),
7014 // verifier follows fall-through
7015 BPF_JMP_IMM(BPF_JNE, BPF_REG_2, 0x100000, 2),
7016 BPF_MOV64_IMM(BPF_REG_0, 0),
7017 BPF_EXIT_INSN(),
7018 // fake-dead code; targeted from branch A to
7019 // prevent dead code sanitization
7020 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_0, 0),
7021 BPF_MOV64_IMM(BPF_REG_0, 0),
7022 BPF_EXIT_INSN(),
7023 },
7024 .fixup_map_array_48b = { 1 },
7025 .result = ACCEPT,
7026 .result_unpriv = REJECT,
7027 .errstr_unpriv = "R2 tried to add from different maps or paths",
7028 .retval = 0,
7029 },
7030 {
7031 "sanitation: alu with different scalars",
7032 .insns = {
7033 BPF_MOV64_IMM(BPF_REG_0, 1),
7034 BPF_LD_MAP_FD(BPF_REG_ARG1, 0),
7035 BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP),
7036 BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16),
7037 BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0),
7038 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
7039 BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
7040 BPF_EXIT_INSN(),
7041 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
7042 BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3),
7043 BPF_MOV64_IMM(BPF_REG_2, 0),
7044 BPF_MOV64_IMM(BPF_REG_3, 0x100000),
7045 BPF_JMP_A(2),
7046 BPF_MOV64_IMM(BPF_REG_2, 42),
7047 BPF_MOV64_IMM(BPF_REG_3, 0x100001),
7048 BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
7049 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
7050 BPF_EXIT_INSN(),
7051 },
7052 .fixup_map_array_48b = { 1 },
7053 .result = ACCEPT,
7054 .retval = 0x100000,
7055 },
7056 {
6937 "map access: value_ptr += known scalar, upper oob arith, test 1", 7057 "map access: value_ptr += known scalar, upper oob arith, test 1",
6938 .insns = { 7058 .insns = {
6939 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), 7059 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index bab13dd025a6..0d26b5e3f966 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -37,6 +37,10 @@ prerequisite()
37 exit $ksft_skip 37 exit $ksft_skip
38 fi 38 fi
39 39
40 present_cpus=`cat $SYSFS/devices/system/cpu/present`
41 present_max=${present_cpus##*-}
42 echo "present_cpus = $present_cpus present_max = $present_max"
43
40 echo -e "\t Cpus in online state: $online_cpus" 44 echo -e "\t Cpus in online state: $online_cpus"
41 45
42 offline_cpus=`cat $SYSFS/devices/system/cpu/offline` 46 offline_cpus=`cat $SYSFS/devices/system/cpu/offline`
@@ -151,6 +155,8 @@ online_cpus=0
151online_max=0 155online_max=0
152offline_cpus=0 156offline_cpus=0
153offline_max=0 157offline_max=0
158present_cpus=0
159present_max=0
154 160
155while getopts e:ahp: opt; do 161while getopts e:ahp: opt; do
156 case $opt in 162 case $opt in
@@ -190,9 +196,10 @@ if [ $allcpus -eq 0 ]; then
190 online_cpu_expect_success $online_max 196 online_cpu_expect_success $online_max
191 197
192 if [[ $offline_cpus -gt 0 ]]; then 198 if [[ $offline_cpus -gt 0 ]]; then
193 echo -e "\t offline to online to offline: cpu $offline_max" 199 echo -e "\t offline to online to offline: cpu $present_max"
194 online_cpu_expect_success $offline_max 200 online_cpu_expect_success $present_max
195 offline_cpu_expect_success $offline_max 201 offline_cpu_expect_success $present_max
202 online_cpu $present_max
196 fi 203 fi
197 exit 0 204 exit 0
198else 205else
diff --git a/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh b/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
index 94fdbf215c14..c4cf6e6d800e 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
@@ -25,6 +25,7 @@ ALL_TESTS="
25 lag_unlink_slaves_test 25 lag_unlink_slaves_test
26 lag_dev_deletion_test 26 lag_dev_deletion_test
27 vlan_interface_uppers_test 27 vlan_interface_uppers_test
28 bridge_extern_learn_test
28 devlink_reload_test 29 devlink_reload_test
29" 30"
30NUM_NETIFS=2 31NUM_NETIFS=2
@@ -541,6 +542,25 @@ vlan_interface_uppers_test()
541 ip link del dev br0 542 ip link del dev br0
542} 543}
543 544
545bridge_extern_learn_test()
546{
547 # Test that externally learned entries added from user space are
548 # marked as offloaded
549 RET=0
550
551 ip link add name br0 type bridge
552 ip link set dev $swp1 master br0
553
554 bridge fdb add de:ad:be:ef:13:37 dev $swp1 master extern_learn
555
556 bridge fdb show brport $swp1 | grep de:ad:be:ef:13:37 | grep -q offload
557 check_err $? "fdb entry not marked as offloaded when should"
558
559 log_test "externally learned fdb entry"
560
561 ip link del dev br0
562}
563
544devlink_reload_test() 564devlink_reload_test()
545{ 565{
546 # Test that after executing all the above configuration tests, a 566 # Test that after executing all the above configuration tests, a
diff --git a/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh
index dcf9f4e913e0..ae6146ec5afd 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/vxlan.sh
@@ -847,6 +847,24 @@ sanitization_vlan_aware_test()
847 847
848 log_test "vlan-aware - failed enslavement to vlan-aware bridge" 848 log_test "vlan-aware - failed enslavement to vlan-aware bridge"
849 849
850 bridge vlan del vid 10 dev vxlan20
851 bridge vlan add vid 20 dev vxlan20 pvid untagged
852
853 # Test that offloading of an unsupported tunnel fails when it is
854 # triggered by addition of VLAN to a local port
855 RET=0
856
857 # TOS must be set to inherit
858 ip link set dev vxlan10 type vxlan tos 42
859
860 ip link set dev $swp1 master br0
861 bridge vlan add vid 10 dev $swp1 &> /dev/null
862 check_fail $?
863
864 log_test "vlan-aware - failed vlan addition to a local port"
865
866 ip link set dev vxlan10 type vxlan tos inherit
867
850 ip link del dev vxlan20 868 ip link del dev vxlan20
851 ip link del dev vxlan10 869 ip link del dev vxlan10
852 ip link del dev br0 870 ip link del dev br0
diff --git a/tools/testing/selftests/filesystems/binderfs/.gitignore b/tools/testing/selftests/filesystems/binderfs/.gitignore
new file mode 100644
index 000000000000..8a5d9bf63dd4
--- /dev/null
+++ b/tools/testing/selftests/filesystems/binderfs/.gitignore
@@ -0,0 +1 @@
binderfs_test
diff --git a/tools/testing/selftests/filesystems/binderfs/Makefile b/tools/testing/selftests/filesystems/binderfs/Makefile
new file mode 100644
index 000000000000..58cb659b56b4
--- /dev/null
+++ b/tools/testing/selftests/filesystems/binderfs/Makefile
@@ -0,0 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0
2
3CFLAGS += -I../../../../../usr/include/
4TEST_GEN_PROGS := binderfs_test
5
6include ../../lib.mk
diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
new file mode 100644
index 000000000000..8c2ed962e1c7
--- /dev/null
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -0,0 +1,275 @@
1// SPDX-License-Identifier: GPL-2.0
2
3#define _GNU_SOURCE
4#include <errno.h>
5#include <fcntl.h>
6#include <sched.h>
7#include <stdbool.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <sys/ioctl.h>
12#include <sys/mount.h>
13#include <sys/stat.h>
14#include <sys/types.h>
15#include <unistd.h>
16#include <linux/android/binder.h>
17#include <linux/android/binderfs.h>
18#include "../../kselftest.h"
19
20static ssize_t write_nointr(int fd, const void *buf, size_t count)
21{
22 ssize_t ret;
23again:
24 ret = write(fd, buf, count);
25 if (ret < 0 && errno == EINTR)
26 goto again;
27
28 return ret;
29}
30
31static void write_to_file(const char *filename, const void *buf, size_t count,
32 int allowed_errno)
33{
34 int fd, saved_errno;
35 ssize_t ret;
36
37 fd = open(filename, O_WRONLY | O_CLOEXEC);
38 if (fd < 0)
39 ksft_exit_fail_msg("%s - Failed to open file %s\n",
40 strerror(errno), filename);
41
42 ret = write_nointr(fd, buf, count);
43 if (ret < 0) {
44 if (allowed_errno && (errno == allowed_errno)) {
45 close(fd);
46 return;
47 }
48
49 goto on_error;
50 }
51
52 if ((size_t)ret != count)
53 goto on_error;
54
55 close(fd);
56 return;
57
58on_error:
59 saved_errno = errno;
60 close(fd);
61 errno = saved_errno;
62
63 if (ret < 0)
64 ksft_exit_fail_msg("%s - Failed to write to file %s\n",
65 strerror(errno), filename);
66
67 ksft_exit_fail_msg("Failed to write to file %s\n", filename);
68}
69
70static void change_to_userns(void)
71{
72 int ret;
73 uid_t uid;
74 gid_t gid;
75 /* {g,u}id_map files only allow a max of 4096 bytes written to them */
76 char idmap[4096];
77
78 uid = getuid();
79 gid = getgid();
80
81 ret = unshare(CLONE_NEWUSER);
82 if (ret < 0)
83 ksft_exit_fail_msg("%s - Failed to unshare user namespace\n",
84 strerror(errno));
85
86 write_to_file("/proc/self/setgroups", "deny", strlen("deny"), ENOENT);
87
88 ret = snprintf(idmap, sizeof(idmap), "0 %d 1", uid);
89 if (ret < 0 || (size_t)ret >= sizeof(idmap))
90 ksft_exit_fail_msg("%s - Failed to prepare uid mapping\n",
91 strerror(errno));
92
93 write_to_file("/proc/self/uid_map", idmap, strlen(idmap), 0);
94
95 ret = snprintf(idmap, sizeof(idmap), "0 %d 1", gid);
96 if (ret < 0 || (size_t)ret >= sizeof(idmap))
97 ksft_exit_fail_msg("%s - Failed to prepare uid mapping\n",
98 strerror(errno));
99
100 write_to_file("/proc/self/gid_map", idmap, strlen(idmap), 0);
101
102 ret = setgid(0);
103 if (ret)
104 ksft_exit_fail_msg("%s - Failed to setgid(0)\n",
105 strerror(errno));
106
107 ret = setuid(0);
108 if (ret)
109 ksft_exit_fail_msg("%s - Failed to setgid(0)\n",
110 strerror(errno));
111}
112
113static void change_to_mountns(void)
114{
115 int ret;
116
117 ret = unshare(CLONE_NEWNS);
118 if (ret < 0)
119 ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
120 strerror(errno));
121
122 ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
123 if (ret < 0)
124 ksft_exit_fail_msg("%s - Failed to mount / as private\n",
125 strerror(errno));
126}
127
128static void rmdir_protect_errno(const char *dir)
129{
130 int saved_errno = errno;
131 (void)rmdir(dir);
132 errno = saved_errno;
133}
134
135static void __do_binderfs_test(void)
136{
137 int fd, ret, saved_errno;
138 size_t len;
139 ssize_t wret;
140 bool keep = false;
141 struct binderfs_device device = { 0 };
142 struct binder_version version = { 0 };
143
144 change_to_mountns();
145
146 ret = mkdir("/dev/binderfs", 0755);
147 if (ret < 0) {
148 if (errno != EEXIST)
149 ksft_exit_fail_msg(
150 "%s - Failed to create binderfs mountpoint\n",
151 strerror(errno));
152
153 keep = true;
154 }
155
156 ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
157 if (ret < 0) {
158 if (errno != ENODEV)
159 ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
160 strerror(errno));
161
162 keep ? : rmdir_protect_errno("/dev/binderfs");
163 ksft_exit_skip(
164 "The Android binderfs filesystem is not available\n");
165 }
166
167 /* binderfs mount test passed */
168 ksft_inc_pass_cnt();
169
170 memcpy(device.name, "my-binder", strlen("my-binder"));
171
172 fd = open("/dev/binderfs/binder-control", O_RDONLY | O_CLOEXEC);
173 if (fd < 0)
174 ksft_exit_fail_msg(
175 "%s - Failed to open binder-control device\n",
176 strerror(errno));
177
178 ret = ioctl(fd, BINDER_CTL_ADD, &device);
179 saved_errno = errno;
180 close(fd);
181 errno = saved_errno;
182 if (ret < 0) {
183 keep ? : rmdir_protect_errno("/dev/binderfs");
184 ksft_exit_fail_msg(
185 "%s - Failed to allocate new binder device\n",
186 strerror(errno));
187 }
188
189 ksft_print_msg(
190 "Allocated new binder device with major %d, minor %d, and name %s\n",
191 device.major, device.minor, device.name);
192
193 /* binder device allocation test passed */
194 ksft_inc_pass_cnt();
195
196 fd = open("/dev/binderfs/my-binder", O_CLOEXEC | O_RDONLY);
197 if (fd < 0) {
198 keep ? : rmdir_protect_errno("/dev/binderfs");
199 ksft_exit_fail_msg("%s - Failed to open my-binder device\n",
200 strerror(errno));
201 }
202
203 ret = ioctl(fd, BINDER_VERSION, &version);
204 saved_errno = errno;
205 close(fd);
206 errno = saved_errno;
207 if (ret < 0) {
208 keep ? : rmdir_protect_errno("/dev/binderfs");
209 ksft_exit_fail_msg(
210 "%s - Failed to open perform BINDER_VERSION request\n",
211 strerror(errno));
212 }
213
214 ksft_print_msg("Detected binder version: %d\n",
215 version.protocol_version);
216
217 /* binder transaction with binderfs binder device passed */
218 ksft_inc_pass_cnt();
219
220 ret = unlink("/dev/binderfs/my-binder");
221 if (ret < 0) {
222 keep ? : rmdir_protect_errno("/dev/binderfs");
223 ksft_exit_fail_msg("%s - Failed to delete binder device\n",
224 strerror(errno));
225 }
226
227 /* binder device removal passed */
228 ksft_inc_pass_cnt();
229
230 ret = unlink("/dev/binderfs/binder-control");
231 if (!ret) {
232 keep ? : rmdir_protect_errno("/dev/binderfs");
233 ksft_exit_fail_msg("Managed to delete binder-control device\n");
234 } else if (errno != EPERM) {
235 keep ? : rmdir_protect_errno("/dev/binderfs");
236 ksft_exit_fail_msg(
237 "%s - Failed to delete binder-control device but exited with unexpected error code\n",
238 strerror(errno));
239 }
240
241 /* binder-control device removal failed as expected */
242 ksft_inc_xfail_cnt();
243
244on_error:
245 ret = umount2("/dev/binderfs", MNT_DETACH);
246 keep ?: rmdir_protect_errno("/dev/binderfs");
247 if (ret < 0)
248 ksft_exit_fail_msg("%s - Failed to unmount binderfs\n",
249 strerror(errno));
250
251 /* binderfs unmount test passed */
252 ksft_inc_pass_cnt();
253}
254
255static void binderfs_test_privileged()
256{
257 if (geteuid() != 0)
258 ksft_print_msg(
259 "Tests are not run as root. Skipping privileged tests\n");
260 else
261 __do_binderfs_test();
262}
263
264static void binderfs_test_unprivileged()
265{
266 change_to_userns();
267 __do_binderfs_test();
268}
269
270int main(int argc, char *argv[])
271{
272 binderfs_test_privileged();
273 binderfs_test_unprivileged();
274 ksft_exit_pass();
275}
diff --git a/tools/testing/selftests/filesystems/binderfs/config b/tools/testing/selftests/filesystems/binderfs/config
new file mode 100644
index 000000000000..02dd6cc9cf99
--- /dev/null
+++ b/tools/testing/selftests/filesystems/binderfs/config
@@ -0,0 +1,3 @@
1CONFIG_ANDROID=y
2CONFIG_ANDROID_BINDERFS=y
3CONFIG_ANDROID_BINDER_IPC=y
diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
index f8d468f54e98..aaa1e9f083c3 100644
--- a/tools/testing/selftests/gpio/gpio-mockup-chardev.c
+++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
@@ -37,7 +37,7 @@ static int get_debugfs(char **path)
37 struct libmnt_table *tb; 37 struct libmnt_table *tb;
38 struct libmnt_iter *itr = NULL; 38 struct libmnt_iter *itr = NULL;
39 struct libmnt_fs *fs; 39 struct libmnt_fs *fs;
40 int found = 0; 40 int found = 0, ret;
41 41
42 cxt = mnt_new_context(); 42 cxt = mnt_new_context();
43 if (!cxt) 43 if (!cxt)
@@ -58,8 +58,11 @@ static int get_debugfs(char **path)
58 break; 58 break;
59 } 59 }
60 } 60 }
61 if (found) 61 if (found) {
62 asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); 62 ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
63 if (ret < 0)
64 err(EXIT_FAILURE, "failed to format string");
65 }
63 66
64 mnt_free_iter(itr); 67 mnt_free_iter(itr);
65 mnt_free_context(cxt); 68 mnt_free_context(cxt);
diff --git a/tools/testing/selftests/ir/Makefile b/tools/testing/selftests/ir/Makefile
index f4ba8eb84b95..ad06489c22a5 100644
--- a/tools/testing/selftests/ir/Makefile
+++ b/tools/testing/selftests/ir/Makefile
@@ -1,5 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2TEST_PROGS := ir_loopback.sh 2TEST_PROGS := ir_loopback.sh
3TEST_GEN_PROGS_EXTENDED := ir_loopback 3TEST_GEN_PROGS_EXTENDED := ir_loopback
4APIDIR := ../../../include/uapi
5CFLAGS += -Wall -O2 -I$(APIDIR)
4 6
5include ../lib.mk 7include ../lib.mk
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 23022e9d32eb..b52cfdefecbf 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -571,7 +571,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
571 * already exist. 571 * already exist.
572 */ 572 */
573 region = (struct userspace_mem_region *) userspace_mem_region_find( 573 region = (struct userspace_mem_region *) userspace_mem_region_find(
574 vm, guest_paddr, guest_paddr + npages * vm->page_size); 574 vm, guest_paddr, (guest_paddr + npages * vm->page_size) - 1);
575 if (region != NULL) 575 if (region != NULL)
576 TEST_ASSERT(false, "overlapping userspace_mem_region already " 576 TEST_ASSERT(false, "overlapping userspace_mem_region already "
577 "exists\n" 577 "exists\n"
@@ -587,15 +587,10 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
587 region = region->next) { 587 region = region->next) {
588 if (region->region.slot == slot) 588 if (region->region.slot == slot)
589 break; 589 break;
590 if ((guest_paddr <= (region->region.guest_phys_addr
591 + region->region.memory_size))
592 && ((guest_paddr + npages * vm->page_size)
593 >= region->region.guest_phys_addr))
594 break;
595 } 590 }
596 if (region != NULL) 591 if (region != NULL)
597 TEST_ASSERT(false, "A mem region with the requested slot " 592 TEST_ASSERT(false, "A mem region with the requested slot "
598 "or overlapping physical memory range already exists.\n" 593 "already exists.\n"
599 " requested slot: %u paddr: 0x%lx npages: 0x%lx\n" 594 " requested slot: %u paddr: 0x%lx npages: 0x%lx\n"
600 " existing slot: %u paddr: 0x%lx size: 0x%lx", 595 " existing slot: %u paddr: 0x%lx size: 0x%lx",
601 slot, guest_paddr, npages, 596 slot, guest_paddr, npages,
diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
index ea3c73e8f4f6..c49c2a28b0eb 100644
--- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
@@ -103,6 +103,12 @@ int main(int argc, char *argv[])
103 103
104 vcpu_ioctl(vm, VCPU_ID, KVM_ENABLE_CAP, &enable_evmcs_cap); 104 vcpu_ioctl(vm, VCPU_ID, KVM_ENABLE_CAP, &enable_evmcs_cap);
105 105
106 /* KVM should return supported EVMCS version range */
107 TEST_ASSERT(((evmcs_ver >> 8) >= (evmcs_ver & 0xff)) &&
108 (evmcs_ver & 0xff) > 0,
109 "Incorrect EVMCS version range: %x:%x\n",
110 evmcs_ver & 0xff, evmcs_ver >> 8);
111
106 run = vcpu_state(vm, VCPU_ID); 112 run = vcpu_state(vm, VCPU_ID);
107 113
108 vcpu_regs_get(vm, VCPU_ID, &regs1); 114 vcpu_regs_get(vm, VCPU_ID, &regs1);
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index f8f3e90700c0..1e6d14d2825c 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -21,6 +21,6 @@ TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
21KSFT_KHDR_INSTALL := 1 21KSFT_KHDR_INSTALL := 1
22include ../lib.mk 22include ../lib.mk
23 23
24$(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma 24$(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
25$(OUTPUT)/tcp_mmap: LDFLAGS += -lpthread 25$(OUTPUT)/tcp_mmap: LDFLAGS += -lpthread
26$(OUTPUT)/tcp_inq: LDFLAGS += -lpthread 26$(OUTPUT)/tcp_inq: LDFLAGS += -lpthread
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index 802b4af18729..1080ff55a788 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -388,6 +388,7 @@ fib_carrier_unicast_test()
388 388
389 set -e 389 set -e
390 $IP link set dev dummy0 carrier off 390 $IP link set dev dummy0 carrier off
391 sleep 1
391 set +e 392 set +e
392 393
393 echo " Carrier down" 394 echo " Carrier down"
diff --git a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
index d8313d0438b7..b90dff8d3a94 100755
--- a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
+++ b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
@@ -1,7 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3 3
4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding" 4ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn"
5NUM_NETIFS=4 5NUM_NETIFS=4
6CHECK_TC="yes" 6CHECK_TC="yes"
7source lib.sh 7source lib.sh
@@ -96,6 +96,51 @@ flooding()
96 flood_test $swp2 $h1 $h2 96 flood_test $swp2 $h1 $h2
97} 97}
98 98
99vlan_deletion()
100{
101 # Test that the deletion of a VLAN on a bridge port does not affect
102 # the PVID VLAN
103 log_info "Add and delete a VLAN on bridge port $swp1"
104
105 bridge vlan add vid 10 dev $swp1
106 bridge vlan del vid 10 dev $swp1
107
108 ping_ipv4
109 ping_ipv6
110}
111
112extern_learn()
113{
114 local mac=de:ad:be:ef:13:37
115 local ageing_time
116
117 # Test that externally learned FDB entries can roam, but not age out
118 RET=0
119
120 bridge fdb add de:ad:be:ef:13:37 dev $swp1 master extern_learn vlan 1
121
122 bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
123 check_err $? "Did not find FDB entry when should"
124
125 # Wait for 10 seconds after the ageing time to make sure the FDB entry
126 # was not aged out
127 ageing_time=$(bridge_ageing_time_get br0)
128 sleep $((ageing_time + 10))
129
130 bridge fdb show brport $swp1 | grep -q de:ad:be:ef:13:37
131 check_err $? "FDB entry was aged out when should not"
132
133 $MZ $h2 -c 1 -p 64 -a $mac -t ip -q
134
135 bridge fdb show brport $swp2 | grep -q de:ad:be:ef:13:37
136 check_err $? "FDB entry did not roam when should"
137
138 log_test "Externally learned FDB entry - ageing & roaming"
139
140 bridge fdb del de:ad:be:ef:13:37 dev $swp2 master vlan 1 &> /dev/null
141 bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null
142}
143
99trap cleanup EXIT 144trap cleanup EXIT
100 145
101setup_prepare 146setup_prepare
diff --git a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
index 56cef3b1c194..bb10e33690b2 100755
--- a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
+++ b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
@@ -629,7 +629,7 @@ __test_ecn_decap()
629 RET=0 629 RET=0
630 630
631 tc filter add dev $h1 ingress pref 77 prot ip \ 631 tc filter add dev $h1 ingress pref 77 prot ip \
632 flower ip_tos $decapped_tos action pass 632 flower ip_tos $decapped_tos action drop
633 sleep 1 633 sleep 1
634 vxlan_encapped_ping_test v2 v1 192.0.2.17 \ 634 vxlan_encapped_ping_test v2 v1 192.0.2.17 \
635 $orig_inner_tos $orig_outer_tos \ 635 $orig_inner_tos $orig_outer_tos \
diff --git a/tools/testing/selftests/net/ip_defrag.c b/tools/testing/selftests/net/ip_defrag.c
index 61ae2782388e..5d56cc0838f6 100644
--- a/tools/testing/selftests/net/ip_defrag.c
+++ b/tools/testing/selftests/net/ip_defrag.c
@@ -203,6 +203,7 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
203{ 203{
204 struct ip *iphdr = (struct ip *)ip_frame; 204 struct ip *iphdr = (struct ip *)ip_frame;
205 struct ip6_hdr *ip6hdr = (struct ip6_hdr *)ip_frame; 205 struct ip6_hdr *ip6hdr = (struct ip6_hdr *)ip_frame;
206 const bool ipv4 = !ipv6;
206 int res; 207 int res;
207 int offset; 208 int offset;
208 int frag_len; 209 int frag_len;
@@ -239,19 +240,53 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
239 iphdr->ip_sum = 0; 240 iphdr->ip_sum = 0;
240 } 241 }
241 242
243 /* Occasionally test in-order fragments. */
244 if (!cfg_overlap && (rand() % 100 < 15)) {
245 offset = 0;
246 while (offset < (UDP_HLEN + payload_len)) {
247 send_fragment(fd_raw, addr, alen, offset, ipv6);
248 offset += max_frag_len;
249 }
250 return;
251 }
252
253 /* Occasionally test IPv4 "runs" (see net/ipv4/ip_fragment.c) */
254 if (ipv4 && !cfg_overlap && (rand() % 100 < 20) &&
255 (payload_len > 9 * max_frag_len)) {
256 offset = 6 * max_frag_len;
257 while (offset < (UDP_HLEN + payload_len)) {
258 send_fragment(fd_raw, addr, alen, offset, ipv6);
259 offset += max_frag_len;
260 }
261 offset = 3 * max_frag_len;
262 while (offset < 6 * max_frag_len) {
263 send_fragment(fd_raw, addr, alen, offset, ipv6);
264 offset += max_frag_len;
265 }
266 offset = 0;
267 while (offset < 3 * max_frag_len) {
268 send_fragment(fd_raw, addr, alen, offset, ipv6);
269 offset += max_frag_len;
270 }
271 return;
272 }
273
242 /* Odd fragments. */ 274 /* Odd fragments. */
243 offset = max_frag_len; 275 offset = max_frag_len;
244 while (offset < (UDP_HLEN + payload_len)) { 276 while (offset < (UDP_HLEN + payload_len)) {
245 send_fragment(fd_raw, addr, alen, offset, ipv6); 277 send_fragment(fd_raw, addr, alen, offset, ipv6);
278 /* IPv4 ignores duplicates, so randomly send a duplicate. */
279 if (ipv4 && (1 == rand() % 100))
280 send_fragment(fd_raw, addr, alen, offset, ipv6);
246 offset += 2 * max_frag_len; 281 offset += 2 * max_frag_len;
247 } 282 }
248 283
249 if (cfg_overlap) { 284 if (cfg_overlap) {
250 /* Send an extra random fragment. */ 285 /* Send an extra random fragment. */
251 offset = rand() % (UDP_HLEN + payload_len - 1);
252 /* sendto() returns EINVAL if offset + frag_len is too small. */
253 if (ipv6) { 286 if (ipv6) {
254 struct ip6_frag *fraghdr = (struct ip6_frag *)(ip_frame + IP6_HLEN); 287 struct ip6_frag *fraghdr = (struct ip6_frag *)(ip_frame + IP6_HLEN);
288 /* sendto() returns EINVAL if offset + frag_len is too small. */
289 offset = rand() % (UDP_HLEN + payload_len - 1);
255 frag_len = max_frag_len + rand() % 256; 290 frag_len = max_frag_len + rand() % 256;
256 /* In IPv6 if !!(frag_len % 8), the fragment is dropped. */ 291 /* In IPv6 if !!(frag_len % 8), the fragment is dropped. */
257 frag_len &= ~0x7; 292 frag_len &= ~0x7;
@@ -259,13 +294,29 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
259 ip6hdr->ip6_plen = htons(frag_len); 294 ip6hdr->ip6_plen = htons(frag_len);
260 frag_len += IP6_HLEN; 295 frag_len += IP6_HLEN;
261 } else { 296 } else {
262 frag_len = IP4_HLEN + UDP_HLEN + rand() % 256; 297 /* In IPv4, duplicates and some fragments completely inside
298 * previously sent fragments are dropped/ignored. So
299 * random offset and frag_len can result in a dropped
300 * fragment instead of a dropped queue/packet. So we
301 * hard-code offset and frag_len.
302 *
303 * See ade446403bfb ("net: ipv4: do not handle duplicate
304 * fragments as overlapping").
305 */
306 if (max_frag_len * 4 < payload_len || max_frag_len < 16) {
307 /* not enough payload to play with random offset and frag_len. */
308 offset = 8;
309 frag_len = IP4_HLEN + UDP_HLEN + max_frag_len;
310 } else {
311 offset = rand() % (payload_len / 2);
312 frag_len = 2 * max_frag_len + 1 + rand() % 256;
313 }
263 iphdr->ip_off = htons(offset / 8 | IP4_MF); 314 iphdr->ip_off = htons(offset / 8 | IP4_MF);
264 iphdr->ip_len = htons(frag_len); 315 iphdr->ip_len = htons(frag_len);
265 } 316 }
266 res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen); 317 res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
267 if (res < 0) 318 if (res < 0)
268 error(1, errno, "sendto overlap"); 319 error(1, errno, "sendto overlap: %d", frag_len);
269 if (res != frag_len) 320 if (res != frag_len)
270 error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len); 321 error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len);
271 frag_counter++; 322 frag_counter++;
@@ -275,6 +326,9 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
275 offset = 0; 326 offset = 0;
276 while (offset < (UDP_HLEN + payload_len)) { 327 while (offset < (UDP_HLEN + payload_len)) {
277 send_fragment(fd_raw, addr, alen, offset, ipv6); 328 send_fragment(fd_raw, addr, alen, offset, ipv6);
329 /* IPv4 ignores duplicates, so randomly send a duplicate. */
330 if (ipv4 && (1 == rand() % 100))
331 send_fragment(fd_raw, addr, alen, offset, ipv6);
278 offset += 2 * max_frag_len; 332 offset += 2 * max_frag_len;
279 } 333 }
280} 334}
@@ -282,7 +336,11 @@ static void send_udp_frags(int fd_raw, struct sockaddr *addr,
282static void run_test(struct sockaddr *addr, socklen_t alen, bool ipv6) 336static void run_test(struct sockaddr *addr, socklen_t alen, bool ipv6)
283{ 337{
284 int fd_tx_raw, fd_rx_udp; 338 int fd_tx_raw, fd_rx_udp;
285 struct timeval tv = { .tv_sec = 0, .tv_usec = 10 * 1000 }; 339 /* Frag queue timeout is set to one second in the calling script;
340 * socket timeout should be just a bit longer to avoid tests interfering
341 * with each other.
342 */
343 struct timeval tv = { .tv_sec = 1, .tv_usec = 10 };
286 int idx; 344 int idx;
287 int min_frag_len = ipv6 ? 1280 : 8; 345 int min_frag_len = ipv6 ? 1280 : 8;
288 346
@@ -308,12 +366,32 @@ static void run_test(struct sockaddr *addr, socklen_t alen, bool ipv6)
308 payload_len += (rand() % 4096)) { 366 payload_len += (rand() % 4096)) {
309 if (cfg_verbose) 367 if (cfg_verbose)
310 printf("payload_len: %d\n", payload_len); 368 printf("payload_len: %d\n", payload_len);
311 max_frag_len = min_frag_len; 369
312 do { 370 if (cfg_overlap) {
371 /* With overlaps, one send/receive pair below takes
372 * at least one second (== timeout) to run, so there
373 * is not enough test time to run a nested loop:
374 * the full overlap test takes 20-30 seconds.
375 */
376 max_frag_len = min_frag_len +
377 rand() % (1500 - FRAG_HLEN - min_frag_len);
313 send_udp_frags(fd_tx_raw, addr, alen, ipv6); 378 send_udp_frags(fd_tx_raw, addr, alen, ipv6);
314 recv_validate_udp(fd_rx_udp); 379 recv_validate_udp(fd_rx_udp);
315 max_frag_len += 8 * (rand() % 8); 380 } else {
316 } while (max_frag_len < (1500 - FRAG_HLEN) && max_frag_len <= payload_len); 381 /* Without overlaps, each packet reassembly (== one
382 * send/receive pair below) takes very little time to
383 * run, so we can easily afford more thourough testing
384 * with a nested loop: the full non-overlap test takes
385 * less than one second).
386 */
387 max_frag_len = min_frag_len;
388 do {
389 send_udp_frags(fd_tx_raw, addr, alen, ipv6);
390 recv_validate_udp(fd_rx_udp);
391 max_frag_len += 8 * (rand() % 8);
392 } while (max_frag_len < (1500 - FRAG_HLEN) &&
393 max_frag_len <= payload_len);
394 }
317 } 395 }
318 396
319 /* Cleanup. */ 397 /* Cleanup. */
diff --git a/tools/testing/selftests/net/ip_defrag.sh b/tools/testing/selftests/net/ip_defrag.sh
index f34672796044..7dd79a9efb17 100755
--- a/tools/testing/selftests/net/ip_defrag.sh
+++ b/tools/testing/selftests/net/ip_defrag.sh
@@ -11,10 +11,17 @@ readonly NETNS="ns-$(mktemp -u XXXXXX)"
11setup() { 11setup() {
12 ip netns add "${NETNS}" 12 ip netns add "${NETNS}"
13 ip -netns "${NETNS}" link set lo up 13 ip -netns "${NETNS}" link set lo up
14
14 ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_high_thresh=9000000 >/dev/null 2>&1 15 ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_high_thresh=9000000 >/dev/null 2>&1
15 ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_low_thresh=7000000 >/dev/null 2>&1 16 ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_low_thresh=7000000 >/dev/null 2>&1
17 ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_time=1 >/dev/null 2>&1
18
16 ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_high_thresh=9000000 >/dev/null 2>&1 19 ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_high_thresh=9000000 >/dev/null 2>&1
17 ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_low_thresh=7000000 >/dev/null 2>&1 20 ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_low_thresh=7000000 >/dev/null 2>&1
21 ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_time=1 >/dev/null 2>&1
22
23 # DST cache can get full with a lot of frags, with GC not keeping up with the test.
24 ip netns exec "${NETNS}" sysctl -w net.ipv6.route.max_size=65536 >/dev/null 2>&1
18} 25}
19 26
20cleanup() { 27cleanup() {
@@ -27,7 +34,6 @@ setup
27echo "ipv4 defrag" 34echo "ipv4 defrag"
28ip netns exec "${NETNS}" ./ip_defrag -4 35ip netns exec "${NETNS}" ./ip_defrag -4
29 36
30
31echo "ipv4 defrag with overlaps" 37echo "ipv4 defrag with overlaps"
32ip netns exec "${NETNS}" ./ip_defrag -4o 38ip netns exec "${NETNS}" ./ip_defrag -4o
33 39
@@ -37,3 +43,4 @@ ip netns exec "${NETNS}" ./ip_defrag -6
37echo "ipv6 defrag with overlaps" 43echo "ipv6 defrag with overlaps"
38ip netns exec "${NETNS}" ./ip_defrag -6o 44ip netns exec "${NETNS}" ./ip_defrag -6o
39 45
46echo "all tests done"
diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh
index 8db35b99457c..71d7fdc513c1 100755
--- a/tools/testing/selftests/net/xfrm_policy.sh
+++ b/tools/testing/selftests/net/xfrm_policy.sh
@@ -28,6 +28,19 @@ KEY_AES=0x0123456789abcdef0123456789012345
28SPI1=0x1 28SPI1=0x1
29SPI2=0x2 29SPI2=0x2
30 30
31do_esp_policy() {
32 local ns=$1
33 local me=$2
34 local remote=$3
35 local lnet=$4
36 local rnet=$5
37
38 # to encrypt packets as they go out (includes forwarded packets that need encapsulation)
39 ip -net $ns xfrm policy add src $lnet dst $rnet dir out tmpl src $me dst $remote proto esp mode tunnel priority 100 action allow
40 # to fwd decrypted packets after esp processing:
41 ip -net $ns xfrm policy add src $rnet dst $lnet dir fwd tmpl src $remote dst $me proto esp mode tunnel priority 100 action allow
42}
43
31do_esp() { 44do_esp() {
32 local ns=$1 45 local ns=$1
33 local me=$2 46 local me=$2
@@ -40,10 +53,59 @@ do_esp() {
40 ip -net $ns xfrm state add src $remote dst $me proto esp spi $spi_in enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $rnet dst $lnet 53 ip -net $ns xfrm state add src $remote dst $me proto esp spi $spi_in enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $rnet dst $lnet
41 ip -net $ns xfrm state add src $me dst $remote proto esp spi $spi_out enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $lnet dst $rnet 54 ip -net $ns xfrm state add src $me dst $remote proto esp spi $spi_out enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $lnet dst $rnet
42 55
43 # to encrypt packets as they go out (includes forwarded packets that need encapsulation) 56 do_esp_policy $ns $me $remote $lnet $rnet
44 ip -net $ns xfrm policy add src $lnet dst $rnet dir out tmpl src $me dst $remote proto esp mode tunnel priority 100 action allow 57}
45 # to fwd decrypted packets after esp processing: 58
46 ip -net $ns xfrm policy add src $rnet dst $lnet dir fwd tmpl src $remote dst $me proto esp mode tunnel priority 100 action allow 59# add policies with different netmasks, to make sure kernel carries
60# the policies contained within new netmask over when search tree is
61# re-built.
62# peer netns that are supposed to be encapsulated via esp have addresses
63# in the 10.0.1.0/24 and 10.0.2.0/24 subnets, respectively.
64#
65# Adding a policy for '10.0.1.0/23' will make it necessary to
66# alter the prefix of 10.0.1.0 subnet.
67# In case new prefix overlaps with existing node, the node and all
68# policies it carries need to be merged with the existing one(s).
69#
70# Do that here.
71do_overlap()
72{
73 local ns=$1
74
75 # adds new nodes to tree (neither network exists yet in policy database).
76 ip -net $ns xfrm policy add src 10.1.0.0/24 dst 10.0.0.0/24 dir fwd priority 200 action block
77
78 # adds a new node in the 10.0.0.0/24 tree (dst node exists).
79 ip -net $ns xfrm policy add src 10.2.0.0/24 dst 10.0.0.0/24 dir fwd priority 200 action block
80
81 # adds a 10.2.0.0/23 node, but for different dst.
82 ip -net $ns xfrm policy add src 10.2.0.0/23 dst 10.0.1.0/24 dir fwd priority 200 action block
83
84 # dst now overlaps with the 10.0.1.0/24 ESP policy in fwd.
85 # kernel must 'promote' existing one (10.0.0.0/24) to 10.0.0.0/23.
86 # But 10.0.0.0/23 also includes existing 10.0.1.0/24, so that node
87 # also has to be merged too, including source-sorted subtrees.
88 # old:
89 # 10.0.0.0/24 (node 1 in dst tree of the bin)
90 # 10.1.0.0/24 (node in src tree of dst node 1)
91 # 10.2.0.0/24 (node in src tree of dst node 1)
92 # 10.0.1.0/24 (node 2 in dst tree of the bin)
93 # 10.0.2.0/24 (node in src tree of dst node 2)
94 # 10.2.0.0/24 (node in src tree of dst node 2)
95 #
96 # The next 'policy add' adds dst '10.0.0.0/23', which means
97 # that dst node 1 and dst node 2 have to be merged including
98 # the sub-tree. As no duplicates are allowed, policies in
99 # the two '10.0.2.0/24' are also merged.
100 #
101 # after the 'add', internal search tree should look like this:
102 # 10.0.0.0/23 (node in dst tree of bin)
103 # 10.0.2.0/24 (node in src tree of dst node)
104 # 10.1.0.0/24 (node in src tree of dst node)
105 # 10.2.0.0/24 (node in src tree of dst node)
106 #
107 # 10.0.0.0/24 and 10.0.1.0/24 nodes have been merged as 10.0.0.0/23.
108 ip -net $ns xfrm policy add src 10.1.0.0/24 dst 10.0.0.0/23 dir fwd priority 200 action block
47} 109}
48 110
49do_esp_policy_get_check() { 111do_esp_policy_get_check() {
@@ -160,6 +222,41 @@ check_xfrm() {
160 return $lret 222 return $lret
161} 223}
162 224
225check_exceptions()
226{
227 logpostfix="$1"
228 local lret=0
229
230 # ping to .254 should be excluded from the tunnel (exception is in place).
231 check_xfrm 0 254
232 if [ $? -ne 0 ]; then
233 echo "FAIL: expected ping to .254 to fail ($logpostfix)"
234 lret=1
235 else
236 echo "PASS: ping to .254 bypassed ipsec tunnel ($logpostfix)"
237 fi
238
239 # ping to .253 should use use ipsec due to direct policy exception.
240 check_xfrm 1 253
241 if [ $? -ne 0 ]; then
242 echo "FAIL: expected ping to .253 to use ipsec tunnel ($logpostfix)"
243 lret=1
244 else
245 echo "PASS: direct policy matches ($logpostfix)"
246 fi
247
248 # ping to .2 should use ipsec.
249 check_xfrm 1 2
250 if [ $? -ne 0 ]; then
251 echo "FAIL: expected ping to .2 to use ipsec tunnel ($logpostfix)"
252 lret=1
253 else
254 echo "PASS: policy matches ($logpostfix)"
255 fi
256
257 return $lret
258}
259
163#check for needed privileges 260#check for needed privileges
164if [ "$(id -u)" -ne 0 ];then 261if [ "$(id -u)" -ne 0 ];then
165 echo "SKIP: Need root privileges" 262 echo "SKIP: Need root privileges"
@@ -270,33 +367,45 @@ do_exception ns4 10.0.3.10 10.0.3.1 10.0.1.253 10.0.1.240/28
270do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96 367do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96
271do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96 368do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96
272 369
273# ping to .254 should now be excluded from the tunnel 370check_exceptions "exceptions"
274check_xfrm 0 254
275if [ $? -ne 0 ]; then 371if [ $? -ne 0 ]; then
276 echo "FAIL: expected ping to .254 to fail"
277 ret=1 372 ret=1
278else
279 echo "PASS: ping to .254 bypassed ipsec tunnel"
280fi 373fi
281 374
282# ping to .253 should use use ipsec due to direct policy exception. 375# insert block policies with adjacent/overlapping netmasks
283check_xfrm 1 253 376do_overlap ns3
284if [ $? -ne 0 ]; then
285 echo "FAIL: expected ping to .253 to use ipsec tunnel"
286 ret=1
287else
288 echo "PASS: direct policy matches"
289fi
290 377
291# ping to .2 should use ipsec. 378check_exceptions "exceptions and block policies"
292check_xfrm 1 2
293if [ $? -ne 0 ]; then 379if [ $? -ne 0 ]; then
294 echo "FAIL: expected ping to .2 to use ipsec tunnel"
295 ret=1 380 ret=1
296else
297 echo "PASS: policy matches"
298fi 381fi
299 382
383for n in ns3 ns4;do
384 ip -net $n xfrm policy set hthresh4 28 24 hthresh6 126 125
385 sleep $((RANDOM%5))
386done
387
388check_exceptions "exceptions and block policies after hresh changes"
389
390# full flush of policy db, check everything gets freed incl. internal meta data
391ip -net ns3 xfrm policy flush
392
393do_esp_policy ns3 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24
394do_exception ns3 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28
395
396# move inexact policies to hash table
397ip -net ns3 xfrm policy set hthresh4 16 16
398
399sleep $((RANDOM%5))
400check_exceptions "exceptions and block policies after hthresh change in ns3"
401
402# restore original hthresh settings -- move policies back to tables
403for n in ns3 ns4;do
404 ip -net $n xfrm policy set hthresh4 32 32 hthresh6 128 128
405 sleep $((RANDOM%5))
406done
407check_exceptions "exceptions and block policies after hresh change to normal"
408
300for i in 1 2 3 4;do ip netns del ns$i;done 409for i in 1 2 3 4;do ip netns del ns$i;done
301 410
302exit $ret 411exit $ret
diff --git a/tools/testing/selftests/netfilter/Makefile b/tools/testing/selftests/netfilter/Makefile
index 47ed6cef93fb..c9ff2b47bd1c 100644
--- a/tools/testing/selftests/netfilter/Makefile
+++ b/tools/testing/selftests/netfilter/Makefile
@@ -1,6 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2# Makefile for netfilter selftests 2# Makefile for netfilter selftests
3 3
4TEST_PROGS := nft_trans_stress.sh 4TEST_PROGS := nft_trans_stress.sh nft_nat.sh
5 5
6include ../lib.mk 6include ../lib.mk
diff --git a/tools/testing/selftests/netfilter/config b/tools/testing/selftests/netfilter/config
index 1017313e41a8..59caa8f71cd8 100644
--- a/tools/testing/selftests/netfilter/config
+++ b/tools/testing/selftests/netfilter/config
@@ -1,2 +1,2 @@
1CONFIG_NET_NS=y 1CONFIG_NET_NS=y
2NF_TABLES_INET=y 2CONFIG_NF_TABLES_INET=y
diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
new file mode 100755
index 000000000000..8ec76681605c
--- /dev/null
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -0,0 +1,762 @@
1#!/bin/bash
2#
3# This test is for basic NAT functionality: snat, dnat, redirect, masquerade.
4#
5
6# Kselftest framework requirement - SKIP code is 4.
7ksft_skip=4
8ret=0
9
10nft --version > /dev/null 2>&1
11if [ $? -ne 0 ];then
12 echo "SKIP: Could not run test without nft tool"
13 exit $ksft_skip
14fi
15
16ip -Version > /dev/null 2>&1
17if [ $? -ne 0 ];then
18 echo "SKIP: Could not run test without ip tool"
19 exit $ksft_skip
20fi
21
22ip netns add ns0
23ip netns add ns1
24ip netns add ns2
25
26ip link add veth0 netns ns0 type veth peer name eth0 netns ns1
27ip link add veth1 netns ns0 type veth peer name eth0 netns ns2
28
29ip -net ns0 link set lo up
30ip -net ns0 link set veth0 up
31ip -net ns0 addr add 10.0.1.1/24 dev veth0
32ip -net ns0 addr add dead:1::1/64 dev veth0
33
34ip -net ns0 link set veth1 up
35ip -net ns0 addr add 10.0.2.1/24 dev veth1
36ip -net ns0 addr add dead:2::1/64 dev veth1
37
38for i in 1 2; do
39 ip -net ns$i link set lo up
40 ip -net ns$i link set eth0 up
41 ip -net ns$i addr add 10.0.$i.99/24 dev eth0
42 ip -net ns$i route add default via 10.0.$i.1
43 ip -net ns$i addr add dead:$i::99/64 dev eth0
44 ip -net ns$i route add default via dead:$i::1
45done
46
47bad_counter()
48{
49 local ns=$1
50 local counter=$2
51 local expect=$3
52
53 echo "ERROR: $counter counter in $ns has unexpected value (expected $expect)" 1>&2
54 ip netns exec $ns nft list counter inet filter $counter 1>&2
55}
56
57check_counters()
58{
59 ns=$1
60 local lret=0
61
62 cnt=$(ip netns exec $ns nft list counter inet filter ns0in | grep -q "packets 1 bytes 84")
63 if [ $? -ne 0 ]; then
64 bad_counter $ns ns0in "packets 1 bytes 84"
65 lret=1
66 fi
67 cnt=$(ip netns exec $ns nft list counter inet filter ns0out | grep -q "packets 1 bytes 84")
68 if [ $? -ne 0 ]; then
69 bad_counter $ns ns0out "packets 1 bytes 84"
70 lret=1
71 fi
72
73 expect="packets 1 bytes 104"
74 cnt=$(ip netns exec $ns nft list counter inet filter ns0in6 | grep -q "$expect")
75 if [ $? -ne 0 ]; then
76 bad_counter $ns ns0in6 "$expect"
77 lret=1
78 fi
79 cnt=$(ip netns exec $ns nft list counter inet filter ns0out6 | grep -q "$expect")
80 if [ $? -ne 0 ]; then
81 bad_counter $ns ns0out6 "$expect"
82 lret=1
83 fi
84
85 return $lret
86}
87
88check_ns0_counters()
89{
90 local ns=$1
91 local lret=0
92
93 cnt=$(ip netns exec ns0 nft list counter inet filter ns0in | grep -q "packets 0 bytes 0")
94 if [ $? -ne 0 ]; then
95 bad_counter ns0 ns0in "packets 0 bytes 0"
96 lret=1
97 fi
98
99 cnt=$(ip netns exec ns0 nft list counter inet filter ns0in6 | grep -q "packets 0 bytes 0")
100 if [ $? -ne 0 ]; then
101 bad_counter ns0 ns0in6 "packets 0 bytes 0"
102 lret=1
103 fi
104
105 cnt=$(ip netns exec ns0 nft list counter inet filter ns0out | grep -q "packets 0 bytes 0")
106 if [ $? -ne 0 ]; then
107 bad_counter ns0 ns0out "packets 0 bytes 0"
108 lret=1
109 fi
110 cnt=$(ip netns exec ns0 nft list counter inet filter ns0out6 | grep -q "packets 0 bytes 0")
111 if [ $? -ne 0 ]; then
112 bad_counter ns0 ns0out6 "packets 0 bytes 0"
113 lret=1
114 fi
115
116 for dir in "in" "out" ; do
117 expect="packets 1 bytes 84"
118 cnt=$(ip netns exec ns0 nft list counter inet filter ${ns}${dir} | grep -q "$expect")
119 if [ $? -ne 0 ]; then
120 bad_counter ns0 $ns$dir "$expect"
121 lret=1
122 fi
123
124 expect="packets 1 bytes 104"
125 cnt=$(ip netns exec ns0 nft list counter inet filter ${ns}${dir}6 | grep -q "$expect")
126 if [ $? -ne 0 ]; then
127 bad_counter ns0 $ns$dir6 "$expect"
128 lret=1
129 fi
130 done
131
132 return $lret
133}
134
135reset_counters()
136{
137 for i in 0 1 2;do
138 ip netns exec ns$i nft reset counters inet > /dev/null
139 done
140}
141
142test_local_dnat6()
143{
144 local lret=0
145ip netns exec ns0 nft -f - <<EOF
146table ip6 nat {
147 chain output {
148 type nat hook output priority 0; policy accept;
149 ip6 daddr dead:1::99 dnat to dead:2::99
150 }
151}
152EOF
153 if [ $? -ne 0 ]; then
154 echo "SKIP: Could not add add ip6 dnat hook"
155 return $ksft_skip
156 fi
157
158 # ping netns1, expect rewrite to netns2
159 ip netns exec ns0 ping -q -c 1 dead:1::99 > /dev/null
160 if [ $? -ne 0 ]; then
161 lret=1
162 echo "ERROR: ping6 failed"
163 return $lret
164 fi
165
166 expect="packets 0 bytes 0"
167 for dir in "in6" "out6" ; do
168 cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
169 if [ $? -ne 0 ]; then
170 bad_counter ns0 ns1$dir "$expect"
171 lret=1
172 fi
173 done
174
175 expect="packets 1 bytes 104"
176 for dir in "in6" "out6" ; do
177 cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
178 if [ $? -ne 0 ]; then
179 bad_counter ns0 ns2$dir "$expect"
180 lret=1
181 fi
182 done
183
184 # expect 0 count in ns1
185 expect="packets 0 bytes 0"
186 for dir in "in6" "out6" ; do
187 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
188 if [ $? -ne 0 ]; then
189 bad_counter ns1 ns0$dir "$expect"
190 lret=1
191 fi
192 done
193
194 # expect 1 packet in ns2
195 expect="packets 1 bytes 104"
196 for dir in "in6" "out6" ; do
197 cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
198 if [ $? -ne 0 ]; then
199 bad_counter ns2 ns0$dir "$expect"
200 lret=1
201 fi
202 done
203
204 test $lret -eq 0 && echo "PASS: ipv6 ping to ns1 was NATted to ns2"
205 ip netns exec ns0 nft flush chain ip6 nat output
206
207 return $lret
208}
209
210test_local_dnat()
211{
212 local lret=0
213ip netns exec ns0 nft -f - <<EOF
214table ip nat {
215 chain output {
216 type nat hook output priority 0; policy accept;
217 ip daddr 10.0.1.99 dnat to 10.0.2.99
218 }
219}
220EOF
221 # ping netns1, expect rewrite to netns2
222 ip netns exec ns0 ping -q -c 1 10.0.1.99 > /dev/null
223 if [ $? -ne 0 ]; then
224 lret=1
225 echo "ERROR: ping failed"
226 return $lret
227 fi
228
229 expect="packets 0 bytes 0"
230 for dir in "in" "out" ; do
231 cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
232 if [ $? -ne 0 ]; then
233 bad_counter ns0 ns1$dir "$expect"
234 lret=1
235 fi
236 done
237
238 expect="packets 1 bytes 84"
239 for dir in "in" "out" ; do
240 cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
241 if [ $? -ne 0 ]; then
242 bad_counter ns0 ns2$dir "$expect"
243 lret=1
244 fi
245 done
246
247 # expect 0 count in ns1
248 expect="packets 0 bytes 0"
249 for dir in "in" "out" ; do
250 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
251 if [ $? -ne 0 ]; then
252 bad_counter ns1 ns0$dir "$expect"
253 lret=1
254 fi
255 done
256
257 # expect 1 packet in ns2
258 expect="packets 1 bytes 84"
259 for dir in "in" "out" ; do
260 cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
261 if [ $? -ne 0 ]; then
262 bad_counter ns2 ns0$dir "$expect"
263 lret=1
264 fi
265 done
266
267 test $lret -eq 0 && echo "PASS: ping to ns1 was NATted to ns2"
268
269 ip netns exec ns0 nft flush chain ip nat output
270
271 reset_counters
272 ip netns exec ns0 ping -q -c 1 10.0.1.99 > /dev/null
273 if [ $? -ne 0 ]; then
274 lret=1
275 echo "ERROR: ping failed"
276 return $lret
277 fi
278
279 expect="packets 1 bytes 84"
280 for dir in "in" "out" ; do
281 cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
282 if [ $? -ne 0 ]; then
283 bad_counter ns1 ns1$dir "$expect"
284 lret=1
285 fi
286 done
287 expect="packets 0 bytes 0"
288 for dir in "in" "out" ; do
289 cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
290 if [ $? -ne 0 ]; then
291 bad_counter ns0 ns2$dir "$expect"
292 lret=1
293 fi
294 done
295
296 # expect 1 count in ns1
297 expect="packets 1 bytes 84"
298 for dir in "in" "out" ; do
299 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
300 if [ $? -ne 0 ]; then
301 bad_counter ns0 ns0$dir "$expect"
302 lret=1
303 fi
304 done
305
306 # expect 0 packet in ns2
307 expect="packets 0 bytes 0"
308 for dir in "in" "out" ; do
309 cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
310 if [ $? -ne 0 ]; then
311 bad_counter ns2 ns2$dir "$expect"
312 lret=1
313 fi
314 done
315
316 test $lret -eq 0 && echo "PASS: ping to ns1 OK after nat output chain flush"
317
318 return $lret
319}
320
321
322test_masquerade6()
323{
324 local lret=0
325
326 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
327
328 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
329 if [ $? -ne 0 ] ; then
330 echo "ERROR: cannot ping ns1 from ns2 via ipv6"
331 return 1
332 lret=1
333 fi
334
335 expect="packets 1 bytes 104"
336 for dir in "in6" "out6" ; do
337 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
338 if [ $? -ne 0 ]; then
339 bad_counter ns1 ns2$dir "$expect"
340 lret=1
341 fi
342
343 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
344 if [ $? -ne 0 ]; then
345 bad_counter ns2 ns1$dir "$expect"
346 lret=1
347 fi
348 done
349
350 reset_counters
351
352# add masquerading rule
353ip netns exec ns0 nft -f - <<EOF
354table ip6 nat {
355 chain postrouting {
356 type nat hook postrouting priority 0; policy accept;
357 meta oif veth0 masquerade
358 }
359}
360EOF
361 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
362 if [ $? -ne 0 ] ; then
363 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerading"
364 lret=1
365 fi
366
367 # ns1 should have seen packets from ns0, due to masquerade
368 expect="packets 1 bytes 104"
369 for dir in "in6" "out6" ; do
370
371 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
372 if [ $? -ne 0 ]; then
373 bad_counter ns1 ns0$dir "$expect"
374 lret=1
375 fi
376
377 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
378 if [ $? -ne 0 ]; then
379 bad_counter ns2 ns1$dir "$expect"
380 lret=1
381 fi
382 done
383
384 # ns1 should not have seen packets from ns2, due to masquerade
385 expect="packets 0 bytes 0"
386 for dir in "in6" "out6" ; do
387 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
388 if [ $? -ne 0 ]; then
389 bad_counter ns1 ns0$dir "$expect"
390 lret=1
391 fi
392
393 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
394 if [ $? -ne 0 ]; then
395 bad_counter ns2 ns1$dir "$expect"
396 lret=1
397 fi
398 done
399
400 ip netns exec ns0 nft flush chain ip6 nat postrouting
401 if [ $? -ne 0 ]; then
402 echo "ERROR: Could not flush ip6 nat postrouting" 1>&2
403 lret=1
404 fi
405
406 test $lret -eq 0 && echo "PASS: IPv6 masquerade for ns2"
407
408 return $lret
409}
410
411test_masquerade()
412{
413 local lret=0
414
415 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
416 ip netns exec ns0 sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
417
418 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
419 if [ $? -ne 0 ] ; then
420 echo "ERROR: canot ping ns1 from ns2"
421 lret=1
422 fi
423
424 expect="packets 1 bytes 84"
425 for dir in "in" "out" ; do
426 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
427 if [ $? -ne 0 ]; then
428 bad_counter ns1 ns2$dir "$expect"
429 lret=1
430 fi
431
432 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
433 if [ $? -ne 0 ]; then
434 bad_counter ns2 ns1$dir "$expect"
435 lret=1
436 fi
437 done
438
439 reset_counters
440
441# add masquerading rule
442ip netns exec ns0 nft -f - <<EOF
443table ip nat {
444 chain postrouting {
445 type nat hook postrouting priority 0; policy accept;
446 meta oif veth0 masquerade
447 }
448}
449EOF
450 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
451 if [ $? -ne 0 ] ; then
452 echo "ERROR: cannot ping ns1 from ns2 with active ip masquerading"
453 lret=1
454 fi
455
456 # ns1 should have seen packets from ns0, due to masquerade
457 expect="packets 1 bytes 84"
458 for dir in "in" "out" ; do
459 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
460 if [ $? -ne 0 ]; then
461 bad_counter ns1 ns0$dir "$expect"
462 lret=1
463 fi
464
465 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
466 if [ $? -ne 0 ]; then
467 bad_counter ns2 ns1$dir "$expect"
468 lret=1
469 fi
470 done
471
472 # ns1 should not have seen packets from ns2, due to masquerade
473 expect="packets 0 bytes 0"
474 for dir in "in" "out" ; do
475 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
476 if [ $? -ne 0 ]; then
477 bad_counter ns1 ns0$dir "$expect"
478 lret=1
479 fi
480
481 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
482 if [ $? -ne 0 ]; then
483 bad_counter ns2 ns1$dir "$expect"
484 lret=1
485 fi
486 done
487
488 ip netns exec ns0 nft flush chain ip nat postrouting
489 if [ $? -ne 0 ]; then
490 echo "ERROR: Could not flush nat postrouting" 1>&2
491 lret=1
492 fi
493
494 test $lret -eq 0 && echo "PASS: IP masquerade for ns2"
495
496 return $lret
497}
498
499test_redirect6()
500{
501 local lret=0
502
503 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
504
505 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
506 if [ $? -ne 0 ] ; then
507 echo "ERROR: cannnot ping ns1 from ns2 via ipv6"
508 lret=1
509 fi
510
511 expect="packets 1 bytes 104"
512 for dir in "in6" "out6" ; do
513 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
514 if [ $? -ne 0 ]; then
515 bad_counter ns1 ns2$dir "$expect"
516 lret=1
517 fi
518
519 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
520 if [ $? -ne 0 ]; then
521 bad_counter ns2 ns1$dir "$expect"
522 lret=1
523 fi
524 done
525
526 reset_counters
527
528# add redirect rule
529ip netns exec ns0 nft -f - <<EOF
530table ip6 nat {
531 chain prerouting {
532 type nat hook prerouting priority 0; policy accept;
533 meta iif veth1 meta l4proto icmpv6 ip6 saddr dead:2::99 ip6 daddr dead:1::99 redirect
534 }
535}
536EOF
537 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
538 if [ $? -ne 0 ] ; then
539 echo "ERROR: cannot ping ns1 from ns2 with active ip6 redirect"
540 lret=1
541 fi
542
543 # ns1 should have seen no packets from ns2, due to redirection
544 expect="packets 0 bytes 0"
545 for dir in "in6" "out6" ; do
546 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
547 if [ $? -ne 0 ]; then
548 bad_counter ns1 ns0$dir "$expect"
549 lret=1
550 fi
551 done
552
553 # ns0 should have seen packets from ns2, due to masquerade
554 expect="packets 1 bytes 104"
555 for dir in "in6" "out6" ; do
556 cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
557 if [ $? -ne 0 ]; then
558 bad_counter ns1 ns0$dir "$expect"
559 lret=1
560 fi
561 done
562
563 ip netns exec ns0 nft delete table ip6 nat
564 if [ $? -ne 0 ]; then
565 echo "ERROR: Could not delete ip6 nat table" 1>&2
566 lret=1
567 fi
568
569 test $lret -eq 0 && echo "PASS: IPv6 redirection for ns2"
570
571 return $lret
572}
573
574test_redirect()
575{
576 local lret=0
577
578 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
579 ip netns exec ns0 sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
580
581 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
582 if [ $? -ne 0 ] ; then
583 echo "ERROR: cannot ping ns1 from ns2"
584 lret=1
585 fi
586
587 expect="packets 1 bytes 84"
588 for dir in "in" "out" ; do
589 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
590 if [ $? -ne 0 ]; then
591 bad_counter ns1 ns2$dir "$expect"
592 lret=1
593 fi
594
595 cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
596 if [ $? -ne 0 ]; then
597 bad_counter ns2 ns1$dir "$expect"
598 lret=1
599 fi
600 done
601
602 reset_counters
603
604# add redirect rule
605ip netns exec ns0 nft -f - <<EOF
606table ip nat {
607 chain prerouting {
608 type nat hook prerouting priority 0; policy accept;
609 meta iif veth1 ip protocol icmp ip saddr 10.0.2.99 ip daddr 10.0.1.99 redirect
610 }
611}
612EOF
613 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
614 if [ $? -ne 0 ] ; then
615 echo "ERROR: cannot ping ns1 from ns2 with active ip redirect"
616 lret=1
617 fi
618
619 # ns1 should have seen no packets from ns2, due to redirection
620 expect="packets 0 bytes 0"
621 for dir in "in" "out" ; do
622
623 cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
624 if [ $? -ne 0 ]; then
625 bad_counter ns1 ns0$dir "$expect"
626 lret=1
627 fi
628 done
629
630 # ns0 should have seen packets from ns2, due to masquerade
631 expect="packets 1 bytes 84"
632 for dir in "in" "out" ; do
633 cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
634 if [ $? -ne 0 ]; then
635 bad_counter ns1 ns0$dir "$expect"
636 lret=1
637 fi
638 done
639
640 ip netns exec ns0 nft delete table ip nat
641 if [ $? -ne 0 ]; then
642 echo "ERROR: Could not delete nat table" 1>&2
643 lret=1
644 fi
645
646 test $lret -eq 0 && echo "PASS: IP redirection for ns2"
647
648 return $lret
649}
650
651
652# ip netns exec ns0 ping -c 1 -q 10.0.$i.99
653for i in 0 1 2; do
654ip netns exec ns$i nft -f - <<EOF
655table inet filter {
656 counter ns0in {}
657 counter ns1in {}
658 counter ns2in {}
659
660 counter ns0out {}
661 counter ns1out {}
662 counter ns2out {}
663
664 counter ns0in6 {}
665 counter ns1in6 {}
666 counter ns2in6 {}
667
668 counter ns0out6 {}
669 counter ns1out6 {}
670 counter ns2out6 {}
671
672 map nsincounter {
673 type ipv4_addr : counter
674 elements = { 10.0.1.1 : "ns0in",
675 10.0.2.1 : "ns0in",
676 10.0.1.99 : "ns1in",
677 10.0.2.99 : "ns2in" }
678 }
679
680 map nsincounter6 {
681 type ipv6_addr : counter
682 elements = { dead:1::1 : "ns0in6",
683 dead:2::1 : "ns0in6",
684 dead:1::99 : "ns1in6",
685 dead:2::99 : "ns2in6" }
686 }
687
688 map nsoutcounter {
689 type ipv4_addr : counter
690 elements = { 10.0.1.1 : "ns0out",
691 10.0.2.1 : "ns0out",
692 10.0.1.99: "ns1out",
693 10.0.2.99: "ns2out" }
694 }
695
696 map nsoutcounter6 {
697 type ipv6_addr : counter
698 elements = { dead:1::1 : "ns0out6",
699 dead:2::1 : "ns0out6",
700 dead:1::99 : "ns1out6",
701 dead:2::99 : "ns2out6" }
702 }
703
704 chain input {
705 type filter hook input priority 0; policy accept;
706 counter name ip saddr map @nsincounter
707 icmpv6 type { "echo-request", "echo-reply" } counter name ip6 saddr map @nsincounter6
708 }
709 chain output {
710 type filter hook output priority 0; policy accept;
711 counter name ip daddr map @nsoutcounter
712 icmpv6 type { "echo-request", "echo-reply" } counter name ip6 daddr map @nsoutcounter6
713 }
714}
715EOF
716done
717
718sleep 3
719# test basic connectivity
720for i in 1 2; do
721 ip netns exec ns0 ping -c 1 -q 10.0.$i.99 > /dev/null
722 if [ $? -ne 0 ];then
723 echo "ERROR: Could not reach other namespace(s)" 1>&2
724 ret=1
725 fi
726
727 ip netns exec ns0 ping -c 1 -q dead:$i::99 > /dev/null
728 if [ $? -ne 0 ];then
729 echo "ERROR: Could not reach other namespace(s) via ipv6" 1>&2
730 ret=1
731 fi
732 check_counters ns$i
733 if [ $? -ne 0 ]; then
734 ret=1
735 fi
736
737 check_ns0_counters ns$i
738 if [ $? -ne 0 ]; then
739 ret=1
740 fi
741 reset_counters
742done
743
744if [ $ret -eq 0 ];then
745 echo "PASS: netns routing/connectivity: ns0 can reach ns1 and ns2"
746fi
747
748reset_counters
749test_local_dnat
750test_local_dnat6
751
752reset_counters
753test_masquerade
754test_masquerade6
755
756reset_counters
757test_redirect
758test_redirect6
759
760for i in 0 1 2; do ip netns del ns$i;done
761
762exit $ret
diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile
index 9050eeea5f5f..1de8bd8ccf5d 100644
--- a/tools/testing/selftests/networking/timestamping/Makefile
+++ b/tools/testing/selftests/networking/timestamping/Makefile
@@ -9,6 +9,3 @@ all: $(TEST_PROGS)
9top_srcdir = ../../../../.. 9top_srcdir = ../../../../..
10KSFT_KHDR_INSTALL := 1 10KSFT_KHDR_INSTALL := 1
11include ../../lib.mk 11include ../../lib.mk
12
13clean:
14 rm -fr $(TEST_GEN_FILES)
diff --git a/tools/testing/selftests/networking/timestamping/txtimestamp.c b/tools/testing/selftests/networking/timestamping/txtimestamp.c
index 2e563d17cf0c..d1bbafb16f47 100644
--- a/tools/testing/selftests/networking/timestamping/txtimestamp.c
+++ b/tools/testing/selftests/networking/timestamping/txtimestamp.c
@@ -240,7 +240,7 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int payload_len)
240 cm->cmsg_type == IP_RECVERR) || 240 cm->cmsg_type == IP_RECVERR) ||
241 (cm->cmsg_level == SOL_IPV6 && 241 (cm->cmsg_level == SOL_IPV6 &&
242 cm->cmsg_type == IPV6_RECVERR) || 242 cm->cmsg_type == IPV6_RECVERR) ||
243 (cm->cmsg_level = SOL_PACKET && 243 (cm->cmsg_level == SOL_PACKET &&
244 cm->cmsg_type == PACKET_TX_TIMESTAMP)) { 244 cm->cmsg_type == PACKET_TX_TIMESTAMP)) {
245 serr = (void *) CMSG_DATA(cm); 245 serr = (void *) CMSG_DATA(cm);
246 if (serr->ee_errno != ENOMSG || 246 if (serr->ee_errno != ENOMSG ||
diff --git a/tools/testing/selftests/proc/.gitignore b/tools/testing/selftests/proc/.gitignore
index 82121a81681f..29bac5ef9a93 100644
--- a/tools/testing/selftests/proc/.gitignore
+++ b/tools/testing/selftests/proc/.gitignore
@@ -10,4 +10,5 @@
10/proc-uptime-002 10/proc-uptime-002
11/read 11/read
12/self 12/self
13/setns-dcache
13/thread-self 14/thread-self
diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
index 1c12c34cf85d..434d033ee067 100644
--- a/tools/testing/selftests/proc/Makefile
+++ b/tools/testing/selftests/proc/Makefile
@@ -14,6 +14,7 @@ TEST_GEN_PROGS += proc-uptime-001
14TEST_GEN_PROGS += proc-uptime-002 14TEST_GEN_PROGS += proc-uptime-002
15TEST_GEN_PROGS += read 15TEST_GEN_PROGS += read
16TEST_GEN_PROGS += self 16TEST_GEN_PROGS += self
17TEST_GEN_PROGS += setns-dcache
17TEST_GEN_PROGS += thread-self 18TEST_GEN_PROGS += thread-self
18 19
19include ../lib.mk 20include ../lib.mk
diff --git a/tools/testing/selftests/proc/setns-dcache.c b/tools/testing/selftests/proc/setns-dcache.c
new file mode 100644
index 000000000000..60ab197a73fc
--- /dev/null
+++ b/tools/testing/selftests/proc/setns-dcache.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright © 2019 Alexey Dobriyan <adobriyan@gmail.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16/*
17 * Test that setns(CLONE_NEWNET) points to new /proc/net content even
18 * if old one is in dcache.
19 *
20 * FIXME /proc/net/unix is under CONFIG_UNIX which can be disabled.
21 */
22#undef NDEBUG
23#include <assert.h>
24#include <errno.h>
25#include <sched.h>
26#include <signal.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <unistd.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <fcntl.h>
34#include <sys/socket.h>
35
36static pid_t pid = -1;
37
38static void f(void)
39{
40 if (pid > 0) {
41 kill(pid, SIGTERM);
42 }
43}
44
45int main(void)
46{
47 int fd[2];
48 char _ = 0;
49 int nsfd;
50
51 atexit(f);
52
53 /* Check for priviledges and syscall availability straight away. */
54 if (unshare(CLONE_NEWNET) == -1) {
55 if (errno == ENOSYS || errno == EPERM) {
56 return 4;
57 }
58 return 1;
59 }
60 /* Distinguisher between two otherwise empty net namespaces. */
61 if (socket(AF_UNIX, SOCK_STREAM, 0) == -1) {
62 return 1;
63 }
64
65 if (pipe(fd) == -1) {
66 return 1;
67 }
68
69 pid = fork();
70 if (pid == -1) {
71 return 1;
72 }
73
74 if (pid == 0) {
75 if (unshare(CLONE_NEWNET) == -1) {
76 return 1;
77 }
78
79 if (write(fd[1], &_, 1) != 1) {
80 return 1;
81 }
82
83 pause();
84
85 return 0;
86 }
87
88 if (read(fd[0], &_, 1) != 1) {
89 return 1;
90 }
91
92 {
93 char buf[64];
94 snprintf(buf, sizeof(buf), "/proc/%u/ns/net", pid);
95 nsfd = open(buf, O_RDONLY);
96 if (nsfd == -1) {
97 return 1;
98 }
99 }
100
101 /* Reliably pin dentry into dcache. */
102 (void)open("/proc/net/unix", O_RDONLY);
103
104 if (setns(nsfd, CLONE_NEWNET) == -1) {
105 return 1;
106 }
107
108 kill(pid, SIGTERM);
109 pid = 0;
110
111 {
112 char buf[4096];
113 ssize_t rv;
114 int fd;
115
116 fd = open("/proc/net/unix", O_RDONLY);
117 if (fd == -1) {
118 return 1;
119 }
120
121#define S "Num RefCount Protocol Flags Type St Inode Path\n"
122 rv = read(fd, buf, sizeof(buf));
123
124 assert(rv == strlen(S));
125 assert(memcmp(buf, S, strlen(S)) == 0);
126 }
127
128 return 0;
129}
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index e20b017e7073..b2065536d407 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -145,15 +145,12 @@ TEST_F(rtc, alarm_alm_set) {
145 145
146 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); 146 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
147 ASSERT_NE(-1, rc); 147 ASSERT_NE(-1, rc);
148 EXPECT_NE(0, rc); 148 ASSERT_NE(0, rc);
149 149
150 /* Disable alarm interrupts */ 150 /* Disable alarm interrupts */
151 rc = ioctl(self->fd, RTC_AIE_OFF, 0); 151 rc = ioctl(self->fd, RTC_AIE_OFF, 0);
152 ASSERT_NE(-1, rc); 152 ASSERT_NE(-1, rc);
153 153
154 if (rc == 0)
155 return;
156
157 rc = read(self->fd, &data, sizeof(unsigned long)); 154 rc = read(self->fd, &data, sizeof(unsigned long));
158 ASSERT_NE(-1, rc); 155 ASSERT_NE(-1, rc);
159 TH_LOG("data: %lx", data); 156 TH_LOG("data: %lx", data);
@@ -202,7 +199,109 @@ TEST_F(rtc, alarm_wkalm_set) {
202 199
203 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv); 200 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
204 ASSERT_NE(-1, rc); 201 ASSERT_NE(-1, rc);
205 EXPECT_NE(0, rc); 202 ASSERT_NE(0, rc);
203
204 rc = read(self->fd, &data, sizeof(unsigned long));
205 ASSERT_NE(-1, rc);
206
207 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
208 ASSERT_NE(-1, rc);
209
210 new = timegm((struct tm *)&tm);
211 ASSERT_EQ(new, secs);
212}
213
214TEST_F(rtc, alarm_alm_set_minute) {
215 struct timeval tv = { .tv_sec = 62 };
216 unsigned long data;
217 struct rtc_time tm;
218 fd_set readfds;
219 time_t secs, new;
220 int rc;
221
222 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
223 ASSERT_NE(-1, rc);
224
225 secs = timegm((struct tm *)&tm) + 60 - tm.tm_sec;
226 gmtime_r(&secs, (struct tm *)&tm);
227
228 rc = ioctl(self->fd, RTC_ALM_SET, &tm);
229 if (rc == -1) {
230 ASSERT_EQ(EINVAL, errno);
231 TH_LOG("skip alarms are not supported.");
232 return;
233 }
234
235 rc = ioctl(self->fd, RTC_ALM_READ, &tm);
236 ASSERT_NE(-1, rc);
237
238 TH_LOG("Alarm time now set to %02d:%02d:%02d.",
239 tm.tm_hour, tm.tm_min, tm.tm_sec);
240
241 /* Enable alarm interrupts */
242 rc = ioctl(self->fd, RTC_AIE_ON, 0);
243 ASSERT_NE(-1, rc);
244
245 FD_ZERO(&readfds);
246 FD_SET(self->fd, &readfds);
247
248 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
249 ASSERT_NE(-1, rc);
250 ASSERT_NE(0, rc);
251
252 /* Disable alarm interrupts */
253 rc = ioctl(self->fd, RTC_AIE_OFF, 0);
254 ASSERT_NE(-1, rc);
255
256 rc = read(self->fd, &data, sizeof(unsigned long));
257 ASSERT_NE(-1, rc);
258 TH_LOG("data: %lx", data);
259
260 rc = ioctl(self->fd, RTC_RD_TIME, &tm);
261 ASSERT_NE(-1, rc);
262
263 new = timegm((struct tm *)&tm);
264 ASSERT_EQ(new, secs);
265}
266
267TEST_F(rtc, alarm_wkalm_set_minute) {
268 struct timeval tv = { .tv_sec = 62 };
269 struct rtc_wkalrm alarm = { 0 };
270 struct rtc_time tm;
271 unsigned long data;
272 fd_set readfds;
273 time_t secs, new;
274 int rc;
275
276 rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
277 ASSERT_NE(-1, rc);
278
279 secs = timegm((struct tm *)&alarm.time) + 60 - alarm.time.tm_sec;
280 gmtime_r(&secs, (struct tm *)&alarm.time);
281
282 alarm.enabled = 1;
283
284 rc = ioctl(self->fd, RTC_WKALM_SET, &alarm);
285 if (rc == -1) {
286 ASSERT_EQ(EINVAL, errno);
287 TH_LOG("skip alarms are not supported.");
288 return;
289 }
290
291 rc = ioctl(self->fd, RTC_WKALM_RD, &alarm);
292 ASSERT_NE(-1, rc);
293
294 TH_LOG("Alarm time now set to %02d/%02d/%02d %02d:%02d:%02d.",
295 alarm.time.tm_mday, alarm.time.tm_mon + 1,
296 alarm.time.tm_year + 1900, alarm.time.tm_hour,
297 alarm.time.tm_min, alarm.time.tm_sec);
298
299 FD_ZERO(&readfds);
300 FD_SET(self->fd, &readfds);
301
302 rc = select(self->fd + 1, &readfds, NULL, NULL, &tv);
303 ASSERT_NE(-1, rc);
304 ASSERT_NE(0, rc);
206 305
207 rc = read(self->fd, &data, sizeof(unsigned long)); 306 rc = read(self->fd, &data, sizeof(unsigned long));
208 ASSERT_NE(-1, rc); 307 ASSERT_NE(-1, rc);
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index fce7f4ce0692..1760b3e39730 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark
9CFLAGS += -Wl,-no-as-needed -Wall 9CFLAGS += -Wl,-no-as-needed -Wall
10 10
11seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h 11seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
12 $(CC) $(CFLAGS) $(LDFLAGS) -lpthread $< -o $@ 12 $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
13 13
14TEST_PROGS += $(BINARIES) 14TEST_PROGS += $(BINARIES)
15EXTRA_CLEAN := $(BINARIES) 15EXTRA_CLEAN := $(BINARIES)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 067cb4607d6c..7e632b465ab4 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1608,7 +1608,16 @@ TEST_F(TRACE_poke, getpid_runs_normally)
1608#ifdef SYSCALL_NUM_RET_SHARE_REG 1608#ifdef SYSCALL_NUM_RET_SHARE_REG
1609# define EXPECT_SYSCALL_RETURN(val, action) EXPECT_EQ(-1, action) 1609# define EXPECT_SYSCALL_RETURN(val, action) EXPECT_EQ(-1, action)
1610#else 1610#else
1611# define EXPECT_SYSCALL_RETURN(val, action) EXPECT_EQ(val, action) 1611# define EXPECT_SYSCALL_RETURN(val, action) \
1612 do { \
1613 errno = 0; \
1614 if (val < 0) { \
1615 EXPECT_EQ(-1, action); \
1616 EXPECT_EQ(-(val), errno); \
1617 } else { \
1618 EXPECT_EQ(val, action); \
1619 } \
1620 } while (0)
1612#endif 1621#endif
1613 1622
1614/* Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for 1623/* Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for
@@ -1647,7 +1656,7 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
1647 1656
1648/* Architecture-specific syscall changing routine. */ 1657/* Architecture-specific syscall changing routine. */
1649void change_syscall(struct __test_metadata *_metadata, 1658void change_syscall(struct __test_metadata *_metadata,
1650 pid_t tracee, int syscall) 1659 pid_t tracee, int syscall, int result)
1651{ 1660{
1652 int ret; 1661 int ret;
1653 ARCH_REGS regs; 1662 ARCH_REGS regs;
@@ -1706,7 +1715,7 @@ void change_syscall(struct __test_metadata *_metadata,
1706#ifdef SYSCALL_NUM_RET_SHARE_REG 1715#ifdef SYSCALL_NUM_RET_SHARE_REG
1707 TH_LOG("Can't modify syscall return on this architecture"); 1716 TH_LOG("Can't modify syscall return on this architecture");
1708#else 1717#else
1709 regs.SYSCALL_RET = EPERM; 1718 regs.SYSCALL_RET = result;
1710#endif 1719#endif
1711 1720
1712#ifdef HAVE_GETREGS 1721#ifdef HAVE_GETREGS
@@ -1734,14 +1743,19 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee,
1734 case 0x1002: 1743 case 0x1002:
1735 /* change getpid to getppid. */ 1744 /* change getpid to getppid. */
1736 EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee)); 1745 EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee));
1737 change_syscall(_metadata, tracee, __NR_getppid); 1746 change_syscall(_metadata, tracee, __NR_getppid, 0);
1738 break; 1747 break;
1739 case 0x1003: 1748 case 0x1003:
1740 /* skip gettid. */ 1749 /* skip gettid with valid return code. */
1741 EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee)); 1750 EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee));
1742 change_syscall(_metadata, tracee, -1); 1751 change_syscall(_metadata, tracee, -1, 45000);
1743 break; 1752 break;
1744 case 0x1004: 1753 case 0x1004:
1754 /* skip openat with error. */
1755 EXPECT_EQ(__NR_openat, get_syscall(_metadata, tracee));
1756 change_syscall(_metadata, tracee, -1, -ESRCH);
1757 break;
1758 case 0x1005:
1745 /* do nothing (allow getppid) */ 1759 /* do nothing (allow getppid) */
1746 EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee)); 1760 EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee));
1747 break; 1761 break;
@@ -1774,9 +1788,11 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
1774 nr = get_syscall(_metadata, tracee); 1788 nr = get_syscall(_metadata, tracee);
1775 1789
1776 if (nr == __NR_getpid) 1790 if (nr == __NR_getpid)
1777 change_syscall(_metadata, tracee, __NR_getppid); 1791 change_syscall(_metadata, tracee, __NR_getppid, 0);
1792 if (nr == __NR_gettid)
1793 change_syscall(_metadata, tracee, -1, 45000);
1778 if (nr == __NR_openat) 1794 if (nr == __NR_openat)
1779 change_syscall(_metadata, tracee, -1); 1795 change_syscall(_metadata, tracee, -1, -ESRCH);
1780} 1796}
1781 1797
1782FIXTURE_DATA(TRACE_syscall) { 1798FIXTURE_DATA(TRACE_syscall) {
@@ -1793,8 +1809,10 @@ FIXTURE_SETUP(TRACE_syscall)
1793 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1002), 1809 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1002),
1794 BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_gettid, 0, 1), 1810 BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_gettid, 0, 1),
1795 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1003), 1811 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1003),
1796 BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getppid, 0, 1), 1812 BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_openat, 0, 1),
1797 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1004), 1813 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1004),
1814 BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getppid, 0, 1),
1815 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1005),
1798 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), 1816 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
1799 }; 1817 };
1800 1818
@@ -1842,15 +1860,26 @@ TEST_F(TRACE_syscall, ptrace_syscall_redirected)
1842 EXPECT_NE(self->mypid, syscall(__NR_getpid)); 1860 EXPECT_NE(self->mypid, syscall(__NR_getpid));
1843} 1861}
1844 1862
1845TEST_F(TRACE_syscall, ptrace_syscall_dropped) 1863TEST_F(TRACE_syscall, ptrace_syscall_errno)
1864{
1865 /* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */
1866 teardown_trace_fixture(_metadata, self->tracer);
1867 self->tracer = setup_trace_fixture(_metadata, tracer_ptrace, NULL,
1868 true);
1869
1870 /* Tracer should skip the open syscall, resulting in ESRCH. */
1871 EXPECT_SYSCALL_RETURN(-ESRCH, syscall(__NR_openat));
1872}
1873
1874TEST_F(TRACE_syscall, ptrace_syscall_faked)
1846{ 1875{
1847 /* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */ 1876 /* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */
1848 teardown_trace_fixture(_metadata, self->tracer); 1877 teardown_trace_fixture(_metadata, self->tracer);
1849 self->tracer = setup_trace_fixture(_metadata, tracer_ptrace, NULL, 1878 self->tracer = setup_trace_fixture(_metadata, tracer_ptrace, NULL,
1850 true); 1879 true);
1851 1880
1852 /* Tracer should skip the open syscall, resulting in EPERM. */ 1881 /* Tracer should skip the gettid syscall, resulting fake pid. */
1853 EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat)); 1882 EXPECT_SYSCALL_RETURN(45000, syscall(__NR_gettid));
1854} 1883}
1855 1884
1856TEST_F(TRACE_syscall, syscall_allowed) 1885TEST_F(TRACE_syscall, syscall_allowed)
@@ -1883,7 +1912,21 @@ TEST_F(TRACE_syscall, syscall_redirected)
1883 EXPECT_NE(self->mypid, syscall(__NR_getpid)); 1912 EXPECT_NE(self->mypid, syscall(__NR_getpid));
1884} 1913}
1885 1914
1886TEST_F(TRACE_syscall, syscall_dropped) 1915TEST_F(TRACE_syscall, syscall_errno)
1916{
1917 long ret;
1918
1919 ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
1920 ASSERT_EQ(0, ret);
1921
1922 ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
1923 ASSERT_EQ(0, ret);
1924
1925 /* openat has been skipped and an errno return. */
1926 EXPECT_SYSCALL_RETURN(-ESRCH, syscall(__NR_openat));
1927}
1928
1929TEST_F(TRACE_syscall, syscall_faked)
1887{ 1930{
1888 long ret; 1931 long ret;
1889 1932
@@ -1894,8 +1937,7 @@ TEST_F(TRACE_syscall, syscall_dropped)
1894 ASSERT_EQ(0, ret); 1937 ASSERT_EQ(0, ret);
1895 1938
1896 /* gettid has been skipped and an altered return value stored. */ 1939 /* gettid has been skipped and an altered return value stored. */
1897 EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_gettid)); 1940 EXPECT_SYSCALL_RETURN(45000, syscall(__NR_gettid));
1898 EXPECT_NE(self->mytid, syscall(__NR_gettid));
1899} 1941}
1900 1942
1901TEST_F(TRACE_syscall, skip_after_RET_TRACE) 1943TEST_F(TRACE_syscall, skip_after_RET_TRACE)
@@ -3044,7 +3086,7 @@ TEST(user_notification_basic)
3044 /* Check that the basic notification machinery works */ 3086 /* Check that the basic notification machinery works */
3045 listener = user_trap_syscall(__NR_getpid, 3087 listener = user_trap_syscall(__NR_getpid,
3046 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3088 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3047 EXPECT_GE(listener, 0); 3089 ASSERT_GE(listener, 0);
3048 3090
3049 /* Installing a second listener in the chain should EBUSY */ 3091 /* Installing a second listener in the chain should EBUSY */
3050 EXPECT_EQ(user_trap_syscall(__NR_getpid, 3092 EXPECT_EQ(user_trap_syscall(__NR_getpid,
@@ -3103,7 +3145,7 @@ TEST(user_notification_kill_in_middle)
3103 3145
3104 listener = user_trap_syscall(__NR_getpid, 3146 listener = user_trap_syscall(__NR_getpid,
3105 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3147 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3106 EXPECT_GE(listener, 0); 3148 ASSERT_GE(listener, 0);
3107 3149
3108 /* 3150 /*
3109 * Check that nothing bad happens when we kill the task in the middle 3151 * Check that nothing bad happens when we kill the task in the middle
@@ -3152,7 +3194,7 @@ TEST(user_notification_signal)
3152 3194
3153 listener = user_trap_syscall(__NR_gettid, 3195 listener = user_trap_syscall(__NR_gettid,
3154 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3196 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3155 EXPECT_GE(listener, 0); 3197 ASSERT_GE(listener, 0);
3156 3198
3157 pid = fork(); 3199 pid = fork();
3158 ASSERT_GE(pid, 0); 3200 ASSERT_GE(pid, 0);
@@ -3215,7 +3257,7 @@ TEST(user_notification_closed_listener)
3215 3257
3216 listener = user_trap_syscall(__NR_getpid, 3258 listener = user_trap_syscall(__NR_getpid,
3217 SECCOMP_FILTER_FLAG_NEW_LISTENER); 3259 SECCOMP_FILTER_FLAG_NEW_LISTENER);
3218 EXPECT_GE(listener, 0); 3260 ASSERT_GE(listener, 0);
3219 3261
3220 /* 3262 /*
3221 * Check that we get an ENOSYS when the listener is closed. 3263 * Check that we get an ENOSYS when the listener is closed.
@@ -3376,7 +3418,7 @@ TEST(seccomp_get_notif_sizes)
3376{ 3418{
3377 struct seccomp_notif_sizes sizes; 3419 struct seccomp_notif_sizes sizes;
3378 3420
3379 EXPECT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); 3421 ASSERT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0);
3380 EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif)); 3422 EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif));
3381 EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp)); 3423 EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp));
3382} 3424}
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json b/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json
index 637ea0219617..0da3545cabdb 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json
@@ -17,7 +17,7 @@
17 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 2", 17 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 2",
18 "expExitCode": "0", 18 "expExitCode": "0",
19 "verifyCmd": "$TC actions get action ife index 2", 19 "verifyCmd": "$TC actions get action ife index 2",
20 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow mark.*index 2", 20 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow mark.*index 2",
21 "matchCount": "1", 21 "matchCount": "1",
22 "teardown": [ 22 "teardown": [
23 "$TC actions flush action ife" 23 "$TC actions flush action ife"
@@ -41,7 +41,7 @@
41 "cmdUnderTest": "$TC actions add action ife encode use mark 10 pipe index 2", 41 "cmdUnderTest": "$TC actions add action ife encode use mark 10 pipe index 2",
42 "expExitCode": "0", 42 "expExitCode": "0",
43 "verifyCmd": "$TC actions get action ife index 2", 43 "verifyCmd": "$TC actions get action ife index 2",
44 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use mark.*index 2", 44 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use mark.*index 2",
45 "matchCount": "1", 45 "matchCount": "1",
46 "teardown": [ 46 "teardown": [
47 "$TC actions flush action ife" 47 "$TC actions flush action ife"
@@ -65,7 +65,7 @@
65 "cmdUnderTest": "$TC actions add action ife encode allow mark continue index 2", 65 "cmdUnderTest": "$TC actions add action ife encode allow mark continue index 2",
66 "expExitCode": "0", 66 "expExitCode": "0",
67 "verifyCmd": "$TC actions get action ife index 2", 67 "verifyCmd": "$TC actions get action ife index 2",
68 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0xED3E.*allow mark.*index 2", 68 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0[xX]ED3E.*allow mark.*index 2",
69 "matchCount": "1", 69 "matchCount": "1",
70 "teardown": [ 70 "teardown": [
71 "$TC actions flush action ife" 71 "$TC actions flush action ife"
@@ -89,7 +89,7 @@
89 "cmdUnderTest": "$TC actions add action ife encode use mark 789 drop index 2", 89 "cmdUnderTest": "$TC actions add action ife encode use mark 789 drop index 2",
90 "expExitCode": "0", 90 "expExitCode": "0",
91 "verifyCmd": "$TC actions get action ife index 2", 91 "verifyCmd": "$TC actions get action ife index 2",
92 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0xED3E.*use mark 789.*index 2", 92 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0[xX]ED3E.*use mark 789.*index 2",
93 "matchCount": "1", 93 "matchCount": "1",
94 "teardown": [ 94 "teardown": [
95 "$TC actions flush action ife" 95 "$TC actions flush action ife"
@@ -113,7 +113,7 @@
113 "cmdUnderTest": "$TC actions add action ife encode use mark 656768 reclassify index 2", 113 "cmdUnderTest": "$TC actions add action ife encode use mark 656768 reclassify index 2",
114 "expExitCode": "0", 114 "expExitCode": "0",
115 "verifyCmd": "$TC actions get action ife index 2", 115 "verifyCmd": "$TC actions get action ife index 2",
116 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*use mark 656768.*index 2", 116 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*use mark 656768.*index 2",
117 "matchCount": "1", 117 "matchCount": "1",
118 "teardown": [ 118 "teardown": [
119 "$TC actions flush action ife" 119 "$TC actions flush action ife"
@@ -137,7 +137,7 @@
137 "cmdUnderTest": "$TC actions add action ife encode use mark 65 jump 1 index 2", 137 "cmdUnderTest": "$TC actions add action ife encode use mark 65 jump 1 index 2",
138 "expExitCode": "0", 138 "expExitCode": "0",
139 "verifyCmd": "$TC actions get action ife index 2", 139 "verifyCmd": "$TC actions get action ife index 2",
140 "matchPattern": "action order [0-9]*: ife encode action jump 1.*type 0xED3E.*use mark 65.*index 2", 140 "matchPattern": "action order [0-9]*: ife encode action jump 1.*type 0[xX]ED3E.*use mark 65.*index 2",
141 "matchCount": "1", 141 "matchCount": "1",
142 "teardown": [ 142 "teardown": [
143 "$TC actions flush action ife" 143 "$TC actions flush action ife"
@@ -161,7 +161,7 @@
161 "cmdUnderTest": "$TC actions add action ife encode use mark 4294967295 reclassify index 90", 161 "cmdUnderTest": "$TC actions add action ife encode use mark 4294967295 reclassify index 90",
162 "expExitCode": "0", 162 "expExitCode": "0",
163 "verifyCmd": "$TC actions get action ife index 90", 163 "verifyCmd": "$TC actions get action ife index 90",
164 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*use mark 4294967295.*index 90", 164 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*use mark 4294967295.*index 90",
165 "matchCount": "1", 165 "matchCount": "1",
166 "teardown": [ 166 "teardown": [
167 "$TC actions flush action ife" 167 "$TC actions flush action ife"
@@ -185,7 +185,7 @@
185 "cmdUnderTest": "$TC actions add action ife encode use mark 4294967295999 pipe index 90", 185 "cmdUnderTest": "$TC actions add action ife encode use mark 4294967295999 pipe index 90",
186 "expExitCode": "255", 186 "expExitCode": "255",
187 "verifyCmd": "$TC actions get action ife index 90", 187 "verifyCmd": "$TC actions get action ife index 90",
188 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use mark 4294967295999.*index 90", 188 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use mark 4294967295999.*index 90",
189 "matchCount": "0", 189 "matchCount": "0",
190 "teardown": [] 190 "teardown": []
191 }, 191 },
@@ -207,7 +207,7 @@
207 "cmdUnderTest": "$TC actions add action ife encode allow prio pass index 9", 207 "cmdUnderTest": "$TC actions add action ife encode allow prio pass index 9",
208 "expExitCode": "0", 208 "expExitCode": "0",
209 "verifyCmd": "$TC actions get action ife index 9", 209 "verifyCmd": "$TC actions get action ife index 9",
210 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow prio.*index 9", 210 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow prio.*index 9",
211 "matchCount": "1", 211 "matchCount": "1",
212 "teardown": [ 212 "teardown": [
213 "$TC actions flush action ife" 213 "$TC actions flush action ife"
@@ -231,7 +231,7 @@
231 "cmdUnderTest": "$TC actions add action ife encode use prio 7 pipe index 9", 231 "cmdUnderTest": "$TC actions add action ife encode use prio 7 pipe index 9",
232 "expExitCode": "0", 232 "expExitCode": "0",
233 "verifyCmd": "$TC actions get action ife index 9", 233 "verifyCmd": "$TC actions get action ife index 9",
234 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use prio 7.*index 9", 234 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use prio 7.*index 9",
235 "matchCount": "1", 235 "matchCount": "1",
236 "teardown": [ 236 "teardown": [
237 "$TC actions flush action ife" 237 "$TC actions flush action ife"
@@ -255,7 +255,7 @@
255 "cmdUnderTest": "$TC actions add action ife encode use prio 3 continue index 9", 255 "cmdUnderTest": "$TC actions add action ife encode use prio 3 continue index 9",
256 "expExitCode": "0", 256 "expExitCode": "0",
257 "verifyCmd": "$TC actions get action ife index 9", 257 "verifyCmd": "$TC actions get action ife index 9",
258 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0xED3E.*use prio 3.*index 9", 258 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0[xX]ED3E.*use prio 3.*index 9",
259 "matchCount": "1", 259 "matchCount": "1",
260 "teardown": [ 260 "teardown": [
261 "$TC actions flush action ife" 261 "$TC actions flush action ife"
@@ -279,7 +279,7 @@
279 "cmdUnderTest": "$TC actions add action ife encode allow prio drop index 9", 279 "cmdUnderTest": "$TC actions add action ife encode allow prio drop index 9",
280 "expExitCode": "0", 280 "expExitCode": "0",
281 "verifyCmd": "$TC actions get action ife index 9", 281 "verifyCmd": "$TC actions get action ife index 9",
282 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0xED3E.*allow prio.*index 9", 282 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0[xX]ED3E.*allow prio.*index 9",
283 "matchCount": "1", 283 "matchCount": "1",
284 "teardown": [ 284 "teardown": [
285 "$TC actions flush action ife" 285 "$TC actions flush action ife"
@@ -303,7 +303,7 @@
303 "cmdUnderTest": "$TC actions add action ife encode use prio 998877 reclassify index 9", 303 "cmdUnderTest": "$TC actions add action ife encode use prio 998877 reclassify index 9",
304 "expExitCode": "0", 304 "expExitCode": "0",
305 "verifyCmd": "$TC actions get action ife index 9", 305 "verifyCmd": "$TC actions get action ife index 9",
306 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*use prio 998877.*index 9", 306 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*use prio 998877.*index 9",
307 "matchCount": "1", 307 "matchCount": "1",
308 "teardown": [ 308 "teardown": [
309 "$TC actions flush action ife" 309 "$TC actions flush action ife"
@@ -327,7 +327,7 @@
327 "cmdUnderTest": "$TC actions add action ife encode use prio 998877 jump 10 index 9", 327 "cmdUnderTest": "$TC actions add action ife encode use prio 998877 jump 10 index 9",
328 "expExitCode": "0", 328 "expExitCode": "0",
329 "verifyCmd": "$TC actions get action ife index 9", 329 "verifyCmd": "$TC actions get action ife index 9",
330 "matchPattern": "action order [0-9]*: ife encode action jump 10.*type 0xED3E.*use prio 998877.*index 9", 330 "matchPattern": "action order [0-9]*: ife encode action jump 10.*type 0[xX]ED3E.*use prio 998877.*index 9",
331 "matchCount": "1", 331 "matchCount": "1",
332 "teardown": [ 332 "teardown": [
333 "$TC actions flush action ife" 333 "$TC actions flush action ife"
@@ -351,7 +351,7 @@
351 "cmdUnderTest": "$TC actions add action ife encode use prio 4294967295 reclassify index 99", 351 "cmdUnderTest": "$TC actions add action ife encode use prio 4294967295 reclassify index 99",
352 "expExitCode": "0", 352 "expExitCode": "0",
353 "verifyCmd": "$TC actions get action ife index 99", 353 "verifyCmd": "$TC actions get action ife index 99",
354 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*use prio 4294967295.*index 99", 354 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*use prio 4294967295.*index 99",
355 "matchCount": "1", 355 "matchCount": "1",
356 "teardown": [ 356 "teardown": [
357 "$TC actions flush action ife" 357 "$TC actions flush action ife"
@@ -375,7 +375,7 @@
375 "cmdUnderTest": "$TC actions add action ife encode use prio 4294967298 pipe index 99", 375 "cmdUnderTest": "$TC actions add action ife encode use prio 4294967298 pipe index 99",
376 "expExitCode": "255", 376 "expExitCode": "255",
377 "verifyCmd": "$TC actions get action ife index 99", 377 "verifyCmd": "$TC actions get action ife index 99",
378 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use prio 4294967298.*index 99", 378 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use prio 4294967298.*index 99",
379 "matchCount": "0", 379 "matchCount": "0",
380 "teardown": [] 380 "teardown": []
381 }, 381 },
@@ -397,7 +397,7 @@
397 "cmdUnderTest": "$TC actions add action ife encode allow tcindex pass index 1", 397 "cmdUnderTest": "$TC actions add action ife encode allow tcindex pass index 1",
398 "expExitCode": "0", 398 "expExitCode": "0",
399 "verifyCmd": "$TC actions get action ife index 1", 399 "verifyCmd": "$TC actions get action ife index 1",
400 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow tcindex.*index 1", 400 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow tcindex.*index 1",
401 "matchCount": "1", 401 "matchCount": "1",
402 "teardown": [ 402 "teardown": [
403 "$TC actions flush action ife" 403 "$TC actions flush action ife"
@@ -421,7 +421,7 @@
421 "cmdUnderTest": "$TC actions add action ife encode use tcindex 111 pipe index 1", 421 "cmdUnderTest": "$TC actions add action ife encode use tcindex 111 pipe index 1",
422 "expExitCode": "0", 422 "expExitCode": "0",
423 "verifyCmd": "$TC actions get action ife index 1", 423 "verifyCmd": "$TC actions get action ife index 1",
424 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use tcindex 111.*index 1", 424 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use tcindex 111.*index 1",
425 "matchCount": "1", 425 "matchCount": "1",
426 "teardown": [ 426 "teardown": [
427 "$TC actions flush action ife" 427 "$TC actions flush action ife"
@@ -445,7 +445,7 @@
445 "cmdUnderTest": "$TC actions add action ife encode use tcindex 1 continue index 1", 445 "cmdUnderTest": "$TC actions add action ife encode use tcindex 1 continue index 1",
446 "expExitCode": "0", 446 "expExitCode": "0",
447 "verifyCmd": "$TC actions get action ife index 1", 447 "verifyCmd": "$TC actions get action ife index 1",
448 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0xED3E.*use tcindex 1.*index 1", 448 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0[xX]ED3E.*use tcindex 1.*index 1",
449 "matchCount": "1", 449 "matchCount": "1",
450 "teardown": [ 450 "teardown": [
451 "$TC actions flush action ife" 451 "$TC actions flush action ife"
@@ -469,7 +469,7 @@
469 "cmdUnderTest": "$TC actions add action ife encode use tcindex 1 continue index 1", 469 "cmdUnderTest": "$TC actions add action ife encode use tcindex 1 continue index 1",
470 "expExitCode": "0", 470 "expExitCode": "0",
471 "verifyCmd": "$TC actions get action ife index 1", 471 "verifyCmd": "$TC actions get action ife index 1",
472 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0xED3E.*use tcindex 1.*index 1", 472 "matchPattern": "action order [0-9]*: ife encode action continue.*type 0[xX]ED3E.*use tcindex 1.*index 1",
473 "matchCount": "1", 473 "matchCount": "1",
474 "teardown": [ 474 "teardown": [
475 "$TC actions flush action ife" 475 "$TC actions flush action ife"
@@ -493,7 +493,7 @@
493 "cmdUnderTest": "$TC actions add action ife encode allow tcindex drop index 77", 493 "cmdUnderTest": "$TC actions add action ife encode allow tcindex drop index 77",
494 "expExitCode": "0", 494 "expExitCode": "0",
495 "verifyCmd": "$TC actions get action ife index 77", 495 "verifyCmd": "$TC actions get action ife index 77",
496 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0xED3E.*allow tcindex.*index 77", 496 "matchPattern": "action order [0-9]*: ife encode action drop.*type 0[xX]ED3E.*allow tcindex.*index 77",
497 "matchCount": "1", 497 "matchCount": "1",
498 "teardown": [ 498 "teardown": [
499 "$TC actions flush action ife" 499 "$TC actions flush action ife"
@@ -517,7 +517,7 @@
517 "cmdUnderTest": "$TC actions add action ife encode allow tcindex reclassify index 77", 517 "cmdUnderTest": "$TC actions add action ife encode allow tcindex reclassify index 77",
518 "expExitCode": "0", 518 "expExitCode": "0",
519 "verifyCmd": "$TC actions get action ife index 77", 519 "verifyCmd": "$TC actions get action ife index 77",
520 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*allow tcindex.*index 77", 520 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*allow tcindex.*index 77",
521 "matchCount": "1", 521 "matchCount": "1",
522 "teardown": [ 522 "teardown": [
523 "$TC actions flush action ife" 523 "$TC actions flush action ife"
@@ -541,7 +541,7 @@
541 "cmdUnderTest": "$TC actions add action ife encode allow tcindex jump 999 index 77", 541 "cmdUnderTest": "$TC actions add action ife encode allow tcindex jump 999 index 77",
542 "expExitCode": "0", 542 "expExitCode": "0",
543 "verifyCmd": "$TC actions get action ife index 77", 543 "verifyCmd": "$TC actions get action ife index 77",
544 "matchPattern": "action order [0-9]*: ife encode action jump 999.*type 0xED3E.*allow tcindex.*index 77", 544 "matchPattern": "action order [0-9]*: ife encode action jump 999.*type 0[xX]ED3E.*allow tcindex.*index 77",
545 "matchCount": "1", 545 "matchCount": "1",
546 "teardown": [ 546 "teardown": [
547 "$TC actions flush action ife" 547 "$TC actions flush action ife"
@@ -565,7 +565,7 @@
565 "cmdUnderTest": "$TC actions add action ife encode use tcindex 65535 pass index 1", 565 "cmdUnderTest": "$TC actions add action ife encode use tcindex 65535 pass index 1",
566 "expExitCode": "0", 566 "expExitCode": "0",
567 "verifyCmd": "$TC actions get action ife index 1", 567 "verifyCmd": "$TC actions get action ife index 1",
568 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*use tcindex 65535.*index 1", 568 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*use tcindex 65535.*index 1",
569 "matchCount": "1", 569 "matchCount": "1",
570 "teardown": [ 570 "teardown": [
571 "$TC actions flush action ife" 571 "$TC actions flush action ife"
@@ -589,7 +589,7 @@
589 "cmdUnderTest": "$TC actions add action ife encode use tcindex 65539 pipe index 1", 589 "cmdUnderTest": "$TC actions add action ife encode use tcindex 65539 pipe index 1",
590 "expExitCode": "255", 590 "expExitCode": "255",
591 "verifyCmd": "$TC actions get action ife index 1", 591 "verifyCmd": "$TC actions get action ife index 1",
592 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*use tcindex 65539.*index 1", 592 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*use tcindex 65539.*index 1",
593 "matchCount": "0", 593 "matchCount": "0",
594 "teardown": [] 594 "teardown": []
595 }, 595 },
@@ -611,7 +611,7 @@
611 "cmdUnderTest": "$TC actions add action ife encode allow mark src 00:11:22:33:44:55 pipe index 1", 611 "cmdUnderTest": "$TC actions add action ife encode allow mark src 00:11:22:33:44:55 pipe index 1",
612 "expExitCode": "0", 612 "expExitCode": "0",
613 "verifyCmd": "$TC actions get action ife index 1", 613 "verifyCmd": "$TC actions get action ife index 1",
614 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*allow mark src 00:11:22:33:44:55.*index 1", 614 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*allow mark src 00:11:22:33:44:55.*index 1",
615 "matchCount": "1", 615 "matchCount": "1",
616 "teardown": [ 616 "teardown": [
617 "$TC actions flush action ife" 617 "$TC actions flush action ife"
@@ -635,7 +635,7 @@
635 "cmdUnderTest": "$TC actions add action ife encode use prio 9876 dst 00:11:22:33:44:55 reclassify index 1", 635 "cmdUnderTest": "$TC actions add action ife encode use prio 9876 dst 00:11:22:33:44:55 reclassify index 1",
636 "expExitCode": "0", 636 "expExitCode": "0",
637 "verifyCmd": "$TC actions get action ife index 1", 637 "verifyCmd": "$TC actions get action ife index 1",
638 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xED3E.*use prio 9876 dst 00:11:22:33:44:55.*index 1", 638 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ED3E.*use prio 9876 dst 00:11:22:33:44:55.*index 1",
639 "matchCount": "1", 639 "matchCount": "1",
640 "teardown": [ 640 "teardown": [
641 "$TC actions flush action ife" 641 "$TC actions flush action ife"
@@ -659,7 +659,7 @@
659 "cmdUnderTest": "$TC actions add action ife encode allow tcindex src 00:aa:bb:cc:dd:ee dst 00:11:22:33:44:55 pass index 11", 659 "cmdUnderTest": "$TC actions add action ife encode allow tcindex src 00:aa:bb:cc:dd:ee dst 00:11:22:33:44:55 pass index 11",
660 "expExitCode": "0", 660 "expExitCode": "0",
661 "verifyCmd": "$TC actions get action ife index 11", 661 "verifyCmd": "$TC actions get action ife index 11",
662 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow tcindex dst 00:11:22:33:44:55 src 00:aa:bb:cc:dd:ee .*index 11", 662 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow tcindex dst 00:11:22:33:44:55 src 00:aa:bb:cc:dd:ee .*index 11",
663 "matchCount": "1", 663 "matchCount": "1",
664 "teardown": [ 664 "teardown": [
665 "$TC actions flush action ife" 665 "$TC actions flush action ife"
@@ -683,7 +683,7 @@
683 "cmdUnderTest": "$TC actions add action ife encode use mark 7 type 0xfefe pass index 1", 683 "cmdUnderTest": "$TC actions add action ife encode use mark 7 type 0xfefe pass index 1",
684 "expExitCode": "0", 684 "expExitCode": "0",
685 "verifyCmd": "$TC actions get action ife index 1", 685 "verifyCmd": "$TC actions get action ife index 1",
686 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xFEFE.*use mark 7.*index 1", 686 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]FEFE.*use mark 7.*index 1",
687 "matchCount": "1", 687 "matchCount": "1",
688 "teardown": [ 688 "teardown": [
689 "$TC actions flush action ife" 689 "$TC actions flush action ife"
@@ -707,7 +707,7 @@
707 "cmdUnderTest": "$TC actions add action ife encode use prio 444 type 0xabba pipe index 21", 707 "cmdUnderTest": "$TC actions add action ife encode use prio 444 type 0xabba pipe index 21",
708 "expExitCode": "0", 708 "expExitCode": "0",
709 "verifyCmd": "$TC actions get action ife index 21", 709 "verifyCmd": "$TC actions get action ife index 21",
710 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xABBA.*use prio 444.*index 21", 710 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ABBA.*use prio 444.*index 21",
711 "matchCount": "1", 711 "matchCount": "1",
712 "teardown": [ 712 "teardown": [
713 "$TC actions flush action ife" 713 "$TC actions flush action ife"
@@ -731,7 +731,7 @@
731 "cmdUnderTest": "$TC actions add action ife encode use tcindex 5000 type 0xabcd reclassify index 21", 731 "cmdUnderTest": "$TC actions add action ife encode use tcindex 5000 type 0xabcd reclassify index 21",
732 "expExitCode": "0", 732 "expExitCode": "0",
733 "verifyCmd": "$TC actions get action ife index 21", 733 "verifyCmd": "$TC actions get action ife index 21",
734 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0xABCD.*use tcindex 5000.*index 21", 734 "matchPattern": "action order [0-9]*: ife encode action reclassify.*type 0[xX]ABCD.*use tcindex 5000.*index 21",
735 "matchCount": "1", 735 "matchCount": "1",
736 "teardown": [ 736 "teardown": [
737 "$TC actions flush action ife" 737 "$TC actions flush action ife"
@@ -739,7 +739,7 @@
739 }, 739 },
740 { 740 {
741 "id": "fac3", 741 "id": "fac3",
742 "name": "Create valid ife encode action with index at 32-bit maximnum", 742 "name": "Create valid ife encode action with index at 32-bit maximum",
743 "category": [ 743 "category": [
744 "actions", 744 "actions",
745 "ife" 745 "ife"
@@ -755,7 +755,7 @@
755 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 4294967295", 755 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 4294967295",
756 "expExitCode": "0", 756 "expExitCode": "0",
757 "verifyCmd": "$TC actions get action ife index 4294967295", 757 "verifyCmd": "$TC actions get action ife index 4294967295",
758 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow mark.*index 4294967295", 758 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow mark.*index 4294967295",
759 "matchCount": "1", 759 "matchCount": "1",
760 "teardown": [ 760 "teardown": [
761 "$TC actions flush action ife" 761 "$TC actions flush action ife"
@@ -779,7 +779,7 @@
779 "cmdUnderTest": "$TC actions add action ife decode pass index 1", 779 "cmdUnderTest": "$TC actions add action ife decode pass index 1",
780 "expExitCode": "0", 780 "expExitCode": "0",
781 "verifyCmd": "$TC actions get action ife index 1", 781 "verifyCmd": "$TC actions get action ife index 1",
782 "matchPattern": "action order [0-9]*: ife decode action pass.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 782 "matchPattern": "action order [0-9]*: ife decode action pass.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
783 "matchCount": "1", 783 "matchCount": "1",
784 "teardown": [ 784 "teardown": [
785 "$TC actions flush action ife" 785 "$TC actions flush action ife"
@@ -803,7 +803,7 @@
803 "cmdUnderTest": "$TC actions add action ife decode pipe index 1", 803 "cmdUnderTest": "$TC actions add action ife decode pipe index 1",
804 "expExitCode": "0", 804 "expExitCode": "0",
805 "verifyCmd": "$TC actions get action ife index 1", 805 "verifyCmd": "$TC actions get action ife index 1",
806 "matchPattern": "action order [0-9]*: ife decode action pipe.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 806 "matchPattern": "action order [0-9]*: ife decode action pipe.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
807 "matchCount": "1", 807 "matchCount": "1",
808 "teardown": [ 808 "teardown": [
809 "$TC actions flush action ife" 809 "$TC actions flush action ife"
@@ -827,7 +827,7 @@
827 "cmdUnderTest": "$TC actions add action ife decode continue index 1", 827 "cmdUnderTest": "$TC actions add action ife decode continue index 1",
828 "expExitCode": "0", 828 "expExitCode": "0",
829 "verifyCmd": "$TC actions get action ife index 1", 829 "verifyCmd": "$TC actions get action ife index 1",
830 "matchPattern": "action order [0-9]*: ife decode action continue.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 830 "matchPattern": "action order [0-9]*: ife decode action continue.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
831 "matchCount": "1", 831 "matchCount": "1",
832 "teardown": [ 832 "teardown": [
833 "$TC actions flush action ife" 833 "$TC actions flush action ife"
@@ -851,7 +851,7 @@
851 "cmdUnderTest": "$TC actions add action ife decode drop index 1", 851 "cmdUnderTest": "$TC actions add action ife decode drop index 1",
852 "expExitCode": "0", 852 "expExitCode": "0",
853 "verifyCmd": "$TC actions get action ife index 1", 853 "verifyCmd": "$TC actions get action ife index 1",
854 "matchPattern": "action order [0-9]*: ife decode action drop.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 854 "matchPattern": "action order [0-9]*: ife decode action drop.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
855 "matchCount": "1", 855 "matchCount": "1",
856 "teardown": [ 856 "teardown": [
857 "$TC actions flush action ife" 857 "$TC actions flush action ife"
@@ -875,7 +875,7 @@
875 "cmdUnderTest": "$TC actions add action ife decode reclassify index 1", 875 "cmdUnderTest": "$TC actions add action ife decode reclassify index 1",
876 "expExitCode": "0", 876 "expExitCode": "0",
877 "verifyCmd": "$TC actions get action ife index 1", 877 "verifyCmd": "$TC actions get action ife index 1",
878 "matchPattern": "action order [0-9]*: ife decode action reclassify.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 878 "matchPattern": "action order [0-9]*: ife decode action reclassify.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
879 "matchCount": "1", 879 "matchCount": "1",
880 "teardown": [ 880 "teardown": [
881 "$TC actions flush action ife" 881 "$TC actions flush action ife"
@@ -899,7 +899,7 @@
899 "cmdUnderTest": "$TC actions add action ife decode jump 10 index 1", 899 "cmdUnderTest": "$TC actions add action ife decode jump 10 index 1",
900 "expExitCode": "0", 900 "expExitCode": "0",
901 "verifyCmd": "$TC actions get action ife index 1", 901 "verifyCmd": "$TC actions get action ife index 1",
902 "matchPattern": "action order [0-9]*: ife decode action jump 10.*type 0x0.*allow mark allow tcindex allow prio.*index 1", 902 "matchPattern": "action order [0-9]*: ife decode action jump 10.*type 0(x0)?.*allow mark allow tcindex allow prio.*index 1",
903 "matchCount": "1", 903 "matchCount": "1",
904 "teardown": [ 904 "teardown": [
905 "$TC actions flush action ife" 905 "$TC actions flush action ife"
@@ -923,7 +923,7 @@
923 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 4294967295999", 923 "cmdUnderTest": "$TC actions add action ife encode allow mark pass index 4294967295999",
924 "expExitCode": "255", 924 "expExitCode": "255",
925 "verifyCmd": "$TC actions get action ife index 4294967295999", 925 "verifyCmd": "$TC actions get action ife index 4294967295999",
926 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*allow mark.*index 4294967295999", 926 "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E.*allow mark.*index 4294967295999",
927 "matchCount": "0", 927 "matchCount": "0",
928 "teardown": [] 928 "teardown": []
929 }, 929 },
@@ -945,7 +945,7 @@
945 "cmdUnderTest": "$TC actions add action ife encode allow mark kuka index 4", 945 "cmdUnderTest": "$TC actions add action ife encode allow mark kuka index 4",
946 "expExitCode": "255", 946 "expExitCode": "255",
947 "verifyCmd": "$TC actions get action ife index 4", 947 "verifyCmd": "$TC actions get action ife index 4",
948 "matchPattern": "action order [0-9]*: ife encode action kuka.*type 0xED3E.*allow mark.*index 4", 948 "matchPattern": "action order [0-9]*: ife encode action kuka.*type 0[xX]ED3E.*allow mark.*index 4",
949 "matchCount": "0", 949 "matchCount": "0",
950 "teardown": [] 950 "teardown": []
951 }, 951 },
@@ -967,7 +967,7 @@
967 "cmdUnderTest": "$TC actions add action ife encode allow prio pipe index 4 cookie aabbccddeeff112233445566778800a1", 967 "cmdUnderTest": "$TC actions add action ife encode allow prio pipe index 4 cookie aabbccddeeff112233445566778800a1",
968 "expExitCode": "0", 968 "expExitCode": "0",
969 "verifyCmd": "$TC actions get action ife index 4", 969 "verifyCmd": "$TC actions get action ife index 4",
970 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*allow prio.*index 4.*cookie aabbccddeeff112233445566778800a1", 970 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*allow prio.*index 4.*cookie aabbccddeeff112233445566778800a1",
971 "matchCount": "1", 971 "matchCount": "1",
972 "teardown": [ 972 "teardown": [
973 "$TC actions flush action ife" 973 "$TC actions flush action ife"
@@ -991,7 +991,7 @@
991 "cmdUnderTest": "$TC actions add action ife encode allow foo pipe index 4", 991 "cmdUnderTest": "$TC actions add action ife encode allow foo pipe index 4",
992 "expExitCode": "255", 992 "expExitCode": "255",
993 "verifyCmd": "$TC actions get action ife index 4", 993 "verifyCmd": "$TC actions get action ife index 4",
994 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0xED3E.*allow foo.*index 4", 994 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]ED3E.*allow foo.*index 4",
995 "matchCount": "0", 995 "matchCount": "0",
996 "teardown": [] 996 "teardown": []
997 }, 997 },
@@ -1013,7 +1013,7 @@
1013 "cmdUnderTest": "$TC actions add action ife encode allow prio type 70000 pipe index 4", 1013 "cmdUnderTest": "$TC actions add action ife encode allow prio type 70000 pipe index 4",
1014 "expExitCode": "255", 1014 "expExitCode": "255",
1015 "verifyCmd": "$TC actions get action ife index 4", 1015 "verifyCmd": "$TC actions get action ife index 4",
1016 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0x11170.*allow prio.*index 4", 1016 "matchPattern": "action order [0-9]*: ife encode action pipe.*type 0[xX]11170.*allow prio.*index 4",
1017 "matchCount": "0", 1017 "matchCount": "0",
1018 "teardown": [] 1018 "teardown": []
1019 }, 1019 },
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json b/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json
index 10b2d894e436..e7e15a7336b6 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json
@@ -82,35 +82,6 @@
82 ] 82 ]
83 }, 83 },
84 { 84 {
85 "id": "ba4e",
86 "name": "Add tunnel_key set action with missing mandatory id parameter",
87 "category": [
88 "actions",
89 "tunnel_key"
90 ],
91 "setup": [
92 [
93 "$TC actions flush action tunnel_key",
94 0,
95 1,
96 255
97 ]
98 ],
99 "cmdUnderTest": "$TC actions add action tunnel_key set src_ip 10.10.10.1 dst_ip 20.20.20.2",
100 "expExitCode": "255",
101 "verifyCmd": "$TC actions list action tunnel_key",
102 "matchPattern": "action order [0-9]+: tunnel_key set.*src_ip 10.10.10.1.*dst_ip 20.20.20.2",
103 "matchCount": "0",
104 "teardown": [
105 [
106 "$TC actions flush action tunnel_key",
107 0,
108 1,
109 255
110 ]
111 ]
112 },
113 {
114 "id": "a5e0", 85 "id": "a5e0",
115 "name": "Add tunnel_key set action with invalid src_ip parameter", 86 "name": "Add tunnel_key set action with invalid src_ip parameter",
116 "category": [ 87 "category": [
@@ -634,7 +605,7 @@
634 "cmdUnderTest": "$TC actions add action tunnel_key set src_ip 10.10.10.1 dst_ip 10.10.10.2 id 7 index 4 cookie aa11bb22cc33dd44ee55ff66aa11b1b2", 605 "cmdUnderTest": "$TC actions add action tunnel_key set src_ip 10.10.10.1 dst_ip 10.10.10.2 id 7 index 4 cookie aa11bb22cc33dd44ee55ff66aa11b1b2",
635 "expExitCode": "0", 606 "expExitCode": "0",
636 "verifyCmd": "$TC actions get action tunnel_key index 4", 607 "verifyCmd": "$TC actions get action tunnel_key index 4",
637 "matchPattern": "action order [0-9]+: tunnel_key.*set.*src_ip 10.10.10.1.*dst_ip 10.10.10.2.*key_id 7.*dst_port 0.*csum pipe.*index 4 ref.*cookie aa11bb22cc33dd44ee55ff66aa11b1b2", 608 "matchPattern": "action order [0-9]+: tunnel_key.*set.*src_ip 10.10.10.1.*dst_ip 10.10.10.2.*key_id 7.*csum pipe.*index 4 ref.*cookie aa11bb22cc33dd44ee55ff66aa11b1b2",
638 "matchCount": "1", 609 "matchCount": "1",
639 "teardown": [ 610 "teardown": [
640 "$TC actions flush action tunnel_key" 611 "$TC actions flush action tunnel_key"
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index c02683cfb6c9..7656c7ce79d9 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,6 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2CFLAGS += -O3 -Wl,-no-as-needed -Wall 2CFLAGS += -O3 -Wl,-no-as-needed -Wall
3LDFLAGS += -lrt -lpthread -lm 3LDLIBS += -lrt -lpthread -lm
4 4
5# these are all "safe" tests that don't modify 5# these are all "safe" tests that don't modify
6# system time or require escalated privileges 6# system time or require escalated privileges
diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c
index 880b96fc80d4..c0534e298b51 100644
--- a/tools/testing/selftests/vm/gup_benchmark.c
+++ b/tools/testing/selftests/vm/gup_benchmark.c
@@ -25,6 +25,7 @@ struct gup_benchmark {
25 __u64 size; 25 __u64 size;
26 __u32 nr_pages_per_call; 26 __u32 nr_pages_per_call;
27 __u32 flags; 27 __u32 flags;
28 __u64 expansion[10]; /* For future use */
28}; 29};
29 30
30int main(int argc, char **argv) 31int main(int argc, char **argv)
diff --git a/tools/testing/selftests/x86/mpx-mini-test.c b/tools/testing/selftests/x86/mpx-mini-test.c
index 50f7e9272481..bf1bb15b6fbe 100644
--- a/tools/testing/selftests/x86/mpx-mini-test.c
+++ b/tools/testing/selftests/x86/mpx-mini-test.c
@@ -1503,7 +1503,7 @@ exit:
1503 exit(20); 1503 exit(20);
1504 } 1504 }
1505 if (successes != total_nr_tests) { 1505 if (successes != total_nr_tests) {
1506 eprintf("ERROR: succeded fewer than number of tries (%d != %d)\n", 1506 eprintf("ERROR: succeeded fewer than number of tries (%d != %d)\n",
1507 successes, total_nr_tests); 1507 successes, total_nr_tests);
1508 exit(21); 1508 exit(21);
1509 } 1509 }
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
index 460b4bdf4c1e..5d546dcdbc80 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -1133,6 +1133,21 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey)
1133 pkey_assert(err); 1133 pkey_assert(err);
1134} 1134}
1135 1135
1136void become_child(void)
1137{
1138 pid_t forkret;
1139
1140 forkret = fork();
1141 pkey_assert(forkret >= 0);
1142 dprintf3("[%d] fork() ret: %d\n", getpid(), forkret);
1143
1144 if (!forkret) {
1145 /* in the child */
1146 return;
1147 }
1148 exit(0);
1149}
1150
1136/* Assumes that all pkeys other than 'pkey' are unallocated */ 1151/* Assumes that all pkeys other than 'pkey' are unallocated */
1137void test_pkey_alloc_exhaust(int *ptr, u16 pkey) 1152void test_pkey_alloc_exhaust(int *ptr, u16 pkey)
1138{ 1153{
@@ -1141,7 +1156,7 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey)
1141 int nr_allocated_pkeys = 0; 1156 int nr_allocated_pkeys = 0;
1142 int i; 1157 int i;
1143 1158
1144 for (i = 0; i < NR_PKEYS*2; i++) { 1159 for (i = 0; i < NR_PKEYS*3; i++) {
1145 int new_pkey; 1160 int new_pkey;
1146 dprintf1("%s() alloc loop: %d\n", __func__, i); 1161 dprintf1("%s() alloc loop: %d\n", __func__, i);
1147 new_pkey = alloc_pkey(); 1162 new_pkey = alloc_pkey();
@@ -1152,21 +1167,27 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey)
1152 if ((new_pkey == -1) && (errno == ENOSPC)) { 1167 if ((new_pkey == -1) && (errno == ENOSPC)) {
1153 dprintf2("%s() failed to allocate pkey after %d tries\n", 1168 dprintf2("%s() failed to allocate pkey after %d tries\n",
1154 __func__, nr_allocated_pkeys); 1169 __func__, nr_allocated_pkeys);
1155 break; 1170 } else {
1171 /*
1172 * Ensure the number of successes never
1173 * exceeds the number of keys supported
1174 * in the hardware.
1175 */
1176 pkey_assert(nr_allocated_pkeys < NR_PKEYS);
1177 allocated_pkeys[nr_allocated_pkeys++] = new_pkey;
1156 } 1178 }
1157 pkey_assert(nr_allocated_pkeys < NR_PKEYS); 1179
1158 allocated_pkeys[nr_allocated_pkeys++] = new_pkey; 1180 /*
1181 * Make sure that allocation state is properly
1182 * preserved across fork().
1183 */
1184 if (i == NR_PKEYS*2)
1185 become_child();
1159 } 1186 }
1160 1187
1161 dprintf3("%s()::%d\n", __func__, __LINE__); 1188 dprintf3("%s()::%d\n", __func__, __LINE__);
1162 1189
1163 /* 1190 /*
1164 * ensure it did not reach the end of the loop without
1165 * failure:
1166 */
1167 pkey_assert(i < NR_PKEYS*2);
1168
1169 /*
1170 * There are 16 pkeys supported in hardware. Three are 1191 * There are 16 pkeys supported in hardware. Three are
1171 * allocated by the time we get here: 1192 * allocated by the time we get here:
1172 * 1. The default key (0) 1193 * 1. The default key (0)
diff --git a/tools/testing/selftests/x86/unwind_vdso.c b/tools/testing/selftests/x86/unwind_vdso.c
index 00a26a82fa98..97311333700e 100644
--- a/tools/testing/selftests/x86/unwind_vdso.c
+++ b/tools/testing/selftests/x86/unwind_vdso.c
@@ -44,7 +44,6 @@ int main()
44#include <stdbool.h> 44#include <stdbool.h>
45#include <sys/ptrace.h> 45#include <sys/ptrace.h>
46#include <sys/user.h> 46#include <sys/user.h>
47#include <sys/ucontext.h>
48#include <link.h> 47#include <link.h>
49#include <sys/auxv.h> 48#include <sys/auxv.h>
50#include <dlfcn.h> 49#include <dlfcn.h>
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
index 89a2444c1df2..59e417ec3e13 100644
--- a/tools/thermal/tmon/Makefile
+++ b/tools/thermal/tmon/Makefile
@@ -6,7 +6,7 @@ VERSION = 1.0
6 6
7BINDIR=usr/bin 7BINDIR=usr/bin
8WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 8WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
9override CFLAGS+= -O1 ${WARNFLAGS} 9override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
10# Add "-fstack-protector" only if toolchain supports it. 10# Add "-fstack-protector" only if toolchain supports it.
11override CFLAGS+= $(call cc-option,-fstack-protector-strong) 11override CFLAGS+= $(call cc-option,-fstack-protector-strong)
12CC?= $(CROSS_COMPILE)gcc 12CC?= $(CROSS_COMPILE)gcc
diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 18fc112b65cd..d3a8755c039c 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -5,7 +5,9 @@
5 * Example use: 5 * Example use:
6 * cat /sys/kernel/debug/page_owner > page_owner_full.txt 6 * cat /sys/kernel/debug/page_owner > page_owner_full.txt
7 * grep -v ^PFN page_owner_full.txt > page_owner.txt 7 * grep -v ^PFN page_owner_full.txt > page_owner.txt
8 * ./sort page_owner.txt sorted_page_owner.txt 8 * ./page_owner_sort page_owner.txt sorted_page_owner.txt
9 *
10 * See Documentation/vm/page_owner.rst
9*/ 11*/
10 12
11#include <stdio.h> 13#include <stdio.h>