diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-06-06 14:03:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-06-06 14:03:46 -0400 |
commit | dd8038ec56c18680ddddf948247f53d427054f45 (patch) | |
tree | 9552d8cd5578bf82e028dd4205b799736f877476 /tools | |
parent | 4eab0ea196f569ed2085a0fa3729f60eb8edaad1 (diff) | |
parent | 7327a946a3b921d60d48924d34ac99eae2fae57d (diff) |
Merge tag 'asoc-fix-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v4.12
This is the usual collection of device specific fixes, all accumilated
since the merge window, plus one fix from Takashi for a nasty use after
free bug that bit some things with deferred probe and an update to the
maintainer address for the former Wolfson parts.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build/feature/test-bpf.c | 1 | ||||
-rw-r--r-- | tools/include/uapi/linux/bpf.h | 11 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.c | 22 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.h | 4 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/Makefile | 6 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/include/uapi/linux/types.h | 22 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_align.c | 453 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_pkt_access.c | 1 | ||||
-rwxr-xr-x | tools/testing/selftests/ftrace/ftracetest | 2 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc | 2 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/functions | 4 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/instances/instance-event.tc | 8 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/.gitignore | 1 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/Makefile | 4 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c | 118 |
15 files changed, 648 insertions, 11 deletions
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c index ebc6dceddb58..7598361ef1f1 100644 --- a/tools/build/feature/test-bpf.c +++ b/tools/build/feature/test-bpf.c | |||
@@ -29,6 +29,7 @@ int main(void) | |||
29 | attr.log_size = 0; | 29 | attr.log_size = 0; |
30 | attr.log_level = 0; | 30 | attr.log_level = 0; |
31 | attr.kern_version = 0; | 31 | attr.kern_version = 0; |
32 | attr.prog_flags = 0; | ||
32 | 33 | ||
33 | /* | 34 | /* |
34 | * Test existence of __NR_bpf and BPF_PROG_LOAD. | 35 | * Test existence of __NR_bpf and BPF_PROG_LOAD. |
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index e553529929f6..94dfa9def355 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
@@ -132,6 +132,13 @@ enum bpf_attach_type { | |||
132 | */ | 132 | */ |
133 | #define BPF_F_ALLOW_OVERRIDE (1U << 0) | 133 | #define BPF_F_ALLOW_OVERRIDE (1U << 0) |
134 | 134 | ||
135 | /* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the | ||
136 | * verifier will perform strict alignment checking as if the kernel | ||
137 | * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set, | ||
138 | * and NET_IP_ALIGN defined to 2. | ||
139 | */ | ||
140 | #define BPF_F_STRICT_ALIGNMENT (1U << 0) | ||
141 | |||
135 | #define BPF_PSEUDO_MAP_FD 1 | 142 | #define BPF_PSEUDO_MAP_FD 1 |
136 | 143 | ||
137 | /* flags for BPF_MAP_UPDATE_ELEM command */ | 144 | /* flags for BPF_MAP_UPDATE_ELEM command */ |
@@ -177,6 +184,7 @@ union bpf_attr { | |||
177 | __u32 log_size; /* size of user buffer */ | 184 | __u32 log_size; /* size of user buffer */ |
178 | __aligned_u64 log_buf; /* user supplied buffer */ | 185 | __aligned_u64 log_buf; /* user supplied buffer */ |
179 | __u32 kern_version; /* checked when prog_type=kprobe */ | 186 | __u32 kern_version; /* checked when prog_type=kprobe */ |
187 | __u32 prog_flags; | ||
180 | }; | 188 | }; |
181 | 189 | ||
182 | struct { /* anonymous struct used by BPF_OBJ_* commands */ | 190 | struct { /* anonymous struct used by BPF_OBJ_* commands */ |
@@ -481,8 +489,7 @@ union bpf_attr { | |||
481 | * u32 bpf_get_socket_uid(skb) | 489 | * u32 bpf_get_socket_uid(skb) |
482 | * Get the owner uid of the socket stored inside sk_buff. | 490 | * Get the owner uid of the socket stored inside sk_buff. |
483 | * @skb: pointer to skb | 491 | * @skb: pointer to skb |
484 | * Return: uid of the socket owner on success or 0 if the socket pointer | 492 | * Return: uid of the socket owner on success or overflowuid if failed. |
485 | * inside sk_buff is NULL | ||
486 | */ | 493 | */ |
487 | #define __BPF_FUNC_MAPPER(FN) \ | 494 | #define __BPF_FUNC_MAPPER(FN) \ |
488 | FN(unspec), \ | 495 | FN(unspec), \ |
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 4fe444b8092e..6e178987af8e 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -117,6 +117,28 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
117 | return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); | 117 | return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); |
118 | } | 118 | } |
119 | 119 | ||
120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | ||
121 | size_t insns_cnt, int strict_alignment, | ||
122 | const char *license, __u32 kern_version, | ||
123 | char *log_buf, size_t log_buf_sz) | ||
124 | { | ||
125 | union bpf_attr attr; | ||
126 | |||
127 | bzero(&attr, sizeof(attr)); | ||
128 | attr.prog_type = type; | ||
129 | attr.insn_cnt = (__u32)insns_cnt; | ||
130 | attr.insns = ptr_to_u64(insns); | ||
131 | attr.license = ptr_to_u64(license); | ||
132 | attr.log_buf = ptr_to_u64(log_buf); | ||
133 | attr.log_size = log_buf_sz; | ||
134 | attr.log_level = 2; | ||
135 | log_buf[0] = 0; | ||
136 | attr.kern_version = kern_version; | ||
137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; | ||
138 | |||
139 | return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); | ||
140 | } | ||
141 | |||
120 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 142 | int bpf_map_update_elem(int fd, const void *key, const void *value, |
121 | __u64 flags) | 143 | __u64 flags) |
122 | { | 144 | { |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index edb4daeff7a5..972bd8333eb7 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -35,6 +35,10 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
35 | size_t insns_cnt, const char *license, | 35 | size_t insns_cnt, const char *license, |
36 | __u32 kern_version, char *log_buf, | 36 | __u32 kern_version, char *log_buf, |
37 | size_t log_buf_sz); | 37 | size_t log_buf_sz); |
38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | ||
39 | size_t insns_cnt, int strict_alignment, | ||
40 | const char *license, __u32 kern_version, | ||
41 | char *log_buf, size_t log_buf_sz); | ||
38 | 42 | ||
39 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 43 | int bpf_map_update_elem(int fd, const void *key, const void *value, |
40 | __u64 flags); | 44 | __u64 flags); |
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 91edd0566237..f389b02d43a0 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile | |||
@@ -11,7 +11,8 @@ endif | |||
11 | CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include | 11 | CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include |
12 | LDLIBS += -lcap -lelf | 12 | LDLIBS += -lcap -lelf |
13 | 13 | ||
14 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs | 14 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \ |
15 | test_align | ||
15 | 16 | ||
16 | TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o | 17 | TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o |
17 | 18 | ||
@@ -34,6 +35,7 @@ $(BPFOBJ): force | |||
34 | CLANG ?= clang | 35 | CLANG ?= clang |
35 | 36 | ||
36 | %.o: %.c | 37 | %.o: %.c |
37 | $(CLANG) -I. -I../../../include/uapi -I../../../../samples/bpf/ \ | 38 | $(CLANG) -I. -I./include/uapi -I../../../include/uapi \ |
39 | -I../../../../samples/bpf/ \ | ||
38 | -Wno-compare-distinct-pointer-types \ | 40 | -Wno-compare-distinct-pointer-types \ |
39 | -O2 -target bpf -c $< -o $@ | 41 | -O2 -target bpf -c $< -o $@ |
diff --git a/tools/testing/selftests/bpf/include/uapi/linux/types.h b/tools/testing/selftests/bpf/include/uapi/linux/types.h new file mode 100644 index 000000000000..51841848fbfe --- /dev/null +++ b/tools/testing/selftests/bpf/include/uapi/linux/types.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef _UAPI_LINUX_TYPES_H | ||
2 | #define _UAPI_LINUX_TYPES_H | ||
3 | |||
4 | #include <asm-generic/int-ll64.h> | ||
5 | |||
6 | /* copied from linux:include/uapi/linux/types.h */ | ||
7 | #define __bitwise | ||
8 | typedef __u16 __bitwise __le16; | ||
9 | typedef __u16 __bitwise __be16; | ||
10 | typedef __u32 __bitwise __le32; | ||
11 | typedef __u32 __bitwise __be32; | ||
12 | typedef __u64 __bitwise __le64; | ||
13 | typedef __u64 __bitwise __be64; | ||
14 | |||
15 | typedef __u16 __bitwise __sum16; | ||
16 | typedef __u32 __bitwise __wsum; | ||
17 | |||
18 | #define __aligned_u64 __u64 __attribute__((aligned(8))) | ||
19 | #define __aligned_be64 __be64 __attribute__((aligned(8))) | ||
20 | #define __aligned_le64 __le64 __attribute__((aligned(8))) | ||
21 | |||
22 | #endif /* _UAPI_LINUX_TYPES_H */ | ||
diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c new file mode 100644 index 000000000000..9644d4e069de --- /dev/null +++ b/tools/testing/selftests/bpf/test_align.c | |||
@@ -0,0 +1,453 @@ | |||
1 | #include <asm/types.h> | ||
2 | #include <linux/types.h> | ||
3 | #include <stdint.h> | ||
4 | #include <stdio.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <unistd.h> | ||
7 | #include <errno.h> | ||
8 | #include <string.h> | ||
9 | #include <stddef.h> | ||
10 | #include <stdbool.h> | ||
11 | |||
12 | #include <linux/unistd.h> | ||
13 | #include <linux/filter.h> | ||
14 | #include <linux/bpf_perf_event.h> | ||
15 | #include <linux/bpf.h> | ||
16 | |||
17 | #include <bpf/bpf.h> | ||
18 | |||
19 | #include "../../../include/linux/filter.h" | ||
20 | |||
21 | #ifndef ARRAY_SIZE | ||
22 | # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
23 | #endif | ||
24 | |||
25 | #define MAX_INSNS 512 | ||
26 | #define MAX_MATCHES 16 | ||
27 | |||
28 | struct bpf_align_test { | ||
29 | const char *descr; | ||
30 | struct bpf_insn insns[MAX_INSNS]; | ||
31 | enum { | ||
32 | UNDEF, | ||
33 | ACCEPT, | ||
34 | REJECT | ||
35 | } result; | ||
36 | enum bpf_prog_type prog_type; | ||
37 | const char *matches[MAX_MATCHES]; | ||
38 | }; | ||
39 | |||
40 | static struct bpf_align_test tests[] = { | ||
41 | { | ||
42 | .descr = "mov", | ||
43 | .insns = { | ||
44 | BPF_MOV64_IMM(BPF_REG_3, 2), | ||
45 | BPF_MOV64_IMM(BPF_REG_3, 4), | ||
46 | BPF_MOV64_IMM(BPF_REG_3, 8), | ||
47 | BPF_MOV64_IMM(BPF_REG_3, 16), | ||
48 | BPF_MOV64_IMM(BPF_REG_3, 32), | ||
49 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
50 | BPF_EXIT_INSN(), | ||
51 | }, | ||
52 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
53 | .matches = { | ||
54 | "1: R1=ctx R3=imm2,min_value=2,max_value=2,min_align=2 R10=fp", | ||
55 | "2: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp", | ||
56 | "3: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=8 R10=fp", | ||
57 | "4: R1=ctx R3=imm16,min_value=16,max_value=16,min_align=16 R10=fp", | ||
58 | "5: R1=ctx R3=imm32,min_value=32,max_value=32,min_align=32 R10=fp", | ||
59 | }, | ||
60 | }, | ||
61 | { | ||
62 | .descr = "shift", | ||
63 | .insns = { | ||
64 | BPF_MOV64_IMM(BPF_REG_3, 1), | ||
65 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
66 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
67 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
68 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
69 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_3, 4), | ||
70 | BPF_MOV64_IMM(BPF_REG_4, 32), | ||
71 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
72 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
73 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
74 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
75 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
76 | BPF_EXIT_INSN(), | ||
77 | }, | ||
78 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
79 | .matches = { | ||
80 | "1: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R10=fp", | ||
81 | "2: R1=ctx R3=imm2,min_value=2,max_value=2,min_align=2 R10=fp", | ||
82 | "3: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp", | ||
83 | "4: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=8 R10=fp", | ||
84 | "5: R1=ctx R3=imm16,min_value=16,max_value=16,min_align=16 R10=fp", | ||
85 | "6: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R10=fp", | ||
86 | "7: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm32,min_value=32,max_value=32,min_align=32 R10=fp", | ||
87 | "8: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm16,min_value=16,max_value=16,min_align=16 R10=fp", | ||
88 | "9: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm8,min_value=8,max_value=8,min_align=8 R10=fp", | ||
89 | "10: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm4,min_value=4,max_value=4,min_align=4 R10=fp", | ||
90 | "11: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm2,min_value=2,max_value=2,min_align=2 R10=fp", | ||
91 | }, | ||
92 | }, | ||
93 | { | ||
94 | .descr = "addsub", | ||
95 | .insns = { | ||
96 | BPF_MOV64_IMM(BPF_REG_3, 4), | ||
97 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 4), | ||
98 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 2), | ||
99 | BPF_MOV64_IMM(BPF_REG_4, 8), | ||
100 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4), | ||
101 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 2), | ||
102 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
103 | BPF_EXIT_INSN(), | ||
104 | }, | ||
105 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
106 | .matches = { | ||
107 | "1: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp", | ||
108 | "2: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=4 R10=fp", | ||
109 | "3: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R10=fp", | ||
110 | "4: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm8,min_value=8,max_value=8,min_align=8 R10=fp", | ||
111 | "5: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm12,min_value=12,max_value=12,min_align=4 R10=fp", | ||
112 | "6: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm14,min_value=14,max_value=14,min_align=2 R10=fp", | ||
113 | }, | ||
114 | }, | ||
115 | { | ||
116 | .descr = "mul", | ||
117 | .insns = { | ||
118 | BPF_MOV64_IMM(BPF_REG_3, 7), | ||
119 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 1), | ||
120 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 2), | ||
121 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 4), | ||
122 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
123 | BPF_EXIT_INSN(), | ||
124 | }, | ||
125 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
126 | .matches = { | ||
127 | "1: R1=ctx R3=imm7,min_value=7,max_value=7,min_align=1 R10=fp", | ||
128 | "2: R1=ctx R3=imm7,min_value=7,max_value=7,min_align=1 R10=fp", | ||
129 | "3: R1=ctx R3=imm14,min_value=14,max_value=14,min_align=2 R10=fp", | ||
130 | "4: R1=ctx R3=imm56,min_value=56,max_value=56,min_align=4 R10=fp", | ||
131 | }, | ||
132 | }, | ||
133 | |||
134 | #define PREP_PKT_POINTERS \ | ||
135 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, \ | ||
136 | offsetof(struct __sk_buff, data)), \ | ||
137 | BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, \ | ||
138 | offsetof(struct __sk_buff, data_end)) | ||
139 | |||
140 | #define LOAD_UNKNOWN(DST_REG) \ | ||
141 | PREP_PKT_POINTERS, \ | ||
142 | BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), \ | ||
143 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 8), \ | ||
144 | BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_0, 1), \ | ||
145 | BPF_EXIT_INSN(), \ | ||
146 | BPF_LDX_MEM(BPF_B, DST_REG, BPF_REG_2, 0) | ||
147 | |||
148 | { | ||
149 | .descr = "unknown shift", | ||
150 | .insns = { | ||
151 | LOAD_UNKNOWN(BPF_REG_3), | ||
152 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
153 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
154 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
155 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1), | ||
156 | LOAD_UNKNOWN(BPF_REG_4), | ||
157 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_4, 5), | ||
158 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
159 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
160 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
161 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1), | ||
162 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
163 | BPF_EXIT_INSN(), | ||
164 | }, | ||
165 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
166 | .matches = { | ||
167 | "7: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R10=fp", | ||
168 | "8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv55,min_align=2 R10=fp", | ||
169 | "9: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv54,min_align=4 R10=fp", | ||
170 | "10: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv53,min_align=8 R10=fp", | ||
171 | "11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv52,min_align=16 R10=fp", | ||
172 | "18: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv56 R10=fp", | ||
173 | "19: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv51,min_align=32 R10=fp", | ||
174 | "20: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv52,min_align=16 R10=fp", | ||
175 | "21: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv53,min_align=8 R10=fp", | ||
176 | "22: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv54,min_align=4 R10=fp", | ||
177 | "23: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv55,min_align=2 R10=fp", | ||
178 | }, | ||
179 | }, | ||
180 | { | ||
181 | .descr = "unknown mul", | ||
182 | .insns = { | ||
183 | LOAD_UNKNOWN(BPF_REG_3), | ||
184 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_3), | ||
185 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 1), | ||
186 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_3), | ||
187 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 2), | ||
188 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_3), | ||
189 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 4), | ||
190 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_3), | ||
191 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 8), | ||
192 | BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 2), | ||
193 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
194 | BPF_EXIT_INSN(), | ||
195 | }, | ||
196 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
197 | .matches = { | ||
198 | "7: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R10=fp", | ||
199 | "8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp", | ||
200 | "9: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv55,min_align=1 R10=fp", | ||
201 | "10: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp", | ||
202 | "11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv54,min_align=2 R10=fp", | ||
203 | "12: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp", | ||
204 | "13: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv53,min_align=4 R10=fp", | ||
205 | "14: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp", | ||
206 | "15: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv52,min_align=8 R10=fp", | ||
207 | "16: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv50,min_align=8 R10=fp" | ||
208 | }, | ||
209 | }, | ||
210 | { | ||
211 | .descr = "packet const offset", | ||
212 | .insns = { | ||
213 | PREP_PKT_POINTERS, | ||
214 | BPF_MOV64_REG(BPF_REG_5, BPF_REG_2), | ||
215 | |||
216 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
217 | |||
218 | /* Skip over ethernet header. */ | ||
219 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14), | ||
220 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_5), | ||
221 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4), | ||
222 | BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1), | ||
223 | BPF_EXIT_INSN(), | ||
224 | |||
225 | BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 0), | ||
226 | BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 1), | ||
227 | BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 2), | ||
228 | BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 3), | ||
229 | BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_5, 0), | ||
230 | BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_5, 2), | ||
231 | BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0), | ||
232 | |||
233 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
234 | BPF_EXIT_INSN(), | ||
235 | }, | ||
236 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
237 | .matches = { | ||
238 | "4: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R5=pkt(id=0,off=0,r=0) R10=fp", | ||
239 | "5: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R5=pkt(id=0,off=14,r=0) R10=fp", | ||
240 | "6: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R4=pkt(id=0,off=14,r=0) R5=pkt(id=0,off=14,r=0) R10=fp", | ||
241 | "10: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv56 R5=pkt(id=0,off=14,r=18) R10=fp", | ||
242 | "14: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv48 R5=pkt(id=0,off=14,r=18) R10=fp", | ||
243 | "15: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv48 R5=pkt(id=0,off=14,r=18) R10=fp", | ||
244 | }, | ||
245 | }, | ||
246 | { | ||
247 | .descr = "packet variable offset", | ||
248 | .insns = { | ||
249 | LOAD_UNKNOWN(BPF_REG_6), | ||
250 | BPF_ALU64_IMM(BPF_LSH, BPF_REG_6, 2), | ||
251 | |||
252 | /* First, add a constant to the R5 packet pointer, | ||
253 | * then a variable with a known alignment. | ||
254 | */ | ||
255 | BPF_MOV64_REG(BPF_REG_5, BPF_REG_2), | ||
256 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14), | ||
257 | BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6), | ||
258 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_5), | ||
259 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4), | ||
260 | BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1), | ||
261 | BPF_EXIT_INSN(), | ||
262 | BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0), | ||
263 | |||
264 | /* Now, test in the other direction. Adding first | ||
265 | * the variable offset to R5, then the constant. | ||
266 | */ | ||
267 | BPF_MOV64_REG(BPF_REG_5, BPF_REG_2), | ||
268 | BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6), | ||
269 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14), | ||
270 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_5), | ||
271 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4), | ||
272 | BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1), | ||
273 | BPF_EXIT_INSN(), | ||
274 | BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0), | ||
275 | |||
276 | /* Test multiple accumulations of unknown values | ||
277 | * into a packet pointer. | ||
278 | */ | ||
279 | BPF_MOV64_REG(BPF_REG_5, BPF_REG_2), | ||
280 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14), | ||
281 | BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6), | ||
282 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 4), | ||
283 | BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6), | ||
284 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_5), | ||
285 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4), | ||
286 | BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1), | ||
287 | BPF_EXIT_INSN(), | ||
288 | BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0), | ||
289 | |||
290 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
291 | BPF_EXIT_INSN(), | ||
292 | }, | ||
293 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
294 | .matches = { | ||
295 | /* Calculated offset in R6 has unknown value, but known | ||
296 | * alignment of 4. | ||
297 | */ | ||
298 | "8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R6=inv54,min_align=4 R10=fp", | ||
299 | |||
300 | /* Offset is added to packet pointer R5, resulting in known | ||
301 | * auxiliary alignment and offset. | ||
302 | */ | ||
303 | "11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R5=pkt(id=1,off=0,r=0),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
304 | |||
305 | /* At the time the word size load is performed from R5, | ||
306 | * it's total offset is NET_IP_ALIGN + reg->off (0) + | ||
307 | * reg->aux_off (14) which is 16. Then the variable | ||
308 | * offset is considered using reg->aux_off_align which | ||
309 | * is 4 and meets the load's requirements. | ||
310 | */ | ||
311 | "15: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=pkt(id=1,off=4,r=4),aux_off=14,aux_off_align=4 R5=pkt(id=1,off=0,r=4),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
312 | |||
313 | |||
314 | /* Variable offset is added to R5 packet pointer, | ||
315 | * resulting in auxiliary alignment of 4. | ||
316 | */ | ||
317 | "18: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off=14,aux_off_align=4 R5=pkt(id=2,off=0,r=0),aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
318 | |||
319 | /* Constant offset is added to R5, resulting in | ||
320 | * reg->off of 14. | ||
321 | */ | ||
322 | "19: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off=14,aux_off_align=4 R5=pkt(id=2,off=14,r=0),aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
323 | |||
324 | /* At the time the word size load is performed from R5, | ||
325 | * it's total offset is NET_IP_ALIGN + reg->off (14) which | ||
326 | * is 16. Then the variable offset is considered using | ||
327 | * reg->aux_off_align which is 4 and meets the load's | ||
328 | * requirements. | ||
329 | */ | ||
330 | "23: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=pkt(id=2,off=18,r=18),aux_off_align=4 R5=pkt(id=2,off=14,r=18),aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
331 | |||
332 | /* Constant offset is added to R5 packet pointer, | ||
333 | * resulting in reg->off value of 14. | ||
334 | */ | ||
335 | "26: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off_align=4 R5=pkt(id=0,off=14,r=8) R6=inv54,min_align=4 R10=fp", | ||
336 | /* Variable offset is added to R5, resulting in an | ||
337 | * auxiliary offset of 14, and an auxiliary alignment of 4. | ||
338 | */ | ||
339 | "27: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off_align=4 R5=pkt(id=3,off=0,r=0),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
340 | /* Constant is added to R5 again, setting reg->off to 4. */ | ||
341 | "28: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off_align=4 R5=pkt(id=3,off=4,r=0),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
342 | /* And once more we add a variable, which causes an accumulation | ||
343 | * of reg->off into reg->aux_off_align, with resulting value of | ||
344 | * 18. The auxiliary alignment stays at 4. | ||
345 | */ | ||
346 | "29: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off_align=4 R5=pkt(id=4,off=0,r=0),aux_off=18,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
347 | /* At the time the word size load is performed from R5, | ||
348 | * it's total offset is NET_IP_ALIGN + reg->off (0) + | ||
349 | * reg->aux_off (18) which is 20. Then the variable offset | ||
350 | * is considered using reg->aux_off_align which is 4 and meets | ||
351 | * the load's requirements. | ||
352 | */ | ||
353 | "33: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=pkt(id=4,off=4,r=4),aux_off=18,aux_off_align=4 R5=pkt(id=4,off=0,r=4),aux_off=18,aux_off_align=4 R6=inv54,min_align=4 R10=fp", | ||
354 | }, | ||
355 | }, | ||
356 | }; | ||
357 | |||
358 | static int probe_filter_length(const struct bpf_insn *fp) | ||
359 | { | ||
360 | int len; | ||
361 | |||
362 | for (len = MAX_INSNS - 1; len > 0; --len) | ||
363 | if (fp[len].code != 0 || fp[len].imm != 0) | ||
364 | break; | ||
365 | return len + 1; | ||
366 | } | ||
367 | |||
368 | static char bpf_vlog[32768]; | ||
369 | |||
370 | static int do_test_single(struct bpf_align_test *test) | ||
371 | { | ||
372 | struct bpf_insn *prog = test->insns; | ||
373 | int prog_type = test->prog_type; | ||
374 | int prog_len, i; | ||
375 | int fd_prog; | ||
376 | int ret; | ||
377 | |||
378 | prog_len = probe_filter_length(prog); | ||
379 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | ||
380 | prog, prog_len, 1, "GPL", 0, | ||
381 | bpf_vlog, sizeof(bpf_vlog)); | ||
382 | if (fd_prog < 0) { | ||
383 | printf("Failed to load program.\n"); | ||
384 | printf("%s", bpf_vlog); | ||
385 | ret = 1; | ||
386 | } else { | ||
387 | ret = 0; | ||
388 | for (i = 0; i < MAX_MATCHES; i++) { | ||
389 | const char *t, *m = test->matches[i]; | ||
390 | |||
391 | if (!m) | ||
392 | break; | ||
393 | t = strstr(bpf_vlog, m); | ||
394 | if (!t) { | ||
395 | printf("Failed to find match: %s\n", m); | ||
396 | ret = 1; | ||
397 | printf("%s", bpf_vlog); | ||
398 | break; | ||
399 | } | ||
400 | } | ||
401 | close(fd_prog); | ||
402 | } | ||
403 | return ret; | ||
404 | } | ||
405 | |||
406 | static int do_test(unsigned int from, unsigned int to) | ||
407 | { | ||
408 | int all_pass = 0; | ||
409 | int all_fail = 0; | ||
410 | unsigned int i; | ||
411 | |||
412 | for (i = from; i < to; i++) { | ||
413 | struct bpf_align_test *test = &tests[i]; | ||
414 | int fail; | ||
415 | |||
416 | printf("Test %3d: %s ... ", | ||
417 | i, test->descr); | ||
418 | fail = do_test_single(test); | ||
419 | if (fail) { | ||
420 | all_fail++; | ||
421 | printf("FAIL\n"); | ||
422 | } else { | ||
423 | all_pass++; | ||
424 | printf("PASS\n"); | ||
425 | } | ||
426 | } | ||
427 | printf("Results: %d pass %d fail\n", | ||
428 | all_pass, all_fail); | ||
429 | return 0; | ||
430 | } | ||
431 | |||
432 | int main(int argc, char **argv) | ||
433 | { | ||
434 | unsigned int from = 0, to = ARRAY_SIZE(tests); | ||
435 | |||
436 | if (argc == 3) { | ||
437 | unsigned int l = atoi(argv[argc - 2]); | ||
438 | unsigned int u = atoi(argv[argc - 1]); | ||
439 | |||
440 | if (l < to && u < to) { | ||
441 | from = l; | ||
442 | to = u + 1; | ||
443 | } | ||
444 | } else if (argc == 2) { | ||
445 | unsigned int t = atoi(argv[argc - 1]); | ||
446 | |||
447 | if (t < to) { | ||
448 | from = t; | ||
449 | to = t + 1; | ||
450 | } | ||
451 | } | ||
452 | return do_test(from, to); | ||
453 | } | ||
diff --git a/tools/testing/selftests/bpf/test_pkt_access.c b/tools/testing/selftests/bpf/test_pkt_access.c index 39387bb7e08c..6e11ba11709e 100644 --- a/tools/testing/selftests/bpf/test_pkt_access.c +++ b/tools/testing/selftests/bpf/test_pkt_access.c | |||
@@ -5,6 +5,7 @@ | |||
5 | * License as published by the Free Software Foundation. | 5 | * License as published by the Free Software Foundation. |
6 | */ | 6 | */ |
7 | #include <stddef.h> | 7 | #include <stddef.h> |
8 | #include <string.h> | ||
8 | #include <linux/bpf.h> | 9 | #include <linux/bpf.h> |
9 | #include <linux/if_ether.h> | 10 | #include <linux/if_ether.h> |
10 | #include <linux/if_packet.h> | 11 | #include <linux/if_packet.h> |
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index 32e6211e1c6e..717581145cfc 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest | |||
@@ -58,7 +58,7 @@ parse_opts() { # opts | |||
58 | ;; | 58 | ;; |
59 | --verbose|-v|-vv) | 59 | --verbose|-v|-vv) |
60 | VERBOSE=$((VERBOSE + 1)) | 60 | VERBOSE=$((VERBOSE + 1)) |
61 | [ $1 == '-vv' ] && VERBOSE=$((VERBOSE + 1)) | 61 | [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1)) |
62 | shift 1 | 62 | shift 1 |
63 | ;; | 63 | ;; |
64 | --debug|-d) | 64 | --debug|-d) |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc index 07bb3e5930b4..aa31368851c9 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc | |||
@@ -48,7 +48,7 @@ test_event_enabled() { | |||
48 | e=`cat $EVENT_ENABLE` | 48 | e=`cat $EVENT_ENABLE` |
49 | if [ "$e" != $val ]; then | 49 | if [ "$e" != $val ]; then |
50 | echo "Expected $val but found $e" | 50 | echo "Expected $val but found $e" |
51 | exit -1 | 51 | exit 1 |
52 | fi | 52 | fi |
53 | } | 53 | } |
54 | 54 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index 9aec6fcb7729..f2019b37370d 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions | |||
@@ -34,10 +34,10 @@ reset_ftrace_filter() { # reset all triggers in set_ftrace_filter | |||
34 | echo > set_ftrace_filter | 34 | echo > set_ftrace_filter |
35 | grep -v '^#' set_ftrace_filter | while read t; do | 35 | grep -v '^#' set_ftrace_filter | while read t; do |
36 | tr=`echo $t | cut -d: -f2` | 36 | tr=`echo $t | cut -d: -f2` |
37 | if [ "$tr" == "" ]; then | 37 | if [ "$tr" = "" ]; then |
38 | continue | 38 | continue |
39 | fi | 39 | fi |
40 | if [ $tr == "enable_event" -o $tr == "disable_event" ]; then | 40 | if [ $tr = "enable_event" -o $tr = "disable_event" ]; then |
41 | tr=`echo $t | cut -d: -f1-4` | 41 | tr=`echo $t | cut -d: -f1-4` |
42 | limit=`echo $t | cut -d: -f5` | 42 | limit=`echo $t | cut -d: -f5` |
43 | else | 43 | else |
diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc index 4c5a061a5b4e..c73db7863adb 100644 --- a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc +++ b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc | |||
@@ -75,9 +75,13 @@ rmdir foo | |||
75 | if [ -d foo ]; then | 75 | if [ -d foo ]; then |
76 | fail "foo still exists" | 76 | fail "foo still exists" |
77 | fi | 77 | fi |
78 | exit 0 | ||
79 | |||
80 | 78 | ||
79 | mkdir foo | ||
80 | echo "schedule:enable_event:sched:sched_switch" > foo/set_ftrace_filter | ||
81 | rmdir foo | ||
82 | if [ -d foo ]; then | ||
83 | fail "foo still exists" | ||
84 | fi | ||
81 | 85 | ||
82 | 86 | ||
83 | instance_slam() { | 87 | instance_slam() { |
diff --git a/tools/testing/selftests/powerpc/tm/.gitignore b/tools/testing/selftests/powerpc/tm/.gitignore index 427621792229..2f1f7b013293 100644 --- a/tools/testing/selftests/powerpc/tm/.gitignore +++ b/tools/testing/selftests/powerpc/tm/.gitignore | |||
@@ -11,3 +11,4 @@ tm-signal-context-chk-fpu | |||
11 | tm-signal-context-chk-gpr | 11 | tm-signal-context-chk-gpr |
12 | tm-signal-context-chk-vmx | 12 | tm-signal-context-chk-vmx |
13 | tm-signal-context-chk-vsx | 13 | tm-signal-context-chk-vsx |
14 | tm-vmx-unavail | ||
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile index 5576ee6a51f2..958c11c14acd 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile | |||
@@ -2,7 +2,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu | |||
2 | tm-signal-context-chk-vmx tm-signal-context-chk-vsx | 2 | tm-signal-context-chk-vmx tm-signal-context-chk-vsx |
3 | 3 | ||
4 | TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ | 4 | TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ |
5 | tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS) | 5 | tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail \ |
6 | $(SIGNAL_CONTEXT_CHK_TESTS) | ||
6 | 7 | ||
7 | include ../../lib.mk | 8 | include ../../lib.mk |
8 | 9 | ||
@@ -13,6 +14,7 @@ CFLAGS += -mhtm | |||
13 | $(OUTPUT)/tm-syscall: tm-syscall-asm.S | 14 | $(OUTPUT)/tm-syscall: tm-syscall-asm.S |
14 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include | 15 | $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include |
15 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread | 16 | $(OUTPUT)/tm-tmspr: CFLAGS += -pthread |
17 | $(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 | ||
16 | 18 | ||
17 | SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) | 19 | SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) |
18 | $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S | 20 | $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S |
diff --git a/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c new file mode 100644 index 000000000000..137185ba4937 --- /dev/null +++ b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright 2017, Michael Neuling, IBM Corp. | ||
3 | * Licensed under GPLv2. | ||
4 | * Original: Breno Leitao <brenohl@br.ibm.com> & | ||
5 | * Gustavo Bueno Romero <gromero@br.ibm.com> | ||
6 | * Edited: Michael Neuling | ||
7 | * | ||
8 | * Force VMX unavailable during a transaction and see if it corrupts | ||
9 | * the checkpointed VMX register state after the abort. | ||
10 | */ | ||
11 | |||
12 | #include <inttypes.h> | ||
13 | #include <htmintrin.h> | ||
14 | #include <string.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <stdio.h> | ||
17 | #include <pthread.h> | ||
18 | #include <sys/mman.h> | ||
19 | #include <unistd.h> | ||
20 | #include <pthread.h> | ||
21 | |||
22 | #include "tm.h" | ||
23 | #include "utils.h" | ||
24 | |||
25 | int passed; | ||
26 | |||
27 | void *worker(void *unused) | ||
28 | { | ||
29 | __int128 vmx0; | ||
30 | uint64_t texasr; | ||
31 | |||
32 | asm goto ( | ||
33 | "li 3, 1;" /* Stick non-zero value in VMX0 */ | ||
34 | "std 3, 0(%[vmx0_ptr]);" | ||
35 | "lvx 0, 0, %[vmx0_ptr];" | ||
36 | |||
37 | /* Wait here a bit so we get scheduled out 255 times */ | ||
38 | "lis 3, 0x3fff;" | ||
39 | "1: ;" | ||
40 | "addi 3, 3, -1;" | ||
41 | "cmpdi 3, 0;" | ||
42 | "bne 1b;" | ||
43 | |||
44 | /* Kernel will hopefully turn VMX off now */ | ||
45 | |||
46 | "tbegin. ;" | ||
47 | "beq failure;" | ||
48 | |||
49 | /* Cause VMX unavail. Any VMX instruction */ | ||
50 | "vaddcuw 0,0,0;" | ||
51 | |||
52 | "tend. ;" | ||
53 | "b %l[success];" | ||
54 | |||
55 | /* Check VMX0 sanity after abort */ | ||
56 | "failure: ;" | ||
57 | "lvx 1, 0, %[vmx0_ptr];" | ||
58 | "vcmpequb. 2, 0, 1;" | ||
59 | "bc 4, 24, %l[value_mismatch];" | ||
60 | "b %l[value_match];" | ||
61 | : | ||
62 | : [vmx0_ptr] "r"(&vmx0) | ||
63 | : "r3" | ||
64 | : success, value_match, value_mismatch | ||
65 | ); | ||
66 | |||
67 | /* HTM aborted and VMX0 is corrupted */ | ||
68 | value_mismatch: | ||
69 | texasr = __builtin_get_texasr(); | ||
70 | |||
71 | printf("\n\n==============\n\n"); | ||
72 | printf("Failure with error: %lx\n", _TEXASR_FAILURE_CODE(texasr)); | ||
73 | printf("Summary error : %lx\n", _TEXASR_FAILURE_SUMMARY(texasr)); | ||
74 | printf("TFIAR exact : %lx\n\n", _TEXASR_TFIAR_EXACT(texasr)); | ||
75 | |||
76 | passed = 0; | ||
77 | return NULL; | ||
78 | |||
79 | /* HTM aborted but VMX0 is correct */ | ||
80 | value_match: | ||
81 | // printf("!"); | ||
82 | return NULL; | ||
83 | |||
84 | success: | ||
85 | // printf("."); | ||
86 | return NULL; | ||
87 | } | ||
88 | |||
89 | int tm_vmx_unavail_test() | ||
90 | { | ||
91 | int threads; | ||
92 | pthread_t *thread; | ||
93 | |||
94 | SKIP_IF(!have_htm()); | ||
95 | |||
96 | passed = 1; | ||
97 | |||
98 | threads = sysconf(_SC_NPROCESSORS_ONLN) * 4; | ||
99 | thread = malloc(sizeof(pthread_t)*threads); | ||
100 | if (!thread) | ||
101 | return EXIT_FAILURE; | ||
102 | |||
103 | for (uint64_t i = 0; i < threads; i++) | ||
104 | pthread_create(&thread[i], NULL, &worker, NULL); | ||
105 | |||
106 | for (uint64_t i = 0; i < threads; i++) | ||
107 | pthread_join(thread[i], NULL); | ||
108 | |||
109 | free(thread); | ||
110 | |||
111 | return passed ? EXIT_SUCCESS : EXIT_FAILURE; | ||
112 | } | ||
113 | |||
114 | |||
115 | int main(int argc, char **argv) | ||
116 | { | ||
117 | return test_harness(tm_vmx_unavail_test, "tm_vmx_unavail_test"); | ||
118 | } | ||