aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/bpf/bpftool/common.c11
-rw-r--r--tools/testing/selftests/bpf/Makefile2
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c40
-rwxr-xr-xtools/testing/selftests/drivers/usb/usbip/usbip_test.sh2
-rw-r--r--tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc28
-rw-r--r--tools/usb/ffs-test.c19
6 files changed, 93 insertions, 9 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 32f9e397a6c0..3f140eff039f 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
217 int err; 217 int err;
218 int fd; 218 int fd;
219 219
220 if (argc < 3) {
221 p_err("too few arguments, id ID and FILE path is required");
222 return -1;
223 } else if (argc > 3) {
224 p_err("too many arguments");
225 return -1;
226 }
227
220 if (!is_prefix(*argv, "id")) { 228 if (!is_prefix(*argv, "id")) {
221 p_err("expected 'id' got %s", *argv); 229 p_err("expected 'id' got %s", *argv);
222 return -1; 230 return -1;
@@ -230,9 +238,6 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
230 } 238 }
231 NEXT_ARG(); 239 NEXT_ARG();
232 240
233 if (argc != 1)
234 usage();
235
236 fd = get_fd_by_id(id); 241 fd = get_fd_by_id(id);
237 if (fd < 0) { 242 if (fd < 0) {
238 p_err("can't get prog by id (%u): %s", id, strerror(errno)); 243 p_err("can't get prog by id (%u): %s", id, strerror(errno));
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 7a6214e9ae58..a362e3d7abc6 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -105,7 +105,7 @@ $(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline
105 105
106BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris) 106BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
107BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) 107BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
108BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --version 2>&1 | grep LLVM) 108BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
109 109
110ifneq ($(BTF_LLC_PROBE),) 110ifneq ($(BTF_LLC_PROBE),)
111ifneq ($(BTF_PAHOLE_PROBE),) 111ifneq ($(BTF_PAHOLE_PROBE),)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index f5f7bcc96046..41106d9d5cc7 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -12005,6 +12005,46 @@ static struct bpf_test tests[] = {
12005 .prog_type = BPF_PROG_TYPE_XDP, 12005 .prog_type = BPF_PROG_TYPE_XDP,
12006 }, 12006 },
12007 { 12007 {
12008 "xadd/w check whether src/dst got mangled, 1",
12009 .insns = {
12010 BPF_MOV64_IMM(BPF_REG_0, 1),
12011 BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
12012 BPF_MOV64_REG(BPF_REG_7, BPF_REG_10),
12013 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12014 BPF_STX_XADD(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12015 BPF_STX_XADD(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12016 BPF_JMP_REG(BPF_JNE, BPF_REG_6, BPF_REG_0, 3),
12017 BPF_JMP_REG(BPF_JNE, BPF_REG_7, BPF_REG_10, 2),
12018 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8),
12019 BPF_EXIT_INSN(),
12020 BPF_MOV64_IMM(BPF_REG_0, 42),
12021 BPF_EXIT_INSN(),
12022 },
12023 .result = ACCEPT,
12024 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
12025 .retval = 3,
12026 },
12027 {
12028 "xadd/w check whether src/dst got mangled, 2",
12029 .insns = {
12030 BPF_MOV64_IMM(BPF_REG_0, 1),
12031 BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
12032 BPF_MOV64_REG(BPF_REG_7, BPF_REG_10),
12033 BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12034 BPF_STX_XADD(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12035 BPF_STX_XADD(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12036 BPF_JMP_REG(BPF_JNE, BPF_REG_6, BPF_REG_0, 3),
12037 BPF_JMP_REG(BPF_JNE, BPF_REG_7, BPF_REG_10, 2),
12038 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -8),
12039 BPF_EXIT_INSN(),
12040 BPF_MOV64_IMM(BPF_REG_0, 42),
12041 BPF_EXIT_INSN(),
12042 },
12043 .result = ACCEPT,
12044 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
12045 .retval = 3,
12046 },
12047 {
12008 "bpf_get_stack return R0 within range", 12048 "bpf_get_stack return R0 within range",
12009 .insns = { 12049 .insns = {
12010 BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), 12050 BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
diff --git a/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh
index 1893d0f59ad7..a72df93cf1f8 100755
--- a/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh
+++ b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh
@@ -46,7 +46,6 @@ if ! /sbin/modprobe -q -n usbip_host; then
46fi 46fi
47 47
48if /sbin/modprobe -q usbip_host; then 48if /sbin/modprobe -q usbip_host; then
49 /sbin/modprobe -q -r test_bitmap
50 echo "usbip_test: module usbip_host is loaded [OK]" 49 echo "usbip_test: module usbip_host is loaded [OK]"
51else 50else
52 echo "usbip_test: module usbip_host failed to load [FAIL]" 51 echo "usbip_test: module usbip_host failed to load [FAIL]"
@@ -56,7 +55,6 @@ fi
56 55
57echo "Load vhci_hcd module" 56echo "Load vhci_hcd module"
58if /sbin/modprobe -q vhci_hcd; then 57if /sbin/modprobe -q vhci_hcd; then
59 /sbin/modprobe -q -r test_bitmap
60 echo "usbip_test: module vhci_hcd is loaded [OK]" 58 echo "usbip_test: module vhci_hcd is loaded [OK]"
61else 59else
62 echo "usbip_test: module vhci_hcd failed to load [FAIL]" 60 echo "usbip_test: module vhci_hcd failed to load [FAIL]"
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc b/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
new file mode 100644
index 000000000000..3b1f45e13a2e
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
@@ -0,0 +1,28 @@
1#!/bin/sh
2# description: Snapshot and tracing setting
3# flags: instance
4
5[ ! -f snapshot ] && exit_unsupported
6
7echo "Set tracing off"
8echo 0 > tracing_on
9
10echo "Allocate and take a snapshot"
11echo 1 > snapshot
12
13# Since trace buffer is empty, snapshot is also empty, but allocated
14grep -q "Snapshot is allocated" snapshot
15
16echo "Ensure keep tracing off"
17test `cat tracing_on` -eq 0
18
19echo "Set tracing on"
20echo 1 > tracing_on
21
22echo "Take a snapshot again"
23echo 1 > snapshot
24
25echo "Ensure keep tracing on"
26test `cat tracing_on` -eq 1
27
28exit 0
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index 95dd14648ba5..0f395dfb7774 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -44,12 +44,25 @@
44 44
45/******************** Little Endian Handling ********************************/ 45/******************** Little Endian Handling ********************************/
46 46
47#define cpu_to_le16(x) htole16(x) 47/*
48#define cpu_to_le32(x) htole32(x) 48 * cpu_to_le16/32 are used when initializing structures, a context where a
49 * function call is not allowed. To solve this, we code cpu_to_le16/32 in a way
50 * that allows them to be used when initializing structures.
51 */
52
53#if __BYTE_ORDER == __LITTLE_ENDIAN
54#define cpu_to_le16(x) (x)
55#define cpu_to_le32(x) (x)
56#else
57#define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
58#define cpu_to_le32(x) \
59 ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
60 (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
61#endif
62
49#define le32_to_cpu(x) le32toh(x) 63#define le32_to_cpu(x) le32toh(x)
50#define le16_to_cpu(x) le16toh(x) 64#define le16_to_cpu(x) le16toh(x)
51 65
52
53/******************** Messages and Errors ***********************************/ 66/******************** Messages and Errors ***********************************/
54 67
55static const char argv0[] = "ffs-test"; 68static const char argv0[] = "ffs-test";