summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/arm/include/uapi/asm/kvm.h12
-rw-r--r--tools/arch/arm64/include/uapi/asm/kvm.h10
-rw-r--r--tools/arch/powerpc/include/uapi/asm/mman.h4
-rw-r--r--tools/arch/sparc/include/uapi/asm/mman.h4
-rw-r--r--tools/arch/x86/include/uapi/asm/kvm.h22
-rw-r--r--tools/arch/x86/include/uapi/asm/vmx.h1
-rwxr-xr-xtools/hv/hv_get_dhcp_info.sh2
-rw-r--r--tools/hv/hv_kvp_daemon.c8
-rwxr-xr-xtools/hv/hv_set_ifconfig.sh2
-rw-r--r--tools/hv/hv_vss_daemon.c4
-rw-r--r--tools/hv/lsvmbus75
-rw-r--r--tools/include/uapi/asm-generic/mman-common.h15
-rw-r--r--tools/include/uapi/asm-generic/mman.h10
-rw-r--r--tools/include/uapi/asm-generic/unistd.h8
-rw-r--r--tools/include/uapi/drm/drm.h1
-rw-r--r--tools/include/uapi/drm/i915_drm.h209
-rw-r--r--tools/include/uapi/linux/if_link.h5
-rw-r--r--tools/include/uapi/linux/kvm.h7
-rw-r--r--tools/include/uapi/linux/sched.h30
-rw-r--r--tools/include/uapi/linux/usbdevice_fs.h26
-rw-r--r--tools/lib/bpf/btf.c5
-rw-r--r--tools/lib/bpf/hashmap.h5
-rw-r--r--tools/lib/bpf/libbpf.c34
-rw-r--r--tools/lib/bpf/xsk.c11
-rw-r--r--tools/objtool/check.c7
-rw-r--r--tools/objtool/check.h3
-rw-r--r--tools/perf/Documentation/Makefile2
-rw-r--r--tools/perf/Documentation/perf-script.txt8
-rw-r--r--tools/perf/Documentation/perf.data-file-format.txt2
-rw-r--r--tools/perf/arch/s390/util/machine.c31
-rw-r--r--tools/perf/arch/x86/entry/syscalls/syscall_64.tbl2
-rw-r--r--tools/perf/bench/numa.c6
-rw-r--r--tools/perf/builtin-ftrace.c2
-rw-r--r--tools/perf/builtin-probe.c10
-rw-r--r--tools/perf/builtin-script.c2
-rw-r--r--tools/perf/builtin-stat.c9
-rw-r--r--tools/perf/pmu-events/jevents.c1
-rwxr-xr-xtools/perf/trace/beauty/usbdevfs_ioctl.sh9
-rw-r--r--tools/perf/ui/browser.c9
-rw-r--r--tools/perf/ui/tui/progress.c2
-rw-r--r--tools/perf/util/annotate.c2
-rw-r--r--tools/perf/util/cpumap.c5
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/header.c11
-rw-r--r--tools/perf/util/machine.c3
-rw-r--r--tools/perf/util/machine.h2
-rw-r--r--tools/perf/util/probe-event.c1
-rw-r--r--tools/perf/util/session.c22
-rw-r--r--tools/perf/util/session.h1
-rw-r--r--tools/perf/util/stat-shadow.c3
-rw-r--r--tools/perf/util/symbol.c7
-rw-r--r--tools/perf/util/symbol.h1
-rw-r--r--tools/perf/util/thread.c12
-rw-r--r--tools/perf/util/zstd.c4
-rw-r--r--tools/scripts/Makefile.include9
-rwxr-xr-xtools/testing/ktest/config-bisect.pl4
-rw-r--r--tools/testing/selftests/bpf/Makefile3
-rw-r--r--tools/testing/selftests/bpf/progs/sendmsg6_prog.c3
-rwxr-xr-xtools/testing/selftests/bpf/test_xdp_vlan.sh57
-rwxr-xr-xtools/testing/selftests/bpf/test_xdp_vlan_mode_generic.sh9
-rwxr-xr-xtools/testing/selftests/bpf/test_xdp_vlan_mode_native.sh9
-rw-r--r--tools/testing/selftests/bpf/verifier/ctx_skb.c11
-rw-r--r--tools/testing/selftests/cgroup/cgroup_util.c3
-rwxr-xr-xtools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh4
-rwxr-xr-xtools/testing/selftests/kmod/kmod.sh6
-rw-r--r--tools/testing/selftests/kselftest.h15
-rw-r--r--tools/testing/selftests/kvm/.gitignore3
-rw-r--r--tools/testing/selftests/kvm/config3
-rw-r--r--tools/testing/selftests/livepatch/functions.sh46
-rw-r--r--tools/testing/selftests/net/.gitignore4
-rwxr-xr-xtools/testing/selftests/net/forwarding/gre_multipath.sh28
-rw-r--r--tools/testing/selftests/net/tls.c223
-rw-r--r--tools/testing/selftests/pidfd/pidfd_test.c6
-rw-r--r--tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json94
-rw-r--r--tools/testing/selftests/x86/test_vsyscall.c2
75 files changed, 1048 insertions, 185 deletions
diff --git a/tools/arch/arm/include/uapi/asm/kvm.h b/tools/arch/arm/include/uapi/asm/kvm.h
index 4602464ebdfb..a4217c1a5d01 100644
--- a/tools/arch/arm/include/uapi/asm/kvm.h
+++ b/tools/arch/arm/include/uapi/asm/kvm.h
@@ -214,6 +214,18 @@ struct kvm_vcpu_events {
214#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM | KVM_REG_SIZE_U64 | \ 214#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM | KVM_REG_SIZE_U64 | \
215 KVM_REG_ARM_FW | ((r) & 0xffff)) 215 KVM_REG_ARM_FW | ((r) & 0xffff))
216#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) 216#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0)
217#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1 KVM_REG_ARM_FW_REG(1)
218 /* Higher values mean better protection. */
219#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL 0
220#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL 1
221#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED 2
222#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 KVM_REG_ARM_FW_REG(2)
223 /* Higher values mean better protection. */
224#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL 0
225#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN 1
226#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL 2
227#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3
228#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4)
217 229
218/* Device Control API: ARM VGIC */ 230/* Device Control API: ARM VGIC */
219#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 231#define KVM_DEV_ARM_VGIC_GRP_ADDR 0
diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h b/tools/arch/arm64/include/uapi/asm/kvm.h
index d819a3e8b552..9a507716ae2f 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -229,6 +229,16 @@ struct kvm_vcpu_events {
229#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ 229#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
230 KVM_REG_ARM_FW | ((r) & 0xffff)) 230 KVM_REG_ARM_FW | ((r) & 0xffff))
231#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) 231#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0)
232#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1 KVM_REG_ARM_FW_REG(1)
233#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL 0
234#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL 1
235#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED 2
236#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 KVM_REG_ARM_FW_REG(2)
237#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL 0
238#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN 1
239#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL 2
240#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3
241#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4)
232 242
233/* SVE registers */ 243/* SVE registers */
234#define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT) 244#define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT)
diff --git a/tools/arch/powerpc/include/uapi/asm/mman.h b/tools/arch/powerpc/include/uapi/asm/mman.h
index f33105bc5ca6..8601d824a9c6 100644
--- a/tools/arch/powerpc/include/uapi/asm/mman.h
+++ b/tools/arch/powerpc/include/uapi/asm/mman.h
@@ -4,12 +4,8 @@
4#define MAP_DENYWRITE 0x0800 4#define MAP_DENYWRITE 0x0800
5#define MAP_EXECUTABLE 0x1000 5#define MAP_EXECUTABLE 0x1000
6#define MAP_GROWSDOWN 0x0100 6#define MAP_GROWSDOWN 0x0100
7#define MAP_HUGETLB 0x40000
8#define MAP_LOCKED 0x80 7#define MAP_LOCKED 0x80
9#define MAP_NONBLOCK 0x10000
10#define MAP_NORESERVE 0x40 8#define MAP_NORESERVE 0x40
11#define MAP_POPULATE 0x8000
12#define MAP_STACK 0x20000
13#include <uapi/asm-generic/mman-common.h> 9#include <uapi/asm-generic/mman-common.h>
14/* MAP_32BIT is undefined on powerpc, fix it for perf */ 10/* MAP_32BIT is undefined on powerpc, fix it for perf */
15#define MAP_32BIT 0 11#define MAP_32BIT 0
diff --git a/tools/arch/sparc/include/uapi/asm/mman.h b/tools/arch/sparc/include/uapi/asm/mman.h
index 38920eed8cbf..7b94dccc843d 100644
--- a/tools/arch/sparc/include/uapi/asm/mman.h
+++ b/tools/arch/sparc/include/uapi/asm/mman.h
@@ -4,12 +4,8 @@
4#define MAP_DENYWRITE 0x0800 4#define MAP_DENYWRITE 0x0800
5#define MAP_EXECUTABLE 0x1000 5#define MAP_EXECUTABLE 0x1000
6#define MAP_GROWSDOWN 0x0200 6#define MAP_GROWSDOWN 0x0200
7#define MAP_HUGETLB 0x40000
8#define MAP_LOCKED 0x100 7#define MAP_LOCKED 0x100
9#define MAP_NONBLOCK 0x10000
10#define MAP_NORESERVE 0x40 8#define MAP_NORESERVE 0x40
11#define MAP_POPULATE 0x8000
12#define MAP_STACK 0x20000
13#include <uapi/asm-generic/mman-common.h> 9#include <uapi/asm-generic/mman-common.h>
14/* MAP_32BIT is undefined on sparc, fix it for perf */ 10/* MAP_32BIT is undefined on sparc, fix it for perf */
15#define MAP_32BIT 0 11#define MAP_32BIT 0
diff --git a/tools/arch/x86/include/uapi/asm/kvm.h b/tools/arch/x86/include/uapi/asm/kvm.h
index d6ab5b4d15e5..503d3f42da16 100644
--- a/tools/arch/x86/include/uapi/asm/kvm.h
+++ b/tools/arch/x86/include/uapi/asm/kvm.h
@@ -378,10 +378,11 @@ struct kvm_sync_regs {
378 struct kvm_vcpu_events events; 378 struct kvm_vcpu_events events;
379}; 379};
380 380
381#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) 381#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)
382#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) 382#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1)
383#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) 383#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)
384#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) 384#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
385#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4)
385 386
386#define KVM_STATE_NESTED_FORMAT_VMX 0 387#define KVM_STATE_NESTED_FORMAT_VMX 0
387#define KVM_STATE_NESTED_FORMAT_SVM 1 /* unused */ 388#define KVM_STATE_NESTED_FORMAT_SVM 1 /* unused */
@@ -432,4 +433,17 @@ struct kvm_nested_state {
432 } data; 433 } data;
433}; 434};
434 435
436/* for KVM_CAP_PMU_EVENT_FILTER */
437struct kvm_pmu_event_filter {
438 __u32 action;
439 __u32 nevents;
440 __u32 fixed_counter_bitmap;
441 __u32 flags;
442 __u32 pad[4];
443 __u64 events[0];
444};
445
446#define KVM_PMU_EVENT_ALLOW 0
447#define KVM_PMU_EVENT_DENY 1
448
435#endif /* _ASM_X86_KVM_H */ 449#endif /* _ASM_X86_KVM_H */
diff --git a/tools/arch/x86/include/uapi/asm/vmx.h b/tools/arch/x86/include/uapi/asm/vmx.h
index d213ec5c3766..f0b0c90dd398 100644
--- a/tools/arch/x86/include/uapi/asm/vmx.h
+++ b/tools/arch/x86/include/uapi/asm/vmx.h
@@ -146,7 +146,6 @@
146 146
147#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 147#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
148#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2 148#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
149#define VMX_ABORT_VMCS_CORRUPTED 3
150#define VMX_ABORT_LOAD_HOST_MSR_FAIL 4 149#define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
151 150
152#endif /* _UAPIVMX_H */ 151#endif /* _UAPIVMX_H */
diff --git a/tools/hv/hv_get_dhcp_info.sh b/tools/hv/hv_get_dhcp_info.sh
index c38686c44656..2f2a3c7df3de 100755
--- a/tools/hv/hv_get_dhcp_info.sh
+++ b/tools/hv/hv_get_dhcp_info.sh
@@ -13,7 +13,7 @@
13# the script prints the string "Disabled" to stdout. 13# the script prints the string "Disabled" to stdout.
14# 14#
15# Each Distro is expected to implement this script in a distro specific 15# Each Distro is expected to implement this script in a distro specific
16# fashion. For instance on Distros that ship with Network Manager enabled, 16# fashion. For instance, on Distros that ship with Network Manager enabled,
17# this script can be based on the Network Manager APIs for retrieving DHCP 17# this script can be based on the Network Manager APIs for retrieving DHCP
18# information. 18# information.
19 19
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index d7e06fe0270e..f5597503c771 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -700,7 +700,7 @@ static void kvp_get_ipconfig_info(char *if_name,
700 700
701 701
702 /* 702 /*
703 * Gather the DNS state. 703 * Gather the DNS state.
704 * Since there is no standard way to get this information 704 * Since there is no standard way to get this information
705 * across various distributions of interest; we just invoke 705 * across various distributions of interest; we just invoke
706 * an external script that needs to be ported across distros 706 * an external script that needs to be ported across distros
@@ -1051,7 +1051,7 @@ static int parse_ip_val_buffer(char *in_buf, int *offset,
1051 char *start; 1051 char *start;
1052 1052
1053 /* 1053 /*
1054 * in_buf has sequence of characters that are seperated by 1054 * in_buf has sequence of characters that are separated by
1055 * the character ';'. The last sequence does not have the 1055 * the character ';'. The last sequence does not have the
1056 * terminating ";" character. 1056 * terminating ";" character.
1057 */ 1057 */
@@ -1386,6 +1386,8 @@ int main(int argc, char *argv[])
1386 daemonize = 0; 1386 daemonize = 0;
1387 break; 1387 break;
1388 case 'h': 1388 case 'h':
1389 print_usage(argv);
1390 exit(0);
1389 default: 1391 default:
1390 print_usage(argv); 1392 print_usage(argv);
1391 exit(EXIT_FAILURE); 1393 exit(EXIT_FAILURE);
@@ -1490,7 +1492,7 @@ int main(int argc, char *argv[])
1490 case KVP_OP_GET_IP_INFO: 1492 case KVP_OP_GET_IP_INFO:
1491 kvp_ip_val = &hv_msg->body.kvp_ip_val; 1493 kvp_ip_val = &hv_msg->body.kvp_ip_val;
1492 1494
1493 error = kvp_mac_to_ip(kvp_ip_val); 1495 error = kvp_mac_to_ip(kvp_ip_val);
1494 1496
1495 if (error) 1497 if (error)
1496 hv_msg->error = error; 1498 hv_msg->error = error;
diff --git a/tools/hv/hv_set_ifconfig.sh b/tools/hv/hv_set_ifconfig.sh
index 7ed9f85ef908..d10fe35b7f25 100755
--- a/tools/hv/hv_set_ifconfig.sh
+++ b/tools/hv/hv_set_ifconfig.sh
@@ -12,7 +12,7 @@
12# be used to configure the interface. 12# be used to configure the interface.
13# 13#
14# Each Distro is expected to implement this script in a distro specific 14# Each Distro is expected to implement this script in a distro specific
15# fashion. For instance on Distros that ship with Network Manager enabled, 15# fashion. For instance, on Distros that ship with Network Manager enabled,
16# this script can be based on the Network Manager APIs for configuring the 16# this script can be based on the Network Manager APIs for configuring the
17# interface. 17# interface.
18# 18#
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index efe1e34dd91b..92902a88f671 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -42,7 +42,7 @@ static int vss_do_freeze(char *dir, unsigned int cmd)
42 * If a partition is mounted more than once, only the first 42 * If a partition is mounted more than once, only the first
43 * FREEZE/THAW can succeed and the later ones will get 43 * FREEZE/THAW can succeed and the later ones will get
44 * EBUSY/EINVAL respectively: there could be 2 cases: 44 * EBUSY/EINVAL respectively: there could be 2 cases:
45 * 1) a user may mount the same partition to differnt directories 45 * 1) a user may mount the same partition to different directories
46 * by mistake or on purpose; 46 * by mistake or on purpose;
47 * 2) The subvolume of btrfs appears to have the same partition 47 * 2) The subvolume of btrfs appears to have the same partition
48 * mounted more than once. 48 * mounted more than once.
@@ -218,6 +218,8 @@ int main(int argc, char *argv[])
218 daemonize = 0; 218 daemonize = 0;
219 break; 219 break;
220 case 'h': 220 case 'h':
221 print_usage(argv);
222 exit(0);
221 default: 223 default:
222 print_usage(argv); 224 print_usage(argv);
223 exit(EXIT_FAILURE); 225 exit(EXIT_FAILURE);
diff --git a/tools/hv/lsvmbus b/tools/hv/lsvmbus
index 55e7374bade0..099f2c44dbed 100644
--- a/tools/hv/lsvmbus
+++ b/tools/hv/lsvmbus
@@ -4,10 +4,10 @@
4import os 4import os
5from optparse import OptionParser 5from optparse import OptionParser
6 6
7help_msg = "print verbose messages. Try -vv, -vvv for more verbose messages"
7parser = OptionParser() 8parser = OptionParser()
8parser.add_option("-v", "--verbose", dest="verbose", 9parser.add_option(
9 help="print verbose messages. Try -vv, -vvv for \ 10 "-v", "--verbose", dest="verbose", help=help_msg, action="count")
10 more verbose messages", action="count")
11 11
12(options, args) = parser.parse_args() 12(options, args) = parser.parse_args()
13 13
@@ -21,27 +21,28 @@ if not os.path.isdir(vmbus_sys_path):
21 exit(-1) 21 exit(-1)
22 22
23vmbus_dev_dict = { 23vmbus_dev_dict = {
24 '{0e0b6031-5213-4934-818b-38d90ced39db}' : '[Operating system shutdown]', 24 '{0e0b6031-5213-4934-818b-38d90ced39db}': '[Operating system shutdown]',
25 '{9527e630-d0ae-497b-adce-e80ab0175caf}' : '[Time Synchronization]', 25 '{9527e630-d0ae-497b-adce-e80ab0175caf}': '[Time Synchronization]',
26 '{57164f39-9115-4e78-ab55-382f3bd5422d}' : '[Heartbeat]', 26 '{57164f39-9115-4e78-ab55-382f3bd5422d}': '[Heartbeat]',
27 '{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}' : '[Data Exchange]', 27 '{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}': '[Data Exchange]',
28 '{35fa2e29-ea23-4236-96ae-3a6ebacba440}' : '[Backup (volume checkpoint)]', 28 '{35fa2e29-ea23-4236-96ae-3a6ebacba440}': '[Backup (volume checkpoint)]',
29 '{34d14be3-dee4-41c8-9ae7-6b174977c192}' : '[Guest services]', 29 '{34d14be3-dee4-41c8-9ae7-6b174977c192}': '[Guest services]',
30 '{525074dc-8985-46e2-8057-a307dc18a502}' : '[Dynamic Memory]', 30 '{525074dc-8985-46e2-8057-a307dc18a502}': '[Dynamic Memory]',
31 '{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}' : 'Synthetic mouse', 31 '{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}': 'Synthetic mouse',
32 '{f912ad6d-2b17-48ea-bd65-f927a61c7684}' : 'Synthetic keyboard', 32 '{f912ad6d-2b17-48ea-bd65-f927a61c7684}': 'Synthetic keyboard',
33 '{da0a7802-e377-4aac-8e77-0558eb1073f8}' : 'Synthetic framebuffer adapter', 33 '{da0a7802-e377-4aac-8e77-0558eb1073f8}': 'Synthetic framebuffer adapter',
34 '{f8615163-df3e-46c5-913f-f2d2f965ed0e}' : 'Synthetic network adapter', 34 '{f8615163-df3e-46c5-913f-f2d2f965ed0e}': 'Synthetic network adapter',
35 '{32412632-86cb-44a2-9b5c-50d1417354f5}' : 'Synthetic IDE Controller', 35 '{32412632-86cb-44a2-9b5c-50d1417354f5}': 'Synthetic IDE Controller',
36 '{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}' : 'Synthetic SCSI Controller', 36 '{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}': 'Synthetic SCSI Controller',
37 '{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}' : 'Synthetic fiber channel adapter', 37 '{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}': 'Synthetic fiber channel adapter',
38 '{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}' : 'Synthetic RDMA adapter', 38 '{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}': 'Synthetic RDMA adapter',
39 '{44c4f61d-4444-4400-9d52-802e27ede19f}' : 'PCI Express pass-through', 39 '{44c4f61d-4444-4400-9d52-802e27ede19f}': 'PCI Express pass-through',
40 '{276aacf4-ac15-426c-98dd-7521ad3f01fe}' : '[Reserved system device]', 40 '{276aacf4-ac15-426c-98dd-7521ad3f01fe}': '[Reserved system device]',
41 '{f8e65716-3cb3-4a06-9a60-1889c5cccab5}' : '[Reserved system device]', 41 '{f8e65716-3cb3-4a06-9a60-1889c5cccab5}': '[Reserved system device]',
42 '{3375baf4-9e15-4b30-b765-67acb10d607b}' : '[Reserved system device]', 42 '{3375baf4-9e15-4b30-b765-67acb10d607b}': '[Reserved system device]',
43} 43}
44 44
45
45def get_vmbus_dev_attr(dev_name, attr): 46def get_vmbus_dev_attr(dev_name, attr):
46 try: 47 try:
47 f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r') 48 f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r')
@@ -52,6 +53,7 @@ def get_vmbus_dev_attr(dev_name, attr):
52 53
53 return lines 54 return lines
54 55
56
55class VMBus_Dev: 57class VMBus_Dev:
56 pass 58 pass
57 59
@@ -66,12 +68,13 @@ for f in os.listdir(vmbus_sys_path):
66 68
67 chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping') 69 chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping')
68 chn_vp_mapping = [c.strip() for c in chn_vp_mapping] 70 chn_vp_mapping = [c.strip() for c in chn_vp_mapping]
69 chn_vp_mapping = sorted(chn_vp_mapping, 71 chn_vp_mapping = sorted(
70 key = lambda c : int(c.split(':')[0])) 72 chn_vp_mapping, key=lambda c: int(c.split(':')[0]))
71 73
72 chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' % 74 chn_vp_mapping = [
73 (c.split(':')[0], c.split(':')[1]) 75 '\tRel_ID=%s, target_cpu=%s' %
74 for c in chn_vp_mapping] 76 (c.split(':')[0], c.split(':')[1]) for c in chn_vp_mapping
77 ]
75 d = VMBus_Dev() 78 d = VMBus_Dev()
76 d.sysfs_path = '%s/%s' % (vmbus_sys_path, f) 79 d.sysfs_path = '%s/%s' % (vmbus_sys_path, f)
77 d.vmbus_id = vmbus_id 80 d.vmbus_id = vmbus_id
@@ -85,7 +88,7 @@ for f in os.listdir(vmbus_sys_path):
85 vmbus_dev_list.append(d) 88 vmbus_dev_list.append(d)
86 89
87 90
88vmbus_dev_list = sorted(vmbus_dev_list, key = lambda d : int(d.vmbus_id)) 91vmbus_dev_list = sorted(vmbus_dev_list, key=lambda d: int(d.vmbus_id))
89 92
90format0 = '%2s: %s' 93format0 = '%2s: %s'
91format1 = '%2s: Class_ID = %s - %s\n%s' 94format1 = '%2s: Class_ID = %s - %s\n%s'
@@ -95,9 +98,15 @@ for d in vmbus_dev_list:
95 if verbose == 0: 98 if verbose == 0:
96 print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc)) 99 print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc))
97 elif verbose == 1: 100 elif verbose == 1:
98 print (('VMBUS ID ' + format1) % \ 101 print(
99 (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)) 102 ('VMBUS ID ' + format1) %
103 (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)
104 )
100 else: 105 else:
101 print (('VMBUS ID ' + format2) % \ 106 print(
102 (d.vmbus_id, d.class_id, d.dev_desc, \ 107 ('VMBUS ID ' + format2) %
103 d.device_id, d.sysfs_path, d.chn_vp_mapping)) 108 (
109 d.vmbus_id, d.class_id, d.dev_desc,
110 d.device_id, d.sysfs_path, d.chn_vp_mapping
111 )
112 )
diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h
index abd238d0f7a4..63b1f506ea67 100644
--- a/tools/include/uapi/asm-generic/mman-common.h
+++ b/tools/include/uapi/asm-generic/mman-common.h
@@ -19,15 +19,18 @@
19#define MAP_TYPE 0x0f /* Mask for type of mapping */ 19#define MAP_TYPE 0x0f /* Mask for type of mapping */
20#define MAP_FIXED 0x10 /* Interpret addr exactly */ 20#define MAP_FIXED 0x10 /* Interpret addr exactly */
21#define MAP_ANONYMOUS 0x20 /* don't use a file */ 21#define MAP_ANONYMOUS 0x20 /* don't use a file */
22#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
23# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be uninitialized */
24#else
25# define MAP_UNINITIALIZED 0x0 /* Don't support this flag */
26#endif
27 22
28/* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ 23/* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */
24#define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */
25#define MAP_NONBLOCK 0x010000 /* do not block on IO */
26#define MAP_STACK 0x020000 /* give out an address that is best suited for process/thread stacks */
27#define MAP_HUGETLB 0x040000 /* create a huge page mapping */
28#define MAP_SYNC 0x080000 /* perform synchronous page faults for the mapping */
29#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ 29#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
30 30
31#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be
32 * uninitialized */
33
31/* 34/*
32 * Flags for mlock 35 * Flags for mlock
33 */ 36 */
diff --git a/tools/include/uapi/asm-generic/mman.h b/tools/include/uapi/asm-generic/mman.h
index 36c197fc44a0..406f7718f9ad 100644
--- a/tools/include/uapi/asm-generic/mman.h
+++ b/tools/include/uapi/asm-generic/mman.h
@@ -9,13 +9,11 @@
9#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ 9#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
10#define MAP_LOCKED 0x2000 /* pages are locked */ 10#define MAP_LOCKED 0x2000 /* pages are locked */
11#define MAP_NORESERVE 0x4000 /* don't check for reservations */ 11#define MAP_NORESERVE 0x4000 /* don't check for reservations */
12#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
13#define MAP_NONBLOCK 0x10000 /* do not block on IO */
14#define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */
15#define MAP_HUGETLB 0x40000 /* create a huge page mapping */
16#define MAP_SYNC 0x80000 /* perform synchronous page faults for the mapping */
17 12
18/* Bits [26:31] are reserved, see mman-common.h for MAP_HUGETLB usage */ 13/*
14 * Bits [26:31] are reserved, see asm-generic/hugetlb_encode.h
15 * for MAP_HUGETLB usage
16 */
19 17
20#define MCL_CURRENT 1 /* lock all current mappings */ 18#define MCL_CURRENT 1 /* lock all current mappings */
21#define MCL_FUTURE 2 /* lock all future mappings */ 19#define MCL_FUTURE 2 /* lock all future mappings */
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index a87904daf103..1be0e798e362 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -844,9 +844,15 @@ __SYSCALL(__NR_fsconfig, sys_fsconfig)
844__SYSCALL(__NR_fsmount, sys_fsmount) 844__SYSCALL(__NR_fsmount, sys_fsmount)
845#define __NR_fspick 433 845#define __NR_fspick 433
846__SYSCALL(__NR_fspick, sys_fspick) 846__SYSCALL(__NR_fspick, sys_fspick)
847#define __NR_pidfd_open 434
848__SYSCALL(__NR_pidfd_open, sys_pidfd_open)
849#ifdef __ARCH_WANT_SYS_CLONE3
850#define __NR_clone3 435
851__SYSCALL(__NR_clone3, sys_clone3)
852#endif
847 853
848#undef __NR_syscalls 854#undef __NR_syscalls
849#define __NR_syscalls 434 855#define __NR_syscalls 436
850 856
851/* 857/*
852 * 32 bit systems traditionally used different 858 * 32 bit systems traditionally used different
diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h
index 661d73f9a919..8a5b2f8f8eb9 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -50,6 +50,7 @@ typedef unsigned int drm_handle_t;
50 50
51#else /* One of the BSDs */ 51#else /* One of the BSDs */
52 52
53#include <stdint.h>
53#include <sys/ioccom.h> 54#include <sys/ioccom.h>
54#include <sys/types.h> 55#include <sys/types.h>
55typedef int8_t __s8; 56typedef int8_t __s8;
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h
index 3a73f5316766..328d05e77d9f 100644
--- a/tools/include/uapi/drm/i915_drm.h
+++ b/tools/include/uapi/drm/i915_drm.h
@@ -136,6 +136,8 @@ enum drm_i915_gem_engine_class {
136struct i915_engine_class_instance { 136struct i915_engine_class_instance {
137 __u16 engine_class; /* see enum drm_i915_gem_engine_class */ 137 __u16 engine_class; /* see enum drm_i915_gem_engine_class */
138 __u16 engine_instance; 138 __u16 engine_instance;
139#define I915_ENGINE_CLASS_INVALID_NONE -1
140#define I915_ENGINE_CLASS_INVALID_VIRTUAL -2
139}; 141};
140 142
141/** 143/**
@@ -355,6 +357,8 @@ typedef struct _drm_i915_sarea {
355#define DRM_I915_PERF_ADD_CONFIG 0x37 357#define DRM_I915_PERF_ADD_CONFIG 0x37
356#define DRM_I915_PERF_REMOVE_CONFIG 0x38 358#define DRM_I915_PERF_REMOVE_CONFIG 0x38
357#define DRM_I915_QUERY 0x39 359#define DRM_I915_QUERY 0x39
360#define DRM_I915_GEM_VM_CREATE 0x3a
361#define DRM_I915_GEM_VM_DESTROY 0x3b
358/* Must be kept compact -- no holes */ 362/* Must be kept compact -- no holes */
359 363
360#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 364#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
@@ -415,6 +419,8 @@ typedef struct _drm_i915_sarea {
415#define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config) 419#define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)
416#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64) 420#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)
417#define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query) 421#define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query)
422#define DRM_IOCTL_I915_GEM_VM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_CREATE, struct drm_i915_gem_vm_control)
423#define DRM_IOCTL_I915_GEM_VM_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_VM_DESTROY, struct drm_i915_gem_vm_control)
418 424
419/* Allow drivers to submit batchbuffers directly to hardware, relying 425/* Allow drivers to submit batchbuffers directly to hardware, relying
420 * on the security mechanisms provided by hardware. 426 * on the security mechanisms provided by hardware.
@@ -598,6 +604,12 @@ typedef struct drm_i915_irq_wait {
598 */ 604 */
599#define I915_PARAM_MMAP_GTT_COHERENT 52 605#define I915_PARAM_MMAP_GTT_COHERENT 52
600 606
607/*
608 * Query whether DRM_I915_GEM_EXECBUFFER2 supports coordination of parallel
609 * execution through use of explicit fence support.
610 * See I915_EXEC_FENCE_OUT and I915_EXEC_FENCE_SUBMIT.
611 */
612#define I915_PARAM_HAS_EXEC_SUBMIT_FENCE 53
601/* Must be kept compact -- no holes and well documented */ 613/* Must be kept compact -- no holes and well documented */
602 614
603typedef struct drm_i915_getparam { 615typedef struct drm_i915_getparam {
@@ -1120,7 +1132,16 @@ struct drm_i915_gem_execbuffer2 {
1120 */ 1132 */
1121#define I915_EXEC_FENCE_ARRAY (1<<19) 1133#define I915_EXEC_FENCE_ARRAY (1<<19)
1122 1134
1123#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1)) 1135/*
1136 * Setting I915_EXEC_FENCE_SUBMIT implies that lower_32_bits(rsvd2) represent
1137 * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
1138 * the batch.
1139 *
1140 * Returns -EINVAL if the sync_file fd cannot be found.
1141 */
1142#define I915_EXEC_FENCE_SUBMIT (1 << 20)
1143
1144#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SUBMIT << 1))
1124 1145
1125#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) 1146#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
1126#define i915_execbuffer2_set_context_id(eb2, context) \ 1147#define i915_execbuffer2_set_context_id(eb2, context) \
@@ -1464,8 +1485,9 @@ struct drm_i915_gem_context_create_ext {
1464 __u32 ctx_id; /* output: id of new context*/ 1485 __u32 ctx_id; /* output: id of new context*/
1465 __u32 flags; 1486 __u32 flags;
1466#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0) 1487#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0)
1488#define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1)
1467#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \ 1489#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \
1468 (-(I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS << 1)) 1490 (-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1))
1469 __u64 extensions; 1491 __u64 extensions;
1470}; 1492};
1471 1493
@@ -1507,6 +1529,41 @@ struct drm_i915_gem_context_param {
1507 * On creation, all new contexts are marked as recoverable. 1529 * On creation, all new contexts are marked as recoverable.
1508 */ 1530 */
1509#define I915_CONTEXT_PARAM_RECOVERABLE 0x8 1531#define I915_CONTEXT_PARAM_RECOVERABLE 0x8
1532
1533 /*
1534 * The id of the associated virtual memory address space (ppGTT) of
1535 * this context. Can be retrieved and passed to another context
1536 * (on the same fd) for both to use the same ppGTT and so share
1537 * address layouts, and avoid reloading the page tables on context
1538 * switches between themselves.
1539 *
1540 * See DRM_I915_GEM_VM_CREATE and DRM_I915_GEM_VM_DESTROY.
1541 */
1542#define I915_CONTEXT_PARAM_VM 0x9
1543
1544/*
1545 * I915_CONTEXT_PARAM_ENGINES:
1546 *
1547 * Bind this context to operate on this subset of available engines. Henceforth,
1548 * the I915_EXEC_RING selector for DRM_IOCTL_I915_GEM_EXECBUFFER2 operates as
1549 * an index into this array of engines; I915_EXEC_DEFAULT selecting engine[0]
1550 * and upwards. Slots 0...N are filled in using the specified (class, instance).
1551 * Use
1552 * engine_class: I915_ENGINE_CLASS_INVALID,
1553 * engine_instance: I915_ENGINE_CLASS_INVALID_NONE
1554 * to specify a gap in the array that can be filled in later, e.g. by a
1555 * virtual engine used for load balancing.
1556 *
1557 * Setting the number of engines bound to the context to 0, by passing a zero
1558 * sized argument, will revert back to default settings.
1559 *
1560 * See struct i915_context_param_engines.
1561 *
1562 * Extensions:
1563 * i915_context_engines_load_balance (I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE)
1564 * i915_context_engines_bond (I915_CONTEXT_ENGINES_EXT_BOND)
1565 */
1566#define I915_CONTEXT_PARAM_ENGINES 0xa
1510/* Must be kept compact -- no holes and well documented */ 1567/* Must be kept compact -- no holes and well documented */
1511 1568
1512 __u64 value; 1569 __u64 value;
@@ -1540,9 +1597,10 @@ struct drm_i915_gem_context_param_sseu {
1540 struct i915_engine_class_instance engine; 1597 struct i915_engine_class_instance engine;
1541 1598
1542 /* 1599 /*
1543 * Unused for now. Must be cleared to zero. 1600 * Unknown flags must be cleared to zero.
1544 */ 1601 */
1545 __u32 flags; 1602 __u32 flags;
1603#define I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX (1u << 0)
1546 1604
1547 /* 1605 /*
1548 * Mask of slices to enable for the context. Valid values are a subset 1606 * Mask of slices to enable for the context. Valid values are a subset
@@ -1570,12 +1628,115 @@ struct drm_i915_gem_context_param_sseu {
1570 __u32 rsvd; 1628 __u32 rsvd;
1571}; 1629};
1572 1630
1631/*
1632 * i915_context_engines_load_balance:
1633 *
1634 * Enable load balancing across this set of engines.
1635 *
1636 * Into the I915_EXEC_DEFAULT slot [0], a virtual engine is created that when
1637 * used will proxy the execbuffer request onto one of the set of engines
1638 * in such a way as to distribute the load evenly across the set.
1639 *
1640 * The set of engines must be compatible (e.g. the same HW class) as they
1641 * will share the same logical GPU context and ring.
1642 *
1643 * To intermix rendering with the virtual engine and direct rendering onto
1644 * the backing engines (bypassing the load balancing proxy), the context must
1645 * be defined to use a single timeline for all engines.
1646 */
1647struct i915_context_engines_load_balance {
1648 struct i915_user_extension base;
1649
1650 __u16 engine_index;
1651 __u16 num_siblings;
1652 __u32 flags; /* all undefined flags must be zero */
1653
1654 __u64 mbz64; /* reserved for future use; must be zero */
1655
1656 struct i915_engine_class_instance engines[0];
1657} __attribute__((packed));
1658
1659#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
1660 struct i915_user_extension base; \
1661 __u16 engine_index; \
1662 __u16 num_siblings; \
1663 __u32 flags; \
1664 __u64 mbz64; \
1665 struct i915_engine_class_instance engines[N__]; \
1666} __attribute__((packed)) name__
1667
1668/*
1669 * i915_context_engines_bond:
1670 *
1671 * Constructed bonded pairs for execution within a virtual engine.
1672 *
1673 * All engines are equal, but some are more equal than others. Given
1674 * the distribution of resources in the HW, it may be preferable to run
1675 * a request on a given subset of engines in parallel to a request on a
1676 * specific engine. We enable this selection of engines within a virtual
1677 * engine by specifying bonding pairs, for any given master engine we will
1678 * only execute on one of the corresponding siblings within the virtual engine.
1679 *
1680 * To execute a request in parallel on the master engine and a sibling requires
1681 * coordination with a I915_EXEC_FENCE_SUBMIT.
1682 */
1683struct i915_context_engines_bond {
1684 struct i915_user_extension base;
1685
1686 struct i915_engine_class_instance master;
1687
1688 __u16 virtual_index; /* index of virtual engine in ctx->engines[] */
1689 __u16 num_bonds;
1690
1691 __u64 flags; /* all undefined flags must be zero */
1692 __u64 mbz64[4]; /* reserved for future use; must be zero */
1693
1694 struct i915_engine_class_instance engines[0];
1695} __attribute__((packed));
1696
1697#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
1698 struct i915_user_extension base; \
1699 struct i915_engine_class_instance master; \
1700 __u16 virtual_index; \
1701 __u16 num_bonds; \
1702 __u64 flags; \
1703 __u64 mbz64[4]; \
1704 struct i915_engine_class_instance engines[N__]; \
1705} __attribute__((packed)) name__
1706
1707struct i915_context_param_engines {
1708 __u64 extensions; /* linked chain of extension blocks, 0 terminates */
1709#define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */
1710#define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */
1711 struct i915_engine_class_instance engines[0];
1712} __attribute__((packed));
1713
1714#define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \
1715 __u64 extensions; \
1716 struct i915_engine_class_instance engines[N__]; \
1717} __attribute__((packed)) name__
1718
1573struct drm_i915_gem_context_create_ext_setparam { 1719struct drm_i915_gem_context_create_ext_setparam {
1574#define I915_CONTEXT_CREATE_EXT_SETPARAM 0 1720#define I915_CONTEXT_CREATE_EXT_SETPARAM 0
1575 struct i915_user_extension base; 1721 struct i915_user_extension base;
1576 struct drm_i915_gem_context_param param; 1722 struct drm_i915_gem_context_param param;
1577}; 1723};
1578 1724
1725struct drm_i915_gem_context_create_ext_clone {
1726#define I915_CONTEXT_CREATE_EXT_CLONE 1
1727 struct i915_user_extension base;
1728 __u32 clone_id;
1729 __u32 flags;
1730#define I915_CONTEXT_CLONE_ENGINES (1u << 0)
1731#define I915_CONTEXT_CLONE_FLAGS (1u << 1)
1732#define I915_CONTEXT_CLONE_SCHEDATTR (1u << 2)
1733#define I915_CONTEXT_CLONE_SSEU (1u << 3)
1734#define I915_CONTEXT_CLONE_TIMELINE (1u << 4)
1735#define I915_CONTEXT_CLONE_VM (1u << 5)
1736#define I915_CONTEXT_CLONE_UNKNOWN -(I915_CONTEXT_CLONE_VM << 1)
1737 __u64 rsvd;
1738};
1739
1579struct drm_i915_gem_context_destroy { 1740struct drm_i915_gem_context_destroy {
1580 __u32 ctx_id; 1741 __u32 ctx_id;
1581 __u32 pad; 1742 __u32 pad;
@@ -1821,6 +1982,7 @@ struct drm_i915_perf_oa_config {
1821struct drm_i915_query_item { 1982struct drm_i915_query_item {
1822 __u64 query_id; 1983 __u64 query_id;
1823#define DRM_I915_QUERY_TOPOLOGY_INFO 1 1984#define DRM_I915_QUERY_TOPOLOGY_INFO 1
1985#define DRM_I915_QUERY_ENGINE_INFO 2
1824/* Must be kept compact -- no holes and well documented */ 1986/* Must be kept compact -- no holes and well documented */
1825 1987
1826 /* 1988 /*
@@ -1919,6 +2081,47 @@ struct drm_i915_query_topology_info {
1919 __u8 data[]; 2081 __u8 data[];
1920}; 2082};
1921 2083
2084/**
2085 * struct drm_i915_engine_info
2086 *
2087 * Describes one engine and it's capabilities as known to the driver.
2088 */
2089struct drm_i915_engine_info {
2090 /** Engine class and instance. */
2091 struct i915_engine_class_instance engine;
2092
2093 /** Reserved field. */
2094 __u32 rsvd0;
2095
2096 /** Engine flags. */
2097 __u64 flags;
2098
2099 /** Capabilities of this engine. */
2100 __u64 capabilities;
2101#define I915_VIDEO_CLASS_CAPABILITY_HEVC (1 << 0)
2102#define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC (1 << 1)
2103
2104 /** Reserved fields. */
2105 __u64 rsvd1[4];
2106};
2107
2108/**
2109 * struct drm_i915_query_engine_info
2110 *
2111 * Engine info query enumerates all engines known to the driver by filling in
2112 * an array of struct drm_i915_engine_info structures.
2113 */
2114struct drm_i915_query_engine_info {
2115 /** Number of struct drm_i915_engine_info structs following. */
2116 __u32 num_engines;
2117
2118 /** MBZ */
2119 __u32 rsvd[3];
2120
2121 /** Marker for drm_i915_engine_info structures. */
2122 struct drm_i915_engine_info engines[];
2123};
2124
1922#if defined(__cplusplus) 2125#if defined(__cplusplus)
1923} 2126}
1924#endif 2127#endif
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 7d113a9602f0..4a8c02cafa9a 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -695,6 +695,7 @@ enum {
695 IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */ 695 IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */
696 IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */ 696 IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */
697 IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */ 697 IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */
698 IFLA_VF_BROADCAST, /* VF broadcast */
698 __IFLA_VF_MAX, 699 __IFLA_VF_MAX,
699}; 700};
700 701
@@ -705,6 +706,10 @@ struct ifla_vf_mac {
705 __u8 mac[32]; /* MAX_ADDR_LEN */ 706 __u8 mac[32]; /* MAX_ADDR_LEN */
706}; 707};
707 708
709struct ifla_vf_broadcast {
710 __u8 broadcast[32];
711};
712
708struct ifla_vf_vlan { 713struct ifla_vf_vlan {
709 __u32 vf; 714 __u32 vf;
710 __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */ 715 __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index c2152f3dd02d..5e3f12d5359e 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -116,7 +116,7 @@ struct kvm_irq_level {
116 * ACPI gsi notion of irq. 116 * ACPI gsi notion of irq.
117 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 117 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47..
118 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 118 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23..
119 * For ARM: See Documentation/virtual/kvm/api.txt 119 * For ARM: See Documentation/virt/kvm/api.txt
120 */ 120 */
121 union { 121 union {
122 __u32 irq; 122 __u32 irq;
@@ -995,6 +995,7 @@ struct kvm_ppc_resize_hpt {
995#define KVM_CAP_ARM_SVE 170 995#define KVM_CAP_ARM_SVE 170
996#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 996#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
997#define KVM_CAP_ARM_PTRAUTH_GENERIC 172 997#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
998#define KVM_CAP_PMU_EVENT_FILTER 173
998 999
999#ifdef KVM_CAP_IRQ_ROUTING 1000#ifdef KVM_CAP_IRQ_ROUTING
1000 1001
@@ -1085,7 +1086,7 @@ struct kvm_xen_hvm_config {
1085 * 1086 *
1086 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1087 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
1087 * the irqfd to operate in resampling mode for level triggered interrupt 1088 * the irqfd to operate in resampling mode for level triggered interrupt
1088 * emulation. See Documentation/virtual/kvm/api.txt. 1089 * emulation. See Documentation/virt/kvm/api.txt.
1089 */ 1090 */
1090#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 1091#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
1091 1092
@@ -1329,6 +1330,8 @@ struct kvm_s390_ucas_mapping {
1329#define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 1330#define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)
1330/* Available with KVM_CAP_PPC_GET_CPU_CHAR */ 1331/* Available with KVM_CAP_PPC_GET_CPU_CHAR */
1331#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) 1332#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
1333/* Available with KVM_CAP_PMU_EVENT_FILTER */
1334#define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter)
1332 1335
1333/* ioctl for vm fd */ 1336/* ioctl for vm fd */
1334#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1337#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
diff --git a/tools/include/uapi/linux/sched.h b/tools/include/uapi/linux/sched.h
index ed4ee170bee2..b3105ac1381a 100644
--- a/tools/include/uapi/linux/sched.h
+++ b/tools/include/uapi/linux/sched.h
@@ -2,6 +2,8 @@
2#ifndef _UAPI_LINUX_SCHED_H 2#ifndef _UAPI_LINUX_SCHED_H
3#define _UAPI_LINUX_SCHED_H 3#define _UAPI_LINUX_SCHED_H
4 4
5#include <linux/types.h>
6
5/* 7/*
6 * cloning flags: 8 * cloning flags:
7 */ 9 */
@@ -32,6 +34,20 @@
32#define CLONE_IO 0x80000000 /* Clone io context */ 34#define CLONE_IO 0x80000000 /* Clone io context */
33 35
34/* 36/*
37 * Arguments for the clone3 syscall
38 */
39struct clone_args {
40 __aligned_u64 flags;
41 __aligned_u64 pidfd;
42 __aligned_u64 child_tid;
43 __aligned_u64 parent_tid;
44 __aligned_u64 exit_signal;
45 __aligned_u64 stack;
46 __aligned_u64 stack_size;
47 __aligned_u64 tls;
48};
49
50/*
35 * Scheduling policies 51 * Scheduling policies
36 */ 52 */
37#define SCHED_NORMAL 0 53#define SCHED_NORMAL 0
@@ -51,9 +67,21 @@
51#define SCHED_FLAG_RESET_ON_FORK 0x01 67#define SCHED_FLAG_RESET_ON_FORK 0x01
52#define SCHED_FLAG_RECLAIM 0x02 68#define SCHED_FLAG_RECLAIM 0x02
53#define SCHED_FLAG_DL_OVERRUN 0x04 69#define SCHED_FLAG_DL_OVERRUN 0x04
70#define SCHED_FLAG_KEEP_POLICY 0x08
71#define SCHED_FLAG_KEEP_PARAMS 0x10
72#define SCHED_FLAG_UTIL_CLAMP_MIN 0x20
73#define SCHED_FLAG_UTIL_CLAMP_MAX 0x40
74
75#define SCHED_FLAG_KEEP_ALL (SCHED_FLAG_KEEP_POLICY | \
76 SCHED_FLAG_KEEP_PARAMS)
77
78#define SCHED_FLAG_UTIL_CLAMP (SCHED_FLAG_UTIL_CLAMP_MIN | \
79 SCHED_FLAG_UTIL_CLAMP_MAX)
54 80
55#define SCHED_FLAG_ALL (SCHED_FLAG_RESET_ON_FORK | \ 81#define SCHED_FLAG_ALL (SCHED_FLAG_RESET_ON_FORK | \
56 SCHED_FLAG_RECLAIM | \ 82 SCHED_FLAG_RECLAIM | \
57 SCHED_FLAG_DL_OVERRUN) 83 SCHED_FLAG_DL_OVERRUN | \
84 SCHED_FLAG_KEEP_ALL | \
85 SCHED_FLAG_UTIL_CLAMP)
58 86
59#endif /* _UAPI_LINUX_SCHED_H */ 87#endif /* _UAPI_LINUX_SCHED_H */
diff --git a/tools/include/uapi/linux/usbdevice_fs.h b/tools/include/uapi/linux/usbdevice_fs.h
index 964e87217be4..78efe870c2b7 100644
--- a/tools/include/uapi/linux/usbdevice_fs.h
+++ b/tools/include/uapi/linux/usbdevice_fs.h
@@ -76,6 +76,26 @@ struct usbdevfs_connectinfo {
76 unsigned char slow; 76 unsigned char slow;
77}; 77};
78 78
79struct usbdevfs_conninfo_ex {
80 __u32 size; /* Size of the structure from the kernel's */
81 /* point of view. Can be used by userspace */
82 /* to determine how much data can be */
83 /* used/trusted. */
84 __u32 busnum; /* USB bus number, as enumerated by the */
85 /* kernel, the device is connected to. */
86 __u32 devnum; /* Device address on the bus. */
87 __u32 speed; /* USB_SPEED_* constants from ch9.h */
88 __u8 num_ports; /* Number of ports the device is connected */
89 /* to on the way to the root hub. It may */
90 /* be bigger than size of 'ports' array so */
91 /* userspace can detect overflows. */
92 __u8 ports[7]; /* List of ports on the way from the root */
93 /* hub to the device. Current limit in */
94 /* USB specification is 7 tiers (root hub, */
95 /* 5 intermediate hubs, device), which */
96 /* gives at most 6 port entries. */
97};
98
79#define USBDEVFS_URB_SHORT_NOT_OK 0x01 99#define USBDEVFS_URB_SHORT_NOT_OK 0x01
80#define USBDEVFS_URB_ISO_ASAP 0x02 100#define USBDEVFS_URB_ISO_ASAP 0x02
81#define USBDEVFS_URB_BULK_CONTINUATION 0x04 101#define USBDEVFS_URB_BULK_CONTINUATION 0x04
@@ -137,6 +157,7 @@ struct usbdevfs_hub_portinfo {
137#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10 157#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
138#define USBDEVFS_CAP_MMAP 0x20 158#define USBDEVFS_CAP_MMAP 0x20
139#define USBDEVFS_CAP_DROP_PRIVILEGES 0x40 159#define USBDEVFS_CAP_DROP_PRIVILEGES 0x40
160#define USBDEVFS_CAP_CONNINFO_EX 0x80
140 161
141/* USBDEVFS_DISCONNECT_CLAIM flags & struct */ 162/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
142 163
@@ -197,5 +218,10 @@ struct usbdevfs_streams {
197#define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams) 218#define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams)
198#define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32) 219#define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
199#define USBDEVFS_GET_SPEED _IO('U', 31) 220#define USBDEVFS_GET_SPEED _IO('U', 31)
221/*
222 * Returns struct usbdevfs_conninfo_ex; length is variable to allow
223 * extending size of the data returned.
224 */
225#define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
200 226
201#endif /* _UAPI_LINUX_USBDEVICE_FS_H */ 227#endif /* _UAPI_LINUX_USBDEVICE_FS_H */
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 467224feb43b..d821107f55f9 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1,6 +1,7 @@
1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
2/* Copyright (c) 2018 Facebook */ 2/* Copyright (c) 2018 Facebook */
3 3
4#include <endian.h>
4#include <stdio.h> 5#include <stdio.h>
5#include <stdlib.h> 6#include <stdlib.h>
6#include <string.h> 7#include <string.h>
@@ -419,9 +420,9 @@ done:
419 420
420static bool btf_check_endianness(const GElf_Ehdr *ehdr) 421static bool btf_check_endianness(const GElf_Ehdr *ehdr)
421{ 422{
422#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 423#if __BYTE_ORDER == __LITTLE_ENDIAN
423 return ehdr->e_ident[EI_DATA] == ELFDATA2LSB; 424 return ehdr->e_ident[EI_DATA] == ELFDATA2LSB;
424#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 425#elif __BYTE_ORDER == __BIG_ENDIAN
425 return ehdr->e_ident[EI_DATA] == ELFDATA2MSB; 426 return ehdr->e_ident[EI_DATA] == ELFDATA2MSB;
426#else 427#else
427# error "Unrecognized __BYTE_ORDER__" 428# error "Unrecognized __BYTE_ORDER__"
diff --git a/tools/lib/bpf/hashmap.h b/tools/lib/bpf/hashmap.h
index 03748a742146..bae8879cdf58 100644
--- a/tools/lib/bpf/hashmap.h
+++ b/tools/lib/bpf/hashmap.h
@@ -10,6 +10,11 @@
10 10
11#include <stdbool.h> 11#include <stdbool.h>
12#include <stddef.h> 12#include <stddef.h>
13#ifdef __GLIBC__
14#include <bits/wordsize.h>
15#else
16#include <bits/reg.h>
17#endif
13#include "libbpf_internal.h" 18#include "libbpf_internal.h"
14 19
15static inline size_t hash_bits(size_t h, int bits) 20static inline size_t hash_bits(size_t h, int bits)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 794dd5064ae8..2586b6cb8f34 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -20,6 +20,7 @@
20#include <inttypes.h> 20#include <inttypes.h>
21#include <string.h> 21#include <string.h>
22#include <unistd.h> 22#include <unistd.h>
23#include <endian.h>
23#include <fcntl.h> 24#include <fcntl.h>
24#include <errno.h> 25#include <errno.h>
25#include <asm/unistd.h> 26#include <asm/unistd.h>
@@ -612,10 +613,10 @@ errout:
612 613
613static int bpf_object__check_endianness(struct bpf_object *obj) 614static int bpf_object__check_endianness(struct bpf_object *obj)
614{ 615{
615#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 616#if __BYTE_ORDER == __LITTLE_ENDIAN
616 if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2LSB) 617 if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2LSB)
617 return 0; 618 return 0;
618#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 619#elif __BYTE_ORDER == __BIG_ENDIAN
619 if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2MSB) 620 if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2MSB)
620 return 0; 621 return 0;
621#else 622#else
@@ -1377,8 +1378,13 @@ static void bpf_object__sanitize_btf(struct bpf_object *obj)
1377 if (!has_datasec && kind == BTF_KIND_VAR) { 1378 if (!has_datasec && kind == BTF_KIND_VAR) {
1378 /* replace VAR with INT */ 1379 /* replace VAR with INT */
1379 t->info = BTF_INFO_ENC(BTF_KIND_INT, 0, 0); 1380 t->info = BTF_INFO_ENC(BTF_KIND_INT, 0, 0);
1380 t->size = sizeof(int); 1381 /*
1381 *(int *)(t+1) = BTF_INT_ENC(0, 0, 32); 1382 * using size = 1 is the safest choice, 4 will be too
1383 * big and cause kernel BTF validation failure if
1384 * original variable took less than 4 bytes
1385 */
1386 t->size = 1;
1387 *(int *)(t+1) = BTF_INT_ENC(0, 0, 8);
1382 } else if (!has_datasec && kind == BTF_KIND_DATASEC) { 1388 } else if (!has_datasec && kind == BTF_KIND_DATASEC) {
1383 /* replace DATASEC with STRUCT */ 1389 /* replace DATASEC with STRUCT */
1384 struct btf_var_secinfo *v = (void *)(t + 1); 1390 struct btf_var_secinfo *v = (void *)(t + 1);
@@ -1500,6 +1506,12 @@ static int bpf_object__sanitize_and_load_btf(struct bpf_object *obj)
1500 BTF_ELF_SEC, err); 1506 BTF_ELF_SEC, err);
1501 btf__free(obj->btf); 1507 btf__free(obj->btf);
1502 obj->btf = NULL; 1508 obj->btf = NULL;
1509 /* btf_ext can't exist without btf, so free it as well */
1510 if (obj->btf_ext) {
1511 btf_ext__free(obj->btf_ext);
1512 obj->btf_ext = NULL;
1513 }
1514
1503 if (bpf_object__is_btf_mandatory(obj)) 1515 if (bpf_object__is_btf_mandatory(obj))
1504 return err; 1516 return err;
1505 } 1517 }
@@ -4507,13 +4519,13 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
4507 const struct perf_buffer_opts *opts) 4519 const struct perf_buffer_opts *opts)
4508{ 4520{
4509 struct perf_buffer_params p = {}; 4521 struct perf_buffer_params p = {};
4510 struct perf_event_attr attr = { 4522 struct perf_event_attr attr = { 0, };
4511 .config = PERF_COUNT_SW_BPF_OUTPUT, 4523
4512 .type = PERF_TYPE_SOFTWARE, 4524 attr.config = PERF_COUNT_SW_BPF_OUTPUT,
4513 .sample_type = PERF_SAMPLE_RAW, 4525 attr.type = PERF_TYPE_SOFTWARE;
4514 .sample_period = 1, 4526 attr.sample_type = PERF_SAMPLE_RAW;
4515 .wakeup_events = 1, 4527 attr.sample_period = 1;
4516 }; 4528 attr.wakeup_events = 1;
4517 4529
4518 p.attr = &attr; 4530 p.attr = &attr;
4519 p.sample_cb = opts ? opts->sample_cb : NULL; 4531 p.sample_cb = opts ? opts->sample_cb : NULL;
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 5007b5d4fd2c..680e63066cf3 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -317,17 +317,16 @@ static int xsk_load_xdp_prog(struct xsk_socket *xsk)
317 317
318static int xsk_get_max_queues(struct xsk_socket *xsk) 318static int xsk_get_max_queues(struct xsk_socket *xsk)
319{ 319{
320 struct ethtool_channels channels; 320 struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS };
321 struct ifreq ifr; 321 struct ifreq ifr = {};
322 int fd, err, ret; 322 int fd, err, ret;
323 323
324 fd = socket(AF_INET, SOCK_DGRAM, 0); 324 fd = socket(AF_INET, SOCK_DGRAM, 0);
325 if (fd < 0) 325 if (fd < 0)
326 return -errno; 326 return -errno;
327 327
328 channels.cmd = ETHTOOL_GCHANNELS;
329 ifr.ifr_data = (void *)&channels; 328 ifr.ifr_data = (void *)&channels;
330 strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1); 329 memcpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1);
331 ifr.ifr_name[IFNAMSIZ - 1] = '\0'; 330 ifr.ifr_name[IFNAMSIZ - 1] = '\0';
332 err = ioctl(fd, SIOCETHTOOL, &ifr); 331 err = ioctl(fd, SIOCETHTOOL, &ifr);
333 if (err && errno != EOPNOTSUPP) { 332 if (err && errno != EOPNOTSUPP) {
@@ -335,7 +334,7 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
335 goto out; 334 goto out;
336 } 335 }
337 336
338 if (channels.max_combined == 0 || errno == EOPNOTSUPP) 337 if (err || channels.max_combined == 0)
339 /* If the device says it has no channels, then all traffic 338 /* If the device says it has no channels, then all traffic
340 * is sent to a single stream, so max queues = 1. 339 * is sent to a single stream, so max queues = 1.
341 */ 340 */
@@ -517,7 +516,7 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname,
517 err = -errno; 516 err = -errno;
518 goto out_socket; 517 goto out_socket;
519 } 518 }
520 strncpy(xsk->ifname, ifname, IFNAMSIZ - 1); 519 memcpy(xsk->ifname, ifname, IFNAMSIZ - 1);
521 xsk->ifname[IFNAMSIZ - 1] = '\0'; 520 xsk->ifname[IFNAMSIZ - 1] = '\0';
522 521
523 err = xsk_set_xdp_socket_config(&xsk->config, usr_config); 522 err = xsk_set_xdp_socket_config(&xsk->config, usr_config);
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5f26620f13f5..176f2f084060 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1946,6 +1946,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
1946 struct alternative *alt; 1946 struct alternative *alt;
1947 struct instruction *insn, *next_insn; 1947 struct instruction *insn, *next_insn;
1948 struct section *sec; 1948 struct section *sec;
1949 u8 visited;
1949 int ret; 1950 int ret;
1950 1951
1951 insn = first; 1952 insn = first;
@@ -1972,12 +1973,12 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
1972 return 1; 1973 return 1;
1973 } 1974 }
1974 1975
1976 visited = 1 << state.uaccess;
1975 if (insn->visited) { 1977 if (insn->visited) {
1976 if (!insn->hint && !insn_state_match(insn, &state)) 1978 if (!insn->hint && !insn_state_match(insn, &state))
1977 return 1; 1979 return 1;
1978 1980
1979 /* If we were here with AC=0, but now have AC=1, go again */ 1981 if (insn->visited & visited)
1980 if (insn->state.uaccess || !state.uaccess)
1981 return 0; 1982 return 0;
1982 } 1983 }
1983 1984
@@ -2024,7 +2025,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
2024 } else 2025 } else
2025 insn->state = state; 2026 insn->state = state;
2026 2027
2027 insn->visited = true; 2028 insn->visited |= visited;
2028 2029
2029 if (!insn->ignore_alts) { 2030 if (!insn->ignore_alts) {
2030 bool skip_orig = false; 2031 bool skip_orig = false;
diff --git a/tools/objtool/check.h b/tools/objtool/check.h
index b881fafcf55d..6d875ca6fce0 100644
--- a/tools/objtool/check.h
+++ b/tools/objtool/check.h
@@ -33,8 +33,9 @@ struct instruction {
33 unsigned int len; 33 unsigned int len;
34 enum insn_type type; 34 enum insn_type type;
35 unsigned long immediate; 35 unsigned long immediate;
36 bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts; 36 bool alt_group, dead_end, ignore, hint, save, restore, ignore_alts;
37 bool retpoline_safe; 37 bool retpoline_safe;
38 u8 visited;
38 struct symbol *call_dest; 39 struct symbol *call_dest;
39 struct instruction *jump_dest; 40 struct instruction *jump_dest;
40 struct instruction *first_jump_src; 41 struct instruction *first_jump_src;
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 6d148a40551c..adc5a7e44b98 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -242,7 +242,7 @@ $(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
242 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ 242 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
243 mv $@+ $@ 243 mv $@+ $@
244 244
245-include $(OUPTUT)doc.dep 245-include $(OUTPUT)doc.dep
246 246
247_cmds_txt = cmds-ancillaryinterrogators.txt \ 247_cmds_txt = cmds-ancillaryinterrogators.txt \
248 cmds-ancillarymanipulators.txt \ 248 cmds-ancillarymanipulators.txt \
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index d4e2e18a5881..caaab28f8400 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -228,11 +228,11 @@ OPTIONS
228 228
229 With the metric option perf script can compute metrics for 229 With the metric option perf script can compute metrics for
230 sampling periods, similar to perf stat. This requires 230 sampling periods, similar to perf stat. This requires
231 specifying a group with multiple metrics with the :S option 231 specifying a group with multiple events defining metrics with the :S option
232 for perf record. perf will sample on the first event, and 232 for perf record. perf will sample on the first event, and
233 compute metrics for all the events in the group. Please note 233 print computed metrics for all the events in the group. Please note
234 that the metric computed is averaged over the whole sampling 234 that the metric computed is averaged over the whole sampling
235 period, not just for the sample point. 235 period (since the last sample), not just for the sample point.
236 236
237 For sample events it's possible to display misc field with -F +misc option, 237 For sample events it's possible to display misc field with -F +misc option,
238 following letters are displayed for each bit: 238 following letters are displayed for each bit:
@@ -384,7 +384,7 @@ include::itrace.txt[]
384 perf script --time 0%-10%,30%-40% 384 perf script --time 0%-10%,30%-40%
385 385
386--max-blocks:: 386--max-blocks::
387 Set the maximum number of program blocks to print with brstackasm for 387 Set the maximum number of program blocks to print with brstackinsn for
388 each sample. 388 each sample.
389 389
390--reltime:: 390--reltime::
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
index 5f54feb19977..d030c87ed9f5 100644
--- a/tools/perf/Documentation/perf.data-file-format.txt
+++ b/tools/perf/Documentation/perf.data-file-format.txt
@@ -126,7 +126,7 @@ vendor,family,model,stepping. For example: GenuineIntel,6,69,1
126 126
127 HEADER_TOTAL_MEM = 10, 127 HEADER_TOTAL_MEM = 10,
128 128
129An uint64_t with the total memory in bytes. 129An uint64_t with the total memory in kilobytes.
130 130
131 HEADER_CMDLINE = 11, 131 HEADER_CMDLINE = 11,
132 132
diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
index a19690a17291..c8c86a0c9b79 100644
--- a/tools/perf/arch/s390/util/machine.c
+++ b/tools/perf/arch/s390/util/machine.c
@@ -6,8 +6,9 @@
6#include "machine.h" 6#include "machine.h"
7#include "api/fs/fs.h" 7#include "api/fs/fs.h"
8#include "debug.h" 8#include "debug.h"
9#include "symbol.h"
9 10
10int arch__fix_module_text_start(u64 *start, const char *name) 11int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
11{ 12{
12 u64 m_start = *start; 13 u64 m_start = *start;
13 char path[PATH_MAX]; 14 char path[PATH_MAX];
@@ -17,7 +18,35 @@ int arch__fix_module_text_start(u64 *start, const char *name)
17 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) { 18 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
18 pr_debug2("Using module %s start:%#lx\n", path, m_start); 19 pr_debug2("Using module %s start:%#lx\n", path, m_start);
19 *start = m_start; 20 *start = m_start;
21 } else {
22 /* Successful read of the modules segment text start address.
23 * Calculate difference between module start address
24 * in memory and module text segment start address.
25 * For example module load address is 0x3ff8011b000
26 * (from /proc/modules) and module text segment start
27 * address is 0x3ff8011b870 (from file above).
28 *
29 * Adjust the module size and subtract the GOT table
30 * size located at the beginning of the module.
31 */
32 *size -= (*start - m_start);
20 } 33 }
21 34
22 return 0; 35 return 0;
23} 36}
37
38/* On s390 kernel text segment start is located at very low memory addresses,
39 * for example 0x10000. Modules are located at very high memory addresses,
40 * for example 0x3ff xxxx xxxx. The gap between end of kernel text segment
41 * and beginning of first module's text segment is very big.
42 * Therefore do not fill this gap and do not assign it to the kernel dso map.
43 */
44void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
45{
46 if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
47 /* Last kernel symbol mapped to end of page */
48 p->end = roundup(p->end, page_size);
49 else
50 p->end = c->start;
51 pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end);
52}
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index b4e6f9e6204a..c29976eca4a8 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -355,6 +355,8 @@
355431 common fsconfig __x64_sys_fsconfig 355431 common fsconfig __x64_sys_fsconfig
356432 common fsmount __x64_sys_fsmount 356432 common fsmount __x64_sys_fsmount
357433 common fspick __x64_sys_fspick 357433 common fspick __x64_sys_fspick
358434 common pidfd_open __x64_sys_pidfd_open
359435 common clone3 __x64_sys_clone3/ptregs
358 360
359# 361#
360# x32-specific system call numbers start at 512 to avoid cache impact 362# x32-specific system call numbers start at 512 to avoid cache impact
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index a640ca7aaada..513cb2f2fa32 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -379,8 +379,10 @@ static u8 *alloc_data(ssize_t bytes0, int map_flags,
379 379
380 /* Allocate and initialize all memory on CPU#0: */ 380 /* Allocate and initialize all memory on CPU#0: */
381 if (init_cpu0) { 381 if (init_cpu0) {
382 orig_mask = bind_to_node(0); 382 int node = numa_node_of_cpu(0);
383 bind_to_memnode(0); 383
384 orig_mask = bind_to_node(node);
385 bind_to_memnode(node);
384 } 386 }
385 387
386 bytes = bytes0 + HPSIZE; 388 bytes = bytes0 + HPSIZE;
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 66d5a6658daf..019312810405 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -173,7 +173,7 @@ static int set_tracing_cpumask(struct cpu_map *cpumap)
173 int last_cpu; 173 int last_cpu;
174 174
175 last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1); 175 last_cpu = cpu_map__cpu(cpumap, cpumap->nr - 1);
176 mask_size = (last_cpu + 3) / 4 + 1; 176 mask_size = last_cpu / 4 + 2; /* one more byte for EOS */
177 mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */ 177 mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */
178 178
179 cpumask = malloc(mask_size); 179 cpumask = malloc(mask_size);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 6418782951a4..3d0ffd41fb55 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -698,6 +698,16 @@ __cmd_probe(int argc, const char **argv)
698 698
699 ret = perf_add_probe_events(params.events, params.nevents); 699 ret = perf_add_probe_events(params.events, params.nevents);
700 if (ret < 0) { 700 if (ret < 0) {
701
702 /*
703 * When perf_add_probe_events() fails it calls
704 * cleanup_perf_probe_events(pevs, npevs), i.e.
705 * cleanup_perf_probe_events(params.events, params.nevents), which
706 * will call clear_perf_probe_event(), so set nevents to zero
707 * to avoid cleanup_params() to call clear_perf_probe_event() again
708 * on the same pevs.
709 */
710 params.nevents = 0;
701 pr_err_with_code(" Error: Failed to add events.", ret); 711 pr_err_with_code(" Error: Failed to add events.", ret);
702 return ret; 712 return ret;
703 } 713 }
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8f24865596af..0140ddb8dd0b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1059,7 +1059,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
1059 1059
1060 printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp); 1060 printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp);
1061 if (ip == end) { 1061 if (ip == end) {
1062 printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp, 1062 printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, ++insn, fp,
1063 &total_cycles); 1063 &total_cycles);
1064 if (PRINT_FIELD(SRCCODE)) 1064 if (PRINT_FIELD(SRCCODE))
1065 printed += print_srccode(thread, x.cpumode, ip); 1065 printed += print_srccode(thread, x.cpumode, ip);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b55a534b4de0..352cf39d7c2f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -607,7 +607,13 @@ try_again:
607 * group leaders. 607 * group leaders.
608 */ 608 */
609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 }); 609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 });
610 perf_evlist__close(evsel_list); 610
611 /*
612 * We need to keep evsel_list alive, because it's processed
613 * later the evsel_list will be closed after.
614 */
615 if (!STAT_RECORD)
616 perf_evlist__close(evsel_list);
611 617
612 return WEXITSTATUS(status); 618 return WEXITSTATUS(status);
613} 619}
@@ -1997,6 +2003,7 @@ int cmd_stat(int argc, const char **argv)
1997 perf_session__write_header(perf_stat.session, evsel_list, fd, true); 2003 perf_session__write_header(perf_stat.session, evsel_list, fd, true);
1998 } 2004 }
1999 2005
2006 perf_evlist__close(evsel_list);
2000 perf_session__delete(perf_stat.session); 2007 perf_session__delete(perf_stat.session);
2001 } 2008 }
2002 2009
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 1a91a197cafb..d413761621b0 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -453,6 +453,7 @@ static struct fixed {
453 { "inst_retired.any_p", "event=0xc0" }, 453 { "inst_retired.any_p", "event=0xc0" },
454 { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" }, 454 { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
455 { "cpu_clk_unhalted.thread", "event=0x3c" }, 455 { "cpu_clk_unhalted.thread", "event=0x3c" },
456 { "cpu_clk_unhalted.core", "event=0x3c" },
456 { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" }, 457 { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
457 { NULL, NULL}, 458 { NULL, NULL},
458}; 459};
diff --git a/tools/perf/trace/beauty/usbdevfs_ioctl.sh b/tools/perf/trace/beauty/usbdevfs_ioctl.sh
index 930b80f422e8..aa597ae53747 100755
--- a/tools/perf/trace/beauty/usbdevfs_ioctl.sh
+++ b/tools/perf/trace/beauty/usbdevfs_ioctl.sh
@@ -3,10 +3,13 @@
3 3
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
6# also as:
7# #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
8
6printf "static const char *usbdevfs_ioctl_cmds[] = {\n" 9printf "static const char *usbdevfs_ioctl_cmds[] = {\n"
7regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)[[:space:]]+_IO[WR]{0,2}\([[:space:]]*'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*" 10regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)(\(\w+\))?[[:space:]]+_IO[CWR]{0,2}\([[:space:]]*(_IOC_\w+,[[:space:]]*)?'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*"
8egrep $regex ${header_dir}/usbdevice_fs.h | egrep -v 'USBDEVFS_\w+32[[:space:]]' | \ 11egrep "$regex" ${header_dir}/usbdevice_fs.h | egrep -v 'USBDEVFS_\w+32[[:space:]]' | \
9 sed -r "s/$regex/\2 \1/g" | \ 12 sed -r "s/$regex/\4 \1/g" | \
10 sort | xargs printf "\t[%s] = \"%s\",\n" 13 sort | xargs printf "\t[%s] = \"%s\",\n"
11printf "};\n\n" 14printf "};\n\n"
12printf "#if 0\n" 15printf "#if 0\n"
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index f80c51d53565..d227d74b28f8 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -1,7 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "../string2.h" 2#include "../util/util.h"
3#include "../config.h" 3#include "../util/string2.h"
4#include "../../perf.h" 4#include "../util/config.h"
5#include "../perf.h"
5#include "libslang.h" 6#include "libslang.h"
6#include "ui.h" 7#include "ui.h"
7#include "util.h" 8#include "util.h"
@@ -14,7 +15,7 @@
14#include "browser.h" 15#include "browser.h"
15#include "helpline.h" 16#include "helpline.h"
16#include "keysyms.h" 17#include "keysyms.h"
17#include "../color.h" 18#include "../util/color.h"
18#include <linux/ctype.h> 19#include <linux/ctype.h>
19#include <linux/zalloc.h> 20#include <linux/zalloc.h>
20 21
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index bc134b82829d..5a24dd3ce4db 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include "../cache.h" 3#include "../../util/cache.h"
4#include "../progress.h" 4#include "../progress.h"
5#include "../libslang.h" 5#include "../libslang.h"
6#include "../ui.h" 6#include "../ui.h"
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ac9ad2330f93..163536720149 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1122,7 +1122,7 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
1122 goto out; 1122 goto out;
1123 1123
1124 (*rawp)[0] = tmp; 1124 (*rawp)[0] = tmp;
1125 *rawp = skip_spaces(*rawp); 1125 *rawp = strim(*rawp);
1126 1126
1127 return 0; 1127 return 0;
1128 1128
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 3acfbe34ebaf..39cce66b4ebc 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -751,7 +751,10 @@ size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
751 unsigned char *bitmap; 751 unsigned char *bitmap;
752 int last_cpu = cpu_map__cpu(map, map->nr - 1); 752 int last_cpu = cpu_map__cpu(map, map->nr - 1);
753 753
754 bitmap = zalloc((last_cpu + 7) / 8); 754 if (buf == NULL)
755 return 0;
756
757 bitmap = zalloc(last_cpu / 8 + 1);
755 if (bitmap == NULL) { 758 if (bitmap == NULL) {
756 buf[0] = '\0'; 759 buf[0] = '\0';
757 return 0; 760 return 0;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ebb46da4dfe5..52459dd5ad0c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1291,6 +1291,7 @@ static void perf_evsel__free_id(struct perf_evsel *evsel)
1291 xyarray__delete(evsel->sample_id); 1291 xyarray__delete(evsel->sample_id);
1292 evsel->sample_id = NULL; 1292 evsel->sample_id = NULL;
1293 zfree(&evsel->id); 1293 zfree(&evsel->id);
1294 evsel->ids = 0;
1294} 1295}
1295 1296
1296static void perf_evsel__free_config_terms(struct perf_evsel *evsel) 1297static void perf_evsel__free_config_terms(struct perf_evsel *evsel)
@@ -2077,6 +2078,7 @@ void perf_evsel__close(struct perf_evsel *evsel)
2077 2078
2078 perf_evsel__close_fd(evsel); 2079 perf_evsel__close_fd(evsel);
2079 perf_evsel__free_fd(evsel); 2080 perf_evsel__free_fd(evsel);
2081 perf_evsel__free_id(evsel);
2080} 2082}
2081 2083
2082int perf_evsel__open_per_cpu(struct perf_evsel *evsel, 2084int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c24db7f4909c..1903d7ec9797 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3559,6 +3559,13 @@ int perf_session__read_header(struct perf_session *session)
3559 data->file.path); 3559 data->file.path);
3560 } 3560 }
3561 3561
3562 if (f_header.attr_size == 0) {
3563 pr_err("ERROR: The %s file's attr size field is 0 which is unexpected.\n"
3564 "Was the 'perf record' command properly terminated?\n",
3565 data->file.path);
3566 return -EINVAL;
3567 }
3568
3562 nr_attrs = f_header.attrs.size / f_header.attr_size; 3569 nr_attrs = f_header.attrs.size / f_header.attr_size;
3563 lseek(fd, f_header.attrs.offset, SEEK_SET); 3570 lseek(fd, f_header.attrs.offset, SEEK_SET);
3564 3571
@@ -3639,7 +3646,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
3639 size += sizeof(struct perf_event_header); 3646 size += sizeof(struct perf_event_header);
3640 size += ids * sizeof(u64); 3647 size += ids * sizeof(u64);
3641 3648
3642 ev = malloc(size); 3649 ev = zalloc(size);
3643 3650
3644 if (ev == NULL) 3651 if (ev == NULL)
3645 return -ENOMEM; 3652 return -ENOMEM;
@@ -3747,7 +3754,7 @@ int perf_event__process_feature(struct perf_session *session,
3747 return 0; 3754 return 0;
3748 3755
3749 ff.buf = (void *)fe->data; 3756 ff.buf = (void *)fe->data;
3750 ff.size = event->header.size - sizeof(event->header); 3757 ff.size = event->header.size - sizeof(*fe);
3751 ff.ph = &session->header; 3758 ff.ph = &session->header;
3752 3759
3753 if (feat_ops[feat].process(&ff, NULL)) 3760 if (feat_ops[feat].process(&ff, NULL))
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index cf826eca3aaf..83b2fbbeeb90 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1378,6 +1378,7 @@ static int machine__set_modules_path(struct machine *machine)
1378 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0); 1378 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
1379} 1379}
1380int __weak arch__fix_module_text_start(u64 *start __maybe_unused, 1380int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
1381 u64 *size __maybe_unused,
1381 const char *name __maybe_unused) 1382 const char *name __maybe_unused)
1382{ 1383{
1383 return 0; 1384 return 0;
@@ -1389,7 +1390,7 @@ static int machine__create_module(void *arg, const char *name, u64 start,
1389 struct machine *machine = arg; 1390 struct machine *machine = arg;
1390 struct map *map; 1391 struct map *map;
1391 1392
1392 if (arch__fix_module_text_start(&start, name) < 0) 1393 if (arch__fix_module_text_start(&start, &size, name) < 0)
1393 return -1; 1394 return -1;
1394 1395
1395 map = machine__findnew_module_map(machine, start, name); 1396 map = machine__findnew_module_map(machine, start, name);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index f70ab98a7bde..7aa38da26427 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -222,7 +222,7 @@ struct symbol *machine__find_kernel_symbol_by_name(struct machine *machine,
222 222
223struct map *machine__findnew_module_map(struct machine *machine, u64 start, 223struct map *machine__findnew_module_map(struct machine *machine, u64 start,
224 const char *filename); 224 const char *filename);
225int arch__fix_module_text_start(u64 *start, const char *name); 225int arch__fix_module_text_start(u64 *start, u64 *size, const char *name);
226 226
227int machine__load_kallsyms(struct machine *machine, const char *filename); 227int machine__load_kallsyms(struct machine *machine, const char *filename);
228 228
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index cd1eb73cfe83..8394d48f8b32 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2230,6 +2230,7 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
2230 field = next; 2230 field = next;
2231 } 2231 }
2232 } 2232 }
2233 pev->nargs = 0;
2233 zfree(&pev->args); 2234 zfree(&pev->args);
2234} 2235}
2235 2236
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d0fd6c614e68..37efa1f43d8b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -36,10 +36,16 @@ static int perf_session__process_compressed_event(struct perf_session *session,
36 void *src; 36 void *src;
37 size_t decomp_size, src_size; 37 size_t decomp_size, src_size;
38 u64 decomp_last_rem = 0; 38 u64 decomp_last_rem = 0;
39 size_t decomp_len = session->header.env.comp_mmap_len; 39 size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
40 struct decomp *decomp, *decomp_last = session->decomp_last; 40 struct decomp *decomp, *decomp_last = session->decomp_last;
41 41
42 decomp = mmap(NULL, sizeof(struct decomp) + decomp_len, PROT_READ|PROT_WRITE, 42 if (decomp_last) {
43 decomp_last_rem = decomp_last->size - decomp_last->head;
44 decomp_len += decomp_last_rem;
45 }
46
47 mmap_len = sizeof(struct decomp) + decomp_len;
48 decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE,
43 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); 49 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
44 if (decomp == MAP_FAILED) { 50 if (decomp == MAP_FAILED) {
45 pr_err("Couldn't allocate memory for decompression\n"); 51 pr_err("Couldn't allocate memory for decompression\n");
@@ -47,10 +53,10 @@ static int perf_session__process_compressed_event(struct perf_session *session,
47 } 53 }
48 54
49 decomp->file_pos = file_offset; 55 decomp->file_pos = file_offset;
56 decomp->mmap_len = mmap_len;
50 decomp->head = 0; 57 decomp->head = 0;
51 58
52 if (decomp_last) { 59 if (decomp_last_rem) {
53 decomp_last_rem = decomp_last->size - decomp_last->head;
54 memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); 60 memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem);
55 decomp->size = decomp_last_rem; 61 decomp->size = decomp_last_rem;
56 } 62 }
@@ -61,7 +67,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
61 decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size, 67 decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
62 &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); 68 &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
63 if (!decomp_size) { 69 if (!decomp_size) {
64 munmap(decomp, sizeof(struct decomp) + decomp_len); 70 munmap(decomp, mmap_len);
65 pr_err("Couldn't decompress data\n"); 71 pr_err("Couldn't decompress data\n");
66 return -1; 72 return -1;
67 } 73 }
@@ -255,15 +261,15 @@ static void perf_session__delete_threads(struct perf_session *session)
255static void perf_session__release_decomp_events(struct perf_session *session) 261static void perf_session__release_decomp_events(struct perf_session *session)
256{ 262{
257 struct decomp *next, *decomp; 263 struct decomp *next, *decomp;
258 size_t decomp_len; 264 size_t mmap_len;
259 next = session->decomp; 265 next = session->decomp;
260 decomp_len = session->header.env.comp_mmap_len;
261 do { 266 do {
262 decomp = next; 267 decomp = next;
263 if (decomp == NULL) 268 if (decomp == NULL)
264 break; 269 break;
265 next = decomp->next; 270 next = decomp->next;
266 munmap(decomp, decomp_len + sizeof(struct decomp)); 271 mmap_len = decomp->mmap_len;
272 munmap(decomp, mmap_len);
267 } while (1); 273 } while (1);
268} 274}
269 275
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd8920b745bc..863dbad87849 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -46,6 +46,7 @@ struct perf_session {
46struct decomp { 46struct decomp {
47 struct decomp *next; 47 struct decomp *next;
48 u64 file_pos; 48 u64 file_pos;
49 size_t mmap_len;
49 u64 head; 50 u64 head;
50 size_t size; 51 size_t size;
51 char data[]; 52 char data[];
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 656065af4971..accb1bf1cfd8 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -819,7 +819,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
819 "stalled cycles per insn", 819 "stalled cycles per insn",
820 ratio); 820 ratio);
821 } else if (have_frontend_stalled) { 821 } else if (have_frontend_stalled) {
822 print_metric(config, ctxp, NULL, NULL, 822 out->new_line(config, ctxp);
823 print_metric(config, ctxp, NULL, "%7.2f ",
823 "stalled cycles per insn", 0); 824 "stalled cycles per insn", 0);
824 } 825 }
825 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { 826 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) {
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 173f3378aaa0..4efde7879474 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -92,6 +92,11 @@ static int prefix_underscores_count(const char *str)
92 return tail - str; 92 return tail - str;
93} 93}
94 94
95void __weak arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
96{
97 p->end = c->start;
98}
99
95const char * __weak arch__normalize_symbol_name(const char *name) 100const char * __weak arch__normalize_symbol_name(const char *name)
96{ 101{
97 return name; 102 return name;
@@ -218,7 +223,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols)
218 curr = rb_entry(nd, struct symbol, rb_node); 223 curr = rb_entry(nd, struct symbol, rb_node);
219 224
220 if (prev->end == prev->start && prev->end != curr->start) 225 if (prev->end == prev->start && prev->end != curr->start)
221 prev->end = curr->start; 226 arch__symbols__fixup_end(prev, curr);
222 } 227 }
223 228
224 /* Last entry */ 229 /* Last entry */
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 12755b42ea93..183f630cb5f1 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -288,6 +288,7 @@ const char *arch__normalize_symbol_name(const char *name);
288#define SYMBOL_A 0 288#define SYMBOL_A 0
289#define SYMBOL_B 1 289#define SYMBOL_B 1
290 290
291void arch__symbols__fixup_end(struct symbol *p, struct symbol *c);
291int arch__compare_symbol_names(const char *namea, const char *nameb); 292int arch__compare_symbol_names(const char *namea, const char *nameb);
292int arch__compare_symbol_names_n(const char *namea, const char *nameb, 293int arch__compare_symbol_names_n(const char *namea, const char *nameb,
293 unsigned int n); 294 unsigned int n);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 873ab505ca80..590793cc5142 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -214,14 +214,24 @@ struct comm *thread__comm(const struct thread *thread)
214 214
215struct comm *thread__exec_comm(const struct thread *thread) 215struct comm *thread__exec_comm(const struct thread *thread)
216{ 216{
217 struct comm *comm, *last = NULL; 217 struct comm *comm, *last = NULL, *second_last = NULL;
218 218
219 list_for_each_entry(comm, &thread->comm_list, list) { 219 list_for_each_entry(comm, &thread->comm_list, list) {
220 if (comm->exec) 220 if (comm->exec)
221 return comm; 221 return comm;
222 second_last = last;
222 last = comm; 223 last = comm;
223 } 224 }
224 225
226 /*
227 * 'last' with no start time might be the parent's comm of a synthesized
228 * thread (created by processing a synthesized fork event). For a main
229 * thread, that is very probably wrong. Prefer a later comm to avoid
230 * that case.
231 */
232 if (second_last && !last->start && thread->pid_ == thread->tid)
233 return second_last;
234
225 return last; 235 return last;
226} 236}
227 237
diff --git a/tools/perf/util/zstd.c b/tools/perf/util/zstd.c
index 23bdb9884576..d2202392ffdb 100644
--- a/tools/perf/util/zstd.c
+++ b/tools/perf/util/zstd.c
@@ -99,8 +99,8 @@ size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size
99 while (input.pos < input.size) { 99 while (input.pos < input.size) {
100 ret = ZSTD_decompressStream(data->dstream, &output, &input); 100 ret = ZSTD_decompressStream(data->dstream, &output, &input);
101 if (ZSTD_isError(ret)) { 101 if (ZSTD_isError(ret)) {
102 pr_err("failed to decompress (B): %ld -> %ld : %s\n", 102 pr_err("failed to decompress (B): %ld -> %ld, dst_size %ld : %s\n",
103 src_size, output.size, ZSTD_getErrorName(ret)); 103 src_size, output.size, dst_size, ZSTD_getErrorName(ret));
104 break; 104 break;
105 } 105 }
106 output.dst = dst + output.pos; 106 output.dst = dst + output.pos;
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 495066bafbe3..ded7a950dc40 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -32,7 +32,6 @@ EXTRA_WARNINGS += -Wno-system-headers
32EXTRA_WARNINGS += -Wold-style-definition 32EXTRA_WARNINGS += -Wold-style-definition
33EXTRA_WARNINGS += -Wpacked 33EXTRA_WARNINGS += -Wpacked
34EXTRA_WARNINGS += -Wredundant-decls 34EXTRA_WARNINGS += -Wredundant-decls
35EXTRA_WARNINGS += -Wshadow
36EXTRA_WARNINGS += -Wstrict-prototypes 35EXTRA_WARNINGS += -Wstrict-prototypes
37EXTRA_WARNINGS += -Wswitch-default 36EXTRA_WARNINGS += -Wswitch-default
38EXTRA_WARNINGS += -Wswitch-enum 37EXTRA_WARNINGS += -Wswitch-enum
@@ -69,8 +68,16 @@ endif
69# will do for now and keep the above -Wstrict-aliasing=3 in place 68# will do for now and keep the above -Wstrict-aliasing=3 in place
70# in newer systems. 69# in newer systems.
71# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h 70# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
71#
72# See https://lkml.org/lkml/2006/11/28/253 and https://gcc.gnu.org/gcc-4.8/changes.html,
73# that takes into account Linus's comments (search for Wshadow) for the reasoning about
74# -Wshadow not being interesting before gcc 4.8.
75
72ifneq ($(filter 3.%,$(MAKE_VERSION)),) # make-3 76ifneq ($(filter 3.%,$(MAKE_VERSION)),) # make-3
73EXTRA_WARNINGS += -fno-strict-aliasing 77EXTRA_WARNINGS += -fno-strict-aliasing
78EXTRA_WARNINGS += -Wno-shadow
79else
80EXTRA_WARNINGS += -Wshadow
74endif 81endif
75 82
76ifneq ($(findstring $(MAKEFLAGS), w),w) 83ifneq ($(findstring $(MAKEFLAGS), w),w)
diff --git a/tools/testing/ktest/config-bisect.pl b/tools/testing/ktest/config-bisect.pl
index 72525426654b..6fd864935319 100755
--- a/tools/testing/ktest/config-bisect.pl
+++ b/tools/testing/ktest/config-bisect.pl
@@ -663,7 +663,7 @@ while ($#ARGV >= 0) {
663 } 663 }
664 664
665 else { 665 else {
666 die "Unknow option $opt\n"; 666 die "Unknown option $opt\n";
667 } 667 }
668} 668}
669 669
@@ -732,7 +732,7 @@ if ($start) {
732 } 732 }
733 } 733 }
734 run_command "cp $good_start $good" or die "failed to copy to $good\n"; 734 run_command "cp $good_start $good" or die "failed to copy to $good\n";
735 run_command "cp $bad_start $bad" or die "faield to copy to $bad\n"; 735 run_command "cp $bad_start $bad" or die "failed to copy to $bad\n";
736} else { 736} else {
737 if ( ! -f $good ) { 737 if ( ! -f $good ) {
738 die "Can not find file $good\n"; 738 die "Can not find file $good\n";
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 11c9c62c3362..c085964e1d05 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -57,7 +57,8 @@ TEST_PROGS := test_kmod.sh \
57 test_lirc_mode2.sh \ 57 test_lirc_mode2.sh \
58 test_skb_cgroup_id.sh \ 58 test_skb_cgroup_id.sh \
59 test_flow_dissector.sh \ 59 test_flow_dissector.sh \
60 test_xdp_vlan.sh \ 60 test_xdp_vlan_mode_generic.sh \
61 test_xdp_vlan_mode_native.sh \
61 test_lwt_ip_encap.sh \ 62 test_lwt_ip_encap.sh \
62 test_tcp_check_syncookie.sh \ 63 test_tcp_check_syncookie.sh \
63 test_tc_tunnel.sh \ 64 test_tc_tunnel.sh \
diff --git a/tools/testing/selftests/bpf/progs/sendmsg6_prog.c b/tools/testing/selftests/bpf/progs/sendmsg6_prog.c
index 5aeaa284fc47..a68062820410 100644
--- a/tools/testing/selftests/bpf/progs/sendmsg6_prog.c
+++ b/tools/testing/selftests/bpf/progs/sendmsg6_prog.c
@@ -41,8 +41,7 @@ int sendmsg_v6_prog(struct bpf_sock_addr *ctx)
41 } 41 }
42 42
43 /* Rewrite destination. */ 43 /* Rewrite destination. */
44 if ((ctx->user_ip6[0] & 0xFFFF) == bpf_htons(0xFACE) && 44 if (ctx->user_ip6[0] == bpf_htonl(0xFACEB00C)) {
45 ctx->user_ip6[0] >> 16 == bpf_htons(0xB00C)) {
46 ctx->user_ip6[0] = bpf_htonl(DST_REWRITE_IP6_0); 45 ctx->user_ip6[0] = bpf_htonl(DST_REWRITE_IP6_0);
47 ctx->user_ip6[1] = bpf_htonl(DST_REWRITE_IP6_1); 46 ctx->user_ip6[1] = bpf_htonl(DST_REWRITE_IP6_1);
48 ctx->user_ip6[2] = bpf_htonl(DST_REWRITE_IP6_2); 47 ctx->user_ip6[2] = bpf_htonl(DST_REWRITE_IP6_2);
diff --git a/tools/testing/selftests/bpf/test_xdp_vlan.sh b/tools/testing/selftests/bpf/test_xdp_vlan.sh
index 51a3a31d1aac..bb8b0da91686 100755
--- a/tools/testing/selftests/bpf/test_xdp_vlan.sh
+++ b/tools/testing/selftests/bpf/test_xdp_vlan.sh
@@ -1,6 +1,14 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# Author: Jesper Dangaard Brouer <hawk@kernel.org>
2 4
3TESTNAME=xdp_vlan 5# Allow wrapper scripts to name test
6if [ -z "$TESTNAME" ]; then
7 TESTNAME=xdp_vlan
8fi
9
10# Default XDP mode
11XDP_MODE=xdpgeneric
4 12
5usage() { 13usage() {
6 echo "Testing XDP + TC eBPF VLAN manipulations: $TESTNAME" 14 echo "Testing XDP + TC eBPF VLAN manipulations: $TESTNAME"
@@ -9,9 +17,23 @@ usage() {
9 echo " -v | --verbose : Verbose" 17 echo " -v | --verbose : Verbose"
10 echo " --flush : Flush before starting (e.g. after --interactive)" 18 echo " --flush : Flush before starting (e.g. after --interactive)"
11 echo " --interactive : Keep netns setup running after test-run" 19 echo " --interactive : Keep netns setup running after test-run"
20 echo " --mode=XXX : Choose XDP mode (xdp | xdpgeneric | xdpdrv)"
12 echo "" 21 echo ""
13} 22}
14 23
24valid_xdp_mode()
25{
26 local mode=$1
27
28 case "$mode" in
29 xdpgeneric | xdpdrv | xdp)
30 return 0
31 ;;
32 *)
33 return 1
34 esac
35}
36
15cleanup() 37cleanup()
16{ 38{
17 local status=$? 39 local status=$?
@@ -37,7 +59,7 @@ cleanup()
37 59
38# Using external program "getopt" to get --long-options 60# Using external program "getopt" to get --long-options
39OPTIONS=$(getopt -o hvfi: \ 61OPTIONS=$(getopt -o hvfi: \
40 --long verbose,flush,help,interactive,debug -- "$@") 62 --long verbose,flush,help,interactive,debug,mode: -- "$@")
41if (( $? != 0 )); then 63if (( $? != 0 )); then
42 usage 64 usage
43 echo "selftests: $TESTNAME [FAILED] Error calling getopt, unknown option?" 65 echo "selftests: $TESTNAME [FAILED] Error calling getopt, unknown option?"
@@ -60,6 +82,11 @@ while true; do
60 cleanup 82 cleanup
61 shift 83 shift
62 ;; 84 ;;
85 --mode )
86 shift
87 XDP_MODE=$1
88 shift
89 ;;
63 -- ) 90 -- )
64 shift 91 shift
65 break 92 break
@@ -81,8 +108,14 @@ if [ "$EUID" -ne 0 ]; then
81 exit 1 108 exit 1
82fi 109fi
83 110
84ip link set dev lo xdp off 2>/dev/null > /dev/null 111valid_xdp_mode $XDP_MODE
85if [ $? -ne 0 ];then 112if [ $? -ne 0 ]; then
113 echo "selftests: $TESTNAME [FAILED] unknown XDP mode ($XDP_MODE)"
114 exit 1
115fi
116
117ip link set dev lo xdpgeneric off 2>/dev/null > /dev/null
118if [ $? -ne 0 ]; then
86 echo "selftests: $TESTNAME [SKIP] need ip xdp support" 119 echo "selftests: $TESTNAME [SKIP] need ip xdp support"
87 exit 0 120 exit 0
88fi 121fi
@@ -155,7 +188,7 @@ ip netns exec ns2 ip link set lo up
155# At this point, the hosts cannot reach each-other, 188# At this point, the hosts cannot reach each-other,
156# because ns2 are using VLAN tags on the packets. 189# because ns2 are using VLAN tags on the packets.
157 190
158ip netns exec ns2 sh -c 'ping -W 1 -c 1 100.64.41.1 || echo "Okay ping fails"' 191ip netns exec ns2 sh -c 'ping -W 1 -c 1 100.64.41.1 || echo "Success: First ping must fail"'
159 192
160 193
161# Now we can use the test_xdp_vlan.c program to pop/push these VLAN tags 194# Now we can use the test_xdp_vlan.c program to pop/push these VLAN tags
@@ -166,7 +199,7 @@ export FILE=test_xdp_vlan.o
166 199
167# First test: Remove VLAN by setting VLAN ID 0, using "xdp_vlan_change" 200# First test: Remove VLAN by setting VLAN ID 0, using "xdp_vlan_change"
168export XDP_PROG=xdp_vlan_change 201export XDP_PROG=xdp_vlan_change
169ip netns exec ns1 ip link set $DEVNS1 xdp object $FILE section $XDP_PROG 202ip netns exec ns1 ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG
170 203
171# In ns1: egress use TC to add back VLAN tag 4011 204# In ns1: egress use TC to add back VLAN tag 4011
172# (del cmd) 205# (del cmd)
@@ -177,8 +210,8 @@ ip netns exec ns1 tc filter add dev $DEVNS1 egress \
177 prio 1 handle 1 bpf da obj $FILE sec tc_vlan_push 210 prio 1 handle 1 bpf da obj $FILE sec tc_vlan_push
178 211
179# Now the namespaces can reach each-other, test with ping: 212# Now the namespaces can reach each-other, test with ping:
180ip netns exec ns2 ping -W 2 -c 3 $IPADDR1 213ip netns exec ns2 ping -i 0.2 -W 2 -c 2 $IPADDR1
181ip netns exec ns1 ping -W 2 -c 3 $IPADDR2 214ip netns exec ns1 ping -i 0.2 -W 2 -c 2 $IPADDR2
182 215
183# Second test: Replace xdp prog, that fully remove vlan header 216# Second test: Replace xdp prog, that fully remove vlan header
184# 217#
@@ -187,9 +220,9 @@ ip netns exec ns1 ping -W 2 -c 3 $IPADDR2
187# ETH_P_8021Q indication, and this cause overwriting of our changes. 220# ETH_P_8021Q indication, and this cause overwriting of our changes.
188# 221#
189export XDP_PROG=xdp_vlan_remove_outer2 222export XDP_PROG=xdp_vlan_remove_outer2
190ip netns exec ns1 ip link set $DEVNS1 xdp off 223ip netns exec ns1 ip link set $DEVNS1 $XDP_MODE off
191ip netns exec ns1 ip link set $DEVNS1 xdp object $FILE section $XDP_PROG 224ip netns exec ns1 ip link set $DEVNS1 $XDP_MODE object $FILE section $XDP_PROG
192 225
193# Now the namespaces should still be able reach each-other, test with ping: 226# Now the namespaces should still be able reach each-other, test with ping:
194ip netns exec ns2 ping -W 2 -c 3 $IPADDR1 227ip netns exec ns2 ping -i 0.2 -W 2 -c 2 $IPADDR1
195ip netns exec ns1 ping -W 2 -c 3 $IPADDR2 228ip netns exec ns1 ping -i 0.2 -W 2 -c 2 $IPADDR2
diff --git a/tools/testing/selftests/bpf/test_xdp_vlan_mode_generic.sh b/tools/testing/selftests/bpf/test_xdp_vlan_mode_generic.sh
new file mode 100755
index 000000000000..c515326d6d59
--- /dev/null
+++ b/tools/testing/selftests/bpf/test_xdp_vlan_mode_generic.sh
@@ -0,0 +1,9 @@
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# Exit on failure
5set -e
6
7# Wrapper script to test generic-XDP
8export TESTNAME=xdp_vlan_mode_generic
9./test_xdp_vlan.sh --mode=xdpgeneric
diff --git a/tools/testing/selftests/bpf/test_xdp_vlan_mode_native.sh b/tools/testing/selftests/bpf/test_xdp_vlan_mode_native.sh
new file mode 100755
index 000000000000..5cf7ce1f16c1
--- /dev/null
+++ b/tools/testing/selftests/bpf/test_xdp_vlan_mode_native.sh
@@ -0,0 +1,9 @@
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# Exit on failure
5set -e
6
7# Wrapper script to test native-XDP
8export TESTNAME=xdp_vlan_mode_native
9./test_xdp_vlan.sh --mode=xdpdrv
diff --git a/tools/testing/selftests/bpf/verifier/ctx_skb.c b/tools/testing/selftests/bpf/verifier/ctx_skb.c
index b0fda2877119..d438193804b2 100644
--- a/tools/testing/selftests/bpf/verifier/ctx_skb.c
+++ b/tools/testing/selftests/bpf/verifier/ctx_skb.c
@@ -975,6 +975,17 @@
975 .prog_type = BPF_PROG_TYPE_CGROUP_SKB, 975 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
976}, 976},
977{ 977{
978 "read gso_segs from CGROUP_SKB",
979 .insns = {
980 BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_1,
981 offsetof(struct __sk_buff, gso_segs)),
982 BPF_MOV64_IMM(BPF_REG_0, 0),
983 BPF_EXIT_INSN(),
984 },
985 .result = ACCEPT,
986 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
987},
988{
978 "write gso_segs from CGROUP_SKB", 989 "write gso_segs from CGROUP_SKB",
979 .insns = { 990 .insns = {
980 BPF_MOV64_IMM(BPF_REG_0, 0), 991 BPF_MOV64_IMM(BPF_REG_0, 0),
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 4c223266299a..bdb69599c4bd 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -191,8 +191,7 @@ int cg_find_unified_root(char *root, size_t len)
191 strtok(NULL, delim); 191 strtok(NULL, delim);
192 strtok(NULL, delim); 192 strtok(NULL, delim);
193 193
194 if (strcmp(fs, "cgroup") == 0 && 194 if (strcmp(type, "cgroup2") == 0) {
195 strcmp(type, "cgroup2") == 0) {
196 strncpy(root, mount, len); 195 strncpy(root, mount, len);
197 return 0; 196 return 0;
198 } 197 }
diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
index 71231ad2dbfb..47315fe48d5a 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
@@ -262,7 +262,7 @@ test_mc_aware()
262 262
263 stop_traffic 263 stop_traffic
264 264
265 log_test "UC performace under MC overload" 265 log_test "UC performance under MC overload"
266 266
267 echo "UC-only throughput $(humanize $ucth1)" 267 echo "UC-only throughput $(humanize $ucth1)"
268 echo "UC+MC throughput $(humanize $ucth2)" 268 echo "UC+MC throughput $(humanize $ucth2)"
@@ -316,7 +316,7 @@ test_uc_aware()
316 316
317 stop_traffic 317 stop_traffic
318 318
319 log_test "MC performace under UC overload" 319 log_test "MC performance under UC overload"
320 echo " ingress UC throughput $(humanize ${uc_ir})" 320 echo " ingress UC throughput $(humanize ${uc_ir})"
321 echo " egress UC throughput $(humanize ${uc_er})" 321 echo " egress UC throughput $(humanize ${uc_er})"
322 echo " sent $attempts BC ARPs, got $passes responses" 322 echo " sent $attempts BC ARPs, got $passes responses"
diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh
index 0a76314b4414..8b944cf042f6 100755
--- a/tools/testing/selftests/kmod/kmod.sh
+++ b/tools/testing/selftests/kmod/kmod.sh
@@ -28,7 +28,7 @@
28# override by exporting to your environment prior running this script. 28# override by exporting to your environment prior running this script.
29# For instance this script assumes you do not have xfs loaded upon boot. 29# For instance this script assumes you do not have xfs loaded upon boot.
30# If this is false, export DEFAULT_KMOD_FS="ext4" prior to running this 30# If this is false, export DEFAULT_KMOD_FS="ext4" prior to running this
31# script if the filesyste module you don't have loaded upon bootup 31# script if the filesystem module you don't have loaded upon bootup
32# is ext4 instead. Refer to allow_user_defaults() for a list of user 32# is ext4 instead. Refer to allow_user_defaults() for a list of user
33# override variables possible. 33# override variables possible.
34# 34#
@@ -263,7 +263,7 @@ config_get_test_result()
263config_reset() 263config_reset()
264{ 264{
265 if ! echo -n "1" >"$DIR"/reset; then 265 if ! echo -n "1" >"$DIR"/reset; then
266 echo "$0: reset shuld have worked" >&2 266 echo "$0: reset should have worked" >&2
267 exit 1 267 exit 1
268 fi 268 fi
269} 269}
@@ -488,7 +488,7 @@ usage()
488 echo Example uses: 488 echo Example uses:
489 echo 489 echo
490 echo "${TEST_NAME}.sh -- executes all tests" 490 echo "${TEST_NAME}.sh -- executes all tests"
491 echo "${TEST_NAME}.sh -t 0008 -- Executes test ID 0008 number of times is recomended" 491 echo "${TEST_NAME}.sh -t 0008 -- Executes test ID 0008 number of times is recommended"
492 echo "${TEST_NAME}.sh -w 0008 -- Watch test ID 0008 run until an error occurs" 492 echo "${TEST_NAME}.sh -w 0008 -- Watch test ID 0008 run until an error occurs"
493 echo "${TEST_NAME}.sh -s 0008 -- Run test ID 0008 once" 493 echo "${TEST_NAME}.sh -s 0008 -- Run test ID 0008 once"
494 echo "${TEST_NAME}.sh -c 0008 3 -- Run test ID 0008 three times" 494 echo "${TEST_NAME}.sh -c 0008 3 -- Run test ID 0008 three times"
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index ec15c4f6af55..0ac49d91a260 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -10,6 +10,7 @@
10#ifndef __KSELFTEST_H 10#ifndef __KSELFTEST_H
11#define __KSELFTEST_H 11#define __KSELFTEST_H
12 12
13#include <errno.h>
13#include <stdlib.h> 14#include <stdlib.h>
14#include <unistd.h> 15#include <unistd.h>
15#include <stdarg.h> 16#include <stdarg.h>
@@ -81,58 +82,68 @@ static inline void ksft_print_cnts(void)
81 82
82static inline void ksft_print_msg(const char *msg, ...) 83static inline void ksft_print_msg(const char *msg, ...)
83{ 84{
85 int saved_errno = errno;
84 va_list args; 86 va_list args;
85 87
86 va_start(args, msg); 88 va_start(args, msg);
87 printf("# "); 89 printf("# ");
90 errno = saved_errno;
88 vprintf(msg, args); 91 vprintf(msg, args);
89 va_end(args); 92 va_end(args);
90} 93}
91 94
92static inline void ksft_test_result_pass(const char *msg, ...) 95static inline void ksft_test_result_pass(const char *msg, ...)
93{ 96{
97 int saved_errno = errno;
94 va_list args; 98 va_list args;
95 99
96 ksft_cnt.ksft_pass++; 100 ksft_cnt.ksft_pass++;
97 101
98 va_start(args, msg); 102 va_start(args, msg);
99 printf("ok %d ", ksft_test_num()); 103 printf("ok %d ", ksft_test_num());
104 errno = saved_errno;
100 vprintf(msg, args); 105 vprintf(msg, args);
101 va_end(args); 106 va_end(args);
102} 107}
103 108
104static inline void ksft_test_result_fail(const char *msg, ...) 109static inline void ksft_test_result_fail(const char *msg, ...)
105{ 110{
111 int saved_errno = errno;
106 va_list args; 112 va_list args;
107 113
108 ksft_cnt.ksft_fail++; 114 ksft_cnt.ksft_fail++;
109 115
110 va_start(args, msg); 116 va_start(args, msg);
111 printf("not ok %d ", ksft_test_num()); 117 printf("not ok %d ", ksft_test_num());
118 errno = saved_errno;
112 vprintf(msg, args); 119 vprintf(msg, args);
113 va_end(args); 120 va_end(args);
114} 121}
115 122
116static inline void ksft_test_result_skip(const char *msg, ...) 123static inline void ksft_test_result_skip(const char *msg, ...)
117{ 124{
125 int saved_errno = errno;
118 va_list args; 126 va_list args;
119 127
120 ksft_cnt.ksft_xskip++; 128 ksft_cnt.ksft_xskip++;
121 129
122 va_start(args, msg); 130 va_start(args, msg);
123 printf("not ok %d # SKIP ", ksft_test_num()); 131 printf("not ok %d # SKIP ", ksft_test_num());
132 errno = saved_errno;
124 vprintf(msg, args); 133 vprintf(msg, args);
125 va_end(args); 134 va_end(args);
126} 135}
127 136
128static inline void ksft_test_result_error(const char *msg, ...) 137static inline void ksft_test_result_error(const char *msg, ...)
129{ 138{
139 int saved_errno = errno;
130 va_list args; 140 va_list args;
131 141
132 ksft_cnt.ksft_error++; 142 ksft_cnt.ksft_error++;
133 143
134 va_start(args, msg); 144 va_start(args, msg);
135 printf("not ok %d # error ", ksft_test_num()); 145 printf("not ok %d # error ", ksft_test_num());
146 errno = saved_errno;
136 vprintf(msg, args); 147 vprintf(msg, args);
137 va_end(args); 148 va_end(args);
138} 149}
@@ -152,10 +163,12 @@ static inline int ksft_exit_fail(void)
152 163
153static inline int ksft_exit_fail_msg(const char *msg, ...) 164static inline int ksft_exit_fail_msg(const char *msg, ...)
154{ 165{
166 int saved_errno = errno;
155 va_list args; 167 va_list args;
156 168
157 va_start(args, msg); 169 va_start(args, msg);
158 printf("Bail out! "); 170 printf("Bail out! ");
171 errno = saved_errno;
159 vprintf(msg, args); 172 vprintf(msg, args);
160 va_end(args); 173 va_end(args);
161 174
@@ -178,10 +191,12 @@ static inline int ksft_exit_xpass(void)
178static inline int ksft_exit_skip(const char *msg, ...) 191static inline int ksft_exit_skip(const char *msg, ...)
179{ 192{
180 if (msg) { 193 if (msg) {
194 int saved_errno = errno;
181 va_list args; 195 va_list args;
182 196
183 va_start(args, msg); 197 va_start(args, msg);
184 printf("not ok %d # SKIP ", 1 + ksft_test_num()); 198 printf("not ok %d # SKIP ", 1 + ksft_test_num());
199 errno = saved_errno;
185 vprintf(msg, args); 200 vprintf(msg, args);
186 va_end(args); 201 va_end(args);
187 } else { 202 } else {
diff --git a/tools/testing/selftests/kvm/.gitignore b/tools/testing/selftests/kvm/.gitignore
index 41266af0d3dc..b35da375530a 100644
--- a/tools/testing/selftests/kvm/.gitignore
+++ b/tools/testing/selftests/kvm/.gitignore
@@ -1,7 +1,7 @@
1/s390x/sync_regs_test
1/x86_64/cr4_cpuid_sync_test 2/x86_64/cr4_cpuid_sync_test
2/x86_64/evmcs_test 3/x86_64/evmcs_test
3/x86_64/hyperv_cpuid 4/x86_64/hyperv_cpuid
4/x86_64/kvm_create_max_vcpus
5/x86_64/mmio_warning_test 5/x86_64/mmio_warning_test
6/x86_64/platform_info_test 6/x86_64/platform_info_test
7/x86_64/set_sregs_test 7/x86_64/set_sregs_test
@@ -13,3 +13,4 @@
13/x86_64/vmx_tsc_adjust_test 13/x86_64/vmx_tsc_adjust_test
14/clear_dirty_log_test 14/clear_dirty_log_test
15/dirty_log_test 15/dirty_log_test
16/kvm_create_max_vcpus
diff --git a/tools/testing/selftests/kvm/config b/tools/testing/selftests/kvm/config
new file mode 100644
index 000000000000..63ed533f73d6
--- /dev/null
+++ b/tools/testing/selftests/kvm/config
@@ -0,0 +1,3 @@
1CONFIG_KVM=y
2CONFIG_KVM_INTEL=y
3CONFIG_KVM_AMD=y
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 30195449c63c..79b0affd21fb 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -13,6 +13,14 @@ function log() {
13 echo "$1" > /dev/kmsg 13 echo "$1" > /dev/kmsg
14} 14}
15 15
16# skip(msg) - testing can't proceed
17# msg - explanation
18function skip() {
19 log "SKIP: $1"
20 echo "SKIP: $1" >&2
21 exit 4
22}
23
16# die(msg) - game over, man 24# die(msg) - game over, man
17# msg - dying words 25# msg - dying words
18function die() { 26function die() {
@@ -21,13 +29,27 @@ function die() {
21 exit 1 29 exit 1
22} 30}
23 31
24# set_dynamic_debug() - setup kernel dynamic debug 32function push_dynamic_debug() {
25# TODO - push and pop this config? 33 DYNAMIC_DEBUG=$(grep '^kernel/livepatch' /sys/kernel/debug/dynamic_debug/control | \
34 awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}')
35}
36
37function pop_dynamic_debug() {
38 if [[ -n "$DYNAMIC_DEBUG" ]]; then
39 echo -n "$DYNAMIC_DEBUG" > /sys/kernel/debug/dynamic_debug/control
40 fi
41}
42
43# set_dynamic_debug() - save the current dynamic debug config and tweak
44# it for the self-tests. Set a script exit trap
45# that restores the original config.
26function set_dynamic_debug() { 46function set_dynamic_debug() {
27 cat << EOF > /sys/kernel/debug/dynamic_debug/control 47 push_dynamic_debug
28file kernel/livepatch/* +p 48 trap pop_dynamic_debug EXIT INT TERM HUP
29func klp_try_switch_task -p 49 cat <<-EOF > /sys/kernel/debug/dynamic_debug/control
30EOF 50 file kernel/livepatch/* +p
51 func klp_try_switch_task -p
52 EOF
31} 53}
32 54
33# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES, 55# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES,
@@ -43,6 +65,12 @@ function loop_until() {
43 done 65 done
44} 66}
45 67
68function assert_mod() {
69 local mod="$1"
70
71 modprobe --dry-run "$mod" &>/dev/null
72}
73
46function is_livepatch_mod() { 74function is_livepatch_mod() {
47 local mod="$1" 75 local mod="$1"
48 76
@@ -75,6 +103,9 @@ function __load_mod() {
75function load_mod() { 103function load_mod() {
76 local mod="$1"; shift 104 local mod="$1"; shift
77 105
106 assert_mod "$mod" ||
107 skip "unable to load module ${mod}, verify CONFIG_TEST_LIVEPATCH=m and run self-tests as root"
108
78 is_livepatch_mod "$mod" && 109 is_livepatch_mod "$mod" &&
79 die "use load_lp() to load the livepatch module $mod" 110 die "use load_lp() to load the livepatch module $mod"
80 111
@@ -88,6 +119,9 @@ function load_mod() {
88function load_lp_nowait() { 119function load_lp_nowait() {
89 local mod="$1"; shift 120 local mod="$1"; shift
90 121
122 assert_mod "$mod" ||
123 skip "unable to load module ${mod}, verify CONFIG_TEST_LIVEPATCH=m and run self-tests as root"
124
91 is_livepatch_mod "$mod" || 125 is_livepatch_mod "$mod" ||
92 die "module $mod is not a livepatch" 126 die "module $mod is not a livepatch"
93 127
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 4ce0bc1612f5..c7cced739c34 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -17,7 +17,7 @@ tcp_inq
17tls 17tls
18txring_overwrite 18txring_overwrite
19ip_defrag 19ip_defrag
20ipv6_flowlabel
21ipv6_flowlabel_mgr
20so_txtime 22so_txtime
21flowlabel
22flowlabel_mgr
23tcp_fastopen_backup_key 23tcp_fastopen_backup_key
diff --git a/tools/testing/selftests/net/forwarding/gre_multipath.sh b/tools/testing/selftests/net/forwarding/gre_multipath.sh
index cca2baa03fb8..a8d8e8b3dc81 100755
--- a/tools/testing/selftests/net/forwarding/gre_multipath.sh
+++ b/tools/testing/selftests/net/forwarding/gre_multipath.sh
@@ -93,18 +93,10 @@ sw1_create()
93 ip route add vrf v$ol1 192.0.2.16/28 \ 93 ip route add vrf v$ol1 192.0.2.16/28 \
94 nexthop dev g1a \ 94 nexthop dev g1a \
95 nexthop dev g1b 95 nexthop dev g1b
96
97 tc qdisc add dev $ul1 clsact
98 tc filter add dev $ul1 egress pref 111 prot ipv4 \
99 flower dst_ip 192.0.2.66 action pass
100 tc filter add dev $ul1 egress pref 222 prot ipv4 \
101 flower dst_ip 192.0.2.82 action pass
102} 96}
103 97
104sw1_destroy() 98sw1_destroy()
105{ 99{
106 tc qdisc del dev $ul1 clsact
107
108 ip route del vrf v$ol1 192.0.2.16/28 100 ip route del vrf v$ol1 192.0.2.16/28
109 101
110 ip route del vrf v$ol1 192.0.2.82/32 via 192.0.2.146 102 ip route del vrf v$ol1 192.0.2.82/32 via 192.0.2.146
@@ -139,10 +131,18 @@ sw2_create()
139 ip route add vrf v$ol2 192.0.2.0/28 \ 131 ip route add vrf v$ol2 192.0.2.0/28 \
140 nexthop dev g2a \ 132 nexthop dev g2a \
141 nexthop dev g2b 133 nexthop dev g2b
134
135 tc qdisc add dev $ul2 clsact
136 tc filter add dev $ul2 ingress pref 111 prot 802.1Q \
137 flower vlan_id 111 action pass
138 tc filter add dev $ul2 ingress pref 222 prot 802.1Q \
139 flower vlan_id 222 action pass
142} 140}
143 141
144sw2_destroy() 142sw2_destroy()
145{ 143{
144 tc qdisc del dev $ul2 clsact
145
146 ip route del vrf v$ol2 192.0.2.0/28 146 ip route del vrf v$ol2 192.0.2.0/28
147 147
148 ip route del vrf v$ol2 192.0.2.81/32 via 192.0.2.145 148 ip route del vrf v$ol2 192.0.2.81/32 via 192.0.2.145
@@ -187,12 +187,16 @@ setup_prepare()
187 sw1_create 187 sw1_create
188 sw2_create 188 sw2_create
189 h2_create 189 h2_create
190
191 forwarding_enable
190} 192}
191 193
192cleanup() 194cleanup()
193{ 195{
194 pre_cleanup 196 pre_cleanup
195 197
198 forwarding_restore
199
196 h2_destroy 200 h2_destroy
197 sw2_destroy 201 sw2_destroy
198 sw1_destroy 202 sw1_destroy
@@ -211,15 +215,15 @@ multipath4_test()
211 nexthop dev g1a weight $weight1 \ 215 nexthop dev g1a weight $weight1 \
212 nexthop dev g1b weight $weight2 216 nexthop dev g1b weight $weight2
213 217
214 local t0_111=$(tc_rule_stats_get $ul1 111 egress) 218 local t0_111=$(tc_rule_stats_get $ul2 111 ingress)
215 local t0_222=$(tc_rule_stats_get $ul1 222 egress) 219 local t0_222=$(tc_rule_stats_get $ul2 222 ingress)
216 220
217 ip vrf exec v$h1 \ 221 ip vrf exec v$h1 \
218 $MZ $h1 -q -p 64 -A 192.0.2.1 -B 192.0.2.18 \ 222 $MZ $h1 -q -p 64 -A 192.0.2.1 -B 192.0.2.18 \
219 -d 1msec -t udp "sp=1024,dp=0-32768" 223 -d 1msec -t udp "sp=1024,dp=0-32768"
220 224
221 local t1_111=$(tc_rule_stats_get $ul1 111 egress) 225 local t1_111=$(tc_rule_stats_get $ul2 111 ingress)
222 local t1_222=$(tc_rule_stats_get $ul1 222 egress) 226 local t1_222=$(tc_rule_stats_get $ul2 222 ingress)
223 227
224 local d111=$((t1_111 - t0_111)) 228 local d111=$((t1_111 - t0_111))
225 local d222=$((t1_222 - t0_222)) 229 local d222=$((t1_222 - t0_222))
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 090fff9dbc48..4c285b6e1db8 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -25,6 +25,80 @@
25#define TLS_PAYLOAD_MAX_LEN 16384 25#define TLS_PAYLOAD_MAX_LEN 16384
26#define SOL_TLS 282 26#define SOL_TLS 282
27 27
28#ifndef ENOTSUPP
29#define ENOTSUPP 524
30#endif
31
32FIXTURE(tls_basic)
33{
34 int fd, cfd;
35 bool notls;
36};
37
38FIXTURE_SETUP(tls_basic)
39{
40 struct sockaddr_in addr;
41 socklen_t len;
42 int sfd, ret;
43
44 self->notls = false;
45 len = sizeof(addr);
46
47 addr.sin_family = AF_INET;
48 addr.sin_addr.s_addr = htonl(INADDR_ANY);
49 addr.sin_port = 0;
50
51 self->fd = socket(AF_INET, SOCK_STREAM, 0);
52 sfd = socket(AF_INET, SOCK_STREAM, 0);
53
54 ret = bind(sfd, &addr, sizeof(addr));
55 ASSERT_EQ(ret, 0);
56 ret = listen(sfd, 10);
57 ASSERT_EQ(ret, 0);
58
59 ret = getsockname(sfd, &addr, &len);
60 ASSERT_EQ(ret, 0);
61
62 ret = connect(self->fd, &addr, sizeof(addr));
63 ASSERT_EQ(ret, 0);
64
65 self->cfd = accept(sfd, &addr, &len);
66 ASSERT_GE(self->cfd, 0);
67
68 close(sfd);
69
70 ret = setsockopt(self->fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
71 if (ret != 0) {
72 ASSERT_EQ(errno, ENOENT);
73 self->notls = true;
74 printf("Failure setting TCP_ULP, testing without tls\n");
75 return;
76 }
77
78 ret = setsockopt(self->cfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
79 ASSERT_EQ(ret, 0);
80}
81
82FIXTURE_TEARDOWN(tls_basic)
83{
84 close(self->fd);
85 close(self->cfd);
86}
87
88/* Send some data through with ULP but no keys */
89TEST_F(tls_basic, base_base)
90{
91 char const *test_str = "test_read";
92 int send_len = 10;
93 char buf[10];
94
95 ASSERT_EQ(strlen(test_str) + 1, send_len);
96
97 EXPECT_EQ(send(self->fd, test_str, send_len, 0), send_len);
98 EXPECT_NE(recv(self->cfd, buf, send_len, 0), -1);
99 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
100};
101
28FIXTURE(tls) 102FIXTURE(tls)
29{ 103{
30 int fd, cfd; 104 int fd, cfd;
@@ -165,6 +239,16 @@ TEST_F(tls, msg_more)
165 EXPECT_EQ(memcmp(buf, test_str, send_len), 0); 239 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
166} 240}
167 241
242TEST_F(tls, msg_more_unsent)
243{
244 char const *test_str = "test_read";
245 int send_len = 10;
246 char buf[10];
247
248 EXPECT_EQ(send(self->fd, test_str, send_len, MSG_MORE), send_len);
249 EXPECT_EQ(recv(self->cfd, buf, send_len, MSG_DONTWAIT), -1);
250}
251
168TEST_F(tls, sendmsg_single) 252TEST_F(tls, sendmsg_single)
169{ 253{
170 struct msghdr msg; 254 struct msghdr msg;
@@ -610,6 +694,42 @@ TEST_F(tls, recv_lowat)
610 EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0); 694 EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0);
611} 695}
612 696
697TEST_F(tls, bidir)
698{
699 char const *test_str = "test_read";
700 int send_len = 10;
701 char buf[10];
702 int ret;
703
704 if (!self->notls) {
705 struct tls12_crypto_info_aes_gcm_128 tls12;
706
707 memset(&tls12, 0, sizeof(tls12));
708 tls12.info.version = TLS_1_3_VERSION;
709 tls12.info.cipher_type = TLS_CIPHER_AES_GCM_128;
710
711 ret = setsockopt(self->fd, SOL_TLS, TLS_RX, &tls12,
712 sizeof(tls12));
713 ASSERT_EQ(ret, 0);
714
715 ret = setsockopt(self->cfd, SOL_TLS, TLS_TX, &tls12,
716 sizeof(tls12));
717 ASSERT_EQ(ret, 0);
718 }
719
720 ASSERT_EQ(strlen(test_str) + 1, send_len);
721
722 EXPECT_EQ(send(self->fd, test_str, send_len, 0), send_len);
723 EXPECT_NE(recv(self->cfd, buf, send_len, 0), -1);
724 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
725
726 memset(buf, 0, sizeof(buf));
727
728 EXPECT_EQ(send(self->cfd, test_str, send_len, 0), send_len);
729 EXPECT_NE(recv(self->fd, buf, send_len, 0), -1);
730 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
731};
732
613TEST_F(tls, pollin) 733TEST_F(tls, pollin)
614{ 734{
615 char const *test_str = "test_poll"; 735 char const *test_str = "test_poll";
@@ -837,6 +957,109 @@ TEST_F(tls, control_msg)
837 EXPECT_EQ(memcmp(buf, test_str, send_len), 0); 957 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
838} 958}
839 959
960TEST_F(tls, shutdown)
961{
962 char const *test_str = "test_read";
963 int send_len = 10;
964 char buf[10];
965
966 ASSERT_EQ(strlen(test_str) + 1, send_len);
967
968 EXPECT_EQ(send(self->fd, test_str, send_len, 0), send_len);
969 EXPECT_NE(recv(self->cfd, buf, send_len, 0), -1);
970 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
971
972 shutdown(self->fd, SHUT_RDWR);
973 shutdown(self->cfd, SHUT_RDWR);
974}
975
976TEST_F(tls, shutdown_unsent)
977{
978 char const *test_str = "test_read";
979 int send_len = 10;
980
981 EXPECT_EQ(send(self->fd, test_str, send_len, MSG_MORE), send_len);
982
983 shutdown(self->fd, SHUT_RDWR);
984 shutdown(self->cfd, SHUT_RDWR);
985}
986
987TEST_F(tls, shutdown_reuse)
988{
989 struct sockaddr_in addr;
990 int ret;
991
992 shutdown(self->fd, SHUT_RDWR);
993 shutdown(self->cfd, SHUT_RDWR);
994 close(self->cfd);
995
996 addr.sin_family = AF_INET;
997 addr.sin_addr.s_addr = htonl(INADDR_ANY);
998 addr.sin_port = 0;
999
1000 ret = bind(self->fd, &addr, sizeof(addr));
1001 EXPECT_EQ(ret, 0);
1002 ret = listen(self->fd, 10);
1003 EXPECT_EQ(ret, -1);
1004 EXPECT_EQ(errno, EINVAL);
1005
1006 ret = connect(self->fd, &addr, sizeof(addr));
1007 EXPECT_EQ(ret, -1);
1008 EXPECT_EQ(errno, EISCONN);
1009}
1010
1011TEST(non_established) {
1012 struct tls12_crypto_info_aes_gcm_256 tls12;
1013 struct sockaddr_in addr;
1014 int sfd, ret, fd;
1015 socklen_t len;
1016
1017 len = sizeof(addr);
1018
1019 memset(&tls12, 0, sizeof(tls12));
1020 tls12.info.version = TLS_1_2_VERSION;
1021 tls12.info.cipher_type = TLS_CIPHER_AES_GCM_256;
1022
1023 addr.sin_family = AF_INET;
1024 addr.sin_addr.s_addr = htonl(INADDR_ANY);
1025 addr.sin_port = 0;
1026
1027 fd = socket(AF_INET, SOCK_STREAM, 0);
1028 sfd = socket(AF_INET, SOCK_STREAM, 0);
1029
1030 ret = bind(sfd, &addr, sizeof(addr));
1031 ASSERT_EQ(ret, 0);
1032 ret = listen(sfd, 10);
1033 ASSERT_EQ(ret, 0);
1034
1035 ret = setsockopt(fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
1036 EXPECT_EQ(ret, -1);
1037 /* TLS ULP not supported */
1038 if (errno == ENOENT)
1039 return;
1040 EXPECT_EQ(errno, ENOTSUPP);
1041
1042 ret = setsockopt(sfd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
1043 EXPECT_EQ(ret, -1);
1044 EXPECT_EQ(errno, ENOTSUPP);
1045
1046 ret = getsockname(sfd, &addr, &len);
1047 ASSERT_EQ(ret, 0);
1048
1049 ret = connect(fd, &addr, sizeof(addr));
1050 ASSERT_EQ(ret, 0);
1051
1052 ret = setsockopt(fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
1053 ASSERT_EQ(ret, 0);
1054
1055 ret = setsockopt(fd, IPPROTO_TCP, TCP_ULP, "tls", sizeof("tls"));
1056 EXPECT_EQ(ret, -1);
1057 EXPECT_EQ(errno, EEXIST);
1058
1059 close(fd);
1060 close(sfd);
1061}
1062
840TEST(keysizes) { 1063TEST(keysizes) {
841 struct tls12_crypto_info_aes_gcm_256 tls12; 1064 struct tls12_crypto_info_aes_gcm_256 tls12;
842 struct sockaddr_in addr; 1065 struct sockaddr_in addr;
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
index 7eaa8a3de262..b632965e60eb 100644
--- a/tools/testing/selftests/pidfd/pidfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_test.c
@@ -339,13 +339,9 @@ static int test_pidfd_send_signal_syscall_support(void)
339 339
340 ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0); 340 ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0);
341 if (ret < 0) { 341 if (ret < 0) {
342 /*
343 * pidfd_send_signal() will currently return ENOSYS when
344 * CONFIG_PROC_FS is not set.
345 */
346 if (errno == ENOSYS) 342 if (errno == ENOSYS)
347 ksft_exit_skip( 343 ksft_exit_skip(
348 "%s test: pidfd_send_signal() syscall not supported (Ensure that CONFIG_PROC_FS=y is set)\n", 344 "%s test: pidfd_send_signal() syscall not supported\n",
349 test_name); 345 test_name);
350 346
351 ksft_exit_fail_msg("%s test: Failed to send signal\n", 347 ksft_exit_fail_msg("%s test: Failed to send signal\n",
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json
index cc7c7d758008..6503b1ce091f 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json
@@ -713,5 +713,99 @@
713 "teardown": [ 713 "teardown": [
714 "$TC actions flush action vlan" 714 "$TC actions flush action vlan"
715 ] 715 ]
716 },
717 {
718 "id": "294e",
719 "name": "Add batch of 32 vlan push actions with cookie",
720 "category": [
721 "actions",
722 "vlan"
723 ],
724 "setup": [
725 [
726 "$TC actions flush action vlan",
727 0,
728 1,
729 255
730 ]
731 ],
732 "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan push protocol 802.1q id 4094 priority 7 pipe index \\$i cookie aabbccddeeff112233445566778800a1 \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
733 "expExitCode": "0",
734 "verifyCmd": "$TC actions list action vlan",
735 "matchPattern": "^[ \t]+index [0-9]+ ref",
736 "matchCount": "32",
737 "teardown": [
738 "$TC actions flush action vlan"
739 ]
740 },
741 {
742 "id": "56f7",
743 "name": "Delete batch of 32 vlan push actions",
744 "category": [
745 "actions",
746 "vlan"
747 ],
748 "setup": [
749 [
750 "$TC actions flush action vlan",
751 0,
752 1,
753 255
754 ],
755 "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan push protocol 802.1q id 4094 priority 7 pipe index \\$i \\\"; args=\\\"\\$args\\$cmd\\\"; done && $TC actions add \\$args\""
756 ],
757 "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions del \\$args\"",
758 "expExitCode": "0",
759 "verifyCmd": "$TC actions list action vlan",
760 "matchPattern": "^[ \t]+index [0-9]+ ref",
761 "matchCount": "0",
762 "teardown": []
763 },
764 {
765 "id": "759f",
766 "name": "Add batch of 32 vlan pop actions with cookie",
767 "category": [
768 "actions",
769 "vlan"
770 ],
771 "setup": [
772 [
773 "$TC actions flush action vlan",
774 0,
775 1,
776 255
777 ]
778 ],
779 "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan pop continue index \\$i cookie aabbccddeeff112233445566778800a1 \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
780 "expExitCode": "0",
781 "verifyCmd": "$TC actions list action vlan",
782 "matchPattern": "^[ \t]+index [0-9]+ ref",
783 "matchCount": "32",
784 "teardown": [
785 "$TC actions flush action vlan"
786 ]
787 },
788 {
789 "id": "c84a",
790 "name": "Delete batch of 32 vlan pop actions",
791 "category": [
792 "actions",
793 "vlan"
794 ],
795 "setup": [
796 [
797 "$TC actions flush action vlan",
798 0,
799 1,
800 255
801 ],
802 "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan pop index \\$i \\\"; args=\\\"\\$args\\$cmd\\\"; done && $TC actions add \\$args\""
803 ],
804 "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action vlan index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions del \\$args\"",
805 "expExitCode": "0",
806 "verifyCmd": "$TC actions list action vlan",
807 "matchPattern": "^[ \t]+index [0-9]+ ref",
808 "matchCount": "0",
809 "teardown": []
716 } 810 }
717] 811]
diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c
index 4602326b8f5b..a4f4d4cf22c3 100644
--- a/tools/testing/selftests/x86/test_vsyscall.c
+++ b/tools/testing/selftests/x86/test_vsyscall.c
@@ -451,7 +451,7 @@ static int test_vsys_x(void)
451 printf("[OK]\tExecuting the vsyscall page failed: #PF(0x%lx)\n", 451 printf("[OK]\tExecuting the vsyscall page failed: #PF(0x%lx)\n",
452 segv_err); 452 segv_err);
453 } else { 453 } else {
454 printf("[FAILT]\tExecution failed with the wrong error: #PF(0x%lx)\n", 454 printf("[FAIL]\tExecution failed with the wrong error: #PF(0x%lx)\n",
455 segv_err); 455 segv_err);
456 return 1; 456 return 1;
457 } 457 }