Thomas Gleixner | 5b497af | 2019-05-29 07:18:09 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Testsuite for BPF interpreter and BPF JIT compiler |
| 4 | * |
| 5 | * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 9 | |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/filter.h> |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 13 | #include <linux/bpf.h> |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 14 | #include <linux/skbuff.h> |
| 15 | #include <linux/netdevice.h> |
| 16 | #include <linux/if_vlan.h> |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 17 | #include <linux/random.h> |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 18 | #include <linux/highmem.h> |
Eric Dumazet | d40bc96 | 2018-02-26 10:52:46 -0800 | [diff] [blame] | 19 | #include <linux/sched.h> |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 20 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 21 | /* General test specific settings */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 22 | #define MAX_SUBTESTS 3 |
Eric Dumazet | 9960d76 | 2018-02-28 08:39:20 -0800 | [diff] [blame] | 23 | #define MAX_TESTRUNS 1000 |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 24 | #define MAX_DATA 128 |
| 25 | #define MAX_INSNS 512 |
| 26 | #define MAX_K 0xffffFFFF |
| 27 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 28 | /* Few constants used to init test 'skb' */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 29 | #define SKB_TYPE 3 |
| 30 | #define SKB_MARK 0x1234aaaa |
| 31 | #define SKB_HASH 0x1234aaab |
| 32 | #define SKB_QUEUE_MAP 123 |
| 33 | #define SKB_VLAN_TCI 0xffff |
Michał Mirosław | 0c4b2d3 | 2018-11-10 19:58:36 +0100 | [diff] [blame] | 34 | #define SKB_VLAN_PRESENT 1 |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 35 | #define SKB_DEV_IFINDEX 577 |
| 36 | #define SKB_DEV_TYPE 588 |
| 37 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 38 | /* Redefine REGs to make tests less verbose */ |
| 39 | #define R0 BPF_REG_0 |
| 40 | #define R1 BPF_REG_1 |
| 41 | #define R2 BPF_REG_2 |
| 42 | #define R3 BPF_REG_3 |
| 43 | #define R4 BPF_REG_4 |
| 44 | #define R5 BPF_REG_5 |
| 45 | #define R6 BPF_REG_6 |
| 46 | #define R7 BPF_REG_7 |
| 47 | #define R8 BPF_REG_8 |
| 48 | #define R9 BPF_REG_9 |
| 49 | #define R10 BPF_REG_10 |
| 50 | |
| 51 | /* Flags that can be passed to test cases */ |
| 52 | #define FLAG_NO_DATA BIT(0) |
| 53 | #define FLAG_EXPECTED_FAIL BIT(1) |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 54 | #define FLAG_SKB_FRAG BIT(2) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 55 | |
| 56 | enum { |
| 57 | CLASSIC = BIT(6), /* Old BPF instructions only. */ |
| 58 | INTERNAL = BIT(7), /* Extended instruction set. */ |
| 59 | }; |
| 60 | |
| 61 | #define TEST_TYPE_MASK (CLASSIC | INTERNAL) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 62 | |
| 63 | struct bpf_test { |
| 64 | const char *descr; |
| 65 | union { |
| 66 | struct sock_filter insns[MAX_INSNS]; |
Alexei Starovoitov | 2695fb5 | 2014-07-24 16:38:21 -0700 | [diff] [blame] | 67 | struct bpf_insn insns_int[MAX_INSNS]; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 68 | struct { |
| 69 | void *insns; |
| 70 | unsigned int len; |
| 71 | } ptr; |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 72 | } u; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 73 | __u8 aux; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 74 | __u8 data[MAX_DATA]; |
| 75 | struct { |
| 76 | int data_size; |
| 77 | __u32 result; |
| 78 | } test[MAX_SUBTESTS]; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 79 | int (*fill_helper)(struct bpf_test *self); |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 80 | int expected_errcode; /* used when FLAG_EXPECTED_FAIL is set in the aux */ |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 81 | __u8 frag_data[MAX_DATA]; |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 82 | int stack_depth; /* for eBPF only, since tests don't call verifier */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 85 | /* Large test cases need separate allocation and fill handler. */ |
| 86 | |
| 87 | static int bpf_fill_maxinsns1(struct bpf_test *self) |
| 88 | { |
| 89 | unsigned int len = BPF_MAXINSNS; |
| 90 | struct sock_filter *insn; |
| 91 | __u32 k = ~0; |
| 92 | int i; |
| 93 | |
| 94 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 95 | if (!insn) |
| 96 | return -ENOMEM; |
| 97 | |
| 98 | for (i = 0; i < len; i++, k--) |
| 99 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, k); |
| 100 | |
| 101 | self->u.ptr.insns = insn; |
| 102 | self->u.ptr.len = len; |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static int bpf_fill_maxinsns2(struct bpf_test *self) |
| 108 | { |
| 109 | unsigned int len = BPF_MAXINSNS; |
| 110 | struct sock_filter *insn; |
| 111 | int i; |
| 112 | |
| 113 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 114 | if (!insn) |
| 115 | return -ENOMEM; |
| 116 | |
| 117 | for (i = 0; i < len; i++) |
| 118 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 119 | |
| 120 | self->u.ptr.insns = insn; |
| 121 | self->u.ptr.len = len; |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | static int bpf_fill_maxinsns3(struct bpf_test *self) |
| 127 | { |
| 128 | unsigned int len = BPF_MAXINSNS; |
| 129 | struct sock_filter *insn; |
| 130 | struct rnd_state rnd; |
| 131 | int i; |
| 132 | |
| 133 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 134 | if (!insn) |
| 135 | return -ENOMEM; |
| 136 | |
| 137 | prandom_seed_state(&rnd, 3141592653589793238ULL); |
| 138 | |
| 139 | for (i = 0; i < len - 1; i++) { |
| 140 | __u32 k = prandom_u32_state(&rnd); |
| 141 | |
| 142 | insn[i] = __BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, k); |
| 143 | } |
| 144 | |
| 145 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 146 | |
| 147 | self->u.ptr.insns = insn; |
| 148 | self->u.ptr.len = len; |
| 149 | |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static int bpf_fill_maxinsns4(struct bpf_test *self) |
| 154 | { |
| 155 | unsigned int len = BPF_MAXINSNS + 1; |
| 156 | struct sock_filter *insn; |
| 157 | int i; |
| 158 | |
| 159 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 160 | if (!insn) |
| 161 | return -ENOMEM; |
| 162 | |
| 163 | for (i = 0; i < len; i++) |
| 164 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 165 | |
| 166 | self->u.ptr.insns = insn; |
| 167 | self->u.ptr.len = len; |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | static int bpf_fill_maxinsns5(struct bpf_test *self) |
| 173 | { |
| 174 | unsigned int len = BPF_MAXINSNS; |
| 175 | struct sock_filter *insn; |
| 176 | int i; |
| 177 | |
| 178 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 179 | if (!insn) |
| 180 | return -ENOMEM; |
| 181 | |
| 182 | insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0); |
| 183 | |
| 184 | for (i = 1; i < len - 1; i++) |
| 185 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 186 | |
| 187 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab); |
| 188 | |
| 189 | self->u.ptr.insns = insn; |
| 190 | self->u.ptr.len = len; |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | static int bpf_fill_maxinsns6(struct bpf_test *self) |
| 196 | { |
| 197 | unsigned int len = BPF_MAXINSNS; |
| 198 | struct sock_filter *insn; |
| 199 | int i; |
| 200 | |
| 201 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 202 | if (!insn) |
| 203 | return -ENOMEM; |
| 204 | |
| 205 | for (i = 0; i < len - 1; i++) |
| 206 | insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 207 | SKF_AD_VLAN_TAG_PRESENT); |
| 208 | |
| 209 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 210 | |
| 211 | self->u.ptr.insns = insn; |
| 212 | self->u.ptr.len = len; |
| 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | static int bpf_fill_maxinsns7(struct bpf_test *self) |
| 218 | { |
| 219 | unsigned int len = BPF_MAXINSNS; |
| 220 | struct sock_filter *insn; |
| 221 | int i; |
| 222 | |
| 223 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 224 | if (!insn) |
| 225 | return -ENOMEM; |
| 226 | |
| 227 | for (i = 0; i < len - 4; i++) |
| 228 | insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 229 | SKF_AD_CPU); |
| 230 | |
| 231 | insn[len - 4] = __BPF_STMT(BPF_MISC | BPF_TAX, 0); |
| 232 | insn[len - 3] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 233 | SKF_AD_CPU); |
| 234 | insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0); |
| 235 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 236 | |
| 237 | self->u.ptr.insns = insn; |
| 238 | self->u.ptr.len = len; |
| 239 | |
| 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | static int bpf_fill_maxinsns8(struct bpf_test *self) |
| 244 | { |
| 245 | unsigned int len = BPF_MAXINSNS; |
| 246 | struct sock_filter *insn; |
| 247 | int i, jmp_off = len - 3; |
| 248 | |
| 249 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 250 | if (!insn) |
| 251 | return -ENOMEM; |
| 252 | |
| 253 | insn[0] = __BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff); |
| 254 | |
| 255 | for (i = 1; i < len - 1; i++) |
| 256 | insn[i] = __BPF_JUMP(BPF_JMP | BPF_JGT, 0xffffffff, jmp_off--, 0); |
| 257 | |
| 258 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 259 | |
| 260 | self->u.ptr.insns = insn; |
| 261 | self->u.ptr.len = len; |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
Daniel Borkmann | 3b52960 | 2015-05-23 01:10:07 +0200 | [diff] [blame] | 266 | static int bpf_fill_maxinsns9(struct bpf_test *self) |
| 267 | { |
| 268 | unsigned int len = BPF_MAXINSNS; |
| 269 | struct bpf_insn *insn; |
| 270 | int i; |
| 271 | |
| 272 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 273 | if (!insn) |
| 274 | return -ENOMEM; |
| 275 | |
| 276 | insn[0] = BPF_JMP_IMM(BPF_JA, 0, 0, len - 2); |
| 277 | insn[1] = BPF_ALU32_IMM(BPF_MOV, R0, 0xcbababab); |
| 278 | insn[2] = BPF_EXIT_INSN(); |
| 279 | |
| 280 | for (i = 3; i < len - 2; i++) |
| 281 | insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xfefefefe); |
| 282 | |
| 283 | insn[len - 2] = BPF_EXIT_INSN(); |
| 284 | insn[len - 1] = BPF_JMP_IMM(BPF_JA, 0, 0, -(len - 1)); |
| 285 | |
| 286 | self->u.ptr.insns = insn; |
| 287 | self->u.ptr.len = len; |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | static int bpf_fill_maxinsns10(struct bpf_test *self) |
| 293 | { |
| 294 | unsigned int len = BPF_MAXINSNS, hlen = len - 2; |
| 295 | struct bpf_insn *insn; |
| 296 | int i; |
| 297 | |
| 298 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 299 | if (!insn) |
| 300 | return -ENOMEM; |
| 301 | |
| 302 | for (i = 0; i < hlen / 2; i++) |
| 303 | insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 2 - 2 * i); |
| 304 | for (i = hlen - 1; i > hlen / 2; i--) |
| 305 | insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 1 - 2 * i); |
| 306 | |
| 307 | insn[hlen / 2] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen / 2 - 1); |
| 308 | insn[hlen] = BPF_ALU32_IMM(BPF_MOV, R0, 0xabababac); |
| 309 | insn[hlen + 1] = BPF_EXIT_INSN(); |
| 310 | |
| 311 | self->u.ptr.insns = insn; |
| 312 | self->u.ptr.len = len; |
| 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 317 | static int __bpf_fill_ja(struct bpf_test *self, unsigned int len, |
| 318 | unsigned int plen) |
| 319 | { |
| 320 | struct sock_filter *insn; |
| 321 | unsigned int rlen; |
| 322 | int i, j; |
| 323 | |
| 324 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 325 | if (!insn) |
| 326 | return -ENOMEM; |
| 327 | |
| 328 | rlen = (len % plen) - 1; |
| 329 | |
| 330 | for (i = 0; i + plen < len; i += plen) |
| 331 | for (j = 0; j < plen; j++) |
| 332 | insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, |
| 333 | plen - 1 - j, 0, 0); |
| 334 | for (j = 0; j < rlen; j++) |
| 335 | insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, rlen - 1 - j, |
| 336 | 0, 0); |
| 337 | |
| 338 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xababcbac); |
| 339 | |
| 340 | self->u.ptr.insns = insn; |
| 341 | self->u.ptr.len = len; |
| 342 | |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | static int bpf_fill_maxinsns11(struct bpf_test *self) |
| 347 | { |
Gary Lin | 16a660e | 2021-01-19 18:25:00 +0800 | [diff] [blame] | 348 | /* Hits 70 passes on x86_64 and triggers NOPs padding. */ |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 349 | return __bpf_fill_ja(self, BPF_MAXINSNS, 68); |
| 350 | } |
| 351 | |
Daniel Borkmann | be08815 | 2018-06-02 23:06:32 +0200 | [diff] [blame] | 352 | static int bpf_fill_maxinsns12(struct bpf_test *self) |
| 353 | { |
| 354 | unsigned int len = BPF_MAXINSNS; |
| 355 | struct sock_filter *insn; |
| 356 | int i = 0; |
| 357 | |
| 358 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 359 | if (!insn) |
| 360 | return -ENOMEM; |
| 361 | |
| 362 | insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0); |
| 363 | |
| 364 | for (i = 1; i < len - 1; i++) |
| 365 | insn[i] = __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0); |
| 366 | |
| 367 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab); |
| 368 | |
| 369 | self->u.ptr.insns = insn; |
| 370 | self->u.ptr.len = len; |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | static int bpf_fill_maxinsns13(struct bpf_test *self) |
| 376 | { |
| 377 | unsigned int len = BPF_MAXINSNS; |
| 378 | struct sock_filter *insn; |
| 379 | int i = 0; |
| 380 | |
| 381 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 382 | if (!insn) |
| 383 | return -ENOMEM; |
| 384 | |
| 385 | for (i = 0; i < len - 3; i++) |
| 386 | insn[i] = __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0); |
| 387 | |
| 388 | insn[len - 3] = __BPF_STMT(BPF_LD | BPF_IMM, 0xabababab); |
| 389 | insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0); |
| 390 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 391 | |
| 392 | self->u.ptr.insns = insn; |
| 393 | self->u.ptr.len = len; |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 398 | static int bpf_fill_ja(struct bpf_test *self) |
| 399 | { |
| 400 | /* Hits exactly 11 passes on x86_64 JIT. */ |
| 401 | return __bpf_fill_ja(self, 12, 9); |
| 402 | } |
| 403 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 404 | static int bpf_fill_ld_abs_get_processor_id(struct bpf_test *self) |
| 405 | { |
| 406 | unsigned int len = BPF_MAXINSNS; |
| 407 | struct sock_filter *insn; |
| 408 | int i; |
| 409 | |
| 410 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 411 | if (!insn) |
| 412 | return -ENOMEM; |
| 413 | |
| 414 | for (i = 0; i < len - 1; i += 2) { |
| 415 | insn[i] = __BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 0); |
| 416 | insn[i + 1] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 417 | SKF_AD_OFF + SKF_AD_CPU); |
| 418 | } |
| 419 | |
| 420 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xbee); |
| 421 | |
| 422 | self->u.ptr.insns = insn; |
| 423 | self->u.ptr.len = len; |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 428 | static int __bpf_fill_stxdw(struct bpf_test *self, int size) |
| 429 | { |
| 430 | unsigned int len = BPF_MAXINSNS; |
| 431 | struct bpf_insn *insn; |
| 432 | int i; |
| 433 | |
| 434 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 435 | if (!insn) |
| 436 | return -ENOMEM; |
| 437 | |
| 438 | insn[0] = BPF_ALU32_IMM(BPF_MOV, R0, 1); |
| 439 | insn[1] = BPF_ST_MEM(size, R10, -40, 42); |
| 440 | |
| 441 | for (i = 2; i < len - 2; i++) |
| 442 | insn[i] = BPF_STX_XADD(size, R10, R0, -40); |
| 443 | |
| 444 | insn[len - 2] = BPF_LDX_MEM(size, R0, R10, -40); |
| 445 | insn[len - 1] = BPF_EXIT_INSN(); |
| 446 | |
| 447 | self->u.ptr.insns = insn; |
| 448 | self->u.ptr.len = len; |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 449 | self->stack_depth = 40; |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 450 | |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static int bpf_fill_stxw(struct bpf_test *self) |
| 455 | { |
| 456 | return __bpf_fill_stxdw(self, BPF_W); |
| 457 | } |
| 458 | |
| 459 | static int bpf_fill_stxdw(struct bpf_test *self) |
| 460 | { |
| 461 | return __bpf_fill_stxdw(self, BPF_DW); |
| 462 | } |
| 463 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 464 | static struct bpf_test tests[] = { |
| 465 | { |
| 466 | "TAX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 467 | .u.insns = { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 468 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 469 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 470 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
| 471 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 472 | BPF_STMT(BPF_ALU | BPF_NEG, 0), /* A == -3 */ |
| 473 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 474 | BPF_STMT(BPF_LD | BPF_LEN, 0), |
| 475 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 476 | BPF_STMT(BPF_MISC | BPF_TAX, 0), /* X == len - 3 */ |
| 477 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 1), |
| 478 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 479 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 480 | CLASSIC, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 481 | { 10, 20, 30, 40, 50 }, |
| 482 | { { 2, 10 }, { 3, 20 }, { 4, 30 } }, |
| 483 | }, |
| 484 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 485 | "TXA", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 486 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 487 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 488 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 489 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 490 | BPF_STMT(BPF_RET | BPF_A, 0) /* A == len * 2 */ |
| 491 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 492 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 493 | { 10, 20, 30, 40, 50 }, |
| 494 | { { 1, 2 }, { 3, 6 }, { 4, 8 } }, |
| 495 | }, |
| 496 | { |
| 497 | "ADD_SUB_MUL_K", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 498 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 499 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 500 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2), |
| 501 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 502 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 503 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xffffffff), |
| 504 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 3), |
| 505 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 506 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 507 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 508 | { }, |
| 509 | { { 0, 0xfffffffd } } |
| 510 | }, |
| 511 | { |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 512 | "DIV_MOD_KX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 513 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 514 | BPF_STMT(BPF_LD | BPF_IMM, 8), |
| 515 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2), |
| 516 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 517 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 518 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0), |
| 519 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 520 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 521 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000), |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 522 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 523 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 524 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), |
| 525 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 526 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 527 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 528 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 529 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 530 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 531 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 532 | { }, |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 533 | { { 0, 0x20000000 } } |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 534 | }, |
| 535 | { |
| 536 | "AND_OR_LSH_K", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 537 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 538 | BPF_STMT(BPF_LD | BPF_IMM, 0xff), |
| 539 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), |
| 540 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27), |
| 541 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 542 | BPF_STMT(BPF_LD | BPF_IMM, 0xf), |
| 543 | BPF_STMT(BPF_ALU | BPF_OR | BPF_K, 0xf0), |
| 544 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 545 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 546 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 547 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 548 | { }, |
| 549 | { { 0, 0x800000ff }, { 1, 0x800000ff } }, |
| 550 | }, |
| 551 | { |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 552 | "LD_IMM_0", |
| 553 | .u.insns = { |
| 554 | BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */ |
| 555 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0), |
| 556 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 557 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 558 | }, |
| 559 | CLASSIC, |
| 560 | { }, |
| 561 | { { 1, 1 } }, |
| 562 | }, |
| 563 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 564 | "LD_IND", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 565 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 566 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 567 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K), |
| 568 | BPF_STMT(BPF_RET | BPF_K, 1) |
| 569 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 570 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 571 | { }, |
| 572 | { { 1, 0 }, { 10, 0 }, { 60, 0 } }, |
| 573 | }, |
| 574 | { |
| 575 | "LD_ABS", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 576 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 577 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000), |
| 578 | BPF_STMT(BPF_RET | BPF_K, 1) |
| 579 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 580 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 581 | { }, |
| 582 | { { 1, 0 }, { 10, 0 }, { 60, 0 } }, |
| 583 | }, |
| 584 | { |
| 585 | "LD_ABS_LL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 586 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 587 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF), |
| 588 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 589 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1), |
| 590 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 591 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 592 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 593 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 594 | { 1, 2, 3 }, |
| 595 | { { 1, 0 }, { 2, 3 } }, |
| 596 | }, |
| 597 | { |
| 598 | "LD_IND_LL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 599 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 600 | BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1), |
| 601 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 602 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 603 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 604 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), |
| 605 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 606 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 607 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 608 | { 1, 2, 3, 0xff }, |
| 609 | { { 1, 1 }, { 3, 3 }, { 4, 0xff } }, |
| 610 | }, |
| 611 | { |
| 612 | "LD_ABS_NET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 613 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 614 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF), |
| 615 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 616 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1), |
| 617 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 618 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 619 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 620 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 621 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, |
| 622 | { { 15, 0 }, { 16, 3 } }, |
| 623 | }, |
| 624 | { |
| 625 | "LD_IND_NET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 626 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 627 | BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15), |
| 628 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 629 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 630 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 631 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), |
| 632 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 633 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 634 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 635 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, |
| 636 | { { 14, 0 }, { 15, 1 }, { 17, 3 } }, |
| 637 | }, |
| 638 | { |
| 639 | "LD_PKTTYPE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 640 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 641 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 642 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 643 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 644 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 645 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 646 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 647 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 648 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 649 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 650 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 651 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 652 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 653 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 654 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 655 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 656 | { }, |
| 657 | { { 1, 3 }, { 10, 3 } }, |
| 658 | }, |
| 659 | { |
| 660 | "LD_MARK", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 661 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 662 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 663 | SKF_AD_OFF + SKF_AD_MARK), |
| 664 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 665 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 666 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 667 | { }, |
| 668 | { { 1, SKB_MARK}, { 10, SKB_MARK} }, |
| 669 | }, |
| 670 | { |
| 671 | "LD_RXHASH", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 672 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 673 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 674 | SKF_AD_OFF + SKF_AD_RXHASH), |
| 675 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 676 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 677 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 678 | { }, |
| 679 | { { 1, SKB_HASH}, { 10, SKB_HASH} }, |
| 680 | }, |
| 681 | { |
| 682 | "LD_QUEUE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 683 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 684 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 685 | SKF_AD_OFF + SKF_AD_QUEUE), |
| 686 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 687 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 688 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 689 | { }, |
| 690 | { { 1, SKB_QUEUE_MAP }, { 10, SKB_QUEUE_MAP } }, |
| 691 | }, |
| 692 | { |
| 693 | "LD_PROTOCOL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 694 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 695 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1), |
| 696 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0), |
| 697 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 698 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 699 | SKF_AD_OFF + SKF_AD_PROTOCOL), |
| 700 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 701 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 702 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 30, 1, 0), |
| 703 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 704 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 705 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 706 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 707 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 708 | { 10, 20, 30 }, |
| 709 | { { 10, ETH_P_IP }, { 100, ETH_P_IP } }, |
| 710 | }, |
| 711 | { |
| 712 | "LD_VLAN_TAG", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 713 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 714 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 715 | SKF_AD_OFF + SKF_AD_VLAN_TAG), |
| 716 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 717 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 718 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 719 | { }, |
| 720 | { |
Michał Mirosław | 0c4b2d3 | 2018-11-10 19:58:36 +0100 | [diff] [blame] | 721 | { 1, SKB_VLAN_TCI }, |
| 722 | { 10, SKB_VLAN_TCI } |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 723 | }, |
| 724 | }, |
| 725 | { |
| 726 | "LD_VLAN_TAG_PRESENT", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 727 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 728 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 729 | SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), |
| 730 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 731 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 732 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 733 | { }, |
| 734 | { |
Michał Mirosław | 0c4b2d3 | 2018-11-10 19:58:36 +0100 | [diff] [blame] | 735 | { 1, SKB_VLAN_PRESENT }, |
| 736 | { 10, SKB_VLAN_PRESENT } |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 737 | }, |
| 738 | }, |
| 739 | { |
| 740 | "LD_IFINDEX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 741 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 742 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 743 | SKF_AD_OFF + SKF_AD_IFINDEX), |
| 744 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 745 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 746 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 747 | { }, |
| 748 | { { 1, SKB_DEV_IFINDEX }, { 10, SKB_DEV_IFINDEX } }, |
| 749 | }, |
| 750 | { |
| 751 | "LD_HATYPE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 752 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 753 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 754 | SKF_AD_OFF + SKF_AD_HATYPE), |
| 755 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 756 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 757 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 758 | { }, |
| 759 | { { 1, SKB_DEV_TYPE }, { 10, SKB_DEV_TYPE } }, |
| 760 | }, |
| 761 | { |
| 762 | "LD_CPU", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 763 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 764 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 765 | SKF_AD_OFF + SKF_AD_CPU), |
| 766 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 767 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 768 | SKF_AD_OFF + SKF_AD_CPU), |
| 769 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 770 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 771 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 772 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 773 | { }, |
| 774 | { { 1, 0 }, { 10, 0 } }, |
| 775 | }, |
| 776 | { |
| 777 | "LD_NLATTR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 778 | .u.insns = { |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 779 | BPF_STMT(BPF_LDX | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 780 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 781 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 782 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 783 | SKF_AD_OFF + SKF_AD_NLATTR), |
| 784 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 785 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 786 | CLASSIC, |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 787 | #ifdef __BIG_ENDIAN |
| 788 | { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 }, |
| 789 | #else |
| 790 | { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 }, |
| 791 | #endif |
| 792 | { { 4, 0 }, { 20, 6 } }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 793 | }, |
| 794 | { |
| 795 | "LD_NLATTR_NEST", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 796 | .u.insns = { |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 797 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 798 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 799 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 800 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 801 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 802 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 803 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 804 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 805 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 806 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 807 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 808 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 809 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 810 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 811 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 812 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 813 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 814 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 815 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 816 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 817 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 818 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 819 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 820 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 821 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
| 822 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 823 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 824 | CLASSIC, |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 825 | #ifdef __BIG_ENDIAN |
| 826 | { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 }, |
| 827 | #else |
| 828 | { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 }, |
| 829 | #endif |
| 830 | { { 4, 0 }, { 20, 10 } }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 831 | }, |
| 832 | { |
| 833 | "LD_PAYLOAD_OFF", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 834 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 835 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 836 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 837 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 838 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 839 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 840 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 841 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 842 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 843 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 844 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 845 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 846 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 847 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 848 | /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800), |
| 849 | * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request, |
| 850 | * id 9737, seq 1, length 64 |
| 851 | */ |
| 852 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 853 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 854 | 0x08, 0x00, |
| 855 | 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40, |
| 856 | 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 }, |
| 857 | { { 30, 0 }, { 100, 42 } }, |
| 858 | }, |
| 859 | { |
| 860 | "LD_ANC_XOR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 861 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 862 | BPF_STMT(BPF_LD | BPF_IMM, 10), |
| 863 | BPF_STMT(BPF_LDX | BPF_IMM, 300), |
| 864 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 865 | SKF_AD_OFF + SKF_AD_ALU_XOR_X), |
| 866 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 867 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 868 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 869 | { }, |
Nathan Chancellor | 0984543 | 2019-08-18 21:34:20 -0700 | [diff] [blame] | 870 | { { 4, 0xA ^ 300 }, { 20, 0xA ^ 300 } }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 871 | }, |
| 872 | { |
| 873 | "SPILL_FILL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 874 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 875 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 876 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
| 877 | BPF_STMT(BPF_ALU | BPF_RSH, 1), |
| 878 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 879 | BPF_STMT(BPF_ST, 1), /* M1 = 1 ^ len */ |
| 880 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_K, 0x80000000), |
| 881 | BPF_STMT(BPF_ST, 2), /* M2 = 1 ^ len ^ 0x80000000 */ |
| 882 | BPF_STMT(BPF_STX, 15), /* M3 = len */ |
| 883 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 884 | BPF_STMT(BPF_LD | BPF_MEM, 2), |
| 885 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 886 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 887 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 888 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 889 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 890 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 891 | { }, |
| 892 | { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } } |
| 893 | }, |
| 894 | { |
| 895 | "JEQ", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 896 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 897 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 898 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 899 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1), |
| 900 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 901 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 902 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 903 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 904 | { 3, 3, 3, 3, 3 }, |
| 905 | { { 1, 0 }, { 3, 1 }, { 4, MAX_K } }, |
| 906 | }, |
| 907 | { |
| 908 | "JGT", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 909 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 910 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 911 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 912 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1), |
| 913 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 914 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 915 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 916 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 917 | { 4, 4, 4, 3, 3 }, |
| 918 | { { 2, 0 }, { 3, 1 }, { 4, MAX_K } }, |
| 919 | }, |
| 920 | { |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 921 | "JGE (jt 0), test 1", |
| 922 | .u.insns = { |
| 923 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 924 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 925 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1), |
| 926 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 927 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 928 | }, |
| 929 | CLASSIC, |
| 930 | { 4, 4, 4, 3, 3 }, |
| 931 | { { 2, 0 }, { 3, 1 }, { 4, 1 } }, |
| 932 | }, |
| 933 | { |
| 934 | "JGE (jt 0), test 2", |
| 935 | .u.insns = { |
| 936 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 937 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 938 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1), |
| 939 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 940 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 941 | }, |
| 942 | CLASSIC, |
| 943 | { 4, 4, 5, 3, 3 }, |
| 944 | { { 4, 1 }, { 5, 1 }, { 6, MAX_K } }, |
| 945 | }, |
| 946 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 947 | "JGE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 948 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 949 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 950 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K), |
| 951 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0), |
| 952 | BPF_STMT(BPF_RET | BPF_K, 10), |
| 953 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 2, 1, 0), |
| 954 | BPF_STMT(BPF_RET | BPF_K, 20), |
| 955 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 3, 1, 0), |
| 956 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 957 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 4, 1, 0), |
| 958 | BPF_STMT(BPF_RET | BPF_K, 40), |
| 959 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 960 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 961 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 962 | { 1, 2, 3, 4, 5 }, |
| 963 | { { 1, 20 }, { 3, 40 }, { 5, MAX_K } }, |
| 964 | }, |
| 965 | { |
| 966 | "JSET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 967 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 968 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 969 | BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1), |
| 970 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 971 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 972 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 973 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 974 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, 4), |
| 975 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 976 | BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0), |
| 977 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 1, 0, 1), |
| 978 | BPF_STMT(BPF_RET | BPF_K, 10), |
| 979 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x80000000, 0, 1), |
| 980 | BPF_STMT(BPF_RET | BPF_K, 20), |
| 981 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 982 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 983 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 984 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 985 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 986 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 987 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 988 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 989 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 990 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 991 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 992 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 993 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 994 | { 0, 0xAA, 0x55, 1 }, |
| 995 | { { 4, 10 }, { 5, 20 }, { 6, MAX_K } }, |
| 996 | }, |
| 997 | { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 998 | "tcpdump port 22", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 999 | .u.insns = { |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 1000 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), |
| 1001 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 0, 8), /* IPv6 */ |
| 1002 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 20), |
| 1003 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), |
| 1004 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), |
| 1005 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 17), |
| 1006 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 54), |
| 1007 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 14, 0), |
| 1008 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 56), |
| 1009 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 12, 13), |
| 1010 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0800, 0, 12), /* IPv4 */ |
| 1011 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), |
| 1012 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), |
| 1013 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), |
| 1014 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 8), |
| 1015 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), |
| 1016 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 6, 0), |
| 1017 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1018 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), |
| 1019 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), |
| 1020 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), |
| 1021 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 1), |
| 1022 | BPF_STMT(BPF_RET | BPF_K, 0xffff), |
| 1023 | BPF_STMT(BPF_RET | BPF_K, 0), |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1024 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1025 | CLASSIC, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1026 | /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800) |
| 1027 | * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.], |
| 1028 | * seq 1305692979:1305693027, ack 3650467037, win 65535, |
| 1029 | * options [nop,nop,TS val 2502645400 ecr 3971138], length 48 |
| 1030 | */ |
| 1031 | { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, |
| 1032 | 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, |
| 1033 | 0x08, 0x00, |
| 1034 | 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, |
| 1035 | 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ |
| 1036 | 0x0a, 0x01, 0x01, 0x95, /* ip src */ |
| 1037 | 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ |
| 1038 | 0xc2, 0x24, |
| 1039 | 0x00, 0x16 /* dst port */ }, |
| 1040 | { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, |
| 1041 | }, |
| 1042 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1043 | "tcpdump complex", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1044 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1045 | /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] - |
| 1046 | * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and |
| 1047 | * (len > 115 or len < 30000000000)' -d |
| 1048 | */ |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 1049 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), |
| 1050 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 30, 0), |
| 1051 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x800, 0, 29), |
| 1052 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), |
| 1053 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 0, 27), |
| 1054 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), |
| 1055 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 25, 0), |
| 1056 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1057 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), |
| 1058 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), |
| 1059 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), |
| 1060 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 20), |
| 1061 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 16), |
| 1062 | BPF_STMT(BPF_ST, 1), |
| 1063 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 14), |
| 1064 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf), |
| 1065 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 2), |
| 1066 | BPF_STMT(BPF_MISC | BPF_TAX, 0x5), /* libpcap emits K on TAX */ |
| 1067 | BPF_STMT(BPF_LD | BPF_MEM, 1), |
| 1068 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 1069 | BPF_STMT(BPF_ST, 5), |
| 1070 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1071 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 26), |
| 1072 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), |
| 1073 | BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 2), |
| 1074 | BPF_STMT(BPF_MISC | BPF_TAX, 0x9), /* libpcap emits K on TAX */ |
| 1075 | BPF_STMT(BPF_LD | BPF_MEM, 5), |
| 1076 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 4, 0), |
| 1077 | BPF_STMT(BPF_LD | BPF_LEN, 0), |
| 1078 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_K, 0x73, 1, 0), |
| 1079 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 0xfc23ac00, 1, 0), |
| 1080 | BPF_STMT(BPF_RET | BPF_K, 0xffff), |
| 1081 | BPF_STMT(BPF_RET | BPF_K, 0), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1082 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1083 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1084 | { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, |
| 1085 | 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, |
| 1086 | 0x08, 0x00, |
| 1087 | 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, |
| 1088 | 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ |
| 1089 | 0x0a, 0x01, 0x01, 0x95, /* ip src */ |
| 1090 | 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ |
| 1091 | 0xc2, 0x24, |
| 1092 | 0x00, 0x16 /* dst port */ }, |
| 1093 | { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, |
| 1094 | }, |
| 1095 | { |
| 1096 | "RET_A", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1097 | .u.insns = { |
Zhen Lei | 53b0fe3 | 2021-07-07 18:07:28 -0700 | [diff] [blame] | 1098 | /* check that uninitialized X and A contain zeros */ |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1099 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 1100 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 1101 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1102 | CLASSIC, |
| 1103 | { }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1104 | { {1, 0}, {2, 0} }, |
| 1105 | }, |
| 1106 | { |
| 1107 | "INT: ADD trivial", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1108 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1109 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1110 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 1111 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
| 1112 | BPF_ALU64_REG(BPF_SUB, R1, R2), |
| 1113 | BPF_ALU64_IMM(BPF_ADD, R1, -1), |
| 1114 | BPF_ALU64_IMM(BPF_MUL, R1, 3), |
| 1115 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 1116 | BPF_EXIT_INSN(), |
| 1117 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1118 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1119 | { }, |
| 1120 | { { 0, 0xfffffffd } } |
| 1121 | }, |
| 1122 | { |
| 1123 | "INT: MUL_X", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1124 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1125 | BPF_ALU64_IMM(BPF_MOV, R0, -1), |
| 1126 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1127 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
| 1128 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1129 | BPF_JMP_IMM(BPF_JEQ, R1, 0xfffffffd, 1), |
| 1130 | BPF_EXIT_INSN(), |
| 1131 | BPF_ALU64_IMM(BPF_MOV, R0, 1), |
| 1132 | BPF_EXIT_INSN(), |
| 1133 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1134 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1135 | { }, |
| 1136 | { { 0, 1 } } |
| 1137 | }, |
| 1138 | { |
| 1139 | "INT: MUL_X2", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1140 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1141 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
| 1142 | BPF_ALU32_IMM(BPF_MOV, R1, -1), |
| 1143 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
| 1144 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1145 | BPF_ALU64_IMM(BPF_RSH, R1, 8), |
| 1146 | BPF_JMP_IMM(BPF_JEQ, R1, 0x2ffffff, 1), |
| 1147 | BPF_EXIT_INSN(), |
| 1148 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1149 | BPF_EXIT_INSN(), |
| 1150 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1151 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1152 | { }, |
| 1153 | { { 0, 1 } } |
| 1154 | }, |
| 1155 | { |
| 1156 | "INT: MUL32_X", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1157 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1158 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
| 1159 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1160 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
| 1161 | BPF_ALU32_REG(BPF_MUL, R1, R2), |
| 1162 | BPF_ALU64_IMM(BPF_RSH, R1, 8), |
| 1163 | BPF_JMP_IMM(BPF_JEQ, R1, 0xffffff, 1), |
| 1164 | BPF_EXIT_INSN(), |
| 1165 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1166 | BPF_EXIT_INSN(), |
| 1167 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1168 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1169 | { }, |
| 1170 | { { 0, 1 } } |
| 1171 | }, |
| 1172 | { |
| 1173 | /* Have to test all register combinations, since |
| 1174 | * JITing of different registers will produce |
| 1175 | * different asm code. |
| 1176 | */ |
| 1177 | "INT: ADD 64-bit", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1178 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1179 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1180 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1181 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1182 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1183 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1184 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1185 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1186 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1187 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1188 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1189 | BPF_ALU64_IMM(BPF_ADD, R0, 20), |
| 1190 | BPF_ALU64_IMM(BPF_ADD, R1, 20), |
| 1191 | BPF_ALU64_IMM(BPF_ADD, R2, 20), |
| 1192 | BPF_ALU64_IMM(BPF_ADD, R3, 20), |
| 1193 | BPF_ALU64_IMM(BPF_ADD, R4, 20), |
| 1194 | BPF_ALU64_IMM(BPF_ADD, R5, 20), |
| 1195 | BPF_ALU64_IMM(BPF_ADD, R6, 20), |
| 1196 | BPF_ALU64_IMM(BPF_ADD, R7, 20), |
| 1197 | BPF_ALU64_IMM(BPF_ADD, R8, 20), |
| 1198 | BPF_ALU64_IMM(BPF_ADD, R9, 20), |
| 1199 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1200 | BPF_ALU64_IMM(BPF_SUB, R1, 10), |
| 1201 | BPF_ALU64_IMM(BPF_SUB, R2, 10), |
| 1202 | BPF_ALU64_IMM(BPF_SUB, R3, 10), |
| 1203 | BPF_ALU64_IMM(BPF_SUB, R4, 10), |
| 1204 | BPF_ALU64_IMM(BPF_SUB, R5, 10), |
| 1205 | BPF_ALU64_IMM(BPF_SUB, R6, 10), |
| 1206 | BPF_ALU64_IMM(BPF_SUB, R7, 10), |
| 1207 | BPF_ALU64_IMM(BPF_SUB, R8, 10), |
| 1208 | BPF_ALU64_IMM(BPF_SUB, R9, 10), |
| 1209 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1210 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1211 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1212 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1213 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1214 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1215 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1216 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1217 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1218 | BPF_ALU64_REG(BPF_ADD, R0, R9), /* R0 == 155 */ |
| 1219 | BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), |
| 1220 | BPF_EXIT_INSN(), |
| 1221 | BPF_ALU64_REG(BPF_ADD, R1, R0), |
| 1222 | BPF_ALU64_REG(BPF_ADD, R1, R1), |
| 1223 | BPF_ALU64_REG(BPF_ADD, R1, R2), |
| 1224 | BPF_ALU64_REG(BPF_ADD, R1, R3), |
| 1225 | BPF_ALU64_REG(BPF_ADD, R1, R4), |
| 1226 | BPF_ALU64_REG(BPF_ADD, R1, R5), |
| 1227 | BPF_ALU64_REG(BPF_ADD, R1, R6), |
| 1228 | BPF_ALU64_REG(BPF_ADD, R1, R7), |
| 1229 | BPF_ALU64_REG(BPF_ADD, R1, R8), |
| 1230 | BPF_ALU64_REG(BPF_ADD, R1, R9), /* R1 == 456 */ |
| 1231 | BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), |
| 1232 | BPF_EXIT_INSN(), |
| 1233 | BPF_ALU64_REG(BPF_ADD, R2, R0), |
| 1234 | BPF_ALU64_REG(BPF_ADD, R2, R1), |
| 1235 | BPF_ALU64_REG(BPF_ADD, R2, R2), |
| 1236 | BPF_ALU64_REG(BPF_ADD, R2, R3), |
| 1237 | BPF_ALU64_REG(BPF_ADD, R2, R4), |
| 1238 | BPF_ALU64_REG(BPF_ADD, R2, R5), |
| 1239 | BPF_ALU64_REG(BPF_ADD, R2, R6), |
| 1240 | BPF_ALU64_REG(BPF_ADD, R2, R7), |
| 1241 | BPF_ALU64_REG(BPF_ADD, R2, R8), |
| 1242 | BPF_ALU64_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ |
| 1243 | BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), |
| 1244 | BPF_EXIT_INSN(), |
| 1245 | BPF_ALU64_REG(BPF_ADD, R3, R0), |
| 1246 | BPF_ALU64_REG(BPF_ADD, R3, R1), |
| 1247 | BPF_ALU64_REG(BPF_ADD, R3, R2), |
| 1248 | BPF_ALU64_REG(BPF_ADD, R3, R3), |
| 1249 | BPF_ALU64_REG(BPF_ADD, R3, R4), |
| 1250 | BPF_ALU64_REG(BPF_ADD, R3, R5), |
| 1251 | BPF_ALU64_REG(BPF_ADD, R3, R6), |
| 1252 | BPF_ALU64_REG(BPF_ADD, R3, R7), |
| 1253 | BPF_ALU64_REG(BPF_ADD, R3, R8), |
| 1254 | BPF_ALU64_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ |
| 1255 | BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), |
| 1256 | BPF_EXIT_INSN(), |
| 1257 | BPF_ALU64_REG(BPF_ADD, R4, R0), |
| 1258 | BPF_ALU64_REG(BPF_ADD, R4, R1), |
| 1259 | BPF_ALU64_REG(BPF_ADD, R4, R2), |
| 1260 | BPF_ALU64_REG(BPF_ADD, R4, R3), |
| 1261 | BPF_ALU64_REG(BPF_ADD, R4, R4), |
| 1262 | BPF_ALU64_REG(BPF_ADD, R4, R5), |
| 1263 | BPF_ALU64_REG(BPF_ADD, R4, R6), |
| 1264 | BPF_ALU64_REG(BPF_ADD, R4, R7), |
| 1265 | BPF_ALU64_REG(BPF_ADD, R4, R8), |
| 1266 | BPF_ALU64_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ |
| 1267 | BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), |
| 1268 | BPF_EXIT_INSN(), |
| 1269 | BPF_ALU64_REG(BPF_ADD, R5, R0), |
| 1270 | BPF_ALU64_REG(BPF_ADD, R5, R1), |
| 1271 | BPF_ALU64_REG(BPF_ADD, R5, R2), |
| 1272 | BPF_ALU64_REG(BPF_ADD, R5, R3), |
| 1273 | BPF_ALU64_REG(BPF_ADD, R5, R4), |
| 1274 | BPF_ALU64_REG(BPF_ADD, R5, R5), |
| 1275 | BPF_ALU64_REG(BPF_ADD, R5, R6), |
| 1276 | BPF_ALU64_REG(BPF_ADD, R5, R7), |
| 1277 | BPF_ALU64_REG(BPF_ADD, R5, R8), |
| 1278 | BPF_ALU64_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ |
| 1279 | BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), |
| 1280 | BPF_EXIT_INSN(), |
| 1281 | BPF_ALU64_REG(BPF_ADD, R6, R0), |
| 1282 | BPF_ALU64_REG(BPF_ADD, R6, R1), |
| 1283 | BPF_ALU64_REG(BPF_ADD, R6, R2), |
| 1284 | BPF_ALU64_REG(BPF_ADD, R6, R3), |
| 1285 | BPF_ALU64_REG(BPF_ADD, R6, R4), |
| 1286 | BPF_ALU64_REG(BPF_ADD, R6, R5), |
| 1287 | BPF_ALU64_REG(BPF_ADD, R6, R6), |
| 1288 | BPF_ALU64_REG(BPF_ADD, R6, R7), |
| 1289 | BPF_ALU64_REG(BPF_ADD, R6, R8), |
| 1290 | BPF_ALU64_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ |
| 1291 | BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), |
| 1292 | BPF_EXIT_INSN(), |
| 1293 | BPF_ALU64_REG(BPF_ADD, R7, R0), |
| 1294 | BPF_ALU64_REG(BPF_ADD, R7, R1), |
| 1295 | BPF_ALU64_REG(BPF_ADD, R7, R2), |
| 1296 | BPF_ALU64_REG(BPF_ADD, R7, R3), |
| 1297 | BPF_ALU64_REG(BPF_ADD, R7, R4), |
| 1298 | BPF_ALU64_REG(BPF_ADD, R7, R5), |
| 1299 | BPF_ALU64_REG(BPF_ADD, R7, R6), |
| 1300 | BPF_ALU64_REG(BPF_ADD, R7, R7), |
| 1301 | BPF_ALU64_REG(BPF_ADD, R7, R8), |
| 1302 | BPF_ALU64_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ |
| 1303 | BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), |
| 1304 | BPF_EXIT_INSN(), |
| 1305 | BPF_ALU64_REG(BPF_ADD, R8, R0), |
| 1306 | BPF_ALU64_REG(BPF_ADD, R8, R1), |
| 1307 | BPF_ALU64_REG(BPF_ADD, R8, R2), |
| 1308 | BPF_ALU64_REG(BPF_ADD, R8, R3), |
| 1309 | BPF_ALU64_REG(BPF_ADD, R8, R4), |
| 1310 | BPF_ALU64_REG(BPF_ADD, R8, R5), |
| 1311 | BPF_ALU64_REG(BPF_ADD, R8, R6), |
| 1312 | BPF_ALU64_REG(BPF_ADD, R8, R7), |
| 1313 | BPF_ALU64_REG(BPF_ADD, R8, R8), |
| 1314 | BPF_ALU64_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ |
| 1315 | BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), |
| 1316 | BPF_EXIT_INSN(), |
| 1317 | BPF_ALU64_REG(BPF_ADD, R9, R0), |
| 1318 | BPF_ALU64_REG(BPF_ADD, R9, R1), |
| 1319 | BPF_ALU64_REG(BPF_ADD, R9, R2), |
| 1320 | BPF_ALU64_REG(BPF_ADD, R9, R3), |
| 1321 | BPF_ALU64_REG(BPF_ADD, R9, R4), |
| 1322 | BPF_ALU64_REG(BPF_ADD, R9, R5), |
| 1323 | BPF_ALU64_REG(BPF_ADD, R9, R6), |
| 1324 | BPF_ALU64_REG(BPF_ADD, R9, R7), |
| 1325 | BPF_ALU64_REG(BPF_ADD, R9, R8), |
| 1326 | BPF_ALU64_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ |
| 1327 | BPF_ALU64_REG(BPF_MOV, R0, R9), |
| 1328 | BPF_EXIT_INSN(), |
| 1329 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1330 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1331 | { }, |
| 1332 | { { 0, 2957380 } } |
| 1333 | }, |
| 1334 | { |
| 1335 | "INT: ADD 32-bit", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1336 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1337 | BPF_ALU32_IMM(BPF_MOV, R0, 20), |
| 1338 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 1339 | BPF_ALU32_IMM(BPF_MOV, R2, 2), |
| 1340 | BPF_ALU32_IMM(BPF_MOV, R3, 3), |
| 1341 | BPF_ALU32_IMM(BPF_MOV, R4, 4), |
| 1342 | BPF_ALU32_IMM(BPF_MOV, R5, 5), |
| 1343 | BPF_ALU32_IMM(BPF_MOV, R6, 6), |
| 1344 | BPF_ALU32_IMM(BPF_MOV, R7, 7), |
| 1345 | BPF_ALU32_IMM(BPF_MOV, R8, 8), |
| 1346 | BPF_ALU32_IMM(BPF_MOV, R9, 9), |
| 1347 | BPF_ALU64_IMM(BPF_ADD, R1, 10), |
| 1348 | BPF_ALU64_IMM(BPF_ADD, R2, 10), |
| 1349 | BPF_ALU64_IMM(BPF_ADD, R3, 10), |
| 1350 | BPF_ALU64_IMM(BPF_ADD, R4, 10), |
| 1351 | BPF_ALU64_IMM(BPF_ADD, R5, 10), |
| 1352 | BPF_ALU64_IMM(BPF_ADD, R6, 10), |
| 1353 | BPF_ALU64_IMM(BPF_ADD, R7, 10), |
| 1354 | BPF_ALU64_IMM(BPF_ADD, R8, 10), |
| 1355 | BPF_ALU64_IMM(BPF_ADD, R9, 10), |
| 1356 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 1357 | BPF_ALU32_REG(BPF_ADD, R0, R2), |
| 1358 | BPF_ALU32_REG(BPF_ADD, R0, R3), |
| 1359 | BPF_ALU32_REG(BPF_ADD, R0, R4), |
| 1360 | BPF_ALU32_REG(BPF_ADD, R0, R5), |
| 1361 | BPF_ALU32_REG(BPF_ADD, R0, R6), |
| 1362 | BPF_ALU32_REG(BPF_ADD, R0, R7), |
| 1363 | BPF_ALU32_REG(BPF_ADD, R0, R8), |
| 1364 | BPF_ALU32_REG(BPF_ADD, R0, R9), /* R0 == 155 */ |
| 1365 | BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), |
| 1366 | BPF_EXIT_INSN(), |
| 1367 | BPF_ALU32_REG(BPF_ADD, R1, R0), |
| 1368 | BPF_ALU32_REG(BPF_ADD, R1, R1), |
| 1369 | BPF_ALU32_REG(BPF_ADD, R1, R2), |
| 1370 | BPF_ALU32_REG(BPF_ADD, R1, R3), |
| 1371 | BPF_ALU32_REG(BPF_ADD, R1, R4), |
| 1372 | BPF_ALU32_REG(BPF_ADD, R1, R5), |
| 1373 | BPF_ALU32_REG(BPF_ADD, R1, R6), |
| 1374 | BPF_ALU32_REG(BPF_ADD, R1, R7), |
| 1375 | BPF_ALU32_REG(BPF_ADD, R1, R8), |
| 1376 | BPF_ALU32_REG(BPF_ADD, R1, R9), /* R1 == 456 */ |
| 1377 | BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), |
| 1378 | BPF_EXIT_INSN(), |
| 1379 | BPF_ALU32_REG(BPF_ADD, R2, R0), |
| 1380 | BPF_ALU32_REG(BPF_ADD, R2, R1), |
| 1381 | BPF_ALU32_REG(BPF_ADD, R2, R2), |
| 1382 | BPF_ALU32_REG(BPF_ADD, R2, R3), |
| 1383 | BPF_ALU32_REG(BPF_ADD, R2, R4), |
| 1384 | BPF_ALU32_REG(BPF_ADD, R2, R5), |
| 1385 | BPF_ALU32_REG(BPF_ADD, R2, R6), |
| 1386 | BPF_ALU32_REG(BPF_ADD, R2, R7), |
| 1387 | BPF_ALU32_REG(BPF_ADD, R2, R8), |
| 1388 | BPF_ALU32_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ |
| 1389 | BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), |
| 1390 | BPF_EXIT_INSN(), |
| 1391 | BPF_ALU32_REG(BPF_ADD, R3, R0), |
| 1392 | BPF_ALU32_REG(BPF_ADD, R3, R1), |
| 1393 | BPF_ALU32_REG(BPF_ADD, R3, R2), |
| 1394 | BPF_ALU32_REG(BPF_ADD, R3, R3), |
| 1395 | BPF_ALU32_REG(BPF_ADD, R3, R4), |
| 1396 | BPF_ALU32_REG(BPF_ADD, R3, R5), |
| 1397 | BPF_ALU32_REG(BPF_ADD, R3, R6), |
| 1398 | BPF_ALU32_REG(BPF_ADD, R3, R7), |
| 1399 | BPF_ALU32_REG(BPF_ADD, R3, R8), |
| 1400 | BPF_ALU32_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ |
| 1401 | BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), |
| 1402 | BPF_EXIT_INSN(), |
| 1403 | BPF_ALU32_REG(BPF_ADD, R4, R0), |
| 1404 | BPF_ALU32_REG(BPF_ADD, R4, R1), |
| 1405 | BPF_ALU32_REG(BPF_ADD, R4, R2), |
| 1406 | BPF_ALU32_REG(BPF_ADD, R4, R3), |
| 1407 | BPF_ALU32_REG(BPF_ADD, R4, R4), |
| 1408 | BPF_ALU32_REG(BPF_ADD, R4, R5), |
| 1409 | BPF_ALU32_REG(BPF_ADD, R4, R6), |
| 1410 | BPF_ALU32_REG(BPF_ADD, R4, R7), |
| 1411 | BPF_ALU32_REG(BPF_ADD, R4, R8), |
| 1412 | BPF_ALU32_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ |
| 1413 | BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), |
| 1414 | BPF_EXIT_INSN(), |
| 1415 | BPF_ALU32_REG(BPF_ADD, R5, R0), |
| 1416 | BPF_ALU32_REG(BPF_ADD, R5, R1), |
| 1417 | BPF_ALU32_REG(BPF_ADD, R5, R2), |
| 1418 | BPF_ALU32_REG(BPF_ADD, R5, R3), |
| 1419 | BPF_ALU32_REG(BPF_ADD, R5, R4), |
| 1420 | BPF_ALU32_REG(BPF_ADD, R5, R5), |
| 1421 | BPF_ALU32_REG(BPF_ADD, R5, R6), |
| 1422 | BPF_ALU32_REG(BPF_ADD, R5, R7), |
| 1423 | BPF_ALU32_REG(BPF_ADD, R5, R8), |
| 1424 | BPF_ALU32_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ |
| 1425 | BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), |
| 1426 | BPF_EXIT_INSN(), |
| 1427 | BPF_ALU32_REG(BPF_ADD, R6, R0), |
| 1428 | BPF_ALU32_REG(BPF_ADD, R6, R1), |
| 1429 | BPF_ALU32_REG(BPF_ADD, R6, R2), |
| 1430 | BPF_ALU32_REG(BPF_ADD, R6, R3), |
| 1431 | BPF_ALU32_REG(BPF_ADD, R6, R4), |
| 1432 | BPF_ALU32_REG(BPF_ADD, R6, R5), |
| 1433 | BPF_ALU32_REG(BPF_ADD, R6, R6), |
| 1434 | BPF_ALU32_REG(BPF_ADD, R6, R7), |
| 1435 | BPF_ALU32_REG(BPF_ADD, R6, R8), |
| 1436 | BPF_ALU32_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ |
| 1437 | BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), |
| 1438 | BPF_EXIT_INSN(), |
| 1439 | BPF_ALU32_REG(BPF_ADD, R7, R0), |
| 1440 | BPF_ALU32_REG(BPF_ADD, R7, R1), |
| 1441 | BPF_ALU32_REG(BPF_ADD, R7, R2), |
| 1442 | BPF_ALU32_REG(BPF_ADD, R7, R3), |
| 1443 | BPF_ALU32_REG(BPF_ADD, R7, R4), |
| 1444 | BPF_ALU32_REG(BPF_ADD, R7, R5), |
| 1445 | BPF_ALU32_REG(BPF_ADD, R7, R6), |
| 1446 | BPF_ALU32_REG(BPF_ADD, R7, R7), |
| 1447 | BPF_ALU32_REG(BPF_ADD, R7, R8), |
| 1448 | BPF_ALU32_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ |
| 1449 | BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), |
| 1450 | BPF_EXIT_INSN(), |
| 1451 | BPF_ALU32_REG(BPF_ADD, R8, R0), |
| 1452 | BPF_ALU32_REG(BPF_ADD, R8, R1), |
| 1453 | BPF_ALU32_REG(BPF_ADD, R8, R2), |
| 1454 | BPF_ALU32_REG(BPF_ADD, R8, R3), |
| 1455 | BPF_ALU32_REG(BPF_ADD, R8, R4), |
| 1456 | BPF_ALU32_REG(BPF_ADD, R8, R5), |
| 1457 | BPF_ALU32_REG(BPF_ADD, R8, R6), |
| 1458 | BPF_ALU32_REG(BPF_ADD, R8, R7), |
| 1459 | BPF_ALU32_REG(BPF_ADD, R8, R8), |
| 1460 | BPF_ALU32_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ |
| 1461 | BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), |
| 1462 | BPF_EXIT_INSN(), |
| 1463 | BPF_ALU32_REG(BPF_ADD, R9, R0), |
| 1464 | BPF_ALU32_REG(BPF_ADD, R9, R1), |
| 1465 | BPF_ALU32_REG(BPF_ADD, R9, R2), |
| 1466 | BPF_ALU32_REG(BPF_ADD, R9, R3), |
| 1467 | BPF_ALU32_REG(BPF_ADD, R9, R4), |
| 1468 | BPF_ALU32_REG(BPF_ADD, R9, R5), |
| 1469 | BPF_ALU32_REG(BPF_ADD, R9, R6), |
| 1470 | BPF_ALU32_REG(BPF_ADD, R9, R7), |
| 1471 | BPF_ALU32_REG(BPF_ADD, R9, R8), |
| 1472 | BPF_ALU32_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ |
| 1473 | BPF_ALU32_REG(BPF_MOV, R0, R9), |
| 1474 | BPF_EXIT_INSN(), |
| 1475 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1476 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1477 | { }, |
| 1478 | { { 0, 2957380 } } |
| 1479 | }, |
| 1480 | { /* Mainly checking JIT here. */ |
| 1481 | "INT: SUB", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1482 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1483 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1484 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1485 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1486 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1487 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1488 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1489 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1490 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1491 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1492 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1493 | BPF_ALU64_REG(BPF_SUB, R0, R0), |
| 1494 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 1495 | BPF_ALU64_REG(BPF_SUB, R0, R2), |
| 1496 | BPF_ALU64_REG(BPF_SUB, R0, R3), |
| 1497 | BPF_ALU64_REG(BPF_SUB, R0, R4), |
| 1498 | BPF_ALU64_REG(BPF_SUB, R0, R5), |
| 1499 | BPF_ALU64_REG(BPF_SUB, R0, R6), |
| 1500 | BPF_ALU64_REG(BPF_SUB, R0, R7), |
| 1501 | BPF_ALU64_REG(BPF_SUB, R0, R8), |
| 1502 | BPF_ALU64_REG(BPF_SUB, R0, R9), |
| 1503 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1504 | BPF_JMP_IMM(BPF_JEQ, R0, -55, 1), |
| 1505 | BPF_EXIT_INSN(), |
| 1506 | BPF_ALU64_REG(BPF_SUB, R1, R0), |
| 1507 | BPF_ALU64_REG(BPF_SUB, R1, R2), |
| 1508 | BPF_ALU64_REG(BPF_SUB, R1, R3), |
| 1509 | BPF_ALU64_REG(BPF_SUB, R1, R4), |
| 1510 | BPF_ALU64_REG(BPF_SUB, R1, R5), |
| 1511 | BPF_ALU64_REG(BPF_SUB, R1, R6), |
| 1512 | BPF_ALU64_REG(BPF_SUB, R1, R7), |
| 1513 | BPF_ALU64_REG(BPF_SUB, R1, R8), |
| 1514 | BPF_ALU64_REG(BPF_SUB, R1, R9), |
| 1515 | BPF_ALU64_IMM(BPF_SUB, R1, 10), |
| 1516 | BPF_ALU64_REG(BPF_SUB, R2, R0), |
| 1517 | BPF_ALU64_REG(BPF_SUB, R2, R1), |
| 1518 | BPF_ALU64_REG(BPF_SUB, R2, R3), |
| 1519 | BPF_ALU64_REG(BPF_SUB, R2, R4), |
| 1520 | BPF_ALU64_REG(BPF_SUB, R2, R5), |
| 1521 | BPF_ALU64_REG(BPF_SUB, R2, R6), |
| 1522 | BPF_ALU64_REG(BPF_SUB, R2, R7), |
| 1523 | BPF_ALU64_REG(BPF_SUB, R2, R8), |
| 1524 | BPF_ALU64_REG(BPF_SUB, R2, R9), |
| 1525 | BPF_ALU64_IMM(BPF_SUB, R2, 10), |
| 1526 | BPF_ALU64_REG(BPF_SUB, R3, R0), |
| 1527 | BPF_ALU64_REG(BPF_SUB, R3, R1), |
| 1528 | BPF_ALU64_REG(BPF_SUB, R3, R2), |
| 1529 | BPF_ALU64_REG(BPF_SUB, R3, R4), |
| 1530 | BPF_ALU64_REG(BPF_SUB, R3, R5), |
| 1531 | BPF_ALU64_REG(BPF_SUB, R3, R6), |
| 1532 | BPF_ALU64_REG(BPF_SUB, R3, R7), |
| 1533 | BPF_ALU64_REG(BPF_SUB, R3, R8), |
| 1534 | BPF_ALU64_REG(BPF_SUB, R3, R9), |
| 1535 | BPF_ALU64_IMM(BPF_SUB, R3, 10), |
| 1536 | BPF_ALU64_REG(BPF_SUB, R4, R0), |
| 1537 | BPF_ALU64_REG(BPF_SUB, R4, R1), |
| 1538 | BPF_ALU64_REG(BPF_SUB, R4, R2), |
| 1539 | BPF_ALU64_REG(BPF_SUB, R4, R3), |
| 1540 | BPF_ALU64_REG(BPF_SUB, R4, R5), |
| 1541 | BPF_ALU64_REG(BPF_SUB, R4, R6), |
| 1542 | BPF_ALU64_REG(BPF_SUB, R4, R7), |
| 1543 | BPF_ALU64_REG(BPF_SUB, R4, R8), |
| 1544 | BPF_ALU64_REG(BPF_SUB, R4, R9), |
| 1545 | BPF_ALU64_IMM(BPF_SUB, R4, 10), |
| 1546 | BPF_ALU64_REG(BPF_SUB, R5, R0), |
| 1547 | BPF_ALU64_REG(BPF_SUB, R5, R1), |
| 1548 | BPF_ALU64_REG(BPF_SUB, R5, R2), |
| 1549 | BPF_ALU64_REG(BPF_SUB, R5, R3), |
| 1550 | BPF_ALU64_REG(BPF_SUB, R5, R4), |
| 1551 | BPF_ALU64_REG(BPF_SUB, R5, R6), |
| 1552 | BPF_ALU64_REG(BPF_SUB, R5, R7), |
| 1553 | BPF_ALU64_REG(BPF_SUB, R5, R8), |
| 1554 | BPF_ALU64_REG(BPF_SUB, R5, R9), |
| 1555 | BPF_ALU64_IMM(BPF_SUB, R5, 10), |
| 1556 | BPF_ALU64_REG(BPF_SUB, R6, R0), |
| 1557 | BPF_ALU64_REG(BPF_SUB, R6, R1), |
| 1558 | BPF_ALU64_REG(BPF_SUB, R6, R2), |
| 1559 | BPF_ALU64_REG(BPF_SUB, R6, R3), |
| 1560 | BPF_ALU64_REG(BPF_SUB, R6, R4), |
| 1561 | BPF_ALU64_REG(BPF_SUB, R6, R5), |
| 1562 | BPF_ALU64_REG(BPF_SUB, R6, R7), |
| 1563 | BPF_ALU64_REG(BPF_SUB, R6, R8), |
| 1564 | BPF_ALU64_REG(BPF_SUB, R6, R9), |
| 1565 | BPF_ALU64_IMM(BPF_SUB, R6, 10), |
| 1566 | BPF_ALU64_REG(BPF_SUB, R7, R0), |
| 1567 | BPF_ALU64_REG(BPF_SUB, R7, R1), |
| 1568 | BPF_ALU64_REG(BPF_SUB, R7, R2), |
| 1569 | BPF_ALU64_REG(BPF_SUB, R7, R3), |
| 1570 | BPF_ALU64_REG(BPF_SUB, R7, R4), |
| 1571 | BPF_ALU64_REG(BPF_SUB, R7, R5), |
| 1572 | BPF_ALU64_REG(BPF_SUB, R7, R6), |
| 1573 | BPF_ALU64_REG(BPF_SUB, R7, R8), |
| 1574 | BPF_ALU64_REG(BPF_SUB, R7, R9), |
| 1575 | BPF_ALU64_IMM(BPF_SUB, R7, 10), |
| 1576 | BPF_ALU64_REG(BPF_SUB, R8, R0), |
| 1577 | BPF_ALU64_REG(BPF_SUB, R8, R1), |
| 1578 | BPF_ALU64_REG(BPF_SUB, R8, R2), |
| 1579 | BPF_ALU64_REG(BPF_SUB, R8, R3), |
| 1580 | BPF_ALU64_REG(BPF_SUB, R8, R4), |
| 1581 | BPF_ALU64_REG(BPF_SUB, R8, R5), |
| 1582 | BPF_ALU64_REG(BPF_SUB, R8, R6), |
| 1583 | BPF_ALU64_REG(BPF_SUB, R8, R7), |
| 1584 | BPF_ALU64_REG(BPF_SUB, R8, R9), |
| 1585 | BPF_ALU64_IMM(BPF_SUB, R8, 10), |
| 1586 | BPF_ALU64_REG(BPF_SUB, R9, R0), |
| 1587 | BPF_ALU64_REG(BPF_SUB, R9, R1), |
| 1588 | BPF_ALU64_REG(BPF_SUB, R9, R2), |
| 1589 | BPF_ALU64_REG(BPF_SUB, R9, R3), |
| 1590 | BPF_ALU64_REG(BPF_SUB, R9, R4), |
| 1591 | BPF_ALU64_REG(BPF_SUB, R9, R5), |
| 1592 | BPF_ALU64_REG(BPF_SUB, R9, R6), |
| 1593 | BPF_ALU64_REG(BPF_SUB, R9, R7), |
| 1594 | BPF_ALU64_REG(BPF_SUB, R9, R8), |
| 1595 | BPF_ALU64_IMM(BPF_SUB, R9, 10), |
| 1596 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1597 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 1598 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 1599 | BPF_ALU64_REG(BPF_SUB, R0, R2), |
| 1600 | BPF_ALU64_REG(BPF_SUB, R0, R3), |
| 1601 | BPF_ALU64_REG(BPF_SUB, R0, R4), |
| 1602 | BPF_ALU64_REG(BPF_SUB, R0, R5), |
| 1603 | BPF_ALU64_REG(BPF_SUB, R0, R6), |
| 1604 | BPF_ALU64_REG(BPF_SUB, R0, R7), |
| 1605 | BPF_ALU64_REG(BPF_SUB, R0, R8), |
| 1606 | BPF_ALU64_REG(BPF_SUB, R0, R9), |
| 1607 | BPF_EXIT_INSN(), |
| 1608 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1609 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1610 | { }, |
| 1611 | { { 0, 11 } } |
| 1612 | }, |
| 1613 | { /* Mainly checking JIT here. */ |
| 1614 | "INT: XOR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1615 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1616 | BPF_ALU64_REG(BPF_SUB, R0, R0), |
| 1617 | BPF_ALU64_REG(BPF_XOR, R1, R1), |
| 1618 | BPF_JMP_REG(BPF_JEQ, R0, R1, 1), |
| 1619 | BPF_EXIT_INSN(), |
| 1620 | BPF_ALU64_IMM(BPF_MOV, R0, 10), |
| 1621 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1622 | BPF_ALU64_REG(BPF_SUB, R1, R1), |
| 1623 | BPF_ALU64_REG(BPF_XOR, R2, R2), |
| 1624 | BPF_JMP_REG(BPF_JEQ, R1, R2, 1), |
| 1625 | BPF_EXIT_INSN(), |
| 1626 | BPF_ALU64_REG(BPF_SUB, R2, R2), |
| 1627 | BPF_ALU64_REG(BPF_XOR, R3, R3), |
| 1628 | BPF_ALU64_IMM(BPF_MOV, R0, 10), |
| 1629 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1630 | BPF_JMP_REG(BPF_JEQ, R2, R3, 1), |
| 1631 | BPF_EXIT_INSN(), |
| 1632 | BPF_ALU64_REG(BPF_SUB, R3, R3), |
| 1633 | BPF_ALU64_REG(BPF_XOR, R4, R4), |
| 1634 | BPF_ALU64_IMM(BPF_MOV, R2, 1), |
| 1635 | BPF_ALU64_IMM(BPF_MOV, R5, -1), |
| 1636 | BPF_JMP_REG(BPF_JEQ, R3, R4, 1), |
| 1637 | BPF_EXIT_INSN(), |
| 1638 | BPF_ALU64_REG(BPF_SUB, R4, R4), |
| 1639 | BPF_ALU64_REG(BPF_XOR, R5, R5), |
| 1640 | BPF_ALU64_IMM(BPF_MOV, R3, 1), |
| 1641 | BPF_ALU64_IMM(BPF_MOV, R7, -1), |
| 1642 | BPF_JMP_REG(BPF_JEQ, R5, R4, 1), |
| 1643 | BPF_EXIT_INSN(), |
| 1644 | BPF_ALU64_IMM(BPF_MOV, R5, 1), |
| 1645 | BPF_ALU64_REG(BPF_SUB, R5, R5), |
| 1646 | BPF_ALU64_REG(BPF_XOR, R6, R6), |
| 1647 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1648 | BPF_ALU64_IMM(BPF_MOV, R8, -1), |
| 1649 | BPF_JMP_REG(BPF_JEQ, R5, R6, 1), |
| 1650 | BPF_EXIT_INSN(), |
| 1651 | BPF_ALU64_REG(BPF_SUB, R6, R6), |
| 1652 | BPF_ALU64_REG(BPF_XOR, R7, R7), |
| 1653 | BPF_JMP_REG(BPF_JEQ, R7, R6, 1), |
| 1654 | BPF_EXIT_INSN(), |
| 1655 | BPF_ALU64_REG(BPF_SUB, R7, R7), |
| 1656 | BPF_ALU64_REG(BPF_XOR, R8, R8), |
| 1657 | BPF_JMP_REG(BPF_JEQ, R7, R8, 1), |
| 1658 | BPF_EXIT_INSN(), |
| 1659 | BPF_ALU64_REG(BPF_SUB, R8, R8), |
| 1660 | BPF_ALU64_REG(BPF_XOR, R9, R9), |
| 1661 | BPF_JMP_REG(BPF_JEQ, R9, R8, 1), |
| 1662 | BPF_EXIT_INSN(), |
| 1663 | BPF_ALU64_REG(BPF_SUB, R9, R9), |
| 1664 | BPF_ALU64_REG(BPF_XOR, R0, R0), |
| 1665 | BPF_JMP_REG(BPF_JEQ, R9, R0, 1), |
| 1666 | BPF_EXIT_INSN(), |
| 1667 | BPF_ALU64_REG(BPF_SUB, R1, R1), |
| 1668 | BPF_ALU64_REG(BPF_XOR, R0, R0), |
| 1669 | BPF_JMP_REG(BPF_JEQ, R9, R0, 2), |
| 1670 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1671 | BPF_EXIT_INSN(), |
| 1672 | BPF_ALU64_IMM(BPF_MOV, R0, 1), |
| 1673 | BPF_EXIT_INSN(), |
| 1674 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1675 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1676 | { }, |
| 1677 | { { 0, 1 } } |
| 1678 | }, |
| 1679 | { /* Mainly checking JIT here. */ |
| 1680 | "INT: MUL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1681 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1682 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
| 1683 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1684 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1685 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1686 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1687 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1688 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1689 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1690 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1691 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1692 | BPF_ALU64_REG(BPF_MUL, R0, R0), |
| 1693 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 1694 | BPF_ALU64_REG(BPF_MUL, R0, R2), |
| 1695 | BPF_ALU64_REG(BPF_MUL, R0, R3), |
| 1696 | BPF_ALU64_REG(BPF_MUL, R0, R4), |
| 1697 | BPF_ALU64_REG(BPF_MUL, R0, R5), |
| 1698 | BPF_ALU64_REG(BPF_MUL, R0, R6), |
| 1699 | BPF_ALU64_REG(BPF_MUL, R0, R7), |
| 1700 | BPF_ALU64_REG(BPF_MUL, R0, R8), |
| 1701 | BPF_ALU64_REG(BPF_MUL, R0, R9), |
| 1702 | BPF_ALU64_IMM(BPF_MUL, R0, 10), |
| 1703 | BPF_JMP_IMM(BPF_JEQ, R0, 439084800, 1), |
| 1704 | BPF_EXIT_INSN(), |
| 1705 | BPF_ALU64_REG(BPF_MUL, R1, R0), |
| 1706 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1707 | BPF_ALU64_REG(BPF_MUL, R1, R3), |
| 1708 | BPF_ALU64_REG(BPF_MUL, R1, R4), |
| 1709 | BPF_ALU64_REG(BPF_MUL, R1, R5), |
| 1710 | BPF_ALU64_REG(BPF_MUL, R1, R6), |
| 1711 | BPF_ALU64_REG(BPF_MUL, R1, R7), |
| 1712 | BPF_ALU64_REG(BPF_MUL, R1, R8), |
| 1713 | BPF_ALU64_REG(BPF_MUL, R1, R9), |
| 1714 | BPF_ALU64_IMM(BPF_MUL, R1, 10), |
| 1715 | BPF_ALU64_REG(BPF_MOV, R2, R1), |
| 1716 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 1717 | BPF_JMP_IMM(BPF_JEQ, R2, 0x5a924, 1), |
| 1718 | BPF_EXIT_INSN(), |
| 1719 | BPF_ALU64_IMM(BPF_LSH, R1, 32), |
| 1720 | BPF_ALU64_IMM(BPF_ARSH, R1, 32), |
| 1721 | BPF_JMP_IMM(BPF_JEQ, R1, 0xebb90000, 1), |
| 1722 | BPF_EXIT_INSN(), |
| 1723 | BPF_ALU64_REG(BPF_MUL, R2, R0), |
| 1724 | BPF_ALU64_REG(BPF_MUL, R2, R1), |
| 1725 | BPF_ALU64_REG(BPF_MUL, R2, R3), |
| 1726 | BPF_ALU64_REG(BPF_MUL, R2, R4), |
| 1727 | BPF_ALU64_REG(BPF_MUL, R2, R5), |
| 1728 | BPF_ALU64_REG(BPF_MUL, R2, R6), |
| 1729 | BPF_ALU64_REG(BPF_MUL, R2, R7), |
| 1730 | BPF_ALU64_REG(BPF_MUL, R2, R8), |
| 1731 | BPF_ALU64_REG(BPF_MUL, R2, R9), |
| 1732 | BPF_ALU64_IMM(BPF_MUL, R2, 10), |
| 1733 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 1734 | BPF_ALU64_REG(BPF_MOV, R0, R2), |
| 1735 | BPF_EXIT_INSN(), |
| 1736 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1737 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1738 | { }, |
| 1739 | { { 0, 0x35d97ef2 } } |
| 1740 | }, |
Daniel Borkmann | 9dd2af8 | 2015-12-17 23:51:57 +0100 | [diff] [blame] | 1741 | { /* Mainly checking JIT here. */ |
| 1742 | "MOV REG64", |
| 1743 | .u.insns_int = { |
| 1744 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1745 | BPF_MOV64_REG(R1, R0), |
| 1746 | BPF_MOV64_REG(R2, R1), |
| 1747 | BPF_MOV64_REG(R3, R2), |
| 1748 | BPF_MOV64_REG(R4, R3), |
| 1749 | BPF_MOV64_REG(R5, R4), |
| 1750 | BPF_MOV64_REG(R6, R5), |
| 1751 | BPF_MOV64_REG(R7, R6), |
| 1752 | BPF_MOV64_REG(R8, R7), |
| 1753 | BPF_MOV64_REG(R9, R8), |
| 1754 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1755 | BPF_ALU64_IMM(BPF_MOV, R1, 0), |
| 1756 | BPF_ALU64_IMM(BPF_MOV, R2, 0), |
| 1757 | BPF_ALU64_IMM(BPF_MOV, R3, 0), |
| 1758 | BPF_ALU64_IMM(BPF_MOV, R4, 0), |
| 1759 | BPF_ALU64_IMM(BPF_MOV, R5, 0), |
| 1760 | BPF_ALU64_IMM(BPF_MOV, R6, 0), |
| 1761 | BPF_ALU64_IMM(BPF_MOV, R7, 0), |
| 1762 | BPF_ALU64_IMM(BPF_MOV, R8, 0), |
| 1763 | BPF_ALU64_IMM(BPF_MOV, R9, 0), |
| 1764 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1765 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1766 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1767 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1768 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1769 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1770 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1771 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1772 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1773 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1774 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1775 | BPF_EXIT_INSN(), |
| 1776 | }, |
| 1777 | INTERNAL, |
| 1778 | { }, |
| 1779 | { { 0, 0xfefe } } |
| 1780 | }, |
| 1781 | { /* Mainly checking JIT here. */ |
| 1782 | "MOV REG32", |
| 1783 | .u.insns_int = { |
| 1784 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1785 | BPF_MOV64_REG(R1, R0), |
| 1786 | BPF_MOV64_REG(R2, R1), |
| 1787 | BPF_MOV64_REG(R3, R2), |
| 1788 | BPF_MOV64_REG(R4, R3), |
| 1789 | BPF_MOV64_REG(R5, R4), |
| 1790 | BPF_MOV64_REG(R6, R5), |
| 1791 | BPF_MOV64_REG(R7, R6), |
| 1792 | BPF_MOV64_REG(R8, R7), |
| 1793 | BPF_MOV64_REG(R9, R8), |
| 1794 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 1795 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 1796 | BPF_ALU32_IMM(BPF_MOV, R2, 0), |
| 1797 | BPF_ALU32_IMM(BPF_MOV, R3, 0), |
| 1798 | BPF_ALU32_IMM(BPF_MOV, R4, 0), |
| 1799 | BPF_ALU32_IMM(BPF_MOV, R5, 0), |
| 1800 | BPF_ALU32_IMM(BPF_MOV, R6, 0), |
| 1801 | BPF_ALU32_IMM(BPF_MOV, R7, 0), |
| 1802 | BPF_ALU32_IMM(BPF_MOV, R8, 0), |
| 1803 | BPF_ALU32_IMM(BPF_MOV, R9, 0), |
| 1804 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1805 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1806 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1807 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1808 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1809 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1810 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1811 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1812 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1813 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1814 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1815 | BPF_EXIT_INSN(), |
| 1816 | }, |
| 1817 | INTERNAL, |
| 1818 | { }, |
| 1819 | { { 0, 0xfefe } } |
| 1820 | }, |
| 1821 | { /* Mainly checking JIT here. */ |
| 1822 | "LD IMM64", |
| 1823 | .u.insns_int = { |
| 1824 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1825 | BPF_MOV64_REG(R1, R0), |
| 1826 | BPF_MOV64_REG(R2, R1), |
| 1827 | BPF_MOV64_REG(R3, R2), |
| 1828 | BPF_MOV64_REG(R4, R3), |
| 1829 | BPF_MOV64_REG(R5, R4), |
| 1830 | BPF_MOV64_REG(R6, R5), |
| 1831 | BPF_MOV64_REG(R7, R6), |
| 1832 | BPF_MOV64_REG(R8, R7), |
| 1833 | BPF_MOV64_REG(R9, R8), |
| 1834 | BPF_LD_IMM64(R0, 0x0LL), |
| 1835 | BPF_LD_IMM64(R1, 0x0LL), |
| 1836 | BPF_LD_IMM64(R2, 0x0LL), |
| 1837 | BPF_LD_IMM64(R3, 0x0LL), |
| 1838 | BPF_LD_IMM64(R4, 0x0LL), |
| 1839 | BPF_LD_IMM64(R5, 0x0LL), |
| 1840 | BPF_LD_IMM64(R6, 0x0LL), |
| 1841 | BPF_LD_IMM64(R7, 0x0LL), |
| 1842 | BPF_LD_IMM64(R8, 0x0LL), |
| 1843 | BPF_LD_IMM64(R9, 0x0LL), |
| 1844 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1845 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1846 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1847 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1848 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1849 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1850 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1851 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1852 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1853 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1854 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1855 | BPF_EXIT_INSN(), |
| 1856 | }, |
| 1857 | INTERNAL, |
| 1858 | { }, |
| 1859 | { { 0, 0xfefe } } |
| 1860 | }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1861 | { |
| 1862 | "INT: ALU MIX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1863 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1864 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
| 1865 | BPF_ALU64_IMM(BPF_ADD, R0, -1), |
| 1866 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1867 | BPF_ALU64_IMM(BPF_XOR, R2, 3), |
| 1868 | BPF_ALU64_REG(BPF_DIV, R0, R2), |
| 1869 | BPF_JMP_IMM(BPF_JEQ, R0, 10, 1), |
| 1870 | BPF_EXIT_INSN(), |
| 1871 | BPF_ALU64_IMM(BPF_MOD, R0, 3), |
| 1872 | BPF_JMP_IMM(BPF_JEQ, R0, 1, 1), |
| 1873 | BPF_EXIT_INSN(), |
| 1874 | BPF_ALU64_IMM(BPF_MOV, R0, -1), |
| 1875 | BPF_EXIT_INSN(), |
| 1876 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1877 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1878 | { }, |
| 1879 | { { 0, -1 } } |
| 1880 | }, |
| 1881 | { |
Alexei Starovoitov | 72b603e | 2014-08-25 12:27:02 -0700 | [diff] [blame] | 1882 | "INT: shifts by register", |
| 1883 | .u.insns_int = { |
| 1884 | BPF_MOV64_IMM(R0, -1234), |
| 1885 | BPF_MOV64_IMM(R1, 1), |
| 1886 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 1887 | BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1), |
| 1888 | BPF_EXIT_INSN(), |
| 1889 | BPF_MOV64_IMM(R2, 1), |
| 1890 | BPF_ALU64_REG(BPF_LSH, R0, R2), |
| 1891 | BPF_MOV32_IMM(R4, -1234), |
| 1892 | BPF_JMP_REG(BPF_JEQ, R0, R4, 1), |
| 1893 | BPF_EXIT_INSN(), |
| 1894 | BPF_ALU64_IMM(BPF_AND, R4, 63), |
| 1895 | BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */ |
| 1896 | BPF_MOV64_IMM(R3, 47), |
| 1897 | BPF_ALU64_REG(BPF_ARSH, R0, R3), |
| 1898 | BPF_JMP_IMM(BPF_JEQ, R0, -617, 1), |
| 1899 | BPF_EXIT_INSN(), |
| 1900 | BPF_MOV64_IMM(R2, 1), |
| 1901 | BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */ |
| 1902 | BPF_JMP_IMM(BPF_JEQ, R4, 92, 1), |
| 1903 | BPF_EXIT_INSN(), |
| 1904 | BPF_MOV64_IMM(R4, 4), |
| 1905 | BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */ |
| 1906 | BPF_JMP_IMM(BPF_JEQ, R4, 64, 1), |
| 1907 | BPF_EXIT_INSN(), |
| 1908 | BPF_MOV64_IMM(R4, 5), |
| 1909 | BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */ |
| 1910 | BPF_JMP_IMM(BPF_JEQ, R4, 160, 1), |
| 1911 | BPF_EXIT_INSN(), |
| 1912 | BPF_MOV64_IMM(R0, -1), |
| 1913 | BPF_EXIT_INSN(), |
| 1914 | }, |
| 1915 | INTERNAL, |
| 1916 | { }, |
| 1917 | { { 0, -1 } } |
| 1918 | }, |
| 1919 | { |
Johan Almbladh | 84024a4 | 2021-08-09 11:18:23 +0200 | [diff] [blame^] | 1920 | /* |
| 1921 | * Register (non-)clobbering test, in the case where a 32-bit |
| 1922 | * JIT implements complex ALU64 operations via function calls. |
| 1923 | * If so, the function call must be invisible in the eBPF |
| 1924 | * registers. The JIT must then save and restore relevant |
| 1925 | * registers during the call. The following tests check that |
| 1926 | * the eBPF registers retain their values after such a call. |
| 1927 | */ |
| 1928 | "INT: Register clobbering, R1 updated", |
| 1929 | .u.insns_int = { |
| 1930 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 1931 | BPF_ALU32_IMM(BPF_MOV, R1, 123456789), |
| 1932 | BPF_ALU32_IMM(BPF_MOV, R2, 2), |
| 1933 | BPF_ALU32_IMM(BPF_MOV, R3, 3), |
| 1934 | BPF_ALU32_IMM(BPF_MOV, R4, 4), |
| 1935 | BPF_ALU32_IMM(BPF_MOV, R5, 5), |
| 1936 | BPF_ALU32_IMM(BPF_MOV, R6, 6), |
| 1937 | BPF_ALU32_IMM(BPF_MOV, R7, 7), |
| 1938 | BPF_ALU32_IMM(BPF_MOV, R8, 8), |
| 1939 | BPF_ALU32_IMM(BPF_MOV, R9, 9), |
| 1940 | BPF_ALU64_IMM(BPF_DIV, R1, 123456789), |
| 1941 | BPF_JMP_IMM(BPF_JNE, R0, 0, 10), |
| 1942 | BPF_JMP_IMM(BPF_JNE, R1, 1, 9), |
| 1943 | BPF_JMP_IMM(BPF_JNE, R2, 2, 8), |
| 1944 | BPF_JMP_IMM(BPF_JNE, R3, 3, 7), |
| 1945 | BPF_JMP_IMM(BPF_JNE, R4, 4, 6), |
| 1946 | BPF_JMP_IMM(BPF_JNE, R5, 5, 5), |
| 1947 | BPF_JMP_IMM(BPF_JNE, R6, 6, 4), |
| 1948 | BPF_JMP_IMM(BPF_JNE, R7, 7, 3), |
| 1949 | BPF_JMP_IMM(BPF_JNE, R8, 8, 2), |
| 1950 | BPF_JMP_IMM(BPF_JNE, R9, 9, 1), |
| 1951 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1952 | BPF_EXIT_INSN(), |
| 1953 | }, |
| 1954 | INTERNAL, |
| 1955 | { }, |
| 1956 | { { 0, 1 } } |
| 1957 | }, |
| 1958 | { |
| 1959 | "INT: Register clobbering, R2 updated", |
| 1960 | .u.insns_int = { |
| 1961 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 1962 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 1963 | BPF_ALU32_IMM(BPF_MOV, R2, 2 * 123456789), |
| 1964 | BPF_ALU32_IMM(BPF_MOV, R3, 3), |
| 1965 | BPF_ALU32_IMM(BPF_MOV, R4, 4), |
| 1966 | BPF_ALU32_IMM(BPF_MOV, R5, 5), |
| 1967 | BPF_ALU32_IMM(BPF_MOV, R6, 6), |
| 1968 | BPF_ALU32_IMM(BPF_MOV, R7, 7), |
| 1969 | BPF_ALU32_IMM(BPF_MOV, R8, 8), |
| 1970 | BPF_ALU32_IMM(BPF_MOV, R9, 9), |
| 1971 | BPF_ALU64_IMM(BPF_DIV, R2, 123456789), |
| 1972 | BPF_JMP_IMM(BPF_JNE, R0, 0, 10), |
| 1973 | BPF_JMP_IMM(BPF_JNE, R1, 1, 9), |
| 1974 | BPF_JMP_IMM(BPF_JNE, R2, 2, 8), |
| 1975 | BPF_JMP_IMM(BPF_JNE, R3, 3, 7), |
| 1976 | BPF_JMP_IMM(BPF_JNE, R4, 4, 6), |
| 1977 | BPF_JMP_IMM(BPF_JNE, R5, 5, 5), |
| 1978 | BPF_JMP_IMM(BPF_JNE, R6, 6, 4), |
| 1979 | BPF_JMP_IMM(BPF_JNE, R7, 7, 3), |
| 1980 | BPF_JMP_IMM(BPF_JNE, R8, 8, 2), |
| 1981 | BPF_JMP_IMM(BPF_JNE, R9, 9, 1), |
| 1982 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1983 | BPF_EXIT_INSN(), |
| 1984 | }, |
| 1985 | INTERNAL, |
| 1986 | { }, |
| 1987 | { { 0, 1 } } |
| 1988 | }, |
| 1989 | { |
| 1990 | /* |
| 1991 | * Test 32-bit JITs that implement complex ALU64 operations as |
| 1992 | * function calls R0 = f(R1, R2), and must re-arrange operands. |
| 1993 | */ |
| 1994 | #define NUMER 0xfedcba9876543210ULL |
| 1995 | #define DENOM 0x0123456789abcdefULL |
| 1996 | "ALU64_DIV X: Operand register permutations", |
| 1997 | .u.insns_int = { |
| 1998 | /* R0 / R2 */ |
| 1999 | BPF_LD_IMM64(R0, NUMER), |
| 2000 | BPF_LD_IMM64(R2, DENOM), |
| 2001 | BPF_ALU64_REG(BPF_DIV, R0, R2), |
| 2002 | BPF_JMP_IMM(BPF_JEQ, R0, NUMER / DENOM, 1), |
| 2003 | BPF_EXIT_INSN(), |
| 2004 | /* R1 / R0 */ |
| 2005 | BPF_LD_IMM64(R1, NUMER), |
| 2006 | BPF_LD_IMM64(R0, DENOM), |
| 2007 | BPF_ALU64_REG(BPF_DIV, R1, R0), |
| 2008 | BPF_JMP_IMM(BPF_JEQ, R1, NUMER / DENOM, 1), |
| 2009 | BPF_EXIT_INSN(), |
| 2010 | /* R0 / R1 */ |
| 2011 | BPF_LD_IMM64(R0, NUMER), |
| 2012 | BPF_LD_IMM64(R1, DENOM), |
| 2013 | BPF_ALU64_REG(BPF_DIV, R0, R1), |
| 2014 | BPF_JMP_IMM(BPF_JEQ, R0, NUMER / DENOM, 1), |
| 2015 | BPF_EXIT_INSN(), |
| 2016 | /* R2 / R0 */ |
| 2017 | BPF_LD_IMM64(R2, NUMER), |
| 2018 | BPF_LD_IMM64(R0, DENOM), |
| 2019 | BPF_ALU64_REG(BPF_DIV, R2, R0), |
| 2020 | BPF_JMP_IMM(BPF_JEQ, R2, NUMER / DENOM, 1), |
| 2021 | BPF_EXIT_INSN(), |
| 2022 | /* R2 / R1 */ |
| 2023 | BPF_LD_IMM64(R2, NUMER), |
| 2024 | BPF_LD_IMM64(R1, DENOM), |
| 2025 | BPF_ALU64_REG(BPF_DIV, R2, R1), |
| 2026 | BPF_JMP_IMM(BPF_JEQ, R2, NUMER / DENOM, 1), |
| 2027 | BPF_EXIT_INSN(), |
| 2028 | /* R1 / R2 */ |
| 2029 | BPF_LD_IMM64(R1, NUMER), |
| 2030 | BPF_LD_IMM64(R2, DENOM), |
| 2031 | BPF_ALU64_REG(BPF_DIV, R1, R2), |
| 2032 | BPF_JMP_IMM(BPF_JEQ, R1, NUMER / DENOM, 1), |
| 2033 | BPF_EXIT_INSN(), |
| 2034 | /* R1 / R1 */ |
| 2035 | BPF_LD_IMM64(R1, NUMER), |
| 2036 | BPF_ALU64_REG(BPF_DIV, R1, R1), |
| 2037 | BPF_JMP_IMM(BPF_JEQ, R1, 1, 1), |
| 2038 | BPF_EXIT_INSN(), |
| 2039 | /* R2 / R2 */ |
| 2040 | BPF_LD_IMM64(R2, DENOM), |
| 2041 | BPF_ALU64_REG(BPF_DIV, R2, R2), |
| 2042 | BPF_JMP_IMM(BPF_JEQ, R2, 1, 1), |
| 2043 | BPF_EXIT_INSN(), |
| 2044 | /* R3 / R4 */ |
| 2045 | BPF_LD_IMM64(R3, NUMER), |
| 2046 | BPF_LD_IMM64(R4, DENOM), |
| 2047 | BPF_ALU64_REG(BPF_DIV, R3, R4), |
| 2048 | BPF_JMP_IMM(BPF_JEQ, R3, NUMER / DENOM, 1), |
| 2049 | BPF_EXIT_INSN(), |
| 2050 | /* Successful return */ |
| 2051 | BPF_LD_IMM64(R0, 1), |
| 2052 | BPF_EXIT_INSN(), |
| 2053 | }, |
| 2054 | INTERNAL, |
| 2055 | { }, |
| 2056 | { { 0, 1 } }, |
| 2057 | #undef NUMER |
| 2058 | #undef DENOM |
| 2059 | }, |
| 2060 | { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 2061 | "check: missing ret", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 2062 | .u.insns = { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 2063 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 2064 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 2065 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 2066 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2067 | { }, |
| 2068 | .fill_helper = NULL, |
| 2069 | .expected_errcode = -EINVAL, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 2070 | }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2071 | { |
| 2072 | "check: div_k_0", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 2073 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2074 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0), |
| 2075 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 2076 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 2077 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2078 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2079 | { }, |
| 2080 | .fill_helper = NULL, |
| 2081 | .expected_errcode = -EINVAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2082 | }, |
| 2083 | { |
| 2084 | "check: unknown insn", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 2085 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2086 | /* seccomp insn, rejected in socket filter */ |
| 2087 | BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0), |
| 2088 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 2089 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 2090 | CLASSIC | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2091 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2092 | { }, |
| 2093 | .fill_helper = NULL, |
| 2094 | .expected_errcode = -EINVAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2095 | }, |
| 2096 | { |
| 2097 | "check: out of range spill/fill", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 2098 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2099 | BPF_STMT(BPF_STX, 16), |
| 2100 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 2101 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 2102 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2103 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2104 | { }, |
| 2105 | .fill_helper = NULL, |
| 2106 | .expected_errcode = -EINVAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 2107 | }, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 2108 | { |
| 2109 | "JUMPS + HOLES", |
| 2110 | .u.insns = { |
| 2111 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2112 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 15), |
| 2113 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2114 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2115 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2116 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2117 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2118 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2119 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2120 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2121 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2122 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2123 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2124 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2125 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2126 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 3, 4), |
| 2127 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2128 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 1, 2), |
| 2129 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2130 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), |
| 2131 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), |
| 2132 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2133 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2134 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2135 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2136 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2137 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2138 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2139 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2140 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2141 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2142 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2143 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2144 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2145 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 2, 3), |
| 2146 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 1, 2), |
| 2147 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2148 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), |
| 2149 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), |
| 2150 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2151 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2152 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2153 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2154 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2155 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2156 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2157 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2158 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2159 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2160 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2161 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2162 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2163 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 2, 3), |
| 2164 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 1, 2), |
| 2165 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2166 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2167 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2168 | }, |
| 2169 | CLASSIC, |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 2170 | { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8, |
| 2171 | 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4, |
| 2172 | 0x08, 0x00, |
| 2173 | 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, |
| 2174 | 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */ |
| 2175 | 0xc0, 0xa8, 0x33, 0x01, |
| 2176 | 0xc0, 0xa8, 0x33, 0x02, |
| 2177 | 0xbb, 0xb6, |
| 2178 | 0xa9, 0xfa, |
| 2179 | 0x00, 0x14, 0x00, 0x00, |
| 2180 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2181 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2182 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2183 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2184 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2185 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2186 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2187 | 0xcc, 0xcc, 0xcc, 0xcc }, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 2188 | { { 88, 0x001b } } |
| 2189 | }, |
| 2190 | { |
| 2191 | "check: RET X", |
| 2192 | .u.insns = { |
| 2193 | BPF_STMT(BPF_RET | BPF_X, 0), |
| 2194 | }, |
| 2195 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2196 | { }, |
| 2197 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2198 | .fill_helper = NULL, |
| 2199 | .expected_errcode = -EINVAL, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 2200 | }, |
| 2201 | { |
| 2202 | "check: LDX + RET X", |
| 2203 | .u.insns = { |
| 2204 | BPF_STMT(BPF_LDX | BPF_IMM, 42), |
| 2205 | BPF_STMT(BPF_RET | BPF_X, 0), |
| 2206 | }, |
| 2207 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2208 | { }, |
| 2209 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2210 | .fill_helper = NULL, |
| 2211 | .expected_errcode = -EINVAL, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 2212 | }, |
Daniel Borkmann | 108cc22 | 2014-05-26 20:17:34 +0200 | [diff] [blame] | 2213 | { /* Mainly checking JIT here. */ |
Daniel Borkmann | 9fe13ba | 2014-05-29 10:22:48 +0200 | [diff] [blame] | 2214 | "M[]: alt STX + LDX", |
Daniel Borkmann | 108cc22 | 2014-05-26 20:17:34 +0200 | [diff] [blame] | 2215 | .u.insns = { |
| 2216 | BPF_STMT(BPF_LDX | BPF_IMM, 100), |
| 2217 | BPF_STMT(BPF_STX, 0), |
| 2218 | BPF_STMT(BPF_LDX | BPF_MEM, 0), |
| 2219 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2220 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2221 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2222 | BPF_STMT(BPF_STX, 1), |
| 2223 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 2224 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2225 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2226 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2227 | BPF_STMT(BPF_STX, 2), |
| 2228 | BPF_STMT(BPF_LDX | BPF_MEM, 2), |
| 2229 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2230 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2231 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2232 | BPF_STMT(BPF_STX, 3), |
| 2233 | BPF_STMT(BPF_LDX | BPF_MEM, 3), |
| 2234 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2235 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2236 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2237 | BPF_STMT(BPF_STX, 4), |
| 2238 | BPF_STMT(BPF_LDX | BPF_MEM, 4), |
| 2239 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2240 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2241 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2242 | BPF_STMT(BPF_STX, 5), |
| 2243 | BPF_STMT(BPF_LDX | BPF_MEM, 5), |
| 2244 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2245 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2246 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2247 | BPF_STMT(BPF_STX, 6), |
| 2248 | BPF_STMT(BPF_LDX | BPF_MEM, 6), |
| 2249 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2250 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2251 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2252 | BPF_STMT(BPF_STX, 7), |
| 2253 | BPF_STMT(BPF_LDX | BPF_MEM, 7), |
| 2254 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2255 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2256 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2257 | BPF_STMT(BPF_STX, 8), |
| 2258 | BPF_STMT(BPF_LDX | BPF_MEM, 8), |
| 2259 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2260 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2261 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2262 | BPF_STMT(BPF_STX, 9), |
| 2263 | BPF_STMT(BPF_LDX | BPF_MEM, 9), |
| 2264 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2265 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2266 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2267 | BPF_STMT(BPF_STX, 10), |
| 2268 | BPF_STMT(BPF_LDX | BPF_MEM, 10), |
| 2269 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2270 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2271 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2272 | BPF_STMT(BPF_STX, 11), |
| 2273 | BPF_STMT(BPF_LDX | BPF_MEM, 11), |
| 2274 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2275 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2276 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2277 | BPF_STMT(BPF_STX, 12), |
| 2278 | BPF_STMT(BPF_LDX | BPF_MEM, 12), |
| 2279 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2280 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2281 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2282 | BPF_STMT(BPF_STX, 13), |
| 2283 | BPF_STMT(BPF_LDX | BPF_MEM, 13), |
| 2284 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2285 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2286 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2287 | BPF_STMT(BPF_STX, 14), |
| 2288 | BPF_STMT(BPF_LDX | BPF_MEM, 14), |
| 2289 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2290 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2291 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2292 | BPF_STMT(BPF_STX, 15), |
| 2293 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 2294 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2295 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2296 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2297 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2298 | }, |
| 2299 | CLASSIC | FLAG_NO_DATA, |
| 2300 | { }, |
| 2301 | { { 0, 116 } }, |
| 2302 | }, |
Daniel Borkmann | 9fe13ba | 2014-05-29 10:22:48 +0200 | [diff] [blame] | 2303 | { /* Mainly checking JIT here. */ |
| 2304 | "M[]: full STX + full LDX", |
| 2305 | .u.insns = { |
| 2306 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb), |
| 2307 | BPF_STMT(BPF_STX, 0), |
| 2308 | BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae), |
| 2309 | BPF_STMT(BPF_STX, 1), |
| 2310 | BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf), |
| 2311 | BPF_STMT(BPF_STX, 2), |
| 2312 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc), |
| 2313 | BPF_STMT(BPF_STX, 3), |
| 2314 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb), |
| 2315 | BPF_STMT(BPF_STX, 4), |
| 2316 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda), |
| 2317 | BPF_STMT(BPF_STX, 5), |
| 2318 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb), |
| 2319 | BPF_STMT(BPF_STX, 6), |
| 2320 | BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade), |
| 2321 | BPF_STMT(BPF_STX, 7), |
| 2322 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec), |
| 2323 | BPF_STMT(BPF_STX, 8), |
| 2324 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc), |
| 2325 | BPF_STMT(BPF_STX, 9), |
| 2326 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac), |
| 2327 | BPF_STMT(BPF_STX, 10), |
| 2328 | BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea), |
| 2329 | BPF_STMT(BPF_STX, 11), |
| 2330 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb), |
| 2331 | BPF_STMT(BPF_STX, 12), |
| 2332 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf), |
| 2333 | BPF_STMT(BPF_STX, 13), |
| 2334 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde), |
| 2335 | BPF_STMT(BPF_STX, 14), |
| 2336 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad), |
| 2337 | BPF_STMT(BPF_STX, 15), |
| 2338 | BPF_STMT(BPF_LDX | BPF_MEM, 0), |
| 2339 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2340 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 2341 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2342 | BPF_STMT(BPF_LDX | BPF_MEM, 2), |
| 2343 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2344 | BPF_STMT(BPF_LDX | BPF_MEM, 3), |
| 2345 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2346 | BPF_STMT(BPF_LDX | BPF_MEM, 4), |
| 2347 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2348 | BPF_STMT(BPF_LDX | BPF_MEM, 5), |
| 2349 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2350 | BPF_STMT(BPF_LDX | BPF_MEM, 6), |
| 2351 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2352 | BPF_STMT(BPF_LDX | BPF_MEM, 7), |
| 2353 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2354 | BPF_STMT(BPF_LDX | BPF_MEM, 8), |
| 2355 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2356 | BPF_STMT(BPF_LDX | BPF_MEM, 9), |
| 2357 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2358 | BPF_STMT(BPF_LDX | BPF_MEM, 10), |
| 2359 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2360 | BPF_STMT(BPF_LDX | BPF_MEM, 11), |
| 2361 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2362 | BPF_STMT(BPF_LDX | BPF_MEM, 12), |
| 2363 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2364 | BPF_STMT(BPF_LDX | BPF_MEM, 13), |
| 2365 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2366 | BPF_STMT(BPF_LDX | BPF_MEM, 14), |
| 2367 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2368 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 2369 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2370 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2371 | }, |
| 2372 | CLASSIC | FLAG_NO_DATA, |
| 2373 | { }, |
| 2374 | { { 0, 0x2a5a5e5 } }, |
| 2375 | }, |
Daniel Borkmann | d50bc15 | 2014-05-29 10:22:49 +0200 | [diff] [blame] | 2376 | { |
| 2377 | "check: SKF_AD_MAX", |
| 2378 | .u.insns = { |
| 2379 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 2380 | SKF_AD_OFF + SKF_AD_MAX), |
| 2381 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2382 | }, |
| 2383 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2384 | { }, |
| 2385 | { }, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 2386 | .fill_helper = NULL, |
| 2387 | .expected_errcode = -EINVAL, |
Daniel Borkmann | d50bc15 | 2014-05-29 10:22:49 +0200 | [diff] [blame] | 2388 | }, |
| 2389 | { /* Passes checker but fails during runtime. */ |
| 2390 | "LD [SKF_AD_OFF-1]", |
| 2391 | .u.insns = { |
| 2392 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 2393 | SKF_AD_OFF - 1), |
| 2394 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 2395 | }, |
| 2396 | CLASSIC, |
| 2397 | { }, |
| 2398 | { { 1, 0 } }, |
| 2399 | }, |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2400 | { |
| 2401 | "load 64-bit immediate", |
| 2402 | .u.insns_int = { |
Alexei Starovoitov | 25ee732 | 2014-09-19 13:53:51 -0700 | [diff] [blame] | 2403 | BPF_LD_IMM64(R1, 0x567800001234LL), |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2404 | BPF_MOV64_REG(R2, R1), |
| 2405 | BPF_MOV64_REG(R3, R2), |
| 2406 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 2407 | BPF_ALU64_IMM(BPF_LSH, R3, 32), |
| 2408 | BPF_ALU64_IMM(BPF_RSH, R3, 32), |
| 2409 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 2410 | BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1), |
| 2411 | BPF_EXIT_INSN(), |
| 2412 | BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1), |
| 2413 | BPF_EXIT_INSN(), |
Xi Wang | 986ccfd | 2015-05-09 04:14:30 -0400 | [diff] [blame] | 2414 | BPF_LD_IMM64(R0, 0x1ffffffffLL), |
| 2415 | BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */ |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2416 | BPF_EXIT_INSN(), |
| 2417 | }, |
| 2418 | INTERNAL, |
| 2419 | { }, |
| 2420 | { { 0, 1 } } |
| 2421 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2422 | /* BPF_ALU | BPF_MOV | BPF_X */ |
| 2423 | { |
| 2424 | "ALU_MOV_X: dst = 2", |
| 2425 | .u.insns_int = { |
| 2426 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2427 | BPF_ALU32_REG(BPF_MOV, R0, R1), |
| 2428 | BPF_EXIT_INSN(), |
| 2429 | }, |
| 2430 | INTERNAL, |
| 2431 | { }, |
| 2432 | { { 0, 2 } }, |
| 2433 | }, |
| 2434 | { |
| 2435 | "ALU_MOV_X: dst = 4294967295", |
| 2436 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2437 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2438 | BPF_ALU32_REG(BPF_MOV, R0, R1), |
| 2439 | BPF_EXIT_INSN(), |
| 2440 | }, |
| 2441 | INTERNAL, |
| 2442 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2443 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2444 | }, |
| 2445 | { |
| 2446 | "ALU64_MOV_X: dst = 2", |
| 2447 | .u.insns_int = { |
| 2448 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2449 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 2450 | BPF_EXIT_INSN(), |
| 2451 | }, |
| 2452 | INTERNAL, |
| 2453 | { }, |
| 2454 | { { 0, 2 } }, |
| 2455 | }, |
| 2456 | { |
| 2457 | "ALU64_MOV_X: dst = 4294967295", |
| 2458 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2459 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2460 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 2461 | BPF_EXIT_INSN(), |
| 2462 | }, |
| 2463 | INTERNAL, |
| 2464 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2465 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2466 | }, |
| 2467 | /* BPF_ALU | BPF_MOV | BPF_K */ |
| 2468 | { |
| 2469 | "ALU_MOV_K: dst = 2", |
| 2470 | .u.insns_int = { |
| 2471 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 2472 | BPF_EXIT_INSN(), |
| 2473 | }, |
| 2474 | INTERNAL, |
| 2475 | { }, |
| 2476 | { { 0, 2 } }, |
| 2477 | }, |
| 2478 | { |
| 2479 | "ALU_MOV_K: dst = 4294967295", |
| 2480 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2481 | BPF_ALU32_IMM(BPF_MOV, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2482 | BPF_EXIT_INSN(), |
| 2483 | }, |
| 2484 | INTERNAL, |
| 2485 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2486 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2487 | }, |
| 2488 | { |
| 2489 | "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff", |
| 2490 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2491 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 2492 | BPF_LD_IMM64(R3, 0x00000000ffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2493 | BPF_ALU32_IMM(BPF_MOV, R2, 0xffffffff), |
| 2494 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2495 | BPF_MOV32_IMM(R0, 2), |
| 2496 | BPF_EXIT_INSN(), |
| 2497 | BPF_MOV32_IMM(R0, 1), |
| 2498 | BPF_EXIT_INSN(), |
| 2499 | }, |
| 2500 | INTERNAL, |
| 2501 | { }, |
| 2502 | { { 0, 0x1 } }, |
| 2503 | }, |
| 2504 | { |
Johan Almbladh | 565731a | 2021-08-09 11:18:17 +0200 | [diff] [blame] | 2505 | "ALU_MOV_K: small negative", |
| 2506 | .u.insns_int = { |
| 2507 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 2508 | BPF_EXIT_INSN(), |
| 2509 | }, |
| 2510 | INTERNAL, |
| 2511 | { }, |
| 2512 | { { 0, -123 } } |
| 2513 | }, |
| 2514 | { |
| 2515 | "ALU_MOV_K: small negative zero extension", |
| 2516 | .u.insns_int = { |
| 2517 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 2518 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 2519 | BPF_EXIT_INSN(), |
| 2520 | }, |
| 2521 | INTERNAL, |
| 2522 | { }, |
| 2523 | { { 0, 0 } } |
| 2524 | }, |
| 2525 | { |
| 2526 | "ALU_MOV_K: large negative", |
| 2527 | .u.insns_int = { |
| 2528 | BPF_ALU32_IMM(BPF_MOV, R0, -123456789), |
| 2529 | BPF_EXIT_INSN(), |
| 2530 | }, |
| 2531 | INTERNAL, |
| 2532 | { }, |
| 2533 | { { 0, -123456789 } } |
| 2534 | }, |
| 2535 | { |
| 2536 | "ALU_MOV_K: large negative zero extension", |
| 2537 | .u.insns_int = { |
| 2538 | BPF_ALU32_IMM(BPF_MOV, R0, -123456789), |
| 2539 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 2540 | BPF_EXIT_INSN(), |
| 2541 | }, |
| 2542 | INTERNAL, |
| 2543 | { }, |
| 2544 | { { 0, 0 } } |
| 2545 | }, |
| 2546 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2547 | "ALU64_MOV_K: dst = 2", |
| 2548 | .u.insns_int = { |
| 2549 | BPF_ALU64_IMM(BPF_MOV, R0, 2), |
| 2550 | BPF_EXIT_INSN(), |
| 2551 | }, |
| 2552 | INTERNAL, |
| 2553 | { }, |
| 2554 | { { 0, 2 } }, |
| 2555 | }, |
| 2556 | { |
| 2557 | "ALU64_MOV_K: dst = 2147483647", |
| 2558 | .u.insns_int = { |
| 2559 | BPF_ALU64_IMM(BPF_MOV, R0, 2147483647), |
| 2560 | BPF_EXIT_INSN(), |
| 2561 | }, |
| 2562 | INTERNAL, |
| 2563 | { }, |
| 2564 | { { 0, 2147483647 } }, |
| 2565 | }, |
| 2566 | { |
| 2567 | "ALU64_OR_K: dst = 0x0", |
| 2568 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2569 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2570 | BPF_LD_IMM64(R3, 0x0), |
| 2571 | BPF_ALU64_IMM(BPF_MOV, R2, 0x0), |
| 2572 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2573 | BPF_MOV32_IMM(R0, 2), |
| 2574 | BPF_EXIT_INSN(), |
| 2575 | BPF_MOV32_IMM(R0, 1), |
| 2576 | BPF_EXIT_INSN(), |
| 2577 | }, |
| 2578 | INTERNAL, |
| 2579 | { }, |
| 2580 | { { 0, 0x1 } }, |
| 2581 | }, |
| 2582 | { |
| 2583 | "ALU64_MOV_K: dst = -1", |
| 2584 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2585 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 2586 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2587 | BPF_ALU64_IMM(BPF_MOV, R2, 0xffffffff), |
| 2588 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2589 | BPF_MOV32_IMM(R0, 2), |
| 2590 | BPF_EXIT_INSN(), |
| 2591 | BPF_MOV32_IMM(R0, 1), |
| 2592 | BPF_EXIT_INSN(), |
| 2593 | }, |
| 2594 | INTERNAL, |
| 2595 | { }, |
| 2596 | { { 0, 0x1 } }, |
| 2597 | }, |
Johan Almbladh | 565731a | 2021-08-09 11:18:17 +0200 | [diff] [blame] | 2598 | { |
| 2599 | "ALU64_MOV_K: small negative", |
| 2600 | .u.insns_int = { |
| 2601 | BPF_ALU64_IMM(BPF_MOV, R0, -123), |
| 2602 | BPF_EXIT_INSN(), |
| 2603 | }, |
| 2604 | INTERNAL, |
| 2605 | { }, |
| 2606 | { { 0, -123 } } |
| 2607 | }, |
| 2608 | { |
| 2609 | "ALU64_MOV_K: small negative sign extension", |
| 2610 | .u.insns_int = { |
| 2611 | BPF_ALU64_IMM(BPF_MOV, R0, -123), |
| 2612 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 2613 | BPF_EXIT_INSN(), |
| 2614 | }, |
| 2615 | INTERNAL, |
| 2616 | { }, |
| 2617 | { { 0, 0xffffffff } } |
| 2618 | }, |
| 2619 | { |
| 2620 | "ALU64_MOV_K: large negative", |
| 2621 | .u.insns_int = { |
| 2622 | BPF_ALU64_IMM(BPF_MOV, R0, -123456789), |
| 2623 | BPF_EXIT_INSN(), |
| 2624 | }, |
| 2625 | INTERNAL, |
| 2626 | { }, |
| 2627 | { { 0, -123456789 } } |
| 2628 | }, |
| 2629 | { |
| 2630 | "ALU64_MOV_K: large negative sign extension", |
| 2631 | .u.insns_int = { |
| 2632 | BPF_ALU64_IMM(BPF_MOV, R0, -123456789), |
| 2633 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 2634 | BPF_EXIT_INSN(), |
| 2635 | }, |
| 2636 | INTERNAL, |
| 2637 | { }, |
| 2638 | { { 0, 0xffffffff } } |
| 2639 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2640 | /* BPF_ALU | BPF_ADD | BPF_X */ |
| 2641 | { |
| 2642 | "ALU_ADD_X: 1 + 2 = 3", |
| 2643 | .u.insns_int = { |
| 2644 | BPF_LD_IMM64(R0, 1), |
| 2645 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2646 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2647 | BPF_EXIT_INSN(), |
| 2648 | }, |
| 2649 | INTERNAL, |
| 2650 | { }, |
| 2651 | { { 0, 3 } }, |
| 2652 | }, |
| 2653 | { |
| 2654 | "ALU_ADD_X: 1 + 4294967294 = 4294967295", |
| 2655 | .u.insns_int = { |
| 2656 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2657 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2658 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2659 | BPF_EXIT_INSN(), |
| 2660 | }, |
| 2661 | INTERNAL, |
| 2662 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2663 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2664 | }, |
| 2665 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2666 | "ALU_ADD_X: 2 + 4294967294 = 0", |
| 2667 | .u.insns_int = { |
| 2668 | BPF_LD_IMM64(R0, 2), |
| 2669 | BPF_LD_IMM64(R1, 4294967294U), |
| 2670 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2671 | BPF_JMP_IMM(BPF_JEQ, R0, 0, 2), |
| 2672 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2673 | BPF_EXIT_INSN(), |
| 2674 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2675 | BPF_EXIT_INSN(), |
| 2676 | }, |
| 2677 | INTERNAL, |
| 2678 | { }, |
| 2679 | { { 0, 1 } }, |
| 2680 | }, |
| 2681 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2682 | "ALU64_ADD_X: 1 + 2 = 3", |
| 2683 | .u.insns_int = { |
| 2684 | BPF_LD_IMM64(R0, 1), |
| 2685 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2686 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2687 | BPF_EXIT_INSN(), |
| 2688 | }, |
| 2689 | INTERNAL, |
| 2690 | { }, |
| 2691 | { { 0, 3 } }, |
| 2692 | }, |
| 2693 | { |
| 2694 | "ALU64_ADD_X: 1 + 4294967294 = 4294967295", |
| 2695 | .u.insns_int = { |
| 2696 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2697 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2698 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2699 | BPF_EXIT_INSN(), |
| 2700 | }, |
| 2701 | INTERNAL, |
| 2702 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2703 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2704 | }, |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2705 | { |
| 2706 | "ALU64_ADD_X: 2 + 4294967294 = 4294967296", |
| 2707 | .u.insns_int = { |
| 2708 | BPF_LD_IMM64(R0, 2), |
| 2709 | BPF_LD_IMM64(R1, 4294967294U), |
| 2710 | BPF_LD_IMM64(R2, 4294967296ULL), |
| 2711 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2712 | BPF_JMP_REG(BPF_JEQ, R0, R2, 2), |
| 2713 | BPF_MOV32_IMM(R0, 0), |
| 2714 | BPF_EXIT_INSN(), |
| 2715 | BPF_MOV32_IMM(R0, 1), |
| 2716 | BPF_EXIT_INSN(), |
| 2717 | }, |
| 2718 | INTERNAL, |
| 2719 | { }, |
| 2720 | { { 0, 1 } }, |
| 2721 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2722 | /* BPF_ALU | BPF_ADD | BPF_K */ |
| 2723 | { |
| 2724 | "ALU_ADD_K: 1 + 2 = 3", |
| 2725 | .u.insns_int = { |
| 2726 | BPF_LD_IMM64(R0, 1), |
| 2727 | BPF_ALU32_IMM(BPF_ADD, R0, 2), |
| 2728 | BPF_EXIT_INSN(), |
| 2729 | }, |
| 2730 | INTERNAL, |
| 2731 | { }, |
| 2732 | { { 0, 3 } }, |
| 2733 | }, |
| 2734 | { |
| 2735 | "ALU_ADD_K: 3 + 0 = 3", |
| 2736 | .u.insns_int = { |
| 2737 | BPF_LD_IMM64(R0, 3), |
| 2738 | BPF_ALU32_IMM(BPF_ADD, R0, 0), |
| 2739 | BPF_EXIT_INSN(), |
| 2740 | }, |
| 2741 | INTERNAL, |
| 2742 | { }, |
| 2743 | { { 0, 3 } }, |
| 2744 | }, |
| 2745 | { |
| 2746 | "ALU_ADD_K: 1 + 4294967294 = 4294967295", |
| 2747 | .u.insns_int = { |
| 2748 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2749 | BPF_ALU32_IMM(BPF_ADD, R0, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2750 | BPF_EXIT_INSN(), |
| 2751 | }, |
| 2752 | INTERNAL, |
| 2753 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2754 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2755 | }, |
| 2756 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2757 | "ALU_ADD_K: 4294967294 + 2 = 0", |
| 2758 | .u.insns_int = { |
| 2759 | BPF_LD_IMM64(R0, 4294967294U), |
| 2760 | BPF_ALU32_IMM(BPF_ADD, R0, 2), |
| 2761 | BPF_JMP_IMM(BPF_JEQ, R0, 0, 2), |
| 2762 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2763 | BPF_EXIT_INSN(), |
| 2764 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2765 | BPF_EXIT_INSN(), |
| 2766 | }, |
| 2767 | INTERNAL, |
| 2768 | { }, |
| 2769 | { { 0, 1 } }, |
| 2770 | }, |
| 2771 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2772 | "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff", |
| 2773 | .u.insns_int = { |
| 2774 | BPF_LD_IMM64(R2, 0x0), |
| 2775 | BPF_LD_IMM64(R3, 0x00000000ffffffff), |
| 2776 | BPF_ALU32_IMM(BPF_ADD, R2, 0xffffffff), |
| 2777 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2778 | BPF_MOV32_IMM(R0, 2), |
| 2779 | BPF_EXIT_INSN(), |
| 2780 | BPF_MOV32_IMM(R0, 1), |
| 2781 | BPF_EXIT_INSN(), |
| 2782 | }, |
| 2783 | INTERNAL, |
| 2784 | { }, |
| 2785 | { { 0, 0x1 } }, |
| 2786 | }, |
| 2787 | { |
Naveen N. Rao | 9c94f6c | 2016-04-05 15:32:56 +0530 | [diff] [blame] | 2788 | "ALU_ADD_K: 0 + 0xffff = 0xffff", |
| 2789 | .u.insns_int = { |
| 2790 | BPF_LD_IMM64(R2, 0x0), |
| 2791 | BPF_LD_IMM64(R3, 0xffff), |
| 2792 | BPF_ALU32_IMM(BPF_ADD, R2, 0xffff), |
| 2793 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2794 | BPF_MOV32_IMM(R0, 2), |
| 2795 | BPF_EXIT_INSN(), |
| 2796 | BPF_MOV32_IMM(R0, 1), |
| 2797 | BPF_EXIT_INSN(), |
| 2798 | }, |
| 2799 | INTERNAL, |
| 2800 | { }, |
| 2801 | { { 0, 0x1 } }, |
| 2802 | }, |
| 2803 | { |
| 2804 | "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff", |
| 2805 | .u.insns_int = { |
| 2806 | BPF_LD_IMM64(R2, 0x0), |
| 2807 | BPF_LD_IMM64(R3, 0x7fffffff), |
| 2808 | BPF_ALU32_IMM(BPF_ADD, R2, 0x7fffffff), |
| 2809 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2810 | BPF_MOV32_IMM(R0, 2), |
| 2811 | BPF_EXIT_INSN(), |
| 2812 | BPF_MOV32_IMM(R0, 1), |
| 2813 | BPF_EXIT_INSN(), |
| 2814 | }, |
| 2815 | INTERNAL, |
| 2816 | { }, |
| 2817 | { { 0, 0x1 } }, |
| 2818 | }, |
| 2819 | { |
| 2820 | "ALU_ADD_K: 0 + 0x80000000 = 0x80000000", |
| 2821 | .u.insns_int = { |
| 2822 | BPF_LD_IMM64(R2, 0x0), |
| 2823 | BPF_LD_IMM64(R3, 0x80000000), |
| 2824 | BPF_ALU32_IMM(BPF_ADD, R2, 0x80000000), |
| 2825 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2826 | BPF_MOV32_IMM(R0, 2), |
| 2827 | BPF_EXIT_INSN(), |
| 2828 | BPF_MOV32_IMM(R0, 1), |
| 2829 | BPF_EXIT_INSN(), |
| 2830 | }, |
| 2831 | INTERNAL, |
| 2832 | { }, |
| 2833 | { { 0, 0x1 } }, |
| 2834 | }, |
| 2835 | { |
| 2836 | "ALU_ADD_K: 0 + 0x80008000 = 0x80008000", |
| 2837 | .u.insns_int = { |
| 2838 | BPF_LD_IMM64(R2, 0x0), |
| 2839 | BPF_LD_IMM64(R3, 0x80008000), |
| 2840 | BPF_ALU32_IMM(BPF_ADD, R2, 0x80008000), |
| 2841 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2842 | BPF_MOV32_IMM(R0, 2), |
| 2843 | BPF_EXIT_INSN(), |
| 2844 | BPF_MOV32_IMM(R0, 1), |
| 2845 | BPF_EXIT_INSN(), |
| 2846 | }, |
| 2847 | INTERNAL, |
| 2848 | { }, |
| 2849 | { { 0, 0x1 } }, |
| 2850 | }, |
| 2851 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2852 | "ALU64_ADD_K: 1 + 2 = 3", |
| 2853 | .u.insns_int = { |
| 2854 | BPF_LD_IMM64(R0, 1), |
| 2855 | BPF_ALU64_IMM(BPF_ADD, R0, 2), |
| 2856 | BPF_EXIT_INSN(), |
| 2857 | }, |
| 2858 | INTERNAL, |
| 2859 | { }, |
| 2860 | { { 0, 3 } }, |
| 2861 | }, |
| 2862 | { |
| 2863 | "ALU64_ADD_K: 3 + 0 = 3", |
| 2864 | .u.insns_int = { |
| 2865 | BPF_LD_IMM64(R0, 3), |
| 2866 | BPF_ALU64_IMM(BPF_ADD, R0, 0), |
| 2867 | BPF_EXIT_INSN(), |
| 2868 | }, |
| 2869 | INTERNAL, |
| 2870 | { }, |
| 2871 | { { 0, 3 } }, |
| 2872 | }, |
| 2873 | { |
| 2874 | "ALU64_ADD_K: 1 + 2147483646 = 2147483647", |
| 2875 | .u.insns_int = { |
| 2876 | BPF_LD_IMM64(R0, 1), |
| 2877 | BPF_ALU64_IMM(BPF_ADD, R0, 2147483646), |
| 2878 | BPF_EXIT_INSN(), |
| 2879 | }, |
| 2880 | INTERNAL, |
| 2881 | { }, |
| 2882 | { { 0, 2147483647 } }, |
| 2883 | }, |
| 2884 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2885 | "ALU64_ADD_K: 4294967294 + 2 = 4294967296", |
| 2886 | .u.insns_int = { |
| 2887 | BPF_LD_IMM64(R0, 4294967294U), |
| 2888 | BPF_LD_IMM64(R1, 4294967296ULL), |
| 2889 | BPF_ALU64_IMM(BPF_ADD, R0, 2), |
| 2890 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 2891 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2892 | BPF_EXIT_INSN(), |
| 2893 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2894 | BPF_EXIT_INSN(), |
| 2895 | }, |
| 2896 | INTERNAL, |
| 2897 | { }, |
| 2898 | { { 0, 1 } }, |
| 2899 | }, |
| 2900 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2901 | "ALU64_ADD_K: 2147483646 + -2147483647 = -1", |
| 2902 | .u.insns_int = { |
| 2903 | BPF_LD_IMM64(R0, 2147483646), |
| 2904 | BPF_ALU64_IMM(BPF_ADD, R0, -2147483647), |
| 2905 | BPF_EXIT_INSN(), |
| 2906 | }, |
| 2907 | INTERNAL, |
| 2908 | { }, |
| 2909 | { { 0, -1 } }, |
| 2910 | }, |
| 2911 | { |
| 2912 | "ALU64_ADD_K: 1 + 0 = 1", |
| 2913 | .u.insns_int = { |
| 2914 | BPF_LD_IMM64(R2, 0x1), |
| 2915 | BPF_LD_IMM64(R3, 0x1), |
| 2916 | BPF_ALU64_IMM(BPF_ADD, R2, 0x0), |
| 2917 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2918 | BPF_MOV32_IMM(R0, 2), |
| 2919 | BPF_EXIT_INSN(), |
| 2920 | BPF_MOV32_IMM(R0, 1), |
| 2921 | BPF_EXIT_INSN(), |
| 2922 | }, |
| 2923 | INTERNAL, |
| 2924 | { }, |
| 2925 | { { 0, 0x1 } }, |
| 2926 | }, |
| 2927 | { |
| 2928 | "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff", |
| 2929 | .u.insns_int = { |
| 2930 | BPF_LD_IMM64(R2, 0x0), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2931 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2932 | BPF_ALU64_IMM(BPF_ADD, R2, 0xffffffff), |
| 2933 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2934 | BPF_MOV32_IMM(R0, 2), |
| 2935 | BPF_EXIT_INSN(), |
| 2936 | BPF_MOV32_IMM(R0, 1), |
| 2937 | BPF_EXIT_INSN(), |
| 2938 | }, |
| 2939 | INTERNAL, |
| 2940 | { }, |
| 2941 | { { 0, 0x1 } }, |
| 2942 | }, |
Naveen N. Rao | 9c94f6c | 2016-04-05 15:32:56 +0530 | [diff] [blame] | 2943 | { |
| 2944 | "ALU64_ADD_K: 0 + 0xffff = 0xffff", |
| 2945 | .u.insns_int = { |
| 2946 | BPF_LD_IMM64(R2, 0x0), |
| 2947 | BPF_LD_IMM64(R3, 0xffff), |
| 2948 | BPF_ALU64_IMM(BPF_ADD, R2, 0xffff), |
| 2949 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2950 | BPF_MOV32_IMM(R0, 2), |
| 2951 | BPF_EXIT_INSN(), |
| 2952 | BPF_MOV32_IMM(R0, 1), |
| 2953 | BPF_EXIT_INSN(), |
| 2954 | }, |
| 2955 | INTERNAL, |
| 2956 | { }, |
| 2957 | { { 0, 0x1 } }, |
| 2958 | }, |
| 2959 | { |
| 2960 | "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff", |
| 2961 | .u.insns_int = { |
| 2962 | BPF_LD_IMM64(R2, 0x0), |
| 2963 | BPF_LD_IMM64(R3, 0x7fffffff), |
| 2964 | BPF_ALU64_IMM(BPF_ADD, R2, 0x7fffffff), |
| 2965 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2966 | BPF_MOV32_IMM(R0, 2), |
| 2967 | BPF_EXIT_INSN(), |
| 2968 | BPF_MOV32_IMM(R0, 1), |
| 2969 | BPF_EXIT_INSN(), |
| 2970 | }, |
| 2971 | INTERNAL, |
| 2972 | { }, |
| 2973 | { { 0, 0x1 } }, |
| 2974 | }, |
| 2975 | { |
| 2976 | "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000", |
| 2977 | .u.insns_int = { |
| 2978 | BPF_LD_IMM64(R2, 0x0), |
| 2979 | BPF_LD_IMM64(R3, 0xffffffff80000000LL), |
| 2980 | BPF_ALU64_IMM(BPF_ADD, R2, 0x80000000), |
| 2981 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2982 | BPF_MOV32_IMM(R0, 2), |
| 2983 | BPF_EXIT_INSN(), |
| 2984 | BPF_MOV32_IMM(R0, 1), |
| 2985 | BPF_EXIT_INSN(), |
| 2986 | }, |
| 2987 | INTERNAL, |
| 2988 | { }, |
| 2989 | { { 0, 0x1 } }, |
| 2990 | }, |
| 2991 | { |
| 2992 | "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000", |
| 2993 | .u.insns_int = { |
| 2994 | BPF_LD_IMM64(R2, 0x0), |
| 2995 | BPF_LD_IMM64(R3, 0xffffffff80008000LL), |
| 2996 | BPF_ALU64_IMM(BPF_ADD, R2, 0x80008000), |
| 2997 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2998 | BPF_MOV32_IMM(R0, 2), |
| 2999 | BPF_EXIT_INSN(), |
| 3000 | BPF_MOV32_IMM(R0, 1), |
| 3001 | BPF_EXIT_INSN(), |
| 3002 | }, |
| 3003 | INTERNAL, |
| 3004 | { }, |
| 3005 | { { 0, 0x1 } }, |
| 3006 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3007 | /* BPF_ALU | BPF_SUB | BPF_X */ |
| 3008 | { |
| 3009 | "ALU_SUB_X: 3 - 1 = 2", |
| 3010 | .u.insns_int = { |
| 3011 | BPF_LD_IMM64(R0, 3), |
| 3012 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3013 | BPF_ALU32_REG(BPF_SUB, R0, R1), |
| 3014 | BPF_EXIT_INSN(), |
| 3015 | }, |
| 3016 | INTERNAL, |
| 3017 | { }, |
| 3018 | { { 0, 2 } }, |
| 3019 | }, |
| 3020 | { |
| 3021 | "ALU_SUB_X: 4294967295 - 4294967294 = 1", |
| 3022 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3023 | BPF_LD_IMM64(R0, 4294967295U), |
| 3024 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3025 | BPF_ALU32_REG(BPF_SUB, R0, R1), |
| 3026 | BPF_EXIT_INSN(), |
| 3027 | }, |
| 3028 | INTERNAL, |
| 3029 | { }, |
| 3030 | { { 0, 1 } }, |
| 3031 | }, |
| 3032 | { |
| 3033 | "ALU64_SUB_X: 3 - 1 = 2", |
| 3034 | .u.insns_int = { |
| 3035 | BPF_LD_IMM64(R0, 3), |
| 3036 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3037 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 3038 | BPF_EXIT_INSN(), |
| 3039 | }, |
| 3040 | INTERNAL, |
| 3041 | { }, |
| 3042 | { { 0, 2 } }, |
| 3043 | }, |
| 3044 | { |
| 3045 | "ALU64_SUB_X: 4294967295 - 4294967294 = 1", |
| 3046 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3047 | BPF_LD_IMM64(R0, 4294967295U), |
| 3048 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3049 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 3050 | BPF_EXIT_INSN(), |
| 3051 | }, |
| 3052 | INTERNAL, |
| 3053 | { }, |
| 3054 | { { 0, 1 } }, |
| 3055 | }, |
| 3056 | /* BPF_ALU | BPF_SUB | BPF_K */ |
| 3057 | { |
| 3058 | "ALU_SUB_K: 3 - 1 = 2", |
| 3059 | .u.insns_int = { |
| 3060 | BPF_LD_IMM64(R0, 3), |
| 3061 | BPF_ALU32_IMM(BPF_SUB, R0, 1), |
| 3062 | BPF_EXIT_INSN(), |
| 3063 | }, |
| 3064 | INTERNAL, |
| 3065 | { }, |
| 3066 | { { 0, 2 } }, |
| 3067 | }, |
| 3068 | { |
| 3069 | "ALU_SUB_K: 3 - 0 = 3", |
| 3070 | .u.insns_int = { |
| 3071 | BPF_LD_IMM64(R0, 3), |
| 3072 | BPF_ALU32_IMM(BPF_SUB, R0, 0), |
| 3073 | BPF_EXIT_INSN(), |
| 3074 | }, |
| 3075 | INTERNAL, |
| 3076 | { }, |
| 3077 | { { 0, 3 } }, |
| 3078 | }, |
| 3079 | { |
| 3080 | "ALU_SUB_K: 4294967295 - 4294967294 = 1", |
| 3081 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3082 | BPF_LD_IMM64(R0, 4294967295U), |
| 3083 | BPF_ALU32_IMM(BPF_SUB, R0, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3084 | BPF_EXIT_INSN(), |
| 3085 | }, |
| 3086 | INTERNAL, |
| 3087 | { }, |
| 3088 | { { 0, 1 } }, |
| 3089 | }, |
| 3090 | { |
| 3091 | "ALU64_SUB_K: 3 - 1 = 2", |
| 3092 | .u.insns_int = { |
| 3093 | BPF_LD_IMM64(R0, 3), |
| 3094 | BPF_ALU64_IMM(BPF_SUB, R0, 1), |
| 3095 | BPF_EXIT_INSN(), |
| 3096 | }, |
| 3097 | INTERNAL, |
| 3098 | { }, |
| 3099 | { { 0, 2 } }, |
| 3100 | }, |
| 3101 | { |
| 3102 | "ALU64_SUB_K: 3 - 0 = 3", |
| 3103 | .u.insns_int = { |
| 3104 | BPF_LD_IMM64(R0, 3), |
| 3105 | BPF_ALU64_IMM(BPF_SUB, R0, 0), |
| 3106 | BPF_EXIT_INSN(), |
| 3107 | }, |
| 3108 | INTERNAL, |
| 3109 | { }, |
| 3110 | { { 0, 3 } }, |
| 3111 | }, |
| 3112 | { |
| 3113 | "ALU64_SUB_K: 4294967294 - 4294967295 = -1", |
| 3114 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3115 | BPF_LD_IMM64(R0, 4294967294U), |
| 3116 | BPF_ALU64_IMM(BPF_SUB, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3117 | BPF_EXIT_INSN(), |
| 3118 | }, |
| 3119 | INTERNAL, |
| 3120 | { }, |
| 3121 | { { 0, -1 } }, |
| 3122 | }, |
| 3123 | { |
| 3124 | "ALU64_ADD_K: 2147483646 - 2147483647 = -1", |
| 3125 | .u.insns_int = { |
| 3126 | BPF_LD_IMM64(R0, 2147483646), |
| 3127 | BPF_ALU64_IMM(BPF_SUB, R0, 2147483647), |
| 3128 | BPF_EXIT_INSN(), |
| 3129 | }, |
| 3130 | INTERNAL, |
| 3131 | { }, |
| 3132 | { { 0, -1 } }, |
| 3133 | }, |
| 3134 | /* BPF_ALU | BPF_MUL | BPF_X */ |
| 3135 | { |
| 3136 | "ALU_MUL_X: 2 * 3 = 6", |
| 3137 | .u.insns_int = { |
| 3138 | BPF_LD_IMM64(R0, 2), |
| 3139 | BPF_ALU32_IMM(BPF_MOV, R1, 3), |
| 3140 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 3141 | BPF_EXIT_INSN(), |
| 3142 | }, |
| 3143 | INTERNAL, |
| 3144 | { }, |
| 3145 | { { 0, 6 } }, |
| 3146 | }, |
| 3147 | { |
| 3148 | "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", |
| 3149 | .u.insns_int = { |
| 3150 | BPF_LD_IMM64(R0, 2), |
| 3151 | BPF_ALU32_IMM(BPF_MOV, R1, 0x7FFFFFF8), |
| 3152 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 3153 | BPF_EXIT_INSN(), |
| 3154 | }, |
| 3155 | INTERNAL, |
| 3156 | { }, |
| 3157 | { { 0, 0xFFFFFFF0 } }, |
| 3158 | }, |
| 3159 | { |
| 3160 | "ALU_MUL_X: -1 * -1 = 1", |
| 3161 | .u.insns_int = { |
| 3162 | BPF_LD_IMM64(R0, -1), |
| 3163 | BPF_ALU32_IMM(BPF_MOV, R1, -1), |
| 3164 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 3165 | BPF_EXIT_INSN(), |
| 3166 | }, |
| 3167 | INTERNAL, |
| 3168 | { }, |
| 3169 | { { 0, 1 } }, |
| 3170 | }, |
| 3171 | { |
| 3172 | "ALU64_MUL_X: 2 * 3 = 6", |
| 3173 | .u.insns_int = { |
| 3174 | BPF_LD_IMM64(R0, 2), |
| 3175 | BPF_ALU32_IMM(BPF_MOV, R1, 3), |
| 3176 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3177 | BPF_EXIT_INSN(), |
| 3178 | }, |
| 3179 | INTERNAL, |
| 3180 | { }, |
| 3181 | { { 0, 6 } }, |
| 3182 | }, |
| 3183 | { |
| 3184 | "ALU64_MUL_X: 1 * 2147483647 = 2147483647", |
| 3185 | .u.insns_int = { |
| 3186 | BPF_LD_IMM64(R0, 1), |
| 3187 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), |
| 3188 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3189 | BPF_EXIT_INSN(), |
| 3190 | }, |
| 3191 | INTERNAL, |
| 3192 | { }, |
| 3193 | { { 0, 2147483647 } }, |
| 3194 | }, |
Johan Almbladh | faa5762 | 2021-08-09 11:18:22 +0200 | [diff] [blame] | 3195 | { |
| 3196 | "ALU64_MUL_X: 64x64 multiply, low word", |
| 3197 | .u.insns_int = { |
| 3198 | BPF_LD_IMM64(R0, 0x0fedcba987654321LL), |
| 3199 | BPF_LD_IMM64(R1, 0x123456789abcdef0LL), |
| 3200 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3201 | BPF_EXIT_INSN(), |
| 3202 | }, |
| 3203 | INTERNAL, |
| 3204 | { }, |
| 3205 | { { 0, 0xe5618cf0 } } |
| 3206 | }, |
| 3207 | { |
| 3208 | "ALU64_MUL_X: 64x64 multiply, high word", |
| 3209 | .u.insns_int = { |
| 3210 | BPF_LD_IMM64(R0, 0x0fedcba987654321LL), |
| 3211 | BPF_LD_IMM64(R1, 0x123456789abcdef0LL), |
| 3212 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3213 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 3214 | BPF_EXIT_INSN(), |
| 3215 | }, |
| 3216 | INTERNAL, |
| 3217 | { }, |
| 3218 | { { 0, 0x2236d88f } } |
| 3219 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3220 | /* BPF_ALU | BPF_MUL | BPF_K */ |
| 3221 | { |
| 3222 | "ALU_MUL_K: 2 * 3 = 6", |
| 3223 | .u.insns_int = { |
| 3224 | BPF_LD_IMM64(R0, 2), |
| 3225 | BPF_ALU32_IMM(BPF_MUL, R0, 3), |
| 3226 | BPF_EXIT_INSN(), |
| 3227 | }, |
| 3228 | INTERNAL, |
| 3229 | { }, |
| 3230 | { { 0, 6 } }, |
| 3231 | }, |
| 3232 | { |
| 3233 | "ALU_MUL_K: 3 * 1 = 3", |
| 3234 | .u.insns_int = { |
| 3235 | BPF_LD_IMM64(R0, 3), |
| 3236 | BPF_ALU32_IMM(BPF_MUL, R0, 1), |
| 3237 | BPF_EXIT_INSN(), |
| 3238 | }, |
| 3239 | INTERNAL, |
| 3240 | { }, |
| 3241 | { { 0, 3 } }, |
| 3242 | }, |
| 3243 | { |
| 3244 | "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", |
| 3245 | .u.insns_int = { |
| 3246 | BPF_LD_IMM64(R0, 2), |
| 3247 | BPF_ALU32_IMM(BPF_MUL, R0, 0x7FFFFFF8), |
| 3248 | BPF_EXIT_INSN(), |
| 3249 | }, |
| 3250 | INTERNAL, |
| 3251 | { }, |
| 3252 | { { 0, 0xFFFFFFF0 } }, |
| 3253 | }, |
| 3254 | { |
| 3255 | "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff", |
| 3256 | .u.insns_int = { |
| 3257 | BPF_LD_IMM64(R2, 0x1), |
| 3258 | BPF_LD_IMM64(R3, 0x00000000ffffffff), |
| 3259 | BPF_ALU32_IMM(BPF_MUL, R2, 0xffffffff), |
| 3260 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3261 | BPF_MOV32_IMM(R0, 2), |
| 3262 | BPF_EXIT_INSN(), |
| 3263 | BPF_MOV32_IMM(R0, 1), |
| 3264 | BPF_EXIT_INSN(), |
| 3265 | }, |
| 3266 | INTERNAL, |
| 3267 | { }, |
| 3268 | { { 0, 0x1 } }, |
| 3269 | }, |
| 3270 | { |
| 3271 | "ALU64_MUL_K: 2 * 3 = 6", |
| 3272 | .u.insns_int = { |
| 3273 | BPF_LD_IMM64(R0, 2), |
| 3274 | BPF_ALU64_IMM(BPF_MUL, R0, 3), |
| 3275 | BPF_EXIT_INSN(), |
| 3276 | }, |
| 3277 | INTERNAL, |
| 3278 | { }, |
| 3279 | { { 0, 6 } }, |
| 3280 | }, |
| 3281 | { |
| 3282 | "ALU64_MUL_K: 3 * 1 = 3", |
| 3283 | .u.insns_int = { |
| 3284 | BPF_LD_IMM64(R0, 3), |
| 3285 | BPF_ALU64_IMM(BPF_MUL, R0, 1), |
| 3286 | BPF_EXIT_INSN(), |
| 3287 | }, |
| 3288 | INTERNAL, |
| 3289 | { }, |
| 3290 | { { 0, 3 } }, |
| 3291 | }, |
| 3292 | { |
| 3293 | "ALU64_MUL_K: 1 * 2147483647 = 2147483647", |
| 3294 | .u.insns_int = { |
| 3295 | BPF_LD_IMM64(R0, 1), |
| 3296 | BPF_ALU64_IMM(BPF_MUL, R0, 2147483647), |
| 3297 | BPF_EXIT_INSN(), |
| 3298 | }, |
| 3299 | INTERNAL, |
| 3300 | { }, |
| 3301 | { { 0, 2147483647 } }, |
| 3302 | }, |
| 3303 | { |
| 3304 | "ALU64_MUL_K: 1 * -2147483647 = -2147483647", |
| 3305 | .u.insns_int = { |
| 3306 | BPF_LD_IMM64(R0, 1), |
| 3307 | BPF_ALU64_IMM(BPF_MUL, R0, -2147483647), |
| 3308 | BPF_EXIT_INSN(), |
| 3309 | }, |
| 3310 | INTERNAL, |
| 3311 | { }, |
| 3312 | { { 0, -2147483647 } }, |
| 3313 | }, |
| 3314 | { |
| 3315 | "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff", |
| 3316 | .u.insns_int = { |
| 3317 | BPF_LD_IMM64(R2, 0x1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3318 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3319 | BPF_ALU64_IMM(BPF_MUL, R2, 0xffffffff), |
| 3320 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3321 | BPF_MOV32_IMM(R0, 2), |
| 3322 | BPF_EXIT_INSN(), |
| 3323 | BPF_MOV32_IMM(R0, 1), |
| 3324 | BPF_EXIT_INSN(), |
| 3325 | }, |
| 3326 | INTERNAL, |
| 3327 | { }, |
| 3328 | { { 0, 0x1 } }, |
| 3329 | }, |
Johan Almbladh | faa5762 | 2021-08-09 11:18:22 +0200 | [diff] [blame] | 3330 | { |
| 3331 | "ALU64_MUL_K: 64x32 multiply, low word", |
| 3332 | .u.insns_int = { |
| 3333 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3334 | BPF_ALU64_IMM(BPF_MUL, R0, 0x12345678), |
| 3335 | BPF_EXIT_INSN(), |
| 3336 | }, |
| 3337 | INTERNAL, |
| 3338 | { }, |
| 3339 | { { 0, 0xe242d208 } } |
| 3340 | }, |
| 3341 | { |
| 3342 | "ALU64_MUL_K: 64x32 multiply, high word", |
| 3343 | .u.insns_int = { |
| 3344 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3345 | BPF_ALU64_IMM(BPF_MUL, R0, 0x12345678), |
| 3346 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 3347 | BPF_EXIT_INSN(), |
| 3348 | }, |
| 3349 | INTERNAL, |
| 3350 | { }, |
| 3351 | { { 0, 0xc28f5c28 } } |
| 3352 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3353 | /* BPF_ALU | BPF_DIV | BPF_X */ |
| 3354 | { |
| 3355 | "ALU_DIV_X: 6 / 2 = 3", |
| 3356 | .u.insns_int = { |
| 3357 | BPF_LD_IMM64(R0, 6), |
| 3358 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3359 | BPF_ALU32_REG(BPF_DIV, R0, R1), |
| 3360 | BPF_EXIT_INSN(), |
| 3361 | }, |
| 3362 | INTERNAL, |
| 3363 | { }, |
| 3364 | { { 0, 3 } }, |
| 3365 | }, |
| 3366 | { |
| 3367 | "ALU_DIV_X: 4294967295 / 4294967295 = 1", |
| 3368 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3369 | BPF_LD_IMM64(R0, 4294967295U), |
| 3370 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3371 | BPF_ALU32_REG(BPF_DIV, R0, R1), |
| 3372 | BPF_EXIT_INSN(), |
| 3373 | }, |
| 3374 | INTERNAL, |
| 3375 | { }, |
| 3376 | { { 0, 1 } }, |
| 3377 | }, |
| 3378 | { |
| 3379 | "ALU64_DIV_X: 6 / 2 = 3", |
| 3380 | .u.insns_int = { |
| 3381 | BPF_LD_IMM64(R0, 6), |
| 3382 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3383 | BPF_ALU64_REG(BPF_DIV, R0, R1), |
| 3384 | BPF_EXIT_INSN(), |
| 3385 | }, |
| 3386 | INTERNAL, |
| 3387 | { }, |
| 3388 | { { 0, 3 } }, |
| 3389 | }, |
| 3390 | { |
| 3391 | "ALU64_DIV_X: 2147483647 / 2147483647 = 1", |
| 3392 | .u.insns_int = { |
| 3393 | BPF_LD_IMM64(R0, 2147483647), |
| 3394 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), |
| 3395 | BPF_ALU64_REG(BPF_DIV, R0, R1), |
| 3396 | BPF_EXIT_INSN(), |
| 3397 | }, |
| 3398 | INTERNAL, |
| 3399 | { }, |
| 3400 | { { 0, 1 } }, |
| 3401 | }, |
| 3402 | { |
| 3403 | "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001", |
| 3404 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3405 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3406 | BPF_LD_IMM64(R4, 0xffffffffffffffffLL), |
| 3407 | BPF_LD_IMM64(R3, 0x0000000000000001LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3408 | BPF_ALU64_REG(BPF_DIV, R2, R4), |
| 3409 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3410 | BPF_MOV32_IMM(R0, 2), |
| 3411 | BPF_EXIT_INSN(), |
| 3412 | BPF_MOV32_IMM(R0, 1), |
| 3413 | BPF_EXIT_INSN(), |
| 3414 | }, |
| 3415 | INTERNAL, |
| 3416 | { }, |
| 3417 | { { 0, 0x1 } }, |
| 3418 | }, |
| 3419 | /* BPF_ALU | BPF_DIV | BPF_K */ |
| 3420 | { |
| 3421 | "ALU_DIV_K: 6 / 2 = 3", |
| 3422 | .u.insns_int = { |
| 3423 | BPF_LD_IMM64(R0, 6), |
| 3424 | BPF_ALU32_IMM(BPF_DIV, R0, 2), |
| 3425 | BPF_EXIT_INSN(), |
| 3426 | }, |
| 3427 | INTERNAL, |
| 3428 | { }, |
| 3429 | { { 0, 3 } }, |
| 3430 | }, |
| 3431 | { |
| 3432 | "ALU_DIV_K: 3 / 1 = 3", |
| 3433 | .u.insns_int = { |
| 3434 | BPF_LD_IMM64(R0, 3), |
| 3435 | BPF_ALU32_IMM(BPF_DIV, R0, 1), |
| 3436 | BPF_EXIT_INSN(), |
| 3437 | }, |
| 3438 | INTERNAL, |
| 3439 | { }, |
| 3440 | { { 0, 3 } }, |
| 3441 | }, |
| 3442 | { |
| 3443 | "ALU_DIV_K: 4294967295 / 4294967295 = 1", |
| 3444 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3445 | BPF_LD_IMM64(R0, 4294967295U), |
| 3446 | BPF_ALU32_IMM(BPF_DIV, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3447 | BPF_EXIT_INSN(), |
| 3448 | }, |
| 3449 | INTERNAL, |
| 3450 | { }, |
| 3451 | { { 0, 1 } }, |
| 3452 | }, |
| 3453 | { |
| 3454 | "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1", |
| 3455 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3456 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3457 | BPF_LD_IMM64(R3, 0x1UL), |
| 3458 | BPF_ALU32_IMM(BPF_DIV, R2, 0xffffffff), |
| 3459 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3460 | BPF_MOV32_IMM(R0, 2), |
| 3461 | BPF_EXIT_INSN(), |
| 3462 | BPF_MOV32_IMM(R0, 1), |
| 3463 | BPF_EXIT_INSN(), |
| 3464 | }, |
| 3465 | INTERNAL, |
| 3466 | { }, |
| 3467 | { { 0, 0x1 } }, |
| 3468 | }, |
| 3469 | { |
| 3470 | "ALU64_DIV_K: 6 / 2 = 3", |
| 3471 | .u.insns_int = { |
| 3472 | BPF_LD_IMM64(R0, 6), |
| 3473 | BPF_ALU64_IMM(BPF_DIV, R0, 2), |
| 3474 | BPF_EXIT_INSN(), |
| 3475 | }, |
| 3476 | INTERNAL, |
| 3477 | { }, |
| 3478 | { { 0, 3 } }, |
| 3479 | }, |
| 3480 | { |
| 3481 | "ALU64_DIV_K: 3 / 1 = 3", |
| 3482 | .u.insns_int = { |
| 3483 | BPF_LD_IMM64(R0, 3), |
| 3484 | BPF_ALU64_IMM(BPF_DIV, R0, 1), |
| 3485 | BPF_EXIT_INSN(), |
| 3486 | }, |
| 3487 | INTERNAL, |
| 3488 | { }, |
| 3489 | { { 0, 3 } }, |
| 3490 | }, |
| 3491 | { |
| 3492 | "ALU64_DIV_K: 2147483647 / 2147483647 = 1", |
| 3493 | .u.insns_int = { |
| 3494 | BPF_LD_IMM64(R0, 2147483647), |
| 3495 | BPF_ALU64_IMM(BPF_DIV, R0, 2147483647), |
| 3496 | BPF_EXIT_INSN(), |
| 3497 | }, |
| 3498 | INTERNAL, |
| 3499 | { }, |
| 3500 | { { 0, 1 } }, |
| 3501 | }, |
| 3502 | { |
| 3503 | "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001", |
| 3504 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3505 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3506 | BPF_LD_IMM64(R3, 0x0000000000000001LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3507 | BPF_ALU64_IMM(BPF_DIV, R2, 0xffffffff), |
| 3508 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3509 | BPF_MOV32_IMM(R0, 2), |
| 3510 | BPF_EXIT_INSN(), |
| 3511 | BPF_MOV32_IMM(R0, 1), |
| 3512 | BPF_EXIT_INSN(), |
| 3513 | }, |
| 3514 | INTERNAL, |
| 3515 | { }, |
| 3516 | { { 0, 0x1 } }, |
| 3517 | }, |
| 3518 | /* BPF_ALU | BPF_MOD | BPF_X */ |
| 3519 | { |
| 3520 | "ALU_MOD_X: 3 % 2 = 1", |
| 3521 | .u.insns_int = { |
| 3522 | BPF_LD_IMM64(R0, 3), |
| 3523 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3524 | BPF_ALU32_REG(BPF_MOD, R0, R1), |
| 3525 | BPF_EXIT_INSN(), |
| 3526 | }, |
| 3527 | INTERNAL, |
| 3528 | { }, |
| 3529 | { { 0, 1 } }, |
| 3530 | }, |
| 3531 | { |
| 3532 | "ALU_MOD_X: 4294967295 % 4294967293 = 2", |
| 3533 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3534 | BPF_LD_IMM64(R0, 4294967295U), |
| 3535 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967293U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3536 | BPF_ALU32_REG(BPF_MOD, R0, R1), |
| 3537 | BPF_EXIT_INSN(), |
| 3538 | }, |
| 3539 | INTERNAL, |
| 3540 | { }, |
| 3541 | { { 0, 2 } }, |
| 3542 | }, |
| 3543 | { |
| 3544 | "ALU64_MOD_X: 3 % 2 = 1", |
| 3545 | .u.insns_int = { |
| 3546 | BPF_LD_IMM64(R0, 3), |
| 3547 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3548 | BPF_ALU64_REG(BPF_MOD, R0, R1), |
| 3549 | BPF_EXIT_INSN(), |
| 3550 | }, |
| 3551 | INTERNAL, |
| 3552 | { }, |
| 3553 | { { 0, 1 } }, |
| 3554 | }, |
| 3555 | { |
| 3556 | "ALU64_MOD_X: 2147483647 % 2147483645 = 2", |
| 3557 | .u.insns_int = { |
| 3558 | BPF_LD_IMM64(R0, 2147483647), |
| 3559 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483645), |
| 3560 | BPF_ALU64_REG(BPF_MOD, R0, R1), |
| 3561 | BPF_EXIT_INSN(), |
| 3562 | }, |
| 3563 | INTERNAL, |
| 3564 | { }, |
| 3565 | { { 0, 2 } }, |
| 3566 | }, |
| 3567 | /* BPF_ALU | BPF_MOD | BPF_K */ |
| 3568 | { |
| 3569 | "ALU_MOD_K: 3 % 2 = 1", |
| 3570 | .u.insns_int = { |
| 3571 | BPF_LD_IMM64(R0, 3), |
| 3572 | BPF_ALU32_IMM(BPF_MOD, R0, 2), |
| 3573 | BPF_EXIT_INSN(), |
| 3574 | }, |
| 3575 | INTERNAL, |
| 3576 | { }, |
| 3577 | { { 0, 1 } }, |
| 3578 | }, |
| 3579 | { |
| 3580 | "ALU_MOD_K: 3 % 1 = 0", |
| 3581 | .u.insns_int = { |
| 3582 | BPF_LD_IMM64(R0, 3), |
| 3583 | BPF_ALU32_IMM(BPF_MOD, R0, 1), |
| 3584 | BPF_EXIT_INSN(), |
| 3585 | }, |
| 3586 | INTERNAL, |
| 3587 | { }, |
| 3588 | { { 0, 0 } }, |
| 3589 | }, |
| 3590 | { |
| 3591 | "ALU_MOD_K: 4294967295 % 4294967293 = 2", |
| 3592 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3593 | BPF_LD_IMM64(R0, 4294967295U), |
| 3594 | BPF_ALU32_IMM(BPF_MOD, R0, 4294967293U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3595 | BPF_EXIT_INSN(), |
| 3596 | }, |
| 3597 | INTERNAL, |
| 3598 | { }, |
| 3599 | { { 0, 2 } }, |
| 3600 | }, |
| 3601 | { |
| 3602 | "ALU64_MOD_K: 3 % 2 = 1", |
| 3603 | .u.insns_int = { |
| 3604 | BPF_LD_IMM64(R0, 3), |
| 3605 | BPF_ALU64_IMM(BPF_MOD, R0, 2), |
| 3606 | BPF_EXIT_INSN(), |
| 3607 | }, |
| 3608 | INTERNAL, |
| 3609 | { }, |
| 3610 | { { 0, 1 } }, |
| 3611 | }, |
| 3612 | { |
| 3613 | "ALU64_MOD_K: 3 % 1 = 0", |
| 3614 | .u.insns_int = { |
| 3615 | BPF_LD_IMM64(R0, 3), |
| 3616 | BPF_ALU64_IMM(BPF_MOD, R0, 1), |
| 3617 | BPF_EXIT_INSN(), |
| 3618 | }, |
| 3619 | INTERNAL, |
| 3620 | { }, |
| 3621 | { { 0, 0 } }, |
| 3622 | }, |
| 3623 | { |
| 3624 | "ALU64_MOD_K: 2147483647 % 2147483645 = 2", |
| 3625 | .u.insns_int = { |
| 3626 | BPF_LD_IMM64(R0, 2147483647), |
| 3627 | BPF_ALU64_IMM(BPF_MOD, R0, 2147483645), |
| 3628 | BPF_EXIT_INSN(), |
| 3629 | }, |
| 3630 | INTERNAL, |
| 3631 | { }, |
| 3632 | { { 0, 2 } }, |
| 3633 | }, |
| 3634 | /* BPF_ALU | BPF_AND | BPF_X */ |
| 3635 | { |
| 3636 | "ALU_AND_X: 3 & 2 = 2", |
| 3637 | .u.insns_int = { |
| 3638 | BPF_LD_IMM64(R0, 3), |
| 3639 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3640 | BPF_ALU32_REG(BPF_AND, R0, R1), |
| 3641 | BPF_EXIT_INSN(), |
| 3642 | }, |
| 3643 | INTERNAL, |
| 3644 | { }, |
| 3645 | { { 0, 2 } }, |
| 3646 | }, |
| 3647 | { |
| 3648 | "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3649 | .u.insns_int = { |
| 3650 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3651 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3652 | BPF_ALU32_REG(BPF_AND, R0, R1), |
| 3653 | BPF_EXIT_INSN(), |
| 3654 | }, |
| 3655 | INTERNAL, |
| 3656 | { }, |
| 3657 | { { 0, 0xffffffff } }, |
| 3658 | }, |
| 3659 | { |
| 3660 | "ALU64_AND_X: 3 & 2 = 2", |
| 3661 | .u.insns_int = { |
| 3662 | BPF_LD_IMM64(R0, 3), |
| 3663 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3664 | BPF_ALU64_REG(BPF_AND, R0, R1), |
| 3665 | BPF_EXIT_INSN(), |
| 3666 | }, |
| 3667 | INTERNAL, |
| 3668 | { }, |
| 3669 | { { 0, 2 } }, |
| 3670 | }, |
| 3671 | { |
| 3672 | "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3673 | .u.insns_int = { |
| 3674 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3675 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3676 | BPF_ALU64_REG(BPF_AND, R0, R1), |
| 3677 | BPF_EXIT_INSN(), |
| 3678 | }, |
| 3679 | INTERNAL, |
| 3680 | { }, |
| 3681 | { { 0, 0xffffffff } }, |
| 3682 | }, |
| 3683 | /* BPF_ALU | BPF_AND | BPF_K */ |
| 3684 | { |
| 3685 | "ALU_AND_K: 3 & 2 = 2", |
| 3686 | .u.insns_int = { |
| 3687 | BPF_LD_IMM64(R0, 3), |
| 3688 | BPF_ALU32_IMM(BPF_AND, R0, 2), |
| 3689 | BPF_EXIT_INSN(), |
| 3690 | }, |
| 3691 | INTERNAL, |
| 3692 | { }, |
| 3693 | { { 0, 2 } }, |
| 3694 | }, |
| 3695 | { |
| 3696 | "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3697 | .u.insns_int = { |
| 3698 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3699 | BPF_ALU32_IMM(BPF_AND, R0, 0xffffffff), |
| 3700 | BPF_EXIT_INSN(), |
| 3701 | }, |
| 3702 | INTERNAL, |
| 3703 | { }, |
| 3704 | { { 0, 0xffffffff } }, |
| 3705 | }, |
| 3706 | { |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 3707 | "ALU_AND_K: Small immediate", |
| 3708 | .u.insns_int = { |
| 3709 | BPF_ALU32_IMM(BPF_MOV, R0, 0x01020304), |
| 3710 | BPF_ALU32_IMM(BPF_AND, R0, 15), |
| 3711 | BPF_EXIT_INSN(), |
| 3712 | }, |
| 3713 | INTERNAL, |
| 3714 | { }, |
| 3715 | { { 0, 4 } } |
| 3716 | }, |
| 3717 | { |
| 3718 | "ALU_AND_K: Large immediate", |
| 3719 | .u.insns_int = { |
| 3720 | BPF_ALU32_IMM(BPF_MOV, R0, 0xf1f2f3f4), |
| 3721 | BPF_ALU32_IMM(BPF_AND, R0, 0xafbfcfdf), |
| 3722 | BPF_EXIT_INSN(), |
| 3723 | }, |
| 3724 | INTERNAL, |
| 3725 | { }, |
| 3726 | { { 0, 0xa1b2c3d4 } } |
| 3727 | }, |
| 3728 | { |
| 3729 | "ALU_AND_K: Zero extension", |
| 3730 | .u.insns_int = { |
| 3731 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3732 | BPF_LD_IMM64(R1, 0x0000000080a0c0e0LL), |
| 3733 | BPF_ALU32_IMM(BPF_AND, R0, 0xf0f0f0f0), |
| 3734 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 3735 | BPF_MOV32_IMM(R0, 2), |
| 3736 | BPF_EXIT_INSN(), |
| 3737 | BPF_MOV32_IMM(R0, 1), |
| 3738 | BPF_EXIT_INSN(), |
| 3739 | }, |
| 3740 | INTERNAL, |
| 3741 | { }, |
| 3742 | { { 0, 1 } } |
| 3743 | }, |
| 3744 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3745 | "ALU64_AND_K: 3 & 2 = 2", |
| 3746 | .u.insns_int = { |
| 3747 | BPF_LD_IMM64(R0, 3), |
| 3748 | BPF_ALU64_IMM(BPF_AND, R0, 2), |
| 3749 | BPF_EXIT_INSN(), |
| 3750 | }, |
| 3751 | INTERNAL, |
| 3752 | { }, |
| 3753 | { { 0, 2 } }, |
| 3754 | }, |
| 3755 | { |
| 3756 | "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3757 | .u.insns_int = { |
| 3758 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3759 | BPF_ALU64_IMM(BPF_AND, R0, 0xffffffff), |
| 3760 | BPF_EXIT_INSN(), |
| 3761 | }, |
| 3762 | INTERNAL, |
| 3763 | { }, |
| 3764 | { { 0, 0xffffffff } }, |
| 3765 | }, |
| 3766 | { |
Johan Almbladh | e92c813 | 2021-08-09 11:18:18 +0200 | [diff] [blame] | 3767 | "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000000000000000", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3768 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3769 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3770 | BPF_LD_IMM64(R3, 0x0000000000000000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3771 | BPF_ALU64_IMM(BPF_AND, R2, 0x0), |
| 3772 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3773 | BPF_MOV32_IMM(R0, 2), |
| 3774 | BPF_EXIT_INSN(), |
| 3775 | BPF_MOV32_IMM(R0, 1), |
| 3776 | BPF_EXIT_INSN(), |
| 3777 | }, |
| 3778 | INTERNAL, |
| 3779 | { }, |
| 3780 | { { 0, 0x1 } }, |
| 3781 | }, |
| 3782 | { |
Johan Almbladh | e92c813 | 2021-08-09 11:18:18 +0200 | [diff] [blame] | 3783 | "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffff0000", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3784 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3785 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3786 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3787 | BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), |
| 3788 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3789 | BPF_MOV32_IMM(R0, 2), |
| 3790 | BPF_EXIT_INSN(), |
| 3791 | BPF_MOV32_IMM(R0, 1), |
| 3792 | BPF_EXIT_INSN(), |
| 3793 | }, |
| 3794 | INTERNAL, |
| 3795 | { }, |
| 3796 | { { 0, 0x1 } }, |
| 3797 | }, |
| 3798 | { |
| 3799 | "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff", |
| 3800 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3801 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3802 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3803 | BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), |
| 3804 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3805 | BPF_MOV32_IMM(R0, 2), |
| 3806 | BPF_EXIT_INSN(), |
| 3807 | BPF_MOV32_IMM(R0, 1), |
| 3808 | BPF_EXIT_INSN(), |
| 3809 | }, |
| 3810 | INTERNAL, |
| 3811 | { }, |
| 3812 | { { 0, 0x1 } }, |
| 3813 | }, |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 3814 | { |
| 3815 | "ALU64_AND_K: Sign extension 1", |
| 3816 | .u.insns_int = { |
| 3817 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3818 | BPF_LD_IMM64(R1, 0x00000000090b0d0fLL), |
| 3819 | BPF_ALU64_IMM(BPF_AND, R0, 0x0f0f0f0f), |
| 3820 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 3821 | BPF_MOV32_IMM(R0, 2), |
| 3822 | BPF_EXIT_INSN(), |
| 3823 | BPF_MOV32_IMM(R0, 1), |
| 3824 | BPF_EXIT_INSN(), |
| 3825 | }, |
| 3826 | INTERNAL, |
| 3827 | { }, |
| 3828 | { { 0, 1 } } |
| 3829 | }, |
| 3830 | { |
| 3831 | "ALU64_AND_K: Sign extension 2", |
| 3832 | .u.insns_int = { |
| 3833 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3834 | BPF_LD_IMM64(R1, 0x0123456780a0c0e0LL), |
| 3835 | BPF_ALU64_IMM(BPF_AND, R0, 0xf0f0f0f0), |
| 3836 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 3837 | BPF_MOV32_IMM(R0, 2), |
| 3838 | BPF_EXIT_INSN(), |
| 3839 | BPF_MOV32_IMM(R0, 1), |
| 3840 | BPF_EXIT_INSN(), |
| 3841 | }, |
| 3842 | INTERNAL, |
| 3843 | { }, |
| 3844 | { { 0, 1 } } |
| 3845 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3846 | /* BPF_ALU | BPF_OR | BPF_X */ |
| 3847 | { |
| 3848 | "ALU_OR_X: 1 | 2 = 3", |
| 3849 | .u.insns_int = { |
| 3850 | BPF_LD_IMM64(R0, 1), |
| 3851 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3852 | BPF_ALU32_REG(BPF_OR, R0, R1), |
| 3853 | BPF_EXIT_INSN(), |
| 3854 | }, |
| 3855 | INTERNAL, |
| 3856 | { }, |
| 3857 | { { 0, 3 } }, |
| 3858 | }, |
| 3859 | { |
| 3860 | "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff", |
| 3861 | .u.insns_int = { |
| 3862 | BPF_LD_IMM64(R0, 0), |
| 3863 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3864 | BPF_ALU32_REG(BPF_OR, R0, R1), |
| 3865 | BPF_EXIT_INSN(), |
| 3866 | }, |
| 3867 | INTERNAL, |
| 3868 | { }, |
| 3869 | { { 0, 0xffffffff } }, |
| 3870 | }, |
| 3871 | { |
| 3872 | "ALU64_OR_X: 1 | 2 = 3", |
| 3873 | .u.insns_int = { |
| 3874 | BPF_LD_IMM64(R0, 1), |
| 3875 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3876 | BPF_ALU64_REG(BPF_OR, R0, R1), |
| 3877 | BPF_EXIT_INSN(), |
| 3878 | }, |
| 3879 | INTERNAL, |
| 3880 | { }, |
| 3881 | { { 0, 3 } }, |
| 3882 | }, |
| 3883 | { |
| 3884 | "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff", |
| 3885 | .u.insns_int = { |
| 3886 | BPF_LD_IMM64(R0, 0), |
| 3887 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3888 | BPF_ALU64_REG(BPF_OR, R0, R1), |
| 3889 | BPF_EXIT_INSN(), |
| 3890 | }, |
| 3891 | INTERNAL, |
| 3892 | { }, |
| 3893 | { { 0, 0xffffffff } }, |
| 3894 | }, |
| 3895 | /* BPF_ALU | BPF_OR | BPF_K */ |
| 3896 | { |
| 3897 | "ALU_OR_K: 1 | 2 = 3", |
| 3898 | .u.insns_int = { |
| 3899 | BPF_LD_IMM64(R0, 1), |
| 3900 | BPF_ALU32_IMM(BPF_OR, R0, 2), |
| 3901 | BPF_EXIT_INSN(), |
| 3902 | }, |
| 3903 | INTERNAL, |
| 3904 | { }, |
| 3905 | { { 0, 3 } }, |
| 3906 | }, |
| 3907 | { |
| 3908 | "ALU_OR_K: 0 & 0xffffffff = 0xffffffff", |
| 3909 | .u.insns_int = { |
| 3910 | BPF_LD_IMM64(R0, 0), |
| 3911 | BPF_ALU32_IMM(BPF_OR, R0, 0xffffffff), |
| 3912 | BPF_EXIT_INSN(), |
| 3913 | }, |
| 3914 | INTERNAL, |
| 3915 | { }, |
| 3916 | { { 0, 0xffffffff } }, |
| 3917 | }, |
| 3918 | { |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 3919 | "ALU_OR_K: Small immediate", |
| 3920 | .u.insns_int = { |
| 3921 | BPF_ALU32_IMM(BPF_MOV, R0, 0x01020304), |
| 3922 | BPF_ALU32_IMM(BPF_OR, R0, 1), |
| 3923 | BPF_EXIT_INSN(), |
| 3924 | }, |
| 3925 | INTERNAL, |
| 3926 | { }, |
| 3927 | { { 0, 0x01020305 } } |
| 3928 | }, |
| 3929 | { |
| 3930 | "ALU_OR_K: Large immediate", |
| 3931 | .u.insns_int = { |
| 3932 | BPF_ALU32_IMM(BPF_MOV, R0, 0x01020304), |
| 3933 | BPF_ALU32_IMM(BPF_OR, R0, 0xa0b0c0d0), |
| 3934 | BPF_EXIT_INSN(), |
| 3935 | }, |
| 3936 | INTERNAL, |
| 3937 | { }, |
| 3938 | { { 0, 0xa1b2c3d4 } } |
| 3939 | }, |
| 3940 | { |
| 3941 | "ALU_OR_K: Zero extension", |
| 3942 | .u.insns_int = { |
| 3943 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 3944 | BPF_LD_IMM64(R1, 0x00000000f9fbfdffLL), |
| 3945 | BPF_ALU32_IMM(BPF_OR, R0, 0xf0f0f0f0), |
| 3946 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 3947 | BPF_MOV32_IMM(R0, 2), |
| 3948 | BPF_EXIT_INSN(), |
| 3949 | BPF_MOV32_IMM(R0, 1), |
| 3950 | BPF_EXIT_INSN(), |
| 3951 | }, |
| 3952 | INTERNAL, |
| 3953 | { }, |
| 3954 | { { 0, 1 } } |
| 3955 | }, |
| 3956 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3957 | "ALU64_OR_K: 1 | 2 = 3", |
| 3958 | .u.insns_int = { |
| 3959 | BPF_LD_IMM64(R0, 1), |
| 3960 | BPF_ALU64_IMM(BPF_OR, R0, 2), |
| 3961 | BPF_EXIT_INSN(), |
| 3962 | }, |
| 3963 | INTERNAL, |
| 3964 | { }, |
| 3965 | { { 0, 3 } }, |
| 3966 | }, |
| 3967 | { |
| 3968 | "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff", |
| 3969 | .u.insns_int = { |
| 3970 | BPF_LD_IMM64(R0, 0), |
| 3971 | BPF_ALU64_IMM(BPF_OR, R0, 0xffffffff), |
| 3972 | BPF_EXIT_INSN(), |
| 3973 | }, |
| 3974 | INTERNAL, |
| 3975 | { }, |
| 3976 | { { 0, 0xffffffff } }, |
| 3977 | }, |
| 3978 | { |
Johan Almbladh | e92c813 | 2021-08-09 11:18:18 +0200 | [diff] [blame] | 3979 | "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffffffff0000", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3980 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3981 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3982 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3983 | BPF_ALU64_IMM(BPF_OR, R2, 0x0), |
| 3984 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3985 | BPF_MOV32_IMM(R0, 2), |
| 3986 | BPF_EXIT_INSN(), |
| 3987 | BPF_MOV32_IMM(R0, 1), |
| 3988 | BPF_EXIT_INSN(), |
| 3989 | }, |
| 3990 | INTERNAL, |
| 3991 | { }, |
| 3992 | { { 0, 0x1 } }, |
| 3993 | }, |
| 3994 | { |
| 3995 | "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff", |
| 3996 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3997 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3998 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3999 | BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), |
| 4000 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4001 | BPF_MOV32_IMM(R0, 2), |
| 4002 | BPF_EXIT_INSN(), |
| 4003 | BPF_MOV32_IMM(R0, 1), |
| 4004 | BPF_EXIT_INSN(), |
| 4005 | }, |
| 4006 | INTERNAL, |
| 4007 | { }, |
| 4008 | { { 0, 0x1 } }, |
| 4009 | }, |
| 4010 | { |
| 4011 | "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff", |
| 4012 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 4013 | BPF_LD_IMM64(R2, 0x0000000000000000LL), |
| 4014 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4015 | BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), |
| 4016 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4017 | BPF_MOV32_IMM(R0, 2), |
| 4018 | BPF_EXIT_INSN(), |
| 4019 | BPF_MOV32_IMM(R0, 1), |
| 4020 | BPF_EXIT_INSN(), |
| 4021 | }, |
| 4022 | INTERNAL, |
| 4023 | { }, |
| 4024 | { { 0, 0x1 } }, |
| 4025 | }, |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 4026 | { |
| 4027 | "ALU64_OR_K: Sign extension 1", |
| 4028 | .u.insns_int = { |
| 4029 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4030 | BPF_LD_IMM64(R1, 0x012345678fafcfefLL), |
| 4031 | BPF_ALU64_IMM(BPF_OR, R0, 0x0f0f0f0f), |
| 4032 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 4033 | BPF_MOV32_IMM(R0, 2), |
| 4034 | BPF_EXIT_INSN(), |
| 4035 | BPF_MOV32_IMM(R0, 1), |
| 4036 | BPF_EXIT_INSN(), |
| 4037 | }, |
| 4038 | INTERNAL, |
| 4039 | { }, |
| 4040 | { { 0, 1 } } |
| 4041 | }, |
| 4042 | { |
| 4043 | "ALU64_OR_K: Sign extension 2", |
| 4044 | .u.insns_int = { |
| 4045 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4046 | BPF_LD_IMM64(R1, 0xfffffffff9fbfdffLL), |
| 4047 | BPF_ALU64_IMM(BPF_OR, R0, 0xf0f0f0f0), |
| 4048 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 4049 | BPF_MOV32_IMM(R0, 2), |
| 4050 | BPF_EXIT_INSN(), |
| 4051 | BPF_MOV32_IMM(R0, 1), |
| 4052 | BPF_EXIT_INSN(), |
| 4053 | }, |
| 4054 | INTERNAL, |
| 4055 | { }, |
| 4056 | { { 0, 1 } } |
| 4057 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4058 | /* BPF_ALU | BPF_XOR | BPF_X */ |
| 4059 | { |
| 4060 | "ALU_XOR_X: 5 ^ 6 = 3", |
| 4061 | .u.insns_int = { |
| 4062 | BPF_LD_IMM64(R0, 5), |
| 4063 | BPF_ALU32_IMM(BPF_MOV, R1, 6), |
| 4064 | BPF_ALU32_REG(BPF_XOR, R0, R1), |
| 4065 | BPF_EXIT_INSN(), |
| 4066 | }, |
| 4067 | INTERNAL, |
| 4068 | { }, |
| 4069 | { { 0, 3 } }, |
| 4070 | }, |
| 4071 | { |
| 4072 | "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe", |
| 4073 | .u.insns_int = { |
| 4074 | BPF_LD_IMM64(R0, 1), |
| 4075 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 4076 | BPF_ALU32_REG(BPF_XOR, R0, R1), |
| 4077 | BPF_EXIT_INSN(), |
| 4078 | }, |
| 4079 | INTERNAL, |
| 4080 | { }, |
| 4081 | { { 0, 0xfffffffe } }, |
| 4082 | }, |
| 4083 | { |
| 4084 | "ALU64_XOR_X: 5 ^ 6 = 3", |
| 4085 | .u.insns_int = { |
| 4086 | BPF_LD_IMM64(R0, 5), |
| 4087 | BPF_ALU32_IMM(BPF_MOV, R1, 6), |
| 4088 | BPF_ALU64_REG(BPF_XOR, R0, R1), |
| 4089 | BPF_EXIT_INSN(), |
| 4090 | }, |
| 4091 | INTERNAL, |
| 4092 | { }, |
| 4093 | { { 0, 3 } }, |
| 4094 | }, |
| 4095 | { |
| 4096 | "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe", |
| 4097 | .u.insns_int = { |
| 4098 | BPF_LD_IMM64(R0, 1), |
| 4099 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 4100 | BPF_ALU64_REG(BPF_XOR, R0, R1), |
| 4101 | BPF_EXIT_INSN(), |
| 4102 | }, |
| 4103 | INTERNAL, |
| 4104 | { }, |
| 4105 | { { 0, 0xfffffffe } }, |
| 4106 | }, |
| 4107 | /* BPF_ALU | BPF_XOR | BPF_K */ |
| 4108 | { |
| 4109 | "ALU_XOR_K: 5 ^ 6 = 3", |
| 4110 | .u.insns_int = { |
| 4111 | BPF_LD_IMM64(R0, 5), |
| 4112 | BPF_ALU32_IMM(BPF_XOR, R0, 6), |
| 4113 | BPF_EXIT_INSN(), |
| 4114 | }, |
| 4115 | INTERNAL, |
| 4116 | { }, |
| 4117 | { { 0, 3 } }, |
| 4118 | }, |
| 4119 | { |
| 4120 | "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe", |
| 4121 | .u.insns_int = { |
| 4122 | BPF_LD_IMM64(R0, 1), |
| 4123 | BPF_ALU32_IMM(BPF_XOR, R0, 0xffffffff), |
| 4124 | BPF_EXIT_INSN(), |
| 4125 | }, |
| 4126 | INTERNAL, |
| 4127 | { }, |
| 4128 | { { 0, 0xfffffffe } }, |
| 4129 | }, |
| 4130 | { |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 4131 | "ALU_XOR_K: Small immediate", |
| 4132 | .u.insns_int = { |
| 4133 | BPF_ALU32_IMM(BPF_MOV, R0, 0x01020304), |
| 4134 | BPF_ALU32_IMM(BPF_XOR, R0, 15), |
| 4135 | BPF_EXIT_INSN(), |
| 4136 | }, |
| 4137 | INTERNAL, |
| 4138 | { }, |
| 4139 | { { 0, 0x0102030b } } |
| 4140 | }, |
| 4141 | { |
| 4142 | "ALU_XOR_K: Large immediate", |
| 4143 | .u.insns_int = { |
| 4144 | BPF_ALU32_IMM(BPF_MOV, R0, 0xf1f2f3f4), |
| 4145 | BPF_ALU32_IMM(BPF_XOR, R0, 0xafbfcfdf), |
| 4146 | BPF_EXIT_INSN(), |
| 4147 | }, |
| 4148 | INTERNAL, |
| 4149 | { }, |
| 4150 | { { 0, 0x5e4d3c2b } } |
| 4151 | }, |
| 4152 | { |
| 4153 | "ALU_XOR_K: Zero extension", |
| 4154 | .u.insns_int = { |
| 4155 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4156 | BPF_LD_IMM64(R1, 0x00000000795b3d1fLL), |
| 4157 | BPF_ALU32_IMM(BPF_XOR, R0, 0xf0f0f0f0), |
| 4158 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 4159 | BPF_MOV32_IMM(R0, 2), |
| 4160 | BPF_EXIT_INSN(), |
| 4161 | BPF_MOV32_IMM(R0, 1), |
| 4162 | BPF_EXIT_INSN(), |
| 4163 | }, |
| 4164 | INTERNAL, |
| 4165 | { }, |
| 4166 | { { 0, 1 } } |
| 4167 | }, |
| 4168 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4169 | "ALU64_XOR_K: 5 ^ 6 = 3", |
| 4170 | .u.insns_int = { |
| 4171 | BPF_LD_IMM64(R0, 5), |
| 4172 | BPF_ALU64_IMM(BPF_XOR, R0, 6), |
| 4173 | BPF_EXIT_INSN(), |
| 4174 | }, |
| 4175 | INTERNAL, |
| 4176 | { }, |
| 4177 | { { 0, 3 } }, |
| 4178 | }, |
| 4179 | { |
Johan Almbladh | e92c813 | 2021-08-09 11:18:18 +0200 | [diff] [blame] | 4180 | "ALU64_XOR_K: 1 ^ 0xffffffff = 0xfffffffe", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4181 | .u.insns_int = { |
| 4182 | BPF_LD_IMM64(R0, 1), |
| 4183 | BPF_ALU64_IMM(BPF_XOR, R0, 0xffffffff), |
| 4184 | BPF_EXIT_INSN(), |
| 4185 | }, |
| 4186 | INTERNAL, |
| 4187 | { }, |
| 4188 | { { 0, 0xfffffffe } }, |
| 4189 | }, |
| 4190 | { |
| 4191 | "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000", |
| 4192 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 4193 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 4194 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4195 | BPF_ALU64_IMM(BPF_XOR, R2, 0x0), |
| 4196 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4197 | BPF_MOV32_IMM(R0, 2), |
| 4198 | BPF_EXIT_INSN(), |
| 4199 | BPF_MOV32_IMM(R0, 1), |
| 4200 | BPF_EXIT_INSN(), |
| 4201 | }, |
| 4202 | INTERNAL, |
| 4203 | { }, |
| 4204 | { { 0, 0x1 } }, |
| 4205 | }, |
| 4206 | { |
| 4207 | "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff", |
| 4208 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 4209 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 4210 | BPF_LD_IMM64(R3, 0xffff00000000ffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4211 | BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), |
| 4212 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4213 | BPF_MOV32_IMM(R0, 2), |
| 4214 | BPF_EXIT_INSN(), |
| 4215 | BPF_MOV32_IMM(R0, 1), |
| 4216 | BPF_EXIT_INSN(), |
| 4217 | }, |
| 4218 | INTERNAL, |
| 4219 | { }, |
| 4220 | { { 0, 0x1 } }, |
| 4221 | }, |
| 4222 | { |
| 4223 | "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff", |
| 4224 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 4225 | BPF_LD_IMM64(R2, 0x0000000000000000LL), |
| 4226 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4227 | BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), |
| 4228 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4229 | BPF_MOV32_IMM(R0, 2), |
| 4230 | BPF_EXIT_INSN(), |
| 4231 | BPF_MOV32_IMM(R0, 1), |
| 4232 | BPF_EXIT_INSN(), |
| 4233 | }, |
| 4234 | INTERNAL, |
| 4235 | { }, |
| 4236 | { { 0, 0x1 } }, |
| 4237 | }, |
Johan Almbladh | ba89bcf | 2021-08-09 11:18:19 +0200 | [diff] [blame] | 4238 | { |
| 4239 | "ALU64_XOR_K: Sign extension 1", |
| 4240 | .u.insns_int = { |
| 4241 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4242 | BPF_LD_IMM64(R1, 0x0123456786a4c2e0LL), |
| 4243 | BPF_ALU64_IMM(BPF_XOR, R0, 0x0f0f0f0f), |
| 4244 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 4245 | BPF_MOV32_IMM(R0, 2), |
| 4246 | BPF_EXIT_INSN(), |
| 4247 | BPF_MOV32_IMM(R0, 1), |
| 4248 | BPF_EXIT_INSN(), |
| 4249 | }, |
| 4250 | INTERNAL, |
| 4251 | { }, |
| 4252 | { { 0, 1 } } |
| 4253 | }, |
| 4254 | { |
| 4255 | "ALU64_XOR_K: Sign extension 2", |
| 4256 | .u.insns_int = { |
| 4257 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4258 | BPF_LD_IMM64(R1, 0xfedcba98795b3d1fLL), |
| 4259 | BPF_ALU64_IMM(BPF_XOR, R0, 0xf0f0f0f0), |
| 4260 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 4261 | BPF_MOV32_IMM(R0, 2), |
| 4262 | BPF_EXIT_INSN(), |
| 4263 | BPF_MOV32_IMM(R0, 1), |
| 4264 | BPF_EXIT_INSN(), |
| 4265 | }, |
| 4266 | INTERNAL, |
| 4267 | { }, |
| 4268 | { { 0, 1 } } |
| 4269 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4270 | /* BPF_ALU | BPF_LSH | BPF_X */ |
| 4271 | { |
| 4272 | "ALU_LSH_X: 1 << 1 = 2", |
| 4273 | .u.insns_int = { |
| 4274 | BPF_LD_IMM64(R0, 1), |
| 4275 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 4276 | BPF_ALU32_REG(BPF_LSH, R0, R1), |
| 4277 | BPF_EXIT_INSN(), |
| 4278 | }, |
| 4279 | INTERNAL, |
| 4280 | { }, |
| 4281 | { { 0, 2 } }, |
| 4282 | }, |
| 4283 | { |
| 4284 | "ALU_LSH_X: 1 << 31 = 0x80000000", |
| 4285 | .u.insns_int = { |
| 4286 | BPF_LD_IMM64(R0, 1), |
| 4287 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 4288 | BPF_ALU32_REG(BPF_LSH, R0, R1), |
| 4289 | BPF_EXIT_INSN(), |
| 4290 | }, |
| 4291 | INTERNAL, |
| 4292 | { }, |
| 4293 | { { 0, 0x80000000 } }, |
| 4294 | }, |
| 4295 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 4296 | "ALU_LSH_X: 0x12345678 << 12 = 0x45678000", |
| 4297 | .u.insns_int = { |
| 4298 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4299 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4300 | BPF_ALU32_REG(BPF_LSH, R0, R1), |
| 4301 | BPF_EXIT_INSN(), |
| 4302 | }, |
| 4303 | INTERNAL, |
| 4304 | { }, |
| 4305 | { { 0, 0x45678000 } } |
| 4306 | }, |
| 4307 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4308 | "ALU64_LSH_X: 1 << 1 = 2", |
| 4309 | .u.insns_int = { |
| 4310 | BPF_LD_IMM64(R0, 1), |
| 4311 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 4312 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4313 | BPF_EXIT_INSN(), |
| 4314 | }, |
| 4315 | INTERNAL, |
| 4316 | { }, |
| 4317 | { { 0, 2 } }, |
| 4318 | }, |
| 4319 | { |
| 4320 | "ALU64_LSH_X: 1 << 31 = 0x80000000", |
| 4321 | .u.insns_int = { |
| 4322 | BPF_LD_IMM64(R0, 1), |
| 4323 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 4324 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4325 | BPF_EXIT_INSN(), |
| 4326 | }, |
| 4327 | INTERNAL, |
| 4328 | { }, |
| 4329 | { { 0, 0x80000000 } }, |
| 4330 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4331 | { |
| 4332 | "ALU64_LSH_X: Shift < 32, low word", |
| 4333 | .u.insns_int = { |
| 4334 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4335 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4336 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4337 | BPF_EXIT_INSN(), |
| 4338 | }, |
| 4339 | INTERNAL, |
| 4340 | { }, |
| 4341 | { { 0, 0xbcdef000 } } |
| 4342 | }, |
| 4343 | { |
| 4344 | "ALU64_LSH_X: Shift < 32, high word", |
| 4345 | .u.insns_int = { |
| 4346 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4347 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4348 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4349 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4350 | BPF_EXIT_INSN(), |
| 4351 | }, |
| 4352 | INTERNAL, |
| 4353 | { }, |
| 4354 | { { 0, 0x3456789a } } |
| 4355 | }, |
| 4356 | { |
| 4357 | "ALU64_LSH_X: Shift > 32, low word", |
| 4358 | .u.insns_int = { |
| 4359 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4360 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4361 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4362 | BPF_EXIT_INSN(), |
| 4363 | }, |
| 4364 | INTERNAL, |
| 4365 | { }, |
| 4366 | { { 0, 0 } } |
| 4367 | }, |
| 4368 | { |
| 4369 | "ALU64_LSH_X: Shift > 32, high word", |
| 4370 | .u.insns_int = { |
| 4371 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4372 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4373 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4374 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4375 | BPF_EXIT_INSN(), |
| 4376 | }, |
| 4377 | INTERNAL, |
| 4378 | { }, |
| 4379 | { { 0, 0x9abcdef0 } } |
| 4380 | }, |
| 4381 | { |
| 4382 | "ALU64_LSH_X: Shift == 32, low word", |
| 4383 | .u.insns_int = { |
| 4384 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4385 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4386 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4387 | BPF_EXIT_INSN(), |
| 4388 | }, |
| 4389 | INTERNAL, |
| 4390 | { }, |
| 4391 | { { 0, 0 } } |
| 4392 | }, |
| 4393 | { |
| 4394 | "ALU64_LSH_X: Shift == 32, high word", |
| 4395 | .u.insns_int = { |
| 4396 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4397 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4398 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4399 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4400 | BPF_EXIT_INSN(), |
| 4401 | }, |
| 4402 | INTERNAL, |
| 4403 | { }, |
| 4404 | { { 0, 0x89abcdef } } |
| 4405 | }, |
| 4406 | { |
| 4407 | "ALU64_LSH_X: Zero shift, low word", |
| 4408 | .u.insns_int = { |
| 4409 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4410 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 4411 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4412 | BPF_EXIT_INSN(), |
| 4413 | }, |
| 4414 | INTERNAL, |
| 4415 | { }, |
| 4416 | { { 0, 0x89abcdef } } |
| 4417 | }, |
| 4418 | { |
| 4419 | "ALU64_LSH_X: Zero shift, high word", |
| 4420 | .u.insns_int = { |
| 4421 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4422 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 4423 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 4424 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4425 | BPF_EXIT_INSN(), |
| 4426 | }, |
| 4427 | INTERNAL, |
| 4428 | { }, |
| 4429 | { { 0, 0x01234567 } } |
| 4430 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4431 | /* BPF_ALU | BPF_LSH | BPF_K */ |
| 4432 | { |
| 4433 | "ALU_LSH_K: 1 << 1 = 2", |
| 4434 | .u.insns_int = { |
| 4435 | BPF_LD_IMM64(R0, 1), |
| 4436 | BPF_ALU32_IMM(BPF_LSH, R0, 1), |
| 4437 | BPF_EXIT_INSN(), |
| 4438 | }, |
| 4439 | INTERNAL, |
| 4440 | { }, |
| 4441 | { { 0, 2 } }, |
| 4442 | }, |
| 4443 | { |
| 4444 | "ALU_LSH_K: 1 << 31 = 0x80000000", |
| 4445 | .u.insns_int = { |
| 4446 | BPF_LD_IMM64(R0, 1), |
| 4447 | BPF_ALU32_IMM(BPF_LSH, R0, 31), |
| 4448 | BPF_EXIT_INSN(), |
| 4449 | }, |
| 4450 | INTERNAL, |
| 4451 | { }, |
| 4452 | { { 0, 0x80000000 } }, |
| 4453 | }, |
| 4454 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 4455 | "ALU_LSH_K: 0x12345678 << 12 = 0x45678000", |
| 4456 | .u.insns_int = { |
| 4457 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4458 | BPF_ALU32_IMM(BPF_LSH, R0, 12), |
| 4459 | BPF_EXIT_INSN(), |
| 4460 | }, |
| 4461 | INTERNAL, |
| 4462 | { }, |
| 4463 | { { 0, 0x45678000 } } |
| 4464 | }, |
| 4465 | { |
| 4466 | "ALU_LSH_K: 0x12345678 << 0 = 0x12345678", |
| 4467 | .u.insns_int = { |
| 4468 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4469 | BPF_ALU32_IMM(BPF_LSH, R0, 0), |
| 4470 | BPF_EXIT_INSN(), |
| 4471 | }, |
| 4472 | INTERNAL, |
| 4473 | { }, |
| 4474 | { { 0, 0x12345678 } } |
| 4475 | }, |
| 4476 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4477 | "ALU64_LSH_K: 1 << 1 = 2", |
| 4478 | .u.insns_int = { |
| 4479 | BPF_LD_IMM64(R0, 1), |
| 4480 | BPF_ALU64_IMM(BPF_LSH, R0, 1), |
| 4481 | BPF_EXIT_INSN(), |
| 4482 | }, |
| 4483 | INTERNAL, |
| 4484 | { }, |
| 4485 | { { 0, 2 } }, |
| 4486 | }, |
| 4487 | { |
| 4488 | "ALU64_LSH_K: 1 << 31 = 0x80000000", |
| 4489 | .u.insns_int = { |
| 4490 | BPF_LD_IMM64(R0, 1), |
| 4491 | BPF_ALU64_IMM(BPF_LSH, R0, 31), |
| 4492 | BPF_EXIT_INSN(), |
| 4493 | }, |
| 4494 | INTERNAL, |
| 4495 | { }, |
| 4496 | { { 0, 0x80000000 } }, |
| 4497 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4498 | { |
| 4499 | "ALU64_LSH_K: Shift < 32, low word", |
| 4500 | .u.insns_int = { |
| 4501 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4502 | BPF_ALU64_IMM(BPF_LSH, R0, 12), |
| 4503 | BPF_EXIT_INSN(), |
| 4504 | }, |
| 4505 | INTERNAL, |
| 4506 | { }, |
| 4507 | { { 0, 0xbcdef000 } } |
| 4508 | }, |
| 4509 | { |
| 4510 | "ALU64_LSH_K: Shift < 32, high word", |
| 4511 | .u.insns_int = { |
| 4512 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4513 | BPF_ALU64_IMM(BPF_LSH, R0, 12), |
| 4514 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4515 | BPF_EXIT_INSN(), |
| 4516 | }, |
| 4517 | INTERNAL, |
| 4518 | { }, |
| 4519 | { { 0, 0x3456789a } } |
| 4520 | }, |
| 4521 | { |
| 4522 | "ALU64_LSH_K: Shift > 32, low word", |
| 4523 | .u.insns_int = { |
| 4524 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4525 | BPF_ALU64_IMM(BPF_LSH, R0, 36), |
| 4526 | BPF_EXIT_INSN(), |
| 4527 | }, |
| 4528 | INTERNAL, |
| 4529 | { }, |
| 4530 | { { 0, 0 } } |
| 4531 | }, |
| 4532 | { |
| 4533 | "ALU64_LSH_K: Shift > 32, high word", |
| 4534 | .u.insns_int = { |
| 4535 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4536 | BPF_ALU64_IMM(BPF_LSH, R0, 36), |
| 4537 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4538 | BPF_EXIT_INSN(), |
| 4539 | }, |
| 4540 | INTERNAL, |
| 4541 | { }, |
| 4542 | { { 0, 0x9abcdef0 } } |
| 4543 | }, |
| 4544 | { |
| 4545 | "ALU64_LSH_K: Shift == 32, low word", |
| 4546 | .u.insns_int = { |
| 4547 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4548 | BPF_ALU64_IMM(BPF_LSH, R0, 32), |
| 4549 | BPF_EXIT_INSN(), |
| 4550 | }, |
| 4551 | INTERNAL, |
| 4552 | { }, |
| 4553 | { { 0, 0 } } |
| 4554 | }, |
| 4555 | { |
| 4556 | "ALU64_LSH_K: Shift == 32, high word", |
| 4557 | .u.insns_int = { |
| 4558 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4559 | BPF_ALU64_IMM(BPF_LSH, R0, 32), |
| 4560 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4561 | BPF_EXIT_INSN(), |
| 4562 | }, |
| 4563 | INTERNAL, |
| 4564 | { }, |
| 4565 | { { 0, 0x89abcdef } } |
| 4566 | }, |
| 4567 | { |
| 4568 | "ALU64_LSH_K: Zero shift", |
| 4569 | .u.insns_int = { |
| 4570 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4571 | BPF_ALU64_IMM(BPF_LSH, R0, 0), |
| 4572 | BPF_EXIT_INSN(), |
| 4573 | }, |
| 4574 | INTERNAL, |
| 4575 | { }, |
| 4576 | { { 0, 0x89abcdef } } |
| 4577 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4578 | /* BPF_ALU | BPF_RSH | BPF_X */ |
| 4579 | { |
| 4580 | "ALU_RSH_X: 2 >> 1 = 1", |
| 4581 | .u.insns_int = { |
| 4582 | BPF_LD_IMM64(R0, 2), |
| 4583 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 4584 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 4585 | BPF_EXIT_INSN(), |
| 4586 | }, |
| 4587 | INTERNAL, |
| 4588 | { }, |
| 4589 | { { 0, 1 } }, |
| 4590 | }, |
| 4591 | { |
| 4592 | "ALU_RSH_X: 0x80000000 >> 31 = 1", |
| 4593 | .u.insns_int = { |
| 4594 | BPF_LD_IMM64(R0, 0x80000000), |
| 4595 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 4596 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 4597 | BPF_EXIT_INSN(), |
| 4598 | }, |
| 4599 | INTERNAL, |
| 4600 | { }, |
| 4601 | { { 0, 1 } }, |
| 4602 | }, |
| 4603 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 4604 | "ALU_RSH_X: 0x12345678 >> 20 = 0x123", |
| 4605 | .u.insns_int = { |
| 4606 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4607 | BPF_ALU32_IMM(BPF_MOV, R1, 20), |
| 4608 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 4609 | BPF_EXIT_INSN(), |
| 4610 | }, |
| 4611 | INTERNAL, |
| 4612 | { }, |
| 4613 | { { 0, 0x123 } } |
| 4614 | }, |
| 4615 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4616 | "ALU64_RSH_X: 2 >> 1 = 1", |
| 4617 | .u.insns_int = { |
| 4618 | BPF_LD_IMM64(R0, 2), |
| 4619 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 4620 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4621 | BPF_EXIT_INSN(), |
| 4622 | }, |
| 4623 | INTERNAL, |
| 4624 | { }, |
| 4625 | { { 0, 1 } }, |
| 4626 | }, |
| 4627 | { |
| 4628 | "ALU64_RSH_X: 0x80000000 >> 31 = 1", |
| 4629 | .u.insns_int = { |
| 4630 | BPF_LD_IMM64(R0, 0x80000000), |
| 4631 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 4632 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4633 | BPF_EXIT_INSN(), |
| 4634 | }, |
| 4635 | INTERNAL, |
| 4636 | { }, |
| 4637 | { { 0, 1 } }, |
| 4638 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4639 | { |
| 4640 | "ALU64_RSH_X: Shift < 32, low word", |
| 4641 | .u.insns_int = { |
| 4642 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4643 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4644 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4645 | BPF_EXIT_INSN(), |
| 4646 | }, |
| 4647 | INTERNAL, |
| 4648 | { }, |
| 4649 | { { 0, 0x56789abc } } |
| 4650 | }, |
| 4651 | { |
| 4652 | "ALU64_RSH_X: Shift < 32, high word", |
| 4653 | .u.insns_int = { |
| 4654 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4655 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4656 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4657 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4658 | BPF_EXIT_INSN(), |
| 4659 | }, |
| 4660 | INTERNAL, |
| 4661 | { }, |
| 4662 | { { 0, 0x00081234 } } |
| 4663 | }, |
| 4664 | { |
| 4665 | "ALU64_RSH_X: Shift > 32, low word", |
| 4666 | .u.insns_int = { |
| 4667 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4668 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4669 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4670 | BPF_EXIT_INSN(), |
| 4671 | }, |
| 4672 | INTERNAL, |
| 4673 | { }, |
| 4674 | { { 0, 0x08123456 } } |
| 4675 | }, |
| 4676 | { |
| 4677 | "ALU64_RSH_X: Shift > 32, high word", |
| 4678 | .u.insns_int = { |
| 4679 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4680 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4681 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4682 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4683 | BPF_EXIT_INSN(), |
| 4684 | }, |
| 4685 | INTERNAL, |
| 4686 | { }, |
| 4687 | { { 0, 0 } } |
| 4688 | }, |
| 4689 | { |
| 4690 | "ALU64_RSH_X: Shift == 32, low word", |
| 4691 | .u.insns_int = { |
| 4692 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4693 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4694 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4695 | BPF_EXIT_INSN(), |
| 4696 | }, |
| 4697 | INTERNAL, |
| 4698 | { }, |
| 4699 | { { 0, 0x81234567 } } |
| 4700 | }, |
| 4701 | { |
| 4702 | "ALU64_RSH_X: Shift == 32, high word", |
| 4703 | .u.insns_int = { |
| 4704 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4705 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4706 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4707 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4708 | BPF_EXIT_INSN(), |
| 4709 | }, |
| 4710 | INTERNAL, |
| 4711 | { }, |
| 4712 | { { 0, 0 } } |
| 4713 | }, |
| 4714 | { |
| 4715 | "ALU64_RSH_X: Zero shift, low word", |
| 4716 | .u.insns_int = { |
| 4717 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4718 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 4719 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4720 | BPF_EXIT_INSN(), |
| 4721 | }, |
| 4722 | INTERNAL, |
| 4723 | { }, |
| 4724 | { { 0, 0x89abcdef } } |
| 4725 | }, |
| 4726 | { |
| 4727 | "ALU64_RSH_X: Zero shift, high word", |
| 4728 | .u.insns_int = { |
| 4729 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4730 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 4731 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 4732 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4733 | BPF_EXIT_INSN(), |
| 4734 | }, |
| 4735 | INTERNAL, |
| 4736 | { }, |
| 4737 | { { 0, 0x81234567 } } |
| 4738 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4739 | /* BPF_ALU | BPF_RSH | BPF_K */ |
| 4740 | { |
| 4741 | "ALU_RSH_K: 2 >> 1 = 1", |
| 4742 | .u.insns_int = { |
| 4743 | BPF_LD_IMM64(R0, 2), |
| 4744 | BPF_ALU32_IMM(BPF_RSH, R0, 1), |
| 4745 | BPF_EXIT_INSN(), |
| 4746 | }, |
| 4747 | INTERNAL, |
| 4748 | { }, |
| 4749 | { { 0, 1 } }, |
| 4750 | }, |
| 4751 | { |
| 4752 | "ALU_RSH_K: 0x80000000 >> 31 = 1", |
| 4753 | .u.insns_int = { |
| 4754 | BPF_LD_IMM64(R0, 0x80000000), |
| 4755 | BPF_ALU32_IMM(BPF_RSH, R0, 31), |
| 4756 | BPF_EXIT_INSN(), |
| 4757 | }, |
| 4758 | INTERNAL, |
| 4759 | { }, |
| 4760 | { { 0, 1 } }, |
| 4761 | }, |
| 4762 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 4763 | "ALU_RSH_K: 0x12345678 >> 20 = 0x123", |
| 4764 | .u.insns_int = { |
| 4765 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4766 | BPF_ALU32_IMM(BPF_RSH, R0, 20), |
| 4767 | BPF_EXIT_INSN(), |
| 4768 | }, |
| 4769 | INTERNAL, |
| 4770 | { }, |
| 4771 | { { 0, 0x123 } } |
| 4772 | }, |
| 4773 | { |
| 4774 | "ALU_RSH_K: 0x12345678 >> 0 = 0x12345678", |
| 4775 | .u.insns_int = { |
| 4776 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12345678), |
| 4777 | BPF_ALU32_IMM(BPF_RSH, R0, 0), |
| 4778 | BPF_EXIT_INSN(), |
| 4779 | }, |
| 4780 | INTERNAL, |
| 4781 | { }, |
| 4782 | { { 0, 0x12345678 } } |
| 4783 | }, |
| 4784 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4785 | "ALU64_RSH_K: 2 >> 1 = 1", |
| 4786 | .u.insns_int = { |
| 4787 | BPF_LD_IMM64(R0, 2), |
| 4788 | BPF_ALU64_IMM(BPF_RSH, R0, 1), |
| 4789 | BPF_EXIT_INSN(), |
| 4790 | }, |
| 4791 | INTERNAL, |
| 4792 | { }, |
| 4793 | { { 0, 1 } }, |
| 4794 | }, |
| 4795 | { |
| 4796 | "ALU64_RSH_K: 0x80000000 >> 31 = 1", |
| 4797 | .u.insns_int = { |
| 4798 | BPF_LD_IMM64(R0, 0x80000000), |
| 4799 | BPF_ALU64_IMM(BPF_RSH, R0, 31), |
| 4800 | BPF_EXIT_INSN(), |
| 4801 | }, |
| 4802 | INTERNAL, |
| 4803 | { }, |
| 4804 | { { 0, 1 } }, |
| 4805 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4806 | { |
| 4807 | "ALU64_RSH_K: Shift < 32, low word", |
| 4808 | .u.insns_int = { |
| 4809 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4810 | BPF_ALU64_IMM(BPF_RSH, R0, 12), |
| 4811 | BPF_EXIT_INSN(), |
| 4812 | }, |
| 4813 | INTERNAL, |
| 4814 | { }, |
| 4815 | { { 0, 0x56789abc } } |
| 4816 | }, |
| 4817 | { |
| 4818 | "ALU64_RSH_K: Shift < 32, high word", |
| 4819 | .u.insns_int = { |
| 4820 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4821 | BPF_ALU64_IMM(BPF_RSH, R0, 12), |
| 4822 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4823 | BPF_EXIT_INSN(), |
| 4824 | }, |
| 4825 | INTERNAL, |
| 4826 | { }, |
| 4827 | { { 0, 0x00081234 } } |
| 4828 | }, |
| 4829 | { |
| 4830 | "ALU64_RSH_K: Shift > 32, low word", |
| 4831 | .u.insns_int = { |
| 4832 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4833 | BPF_ALU64_IMM(BPF_RSH, R0, 36), |
| 4834 | BPF_EXIT_INSN(), |
| 4835 | }, |
| 4836 | INTERNAL, |
| 4837 | { }, |
| 4838 | { { 0, 0x08123456 } } |
| 4839 | }, |
| 4840 | { |
| 4841 | "ALU64_RSH_K: Shift > 32, high word", |
| 4842 | .u.insns_int = { |
| 4843 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4844 | BPF_ALU64_IMM(BPF_RSH, R0, 36), |
| 4845 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4846 | BPF_EXIT_INSN(), |
| 4847 | }, |
| 4848 | INTERNAL, |
| 4849 | { }, |
| 4850 | { { 0, 0 } } |
| 4851 | }, |
| 4852 | { |
| 4853 | "ALU64_RSH_K: Shift == 32, low word", |
| 4854 | .u.insns_int = { |
| 4855 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4856 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4857 | BPF_EXIT_INSN(), |
| 4858 | }, |
| 4859 | INTERNAL, |
| 4860 | { }, |
| 4861 | { { 0, 0x81234567 } } |
| 4862 | }, |
| 4863 | { |
| 4864 | "ALU64_RSH_K: Shift == 32, high word", |
| 4865 | .u.insns_int = { |
| 4866 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4867 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4868 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4869 | BPF_EXIT_INSN(), |
| 4870 | }, |
| 4871 | INTERNAL, |
| 4872 | { }, |
| 4873 | { { 0, 0 } } |
| 4874 | }, |
| 4875 | { |
| 4876 | "ALU64_RSH_K: Zero shift", |
| 4877 | .u.insns_int = { |
| 4878 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4879 | BPF_ALU64_IMM(BPF_RSH, R0, 0), |
| 4880 | BPF_EXIT_INSN(), |
| 4881 | }, |
| 4882 | INTERNAL, |
| 4883 | { }, |
| 4884 | { { 0, 0x89abcdef } } |
| 4885 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4886 | /* BPF_ALU | BPF_ARSH | BPF_X */ |
| 4887 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 4888 | "ALU32_ARSH_X: -1234 >> 7 = -10", |
| 4889 | .u.insns_int = { |
| 4890 | BPF_ALU32_IMM(BPF_MOV, R0, -1234), |
| 4891 | BPF_ALU32_IMM(BPF_MOV, R1, 7), |
| 4892 | BPF_ALU32_REG(BPF_ARSH, R0, R1), |
| 4893 | BPF_EXIT_INSN(), |
| 4894 | }, |
| 4895 | INTERNAL, |
| 4896 | { }, |
| 4897 | { { 0, -10 } } |
| 4898 | }, |
| 4899 | { |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4900 | "ALU64_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4901 | .u.insns_int = { |
| 4902 | BPF_LD_IMM64(R0, 0xff00ff0000000000LL), |
| 4903 | BPF_ALU32_IMM(BPF_MOV, R1, 40), |
| 4904 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4905 | BPF_EXIT_INSN(), |
| 4906 | }, |
| 4907 | INTERNAL, |
| 4908 | { }, |
| 4909 | { { 0, 0xffff00ff } }, |
| 4910 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 4911 | { |
| 4912 | "ALU64_ARSH_X: Shift < 32, low word", |
| 4913 | .u.insns_int = { |
| 4914 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4915 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4916 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4917 | BPF_EXIT_INSN(), |
| 4918 | }, |
| 4919 | INTERNAL, |
| 4920 | { }, |
| 4921 | { { 0, 0x56789abc } } |
| 4922 | }, |
| 4923 | { |
| 4924 | "ALU64_ARSH_X: Shift < 32, high word", |
| 4925 | .u.insns_int = { |
| 4926 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4927 | BPF_ALU32_IMM(BPF_MOV, R1, 12), |
| 4928 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4929 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4930 | BPF_EXIT_INSN(), |
| 4931 | }, |
| 4932 | INTERNAL, |
| 4933 | { }, |
| 4934 | { { 0, 0xfff81234 } } |
| 4935 | }, |
| 4936 | { |
| 4937 | "ALU64_ARSH_X: Shift > 32, low word", |
| 4938 | .u.insns_int = { |
| 4939 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4940 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4941 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4942 | BPF_EXIT_INSN(), |
| 4943 | }, |
| 4944 | INTERNAL, |
| 4945 | { }, |
| 4946 | { { 0, 0xf8123456 } } |
| 4947 | }, |
| 4948 | { |
| 4949 | "ALU64_ARSH_X: Shift > 32, high word", |
| 4950 | .u.insns_int = { |
| 4951 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4952 | BPF_ALU32_IMM(BPF_MOV, R1, 36), |
| 4953 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4954 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4955 | BPF_EXIT_INSN(), |
| 4956 | }, |
| 4957 | INTERNAL, |
| 4958 | { }, |
| 4959 | { { 0, -1 } } |
| 4960 | }, |
| 4961 | { |
| 4962 | "ALU64_ARSH_X: Shift == 32, low word", |
| 4963 | .u.insns_int = { |
| 4964 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4965 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4966 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4967 | BPF_EXIT_INSN(), |
| 4968 | }, |
| 4969 | INTERNAL, |
| 4970 | { }, |
| 4971 | { { 0, 0x81234567 } } |
| 4972 | }, |
| 4973 | { |
| 4974 | "ALU64_ARSH_X: Shift == 32, high word", |
| 4975 | .u.insns_int = { |
| 4976 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4977 | BPF_ALU32_IMM(BPF_MOV, R1, 32), |
| 4978 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4979 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 4980 | BPF_EXIT_INSN(), |
| 4981 | }, |
| 4982 | INTERNAL, |
| 4983 | { }, |
| 4984 | { { 0, -1 } } |
| 4985 | }, |
| 4986 | { |
| 4987 | "ALU64_ARSH_X: Zero shift, low word", |
| 4988 | .u.insns_int = { |
| 4989 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 4990 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 4991 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4992 | BPF_EXIT_INSN(), |
| 4993 | }, |
| 4994 | INTERNAL, |
| 4995 | { }, |
| 4996 | { { 0, 0x89abcdef } } |
| 4997 | }, |
| 4998 | { |
| 4999 | "ALU64_ARSH_X: Zero shift, high word", |
| 5000 | .u.insns_int = { |
| 5001 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5002 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 5003 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 5004 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 5005 | BPF_EXIT_INSN(), |
| 5006 | }, |
| 5007 | INTERNAL, |
| 5008 | { }, |
| 5009 | { { 0, 0x81234567 } } |
| 5010 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5011 | /* BPF_ALU | BPF_ARSH | BPF_K */ |
| 5012 | { |
Johan Almbladh | 0f2fca1 | 2021-08-09 11:18:20 +0200 | [diff] [blame] | 5013 | "ALU32_ARSH_K: -1234 >> 7 = -10", |
| 5014 | .u.insns_int = { |
| 5015 | BPF_ALU32_IMM(BPF_MOV, R0, -1234), |
| 5016 | BPF_ALU32_IMM(BPF_ARSH, R0, 7), |
| 5017 | BPF_EXIT_INSN(), |
| 5018 | }, |
| 5019 | INTERNAL, |
| 5020 | { }, |
| 5021 | { { 0, -10 } } |
| 5022 | }, |
| 5023 | { |
| 5024 | "ALU32_ARSH_K: -1234 >> 0 = -1234", |
| 5025 | .u.insns_int = { |
| 5026 | BPF_ALU32_IMM(BPF_MOV, R0, -1234), |
| 5027 | BPF_ALU32_IMM(BPF_ARSH, R0, 0), |
| 5028 | BPF_EXIT_INSN(), |
| 5029 | }, |
| 5030 | INTERNAL, |
| 5031 | { }, |
| 5032 | { { 0, -1234 } } |
| 5033 | }, |
| 5034 | { |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 5035 | "ALU64_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5036 | .u.insns_int = { |
| 5037 | BPF_LD_IMM64(R0, 0xff00ff0000000000LL), |
| 5038 | BPF_ALU64_IMM(BPF_ARSH, R0, 40), |
| 5039 | BPF_EXIT_INSN(), |
| 5040 | }, |
| 5041 | INTERNAL, |
| 5042 | { }, |
| 5043 | { { 0, 0xffff00ff } }, |
| 5044 | }, |
Johan Almbladh | 3b9890e | 2021-08-09 11:18:21 +0200 | [diff] [blame] | 5045 | { |
| 5046 | "ALU64_ARSH_K: Shift < 32, low word", |
| 5047 | .u.insns_int = { |
| 5048 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5049 | BPF_ALU64_IMM(BPF_RSH, R0, 12), |
| 5050 | BPF_EXIT_INSN(), |
| 5051 | }, |
| 5052 | INTERNAL, |
| 5053 | { }, |
| 5054 | { { 0, 0x56789abc } } |
| 5055 | }, |
| 5056 | { |
| 5057 | "ALU64_ARSH_K: Shift < 32, high word", |
| 5058 | .u.insns_int = { |
| 5059 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5060 | BPF_ALU64_IMM(BPF_ARSH, R0, 12), |
| 5061 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 5062 | BPF_EXIT_INSN(), |
| 5063 | }, |
| 5064 | INTERNAL, |
| 5065 | { }, |
| 5066 | { { 0, 0xfff81234 } } |
| 5067 | }, |
| 5068 | { |
| 5069 | "ALU64_ARSH_K: Shift > 32, low word", |
| 5070 | .u.insns_int = { |
| 5071 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5072 | BPF_ALU64_IMM(BPF_ARSH, R0, 36), |
| 5073 | BPF_EXIT_INSN(), |
| 5074 | }, |
| 5075 | INTERNAL, |
| 5076 | { }, |
| 5077 | { { 0, 0xf8123456 } } |
| 5078 | }, |
| 5079 | { |
| 5080 | "ALU64_ARSH_K: Shift > 32, high word", |
| 5081 | .u.insns_int = { |
| 5082 | BPF_LD_IMM64(R0, 0xf123456789abcdefLL), |
| 5083 | BPF_ALU64_IMM(BPF_ARSH, R0, 36), |
| 5084 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 5085 | BPF_EXIT_INSN(), |
| 5086 | }, |
| 5087 | INTERNAL, |
| 5088 | { }, |
| 5089 | { { 0, -1 } } |
| 5090 | }, |
| 5091 | { |
| 5092 | "ALU64_ARSH_K: Shift == 32, low word", |
| 5093 | .u.insns_int = { |
| 5094 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5095 | BPF_ALU64_IMM(BPF_ARSH, R0, 32), |
| 5096 | BPF_EXIT_INSN(), |
| 5097 | }, |
| 5098 | INTERNAL, |
| 5099 | { }, |
| 5100 | { { 0, 0x81234567 } } |
| 5101 | }, |
| 5102 | { |
| 5103 | "ALU64_ARSH_K: Shift == 32, high word", |
| 5104 | .u.insns_int = { |
| 5105 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5106 | BPF_ALU64_IMM(BPF_ARSH, R0, 32), |
| 5107 | BPF_ALU64_IMM(BPF_RSH, R0, 32), |
| 5108 | BPF_EXIT_INSN(), |
| 5109 | }, |
| 5110 | INTERNAL, |
| 5111 | { }, |
| 5112 | { { 0, -1 } } |
| 5113 | }, |
| 5114 | { |
| 5115 | "ALU64_ARSH_K: Zero shoft", |
| 5116 | .u.insns_int = { |
| 5117 | BPF_LD_IMM64(R0, 0x8123456789abcdefLL), |
| 5118 | BPF_ALU64_IMM(BPF_ARSH, R0, 0), |
| 5119 | BPF_EXIT_INSN(), |
| 5120 | }, |
| 5121 | INTERNAL, |
| 5122 | { }, |
| 5123 | { { 0, 0x89abcdef } } |
| 5124 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5125 | /* BPF_ALU | BPF_NEG */ |
| 5126 | { |
| 5127 | "ALU_NEG: -(3) = -3", |
| 5128 | .u.insns_int = { |
| 5129 | BPF_ALU32_IMM(BPF_MOV, R0, 3), |
| 5130 | BPF_ALU32_IMM(BPF_NEG, R0, 0), |
| 5131 | BPF_EXIT_INSN(), |
| 5132 | }, |
| 5133 | INTERNAL, |
| 5134 | { }, |
| 5135 | { { 0, -3 } }, |
| 5136 | }, |
| 5137 | { |
| 5138 | "ALU_NEG: -(-3) = 3", |
| 5139 | .u.insns_int = { |
| 5140 | BPF_ALU32_IMM(BPF_MOV, R0, -3), |
| 5141 | BPF_ALU32_IMM(BPF_NEG, R0, 0), |
| 5142 | BPF_EXIT_INSN(), |
| 5143 | }, |
| 5144 | INTERNAL, |
| 5145 | { }, |
| 5146 | { { 0, 3 } }, |
| 5147 | }, |
| 5148 | { |
| 5149 | "ALU64_NEG: -(3) = -3", |
| 5150 | .u.insns_int = { |
| 5151 | BPF_LD_IMM64(R0, 3), |
| 5152 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 5153 | BPF_EXIT_INSN(), |
| 5154 | }, |
| 5155 | INTERNAL, |
| 5156 | { }, |
| 5157 | { { 0, -3 } }, |
| 5158 | }, |
| 5159 | { |
| 5160 | "ALU64_NEG: -(-3) = 3", |
| 5161 | .u.insns_int = { |
| 5162 | BPF_LD_IMM64(R0, -3), |
| 5163 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 5164 | BPF_EXIT_INSN(), |
| 5165 | }, |
| 5166 | INTERNAL, |
| 5167 | { }, |
| 5168 | { { 0, 3 } }, |
| 5169 | }, |
| 5170 | /* BPF_ALU | BPF_END | BPF_FROM_BE */ |
| 5171 | { |
| 5172 | "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef", |
| 5173 | .u.insns_int = { |
| 5174 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5175 | BPF_ENDIAN(BPF_FROM_BE, R0, 16), |
| 5176 | BPF_EXIT_INSN(), |
| 5177 | }, |
| 5178 | INTERNAL, |
| 5179 | { }, |
| 5180 | { { 0, cpu_to_be16(0xcdef) } }, |
| 5181 | }, |
| 5182 | { |
| 5183 | "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef", |
| 5184 | .u.insns_int = { |
| 5185 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5186 | BPF_ENDIAN(BPF_FROM_BE, R0, 32), |
Xi Wang | ba29bec | 2015-07-08 14:00:56 -0700 | [diff] [blame] | 5187 | BPF_ALU64_REG(BPF_MOV, R1, R0), |
| 5188 | BPF_ALU64_IMM(BPF_RSH, R1, 32), |
| 5189 | BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */ |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5190 | BPF_EXIT_INSN(), |
| 5191 | }, |
| 5192 | INTERNAL, |
| 5193 | { }, |
| 5194 | { { 0, cpu_to_be32(0x89abcdef) } }, |
| 5195 | }, |
| 5196 | { |
| 5197 | "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef", |
| 5198 | .u.insns_int = { |
| 5199 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5200 | BPF_ENDIAN(BPF_FROM_BE, R0, 64), |
| 5201 | BPF_EXIT_INSN(), |
| 5202 | }, |
| 5203 | INTERNAL, |
| 5204 | { }, |
| 5205 | { { 0, (u32) cpu_to_be64(0x0123456789abcdefLL) } }, |
| 5206 | }, |
| 5207 | /* BPF_ALU | BPF_END | BPF_FROM_LE */ |
| 5208 | { |
| 5209 | "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd", |
| 5210 | .u.insns_int = { |
| 5211 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5212 | BPF_ENDIAN(BPF_FROM_LE, R0, 16), |
| 5213 | BPF_EXIT_INSN(), |
| 5214 | }, |
| 5215 | INTERNAL, |
| 5216 | { }, |
| 5217 | { { 0, cpu_to_le16(0xcdef) } }, |
| 5218 | }, |
| 5219 | { |
| 5220 | "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89", |
| 5221 | .u.insns_int = { |
| 5222 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5223 | BPF_ENDIAN(BPF_FROM_LE, R0, 32), |
Xi Wang | ba29bec | 2015-07-08 14:00:56 -0700 | [diff] [blame] | 5224 | BPF_ALU64_REG(BPF_MOV, R1, R0), |
| 5225 | BPF_ALU64_IMM(BPF_RSH, R1, 32), |
| 5226 | BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */ |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5227 | BPF_EXIT_INSN(), |
| 5228 | }, |
| 5229 | INTERNAL, |
| 5230 | { }, |
| 5231 | { { 0, cpu_to_le32(0x89abcdef) } }, |
| 5232 | }, |
| 5233 | { |
| 5234 | "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301", |
| 5235 | .u.insns_int = { |
| 5236 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 5237 | BPF_ENDIAN(BPF_FROM_LE, R0, 64), |
| 5238 | BPF_EXIT_INSN(), |
| 5239 | }, |
| 5240 | INTERNAL, |
| 5241 | { }, |
| 5242 | { { 0, (u32) cpu_to_le64(0x0123456789abcdefLL) } }, |
| 5243 | }, |
| 5244 | /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */ |
| 5245 | { |
| 5246 | "ST_MEM_B: Store/Load byte: max negative", |
| 5247 | .u.insns_int = { |
| 5248 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5249 | BPF_ST_MEM(BPF_B, R10, -40, 0xff), |
| 5250 | BPF_LDX_MEM(BPF_B, R0, R10, -40), |
| 5251 | BPF_EXIT_INSN(), |
| 5252 | }, |
| 5253 | INTERNAL, |
| 5254 | { }, |
| 5255 | { { 0, 0xff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5256 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5257 | }, |
| 5258 | { |
| 5259 | "ST_MEM_B: Store/Load byte: max positive", |
| 5260 | .u.insns_int = { |
| 5261 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5262 | BPF_ST_MEM(BPF_H, R10, -40, 0x7f), |
| 5263 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 5264 | BPF_EXIT_INSN(), |
| 5265 | }, |
| 5266 | INTERNAL, |
| 5267 | { }, |
| 5268 | { { 0, 0x7f } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5269 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5270 | }, |
| 5271 | { |
| 5272 | "STX_MEM_B: Store/Load byte: max negative", |
| 5273 | .u.insns_int = { |
| 5274 | BPF_LD_IMM64(R0, 0), |
| 5275 | BPF_LD_IMM64(R1, 0xffLL), |
| 5276 | BPF_STX_MEM(BPF_B, R10, R1, -40), |
| 5277 | BPF_LDX_MEM(BPF_B, R0, R10, -40), |
| 5278 | BPF_EXIT_INSN(), |
| 5279 | }, |
| 5280 | INTERNAL, |
| 5281 | { }, |
| 5282 | { { 0, 0xff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5283 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5284 | }, |
| 5285 | { |
| 5286 | "ST_MEM_H: Store/Load half word: max negative", |
| 5287 | .u.insns_int = { |
| 5288 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5289 | BPF_ST_MEM(BPF_H, R10, -40, 0xffff), |
| 5290 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 5291 | BPF_EXIT_INSN(), |
| 5292 | }, |
| 5293 | INTERNAL, |
| 5294 | { }, |
| 5295 | { { 0, 0xffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5296 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5297 | }, |
| 5298 | { |
| 5299 | "ST_MEM_H: Store/Load half word: max positive", |
| 5300 | .u.insns_int = { |
| 5301 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5302 | BPF_ST_MEM(BPF_H, R10, -40, 0x7fff), |
| 5303 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 5304 | BPF_EXIT_INSN(), |
| 5305 | }, |
| 5306 | INTERNAL, |
| 5307 | { }, |
| 5308 | { { 0, 0x7fff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5309 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5310 | }, |
| 5311 | { |
| 5312 | "STX_MEM_H: Store/Load half word: max negative", |
| 5313 | .u.insns_int = { |
| 5314 | BPF_LD_IMM64(R0, 0), |
| 5315 | BPF_LD_IMM64(R1, 0xffffLL), |
| 5316 | BPF_STX_MEM(BPF_H, R10, R1, -40), |
| 5317 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 5318 | BPF_EXIT_INSN(), |
| 5319 | }, |
| 5320 | INTERNAL, |
| 5321 | { }, |
| 5322 | { { 0, 0xffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5323 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5324 | }, |
| 5325 | { |
| 5326 | "ST_MEM_W: Store/Load word: max negative", |
| 5327 | .u.insns_int = { |
| 5328 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5329 | BPF_ST_MEM(BPF_W, R10, -40, 0xffffffff), |
| 5330 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 5331 | BPF_EXIT_INSN(), |
| 5332 | }, |
| 5333 | INTERNAL, |
| 5334 | { }, |
| 5335 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5336 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5337 | }, |
| 5338 | { |
| 5339 | "ST_MEM_W: Store/Load word: max positive", |
| 5340 | .u.insns_int = { |
| 5341 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5342 | BPF_ST_MEM(BPF_W, R10, -40, 0x7fffffff), |
| 5343 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 5344 | BPF_EXIT_INSN(), |
| 5345 | }, |
| 5346 | INTERNAL, |
| 5347 | { }, |
| 5348 | { { 0, 0x7fffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5349 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5350 | }, |
| 5351 | { |
| 5352 | "STX_MEM_W: Store/Load word: max negative", |
| 5353 | .u.insns_int = { |
| 5354 | BPF_LD_IMM64(R0, 0), |
| 5355 | BPF_LD_IMM64(R1, 0xffffffffLL), |
| 5356 | BPF_STX_MEM(BPF_W, R10, R1, -40), |
| 5357 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 5358 | BPF_EXIT_INSN(), |
| 5359 | }, |
| 5360 | INTERNAL, |
| 5361 | { }, |
| 5362 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5363 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5364 | }, |
| 5365 | { |
| 5366 | "ST_MEM_DW: Store/Load double word: max negative", |
| 5367 | .u.insns_int = { |
| 5368 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5369 | BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), |
| 5370 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 5371 | BPF_EXIT_INSN(), |
| 5372 | }, |
| 5373 | INTERNAL, |
| 5374 | { }, |
| 5375 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5376 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5377 | }, |
| 5378 | { |
| 5379 | "ST_MEM_DW: Store/Load double word: max negative 2", |
| 5380 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 5381 | BPF_LD_IMM64(R2, 0xffff00000000ffffLL), |
| 5382 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5383 | BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), |
| 5384 | BPF_LDX_MEM(BPF_DW, R2, R10, -40), |
| 5385 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 5386 | BPF_MOV32_IMM(R0, 2), |
| 5387 | BPF_EXIT_INSN(), |
| 5388 | BPF_MOV32_IMM(R0, 1), |
| 5389 | BPF_EXIT_INSN(), |
| 5390 | }, |
| 5391 | INTERNAL, |
| 5392 | { }, |
| 5393 | { { 0, 0x1 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5394 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5395 | }, |
| 5396 | { |
| 5397 | "ST_MEM_DW: Store/Load double word: max positive", |
| 5398 | .u.insns_int = { |
| 5399 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5400 | BPF_ST_MEM(BPF_DW, R10, -40, 0x7fffffff), |
| 5401 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 5402 | BPF_EXIT_INSN(), |
| 5403 | }, |
| 5404 | INTERNAL, |
| 5405 | { }, |
| 5406 | { { 0, 0x7fffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5407 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5408 | }, |
| 5409 | { |
| 5410 | "STX_MEM_DW: Store/Load double word: max negative", |
| 5411 | .u.insns_int = { |
| 5412 | BPF_LD_IMM64(R0, 0), |
| 5413 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
Johan Almbladh | ae7f470 | 2021-07-21 12:40:58 +0200 | [diff] [blame] | 5414 | BPF_STX_MEM(BPF_DW, R10, R1, -40), |
| 5415 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5416 | BPF_EXIT_INSN(), |
| 5417 | }, |
| 5418 | INTERNAL, |
| 5419 | { }, |
| 5420 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5421 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5422 | }, |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5423 | /* BPF_STX | BPF_ATOMIC | BPF_W/DW */ |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5424 | { |
| 5425 | "STX_XADD_W: Test: 0x12 + 0x10 = 0x22", |
| 5426 | .u.insns_int = { |
| 5427 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5428 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5429 | BPF_ATOMIC_OP(BPF_W, BPF_ADD, R10, R0, -40), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5430 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 5431 | BPF_EXIT_INSN(), |
| 5432 | }, |
| 5433 | INTERNAL, |
| 5434 | { }, |
| 5435 | { { 0, 0x22 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5436 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5437 | }, |
| 5438 | { |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5439 | "STX_XADD_W: Test side-effects, r10: 0x12 + 0x10 = 0x22", |
| 5440 | .u.insns_int = { |
| 5441 | BPF_ALU64_REG(BPF_MOV, R1, R10), |
| 5442 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5443 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5444 | BPF_ATOMIC_OP(BPF_W, BPF_ADD, R10, R0, -40), |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5445 | BPF_ALU64_REG(BPF_MOV, R0, R10), |
| 5446 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 5447 | BPF_EXIT_INSN(), |
| 5448 | }, |
| 5449 | INTERNAL, |
| 5450 | { }, |
| 5451 | { { 0, 0 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5452 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5453 | }, |
| 5454 | { |
| 5455 | "STX_XADD_W: Test side-effects, r0: 0x12 + 0x10 = 0x22", |
| 5456 | .u.insns_int = { |
| 5457 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5458 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5459 | BPF_ATOMIC_OP(BPF_W, BPF_ADD, R10, R0, -40), |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5460 | BPF_EXIT_INSN(), |
| 5461 | }, |
| 5462 | INTERNAL, |
| 5463 | { }, |
| 5464 | { { 0, 0x12 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5465 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5466 | }, |
| 5467 | { |
| 5468 | "STX_XADD_W: X + 1 + 1 + 1 + ...", |
| 5469 | { }, |
| 5470 | INTERNAL, |
| 5471 | { }, |
| 5472 | { { 0, 4134 } }, |
| 5473 | .fill_helper = bpf_fill_stxw, |
| 5474 | }, |
| 5475 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5476 | "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22", |
| 5477 | .u.insns_int = { |
| 5478 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5479 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5480 | BPF_ATOMIC_OP(BPF_DW, BPF_ADD, R10, R0, -40), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5481 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 5482 | BPF_EXIT_INSN(), |
| 5483 | }, |
| 5484 | INTERNAL, |
| 5485 | { }, |
| 5486 | { { 0, 0x22 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5487 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 5488 | }, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5489 | { |
| 5490 | "STX_XADD_DW: Test side-effects, r10: 0x12 + 0x10 = 0x22", |
| 5491 | .u.insns_int = { |
| 5492 | BPF_ALU64_REG(BPF_MOV, R1, R10), |
| 5493 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5494 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5495 | BPF_ATOMIC_OP(BPF_DW, BPF_ADD, R10, R0, -40), |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5496 | BPF_ALU64_REG(BPF_MOV, R0, R10), |
| 5497 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 5498 | BPF_EXIT_INSN(), |
| 5499 | }, |
| 5500 | INTERNAL, |
| 5501 | { }, |
| 5502 | { { 0, 0 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5503 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5504 | }, |
| 5505 | { |
| 5506 | "STX_XADD_DW: Test side-effects, r0: 0x12 + 0x10 = 0x22", |
| 5507 | .u.insns_int = { |
| 5508 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 5509 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
Brendan Jackman | 91c960b | 2021-01-14 18:17:44 +0000 | [diff] [blame] | 5510 | BPF_ATOMIC_OP(BPF_DW, BPF_ADD, R10, R0, -40), |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5511 | BPF_EXIT_INSN(), |
| 5512 | }, |
| 5513 | INTERNAL, |
| 5514 | { }, |
| 5515 | { { 0, 0x12 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5516 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 5517 | }, |
| 5518 | { |
| 5519 | "STX_XADD_DW: X + 1 + 1 + 1 + ...", |
| 5520 | { }, |
| 5521 | INTERNAL, |
| 5522 | { }, |
| 5523 | { { 0, 4134 } }, |
| 5524 | .fill_helper = bpf_fill_stxdw, |
| 5525 | }, |
Johan Almbladh | b55dfa8 | 2021-08-09 11:18:16 +0200 | [diff] [blame] | 5526 | /* BPF_JMP32 | BPF_JEQ | BPF_K */ |
| 5527 | { |
| 5528 | "JMP32_JEQ_K: Small immediate", |
| 5529 | .u.insns_int = { |
| 5530 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5531 | BPF_JMP32_IMM(BPF_JEQ, R0, 321, 1), |
| 5532 | BPF_JMP32_IMM(BPF_JEQ, R0, 123, 1), |
| 5533 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5534 | BPF_EXIT_INSN(), |
| 5535 | }, |
| 5536 | INTERNAL, |
| 5537 | { }, |
| 5538 | { { 0, 123 } } |
| 5539 | }, |
| 5540 | { |
| 5541 | "JMP32_JEQ_K: Large immediate", |
| 5542 | .u.insns_int = { |
| 5543 | BPF_ALU32_IMM(BPF_MOV, R0, 12345678), |
| 5544 | BPF_JMP32_IMM(BPF_JEQ, R0, 12345678 & 0xffff, 1), |
| 5545 | BPF_JMP32_IMM(BPF_JEQ, R0, 12345678, 1), |
| 5546 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5547 | BPF_EXIT_INSN(), |
| 5548 | }, |
| 5549 | INTERNAL, |
| 5550 | { }, |
| 5551 | { { 0, 12345678 } } |
| 5552 | }, |
| 5553 | { |
| 5554 | "JMP32_JEQ_K: negative immediate", |
| 5555 | .u.insns_int = { |
| 5556 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5557 | BPF_JMP32_IMM(BPF_JEQ, R0, 123, 1), |
| 5558 | BPF_JMP32_IMM(BPF_JEQ, R0, -123, 1), |
| 5559 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5560 | BPF_EXIT_INSN(), |
| 5561 | }, |
| 5562 | INTERNAL, |
| 5563 | { }, |
| 5564 | { { 0, -123 } } |
| 5565 | }, |
| 5566 | /* BPF_JMP32 | BPF_JEQ | BPF_X */ |
| 5567 | { |
| 5568 | "JMP32_JEQ_X", |
| 5569 | .u.insns_int = { |
| 5570 | BPF_ALU32_IMM(BPF_MOV, R0, 1234), |
| 5571 | BPF_ALU32_IMM(BPF_MOV, R1, 4321), |
| 5572 | BPF_JMP32_REG(BPF_JEQ, R0, R1, 2), |
| 5573 | BPF_ALU32_IMM(BPF_MOV, R1, 1234), |
| 5574 | BPF_JMP32_REG(BPF_JEQ, R0, R1, 1), |
| 5575 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5576 | BPF_EXIT_INSN(), |
| 5577 | }, |
| 5578 | INTERNAL, |
| 5579 | { }, |
| 5580 | { { 0, 1234 } } |
| 5581 | }, |
| 5582 | /* BPF_JMP32 | BPF_JNE | BPF_K */ |
| 5583 | { |
| 5584 | "JMP32_JNE_K: Small immediate", |
| 5585 | .u.insns_int = { |
| 5586 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5587 | BPF_JMP32_IMM(BPF_JNE, R0, 123, 1), |
| 5588 | BPF_JMP32_IMM(BPF_JNE, R0, 321, 1), |
| 5589 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5590 | BPF_EXIT_INSN(), |
| 5591 | }, |
| 5592 | INTERNAL, |
| 5593 | { }, |
| 5594 | { { 0, 123 } } |
| 5595 | }, |
| 5596 | { |
| 5597 | "JMP32_JNE_K: Large immediate", |
| 5598 | .u.insns_int = { |
| 5599 | BPF_ALU32_IMM(BPF_MOV, R0, 12345678), |
| 5600 | BPF_JMP32_IMM(BPF_JNE, R0, 12345678, 1), |
| 5601 | BPF_JMP32_IMM(BPF_JNE, R0, 12345678 & 0xffff, 1), |
| 5602 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5603 | BPF_EXIT_INSN(), |
| 5604 | }, |
| 5605 | INTERNAL, |
| 5606 | { }, |
| 5607 | { { 0, 12345678 } } |
| 5608 | }, |
| 5609 | { |
| 5610 | "JMP32_JNE_K: negative immediate", |
| 5611 | .u.insns_int = { |
| 5612 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5613 | BPF_JMP32_IMM(BPF_JNE, R0, -123, 1), |
| 5614 | BPF_JMP32_IMM(BPF_JNE, R0, 123, 1), |
| 5615 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5616 | BPF_EXIT_INSN(), |
| 5617 | }, |
| 5618 | INTERNAL, |
| 5619 | { }, |
| 5620 | { { 0, -123 } } |
| 5621 | }, |
| 5622 | /* BPF_JMP32 | BPF_JNE | BPF_X */ |
| 5623 | { |
| 5624 | "JMP32_JNE_X", |
| 5625 | .u.insns_int = { |
| 5626 | BPF_ALU32_IMM(BPF_MOV, R0, 1234), |
| 5627 | BPF_ALU32_IMM(BPF_MOV, R1, 1234), |
| 5628 | BPF_JMP32_REG(BPF_JNE, R0, R1, 2), |
| 5629 | BPF_ALU32_IMM(BPF_MOV, R1, 4321), |
| 5630 | BPF_JMP32_REG(BPF_JNE, R0, R1, 1), |
| 5631 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5632 | BPF_EXIT_INSN(), |
| 5633 | }, |
| 5634 | INTERNAL, |
| 5635 | { }, |
| 5636 | { { 0, 1234 } } |
| 5637 | }, |
| 5638 | /* BPF_JMP32 | BPF_JSET | BPF_K */ |
| 5639 | { |
| 5640 | "JMP32_JSET_K: Small immediate", |
| 5641 | .u.insns_int = { |
| 5642 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 5643 | BPF_JMP32_IMM(BPF_JSET, R0, 2, 1), |
| 5644 | BPF_JMP32_IMM(BPF_JSET, R0, 3, 1), |
| 5645 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5646 | BPF_EXIT_INSN(), |
| 5647 | }, |
| 5648 | INTERNAL, |
| 5649 | { }, |
| 5650 | { { 0, 1 } } |
| 5651 | }, |
| 5652 | { |
| 5653 | "JMP32_JSET_K: Large immediate", |
| 5654 | .u.insns_int = { |
| 5655 | BPF_ALU32_IMM(BPF_MOV, R0, 0x40000000), |
| 5656 | BPF_JMP32_IMM(BPF_JSET, R0, 0x3fffffff, 1), |
| 5657 | BPF_JMP32_IMM(BPF_JSET, R0, 0x60000000, 1), |
| 5658 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5659 | BPF_EXIT_INSN(), |
| 5660 | }, |
| 5661 | INTERNAL, |
| 5662 | { }, |
| 5663 | { { 0, 0x40000000 } } |
| 5664 | }, |
| 5665 | { |
| 5666 | "JMP32_JSET_K: negative immediate", |
| 5667 | .u.insns_int = { |
| 5668 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5669 | BPF_JMP32_IMM(BPF_JSET, R0, -1, 1), |
| 5670 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5671 | BPF_EXIT_INSN(), |
| 5672 | }, |
| 5673 | INTERNAL, |
| 5674 | { }, |
| 5675 | { { 0, -123 } } |
| 5676 | }, |
| 5677 | /* BPF_JMP32 | BPF_JSET | BPF_X */ |
| 5678 | { |
| 5679 | "JMP32_JSET_X", |
| 5680 | .u.insns_int = { |
| 5681 | BPF_ALU32_IMM(BPF_MOV, R0, 8), |
| 5682 | BPF_ALU32_IMM(BPF_MOV, R1, 7), |
| 5683 | BPF_JMP32_REG(BPF_JSET, R0, R1, 2), |
| 5684 | BPF_ALU32_IMM(BPF_MOV, R1, 8 | 2), |
| 5685 | BPF_JMP32_REG(BPF_JNE, R0, R1, 1), |
| 5686 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5687 | BPF_EXIT_INSN(), |
| 5688 | }, |
| 5689 | INTERNAL, |
| 5690 | { }, |
| 5691 | { { 0, 8 } } |
| 5692 | }, |
| 5693 | /* BPF_JMP32 | BPF_JGT | BPF_K */ |
| 5694 | { |
| 5695 | "JMP32_JGT_K: Small immediate", |
| 5696 | .u.insns_int = { |
| 5697 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5698 | BPF_JMP32_IMM(BPF_JGT, R0, 123, 1), |
| 5699 | BPF_JMP32_IMM(BPF_JGT, R0, 122, 1), |
| 5700 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5701 | BPF_EXIT_INSN(), |
| 5702 | }, |
| 5703 | INTERNAL, |
| 5704 | { }, |
| 5705 | { { 0, 123 } } |
| 5706 | }, |
| 5707 | { |
| 5708 | "JMP32_JGT_K: Large immediate", |
| 5709 | .u.insns_int = { |
| 5710 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5711 | BPF_JMP32_IMM(BPF_JGT, R0, 0xffffffff, 1), |
| 5712 | BPF_JMP32_IMM(BPF_JGT, R0, 0xfffffffd, 1), |
| 5713 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5714 | BPF_EXIT_INSN(), |
| 5715 | }, |
| 5716 | INTERNAL, |
| 5717 | { }, |
| 5718 | { { 0, 0xfffffffe } } |
| 5719 | }, |
| 5720 | /* BPF_JMP32 | BPF_JGT | BPF_X */ |
| 5721 | { |
| 5722 | "JMP32_JGT_X", |
| 5723 | .u.insns_int = { |
| 5724 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5725 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 5726 | BPF_JMP32_REG(BPF_JGT, R0, R1, 2), |
| 5727 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfffffffd), |
| 5728 | BPF_JMP32_REG(BPF_JGT, R0, R1, 1), |
| 5729 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5730 | BPF_EXIT_INSN(), |
| 5731 | }, |
| 5732 | INTERNAL, |
| 5733 | { }, |
| 5734 | { { 0, 0xfffffffe } } |
| 5735 | }, |
| 5736 | /* BPF_JMP32 | BPF_JGE | BPF_K */ |
| 5737 | { |
| 5738 | "JMP32_JGE_K: Small immediate", |
| 5739 | .u.insns_int = { |
| 5740 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5741 | BPF_JMP32_IMM(BPF_JGE, R0, 124, 1), |
| 5742 | BPF_JMP32_IMM(BPF_JGE, R0, 123, 1), |
| 5743 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5744 | BPF_EXIT_INSN(), |
| 5745 | }, |
| 5746 | INTERNAL, |
| 5747 | { }, |
| 5748 | { { 0, 123 } } |
| 5749 | }, |
| 5750 | { |
| 5751 | "JMP32_JGE_K: Large immediate", |
| 5752 | .u.insns_int = { |
| 5753 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5754 | BPF_JMP32_IMM(BPF_JGE, R0, 0xffffffff, 1), |
| 5755 | BPF_JMP32_IMM(BPF_JGE, R0, 0xfffffffe, 1), |
| 5756 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5757 | BPF_EXIT_INSN(), |
| 5758 | }, |
| 5759 | INTERNAL, |
| 5760 | { }, |
| 5761 | { { 0, 0xfffffffe } } |
| 5762 | }, |
| 5763 | /* BPF_JMP32 | BPF_JGE | BPF_X */ |
| 5764 | { |
| 5765 | "JMP32_JGE_X", |
| 5766 | .u.insns_int = { |
| 5767 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5768 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 5769 | BPF_JMP32_REG(BPF_JGE, R0, R1, 2), |
| 5770 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfffffffe), |
| 5771 | BPF_JMP32_REG(BPF_JGE, R0, R1, 1), |
| 5772 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5773 | BPF_EXIT_INSN(), |
| 5774 | }, |
| 5775 | INTERNAL, |
| 5776 | { }, |
| 5777 | { { 0, 0xfffffffe } } |
| 5778 | }, |
| 5779 | /* BPF_JMP32 | BPF_JLT | BPF_K */ |
| 5780 | { |
| 5781 | "JMP32_JLT_K: Small immediate", |
| 5782 | .u.insns_int = { |
| 5783 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5784 | BPF_JMP32_IMM(BPF_JLT, R0, 123, 1), |
| 5785 | BPF_JMP32_IMM(BPF_JLT, R0, 124, 1), |
| 5786 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5787 | BPF_EXIT_INSN(), |
| 5788 | }, |
| 5789 | INTERNAL, |
| 5790 | { }, |
| 5791 | { { 0, 123 } } |
| 5792 | }, |
| 5793 | { |
| 5794 | "JMP32_JLT_K: Large immediate", |
| 5795 | .u.insns_int = { |
| 5796 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5797 | BPF_JMP32_IMM(BPF_JLT, R0, 0xfffffffd, 1), |
| 5798 | BPF_JMP32_IMM(BPF_JLT, R0, 0xffffffff, 1), |
| 5799 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5800 | BPF_EXIT_INSN(), |
| 5801 | }, |
| 5802 | INTERNAL, |
| 5803 | { }, |
| 5804 | { { 0, 0xfffffffe } } |
| 5805 | }, |
| 5806 | /* BPF_JMP32 | BPF_JLT | BPF_X */ |
| 5807 | { |
| 5808 | "JMP32_JLT_X", |
| 5809 | .u.insns_int = { |
| 5810 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5811 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfffffffd), |
| 5812 | BPF_JMP32_REG(BPF_JLT, R0, R1, 2), |
| 5813 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 5814 | BPF_JMP32_REG(BPF_JLT, R0, R1, 1), |
| 5815 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5816 | BPF_EXIT_INSN(), |
| 5817 | }, |
| 5818 | INTERNAL, |
| 5819 | { }, |
| 5820 | { { 0, 0xfffffffe } } |
| 5821 | }, |
| 5822 | /* BPF_JMP32 | BPF_JLE | BPF_K */ |
| 5823 | { |
| 5824 | "JMP32_JLE_K: Small immediate", |
| 5825 | .u.insns_int = { |
| 5826 | BPF_ALU32_IMM(BPF_MOV, R0, 123), |
| 5827 | BPF_JMP32_IMM(BPF_JLE, R0, 122, 1), |
| 5828 | BPF_JMP32_IMM(BPF_JLE, R0, 123, 1), |
| 5829 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5830 | BPF_EXIT_INSN(), |
| 5831 | }, |
| 5832 | INTERNAL, |
| 5833 | { }, |
| 5834 | { { 0, 123 } } |
| 5835 | }, |
| 5836 | { |
| 5837 | "JMP32_JLE_K: Large immediate", |
| 5838 | .u.insns_int = { |
| 5839 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5840 | BPF_JMP32_IMM(BPF_JLE, R0, 0xfffffffd, 1), |
| 5841 | BPF_JMP32_IMM(BPF_JLE, R0, 0xfffffffe, 1), |
| 5842 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5843 | BPF_EXIT_INSN(), |
| 5844 | }, |
| 5845 | INTERNAL, |
| 5846 | { }, |
| 5847 | { { 0, 0xfffffffe } } |
| 5848 | }, |
| 5849 | /* BPF_JMP32 | BPF_JLE | BPF_X */ |
| 5850 | { |
| 5851 | "JMP32_JLE_X", |
| 5852 | .u.insns_int = { |
| 5853 | BPF_ALU32_IMM(BPF_MOV, R0, 0xfffffffe), |
| 5854 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfffffffd), |
| 5855 | BPF_JMP32_REG(BPF_JLE, R0, R1, 2), |
| 5856 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfffffffe), |
| 5857 | BPF_JMP32_REG(BPF_JLE, R0, R1, 1), |
| 5858 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5859 | BPF_EXIT_INSN(), |
| 5860 | }, |
| 5861 | INTERNAL, |
| 5862 | { }, |
| 5863 | { { 0, 0xfffffffe } } |
| 5864 | }, |
| 5865 | /* BPF_JMP32 | BPF_JSGT | BPF_K */ |
| 5866 | { |
| 5867 | "JMP32_JSGT_K: Small immediate", |
| 5868 | .u.insns_int = { |
| 5869 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5870 | BPF_JMP32_IMM(BPF_JSGT, R0, -123, 1), |
| 5871 | BPF_JMP32_IMM(BPF_JSGT, R0, -124, 1), |
| 5872 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5873 | BPF_EXIT_INSN(), |
| 5874 | }, |
| 5875 | INTERNAL, |
| 5876 | { }, |
| 5877 | { { 0, -123 } } |
| 5878 | }, |
| 5879 | { |
| 5880 | "JMP32_JSGT_K: Large immediate", |
| 5881 | .u.insns_int = { |
| 5882 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5883 | BPF_JMP32_IMM(BPF_JSGT, R0, -12345678, 1), |
| 5884 | BPF_JMP32_IMM(BPF_JSGT, R0, -12345679, 1), |
| 5885 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5886 | BPF_EXIT_INSN(), |
| 5887 | }, |
| 5888 | INTERNAL, |
| 5889 | { }, |
| 5890 | { { 0, -12345678 } } |
| 5891 | }, |
| 5892 | /* BPF_JMP32 | BPF_JSGT | BPF_X */ |
| 5893 | { |
| 5894 | "JMP32_JSGT_X", |
| 5895 | .u.insns_int = { |
| 5896 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5897 | BPF_ALU32_IMM(BPF_MOV, R1, -12345678), |
| 5898 | BPF_JMP32_REG(BPF_JSGT, R0, R1, 2), |
| 5899 | BPF_ALU32_IMM(BPF_MOV, R1, -12345679), |
| 5900 | BPF_JMP32_REG(BPF_JSGT, R0, R1, 1), |
| 5901 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5902 | BPF_EXIT_INSN(), |
| 5903 | }, |
| 5904 | INTERNAL, |
| 5905 | { }, |
| 5906 | { { 0, -12345678 } } |
| 5907 | }, |
| 5908 | /* BPF_JMP32 | BPF_JSGE | BPF_K */ |
| 5909 | { |
| 5910 | "JMP32_JSGE_K: Small immediate", |
| 5911 | .u.insns_int = { |
| 5912 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5913 | BPF_JMP32_IMM(BPF_JSGE, R0, -122, 1), |
| 5914 | BPF_JMP32_IMM(BPF_JSGE, R0, -123, 1), |
| 5915 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5916 | BPF_EXIT_INSN(), |
| 5917 | }, |
| 5918 | INTERNAL, |
| 5919 | { }, |
| 5920 | { { 0, -123 } } |
| 5921 | }, |
| 5922 | { |
| 5923 | "JMP32_JSGE_K: Large immediate", |
| 5924 | .u.insns_int = { |
| 5925 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5926 | BPF_JMP32_IMM(BPF_JSGE, R0, -12345677, 1), |
| 5927 | BPF_JMP32_IMM(BPF_JSGE, R0, -12345678, 1), |
| 5928 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5929 | BPF_EXIT_INSN(), |
| 5930 | }, |
| 5931 | INTERNAL, |
| 5932 | { }, |
| 5933 | { { 0, -12345678 } } |
| 5934 | }, |
| 5935 | /* BPF_JMP32 | BPF_JSGE | BPF_X */ |
| 5936 | { |
| 5937 | "JMP32_JSGE_X", |
| 5938 | .u.insns_int = { |
| 5939 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5940 | BPF_ALU32_IMM(BPF_MOV, R1, -12345677), |
| 5941 | BPF_JMP32_REG(BPF_JSGE, R0, R1, 2), |
| 5942 | BPF_ALU32_IMM(BPF_MOV, R1, -12345678), |
| 5943 | BPF_JMP32_REG(BPF_JSGE, R0, R1, 1), |
| 5944 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5945 | BPF_EXIT_INSN(), |
| 5946 | }, |
| 5947 | INTERNAL, |
| 5948 | { }, |
| 5949 | { { 0, -12345678 } } |
| 5950 | }, |
| 5951 | /* BPF_JMP32 | BPF_JSLT | BPF_K */ |
| 5952 | { |
| 5953 | "JMP32_JSLT_K: Small immediate", |
| 5954 | .u.insns_int = { |
| 5955 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5956 | BPF_JMP32_IMM(BPF_JSLT, R0, -123, 1), |
| 5957 | BPF_JMP32_IMM(BPF_JSLT, R0, -122, 1), |
| 5958 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5959 | BPF_EXIT_INSN(), |
| 5960 | }, |
| 5961 | INTERNAL, |
| 5962 | { }, |
| 5963 | { { 0, -123 } } |
| 5964 | }, |
| 5965 | { |
| 5966 | "JMP32_JSLT_K: Large immediate", |
| 5967 | .u.insns_int = { |
| 5968 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5969 | BPF_JMP32_IMM(BPF_JSLT, R0, -12345678, 1), |
| 5970 | BPF_JMP32_IMM(BPF_JSLT, R0, -12345677, 1), |
| 5971 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5972 | BPF_EXIT_INSN(), |
| 5973 | }, |
| 5974 | INTERNAL, |
| 5975 | { }, |
| 5976 | { { 0, -12345678 } } |
| 5977 | }, |
| 5978 | /* BPF_JMP32 | BPF_JSLT | BPF_X */ |
| 5979 | { |
| 5980 | "JMP32_JSLT_X", |
| 5981 | .u.insns_int = { |
| 5982 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 5983 | BPF_ALU32_IMM(BPF_MOV, R1, -12345678), |
| 5984 | BPF_JMP32_REG(BPF_JSLT, R0, R1, 2), |
| 5985 | BPF_ALU32_IMM(BPF_MOV, R1, -12345677), |
| 5986 | BPF_JMP32_REG(BPF_JSLT, R0, R1, 1), |
| 5987 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 5988 | BPF_EXIT_INSN(), |
| 5989 | }, |
| 5990 | INTERNAL, |
| 5991 | { }, |
| 5992 | { { 0, -12345678 } } |
| 5993 | }, |
| 5994 | /* BPF_JMP32 | BPF_JSLE | BPF_K */ |
| 5995 | { |
| 5996 | "JMP32_JSLE_K: Small immediate", |
| 5997 | .u.insns_int = { |
| 5998 | BPF_ALU32_IMM(BPF_MOV, R0, -123), |
| 5999 | BPF_JMP32_IMM(BPF_JSLE, R0, -124, 1), |
| 6000 | BPF_JMP32_IMM(BPF_JSLE, R0, -123, 1), |
| 6001 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6002 | BPF_EXIT_INSN(), |
| 6003 | }, |
| 6004 | INTERNAL, |
| 6005 | { }, |
| 6006 | { { 0, -123 } } |
| 6007 | }, |
| 6008 | { |
| 6009 | "JMP32_JSLE_K: Large immediate", |
| 6010 | .u.insns_int = { |
| 6011 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 6012 | BPF_JMP32_IMM(BPF_JSLE, R0, -12345679, 1), |
| 6013 | BPF_JMP32_IMM(BPF_JSLE, R0, -12345678, 1), |
| 6014 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6015 | BPF_EXIT_INSN(), |
| 6016 | }, |
| 6017 | INTERNAL, |
| 6018 | { }, |
| 6019 | { { 0, -12345678 } } |
| 6020 | }, |
| 6021 | /* BPF_JMP32 | BPF_JSLE | BPF_K */ |
| 6022 | { |
| 6023 | "JMP32_JSLE_X", |
| 6024 | .u.insns_int = { |
| 6025 | BPF_ALU32_IMM(BPF_MOV, R0, -12345678), |
| 6026 | BPF_ALU32_IMM(BPF_MOV, R1, -12345679), |
| 6027 | BPF_JMP32_REG(BPF_JSLE, R0, R1, 2), |
| 6028 | BPF_ALU32_IMM(BPF_MOV, R1, -12345678), |
| 6029 | BPF_JMP32_REG(BPF_JSLE, R0, R1, 1), |
| 6030 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6031 | BPF_EXIT_INSN(), |
| 6032 | }, |
| 6033 | INTERNAL, |
| 6034 | { }, |
| 6035 | { { 0, -12345678 } } |
| 6036 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6037 | /* BPF_JMP | BPF_EXIT */ |
| 6038 | { |
| 6039 | "JMP_EXIT", |
| 6040 | .u.insns_int = { |
| 6041 | BPF_ALU32_IMM(BPF_MOV, R0, 0x4711), |
| 6042 | BPF_EXIT_INSN(), |
| 6043 | BPF_ALU32_IMM(BPF_MOV, R0, 0x4712), |
| 6044 | }, |
| 6045 | INTERNAL, |
| 6046 | { }, |
| 6047 | { { 0, 0x4711 } }, |
| 6048 | }, |
| 6049 | /* BPF_JMP | BPF_JA */ |
| 6050 | { |
| 6051 | "JMP_JA: Unconditional jump: if (true) return 1", |
| 6052 | .u.insns_int = { |
| 6053 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6054 | BPF_JMP_IMM(BPF_JA, 0, 0, 1), |
| 6055 | BPF_EXIT_INSN(), |
| 6056 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6057 | BPF_EXIT_INSN(), |
| 6058 | }, |
| 6059 | INTERNAL, |
| 6060 | { }, |
| 6061 | { { 0, 1 } }, |
| 6062 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6063 | /* BPF_JMP | BPF_JSLT | BPF_K */ |
| 6064 | { |
| 6065 | "JMP_JSLT_K: Signed jump: if (-2 < -1) return 1", |
| 6066 | .u.insns_int = { |
| 6067 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6068 | BPF_LD_IMM64(R1, 0xfffffffffffffffeLL), |
| 6069 | BPF_JMP_IMM(BPF_JSLT, R1, -1, 1), |
| 6070 | BPF_EXIT_INSN(), |
| 6071 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6072 | BPF_EXIT_INSN(), |
| 6073 | }, |
| 6074 | INTERNAL, |
| 6075 | { }, |
| 6076 | { { 0, 1 } }, |
| 6077 | }, |
| 6078 | { |
| 6079 | "JMP_JSLT_K: Signed jump: if (-1 < -1) return 0", |
| 6080 | .u.insns_int = { |
| 6081 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6082 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6083 | BPF_JMP_IMM(BPF_JSLT, R1, -1, 1), |
| 6084 | BPF_EXIT_INSN(), |
| 6085 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6086 | BPF_EXIT_INSN(), |
| 6087 | }, |
| 6088 | INTERNAL, |
| 6089 | { }, |
| 6090 | { { 0, 1 } }, |
| 6091 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6092 | /* BPF_JMP | BPF_JSGT | BPF_K */ |
| 6093 | { |
| 6094 | "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1", |
| 6095 | .u.insns_int = { |
| 6096 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6097 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6098 | BPF_JMP_IMM(BPF_JSGT, R1, -2, 1), |
| 6099 | BPF_EXIT_INSN(), |
| 6100 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6101 | BPF_EXIT_INSN(), |
| 6102 | }, |
| 6103 | INTERNAL, |
| 6104 | { }, |
| 6105 | { { 0, 1 } }, |
| 6106 | }, |
| 6107 | { |
| 6108 | "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0", |
| 6109 | .u.insns_int = { |
| 6110 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6111 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6112 | BPF_JMP_IMM(BPF_JSGT, R1, -1, 1), |
| 6113 | BPF_EXIT_INSN(), |
| 6114 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6115 | BPF_EXIT_INSN(), |
| 6116 | }, |
| 6117 | INTERNAL, |
| 6118 | { }, |
| 6119 | { { 0, 1 } }, |
| 6120 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6121 | /* BPF_JMP | BPF_JSLE | BPF_K */ |
| 6122 | { |
| 6123 | "JMP_JSLE_K: Signed jump: if (-2 <= -1) return 1", |
| 6124 | .u.insns_int = { |
| 6125 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6126 | BPF_LD_IMM64(R1, 0xfffffffffffffffeLL), |
| 6127 | BPF_JMP_IMM(BPF_JSLE, R1, -1, 1), |
| 6128 | BPF_EXIT_INSN(), |
| 6129 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6130 | BPF_EXIT_INSN(), |
| 6131 | }, |
| 6132 | INTERNAL, |
| 6133 | { }, |
| 6134 | { { 0, 1 } }, |
| 6135 | }, |
| 6136 | { |
| 6137 | "JMP_JSLE_K: Signed jump: if (-1 <= -1) return 1", |
| 6138 | .u.insns_int = { |
| 6139 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6140 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6141 | BPF_JMP_IMM(BPF_JSLE, R1, -1, 1), |
| 6142 | BPF_EXIT_INSN(), |
| 6143 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6144 | BPF_EXIT_INSN(), |
| 6145 | }, |
| 6146 | INTERNAL, |
| 6147 | { }, |
| 6148 | { { 0, 1 } }, |
| 6149 | }, |
| 6150 | { |
| 6151 | "JMP_JSLE_K: Signed jump: value walk 1", |
| 6152 | .u.insns_int = { |
| 6153 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6154 | BPF_LD_IMM64(R1, 3), |
| 6155 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 6), |
| 6156 | BPF_ALU64_IMM(BPF_SUB, R1, 1), |
| 6157 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 4), |
| 6158 | BPF_ALU64_IMM(BPF_SUB, R1, 1), |
| 6159 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 2), |
| 6160 | BPF_ALU64_IMM(BPF_SUB, R1, 1), |
| 6161 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 1), |
| 6162 | BPF_EXIT_INSN(), /* bad exit */ |
| 6163 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 6164 | BPF_EXIT_INSN(), |
| 6165 | }, |
| 6166 | INTERNAL, |
| 6167 | { }, |
| 6168 | { { 0, 1 } }, |
| 6169 | }, |
| 6170 | { |
| 6171 | "JMP_JSLE_K: Signed jump: value walk 2", |
| 6172 | .u.insns_int = { |
| 6173 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6174 | BPF_LD_IMM64(R1, 3), |
| 6175 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 4), |
| 6176 | BPF_ALU64_IMM(BPF_SUB, R1, 2), |
| 6177 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 2), |
| 6178 | BPF_ALU64_IMM(BPF_SUB, R1, 2), |
| 6179 | BPF_JMP_IMM(BPF_JSLE, R1, 0, 1), |
| 6180 | BPF_EXIT_INSN(), /* bad exit */ |
| 6181 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 6182 | BPF_EXIT_INSN(), |
| 6183 | }, |
| 6184 | INTERNAL, |
| 6185 | { }, |
| 6186 | { { 0, 1 } }, |
| 6187 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6188 | /* BPF_JMP | BPF_JSGE | BPF_K */ |
| 6189 | { |
| 6190 | "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1", |
| 6191 | .u.insns_int = { |
| 6192 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6193 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6194 | BPF_JMP_IMM(BPF_JSGE, R1, -2, 1), |
| 6195 | BPF_EXIT_INSN(), |
| 6196 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6197 | BPF_EXIT_INSN(), |
| 6198 | }, |
| 6199 | INTERNAL, |
| 6200 | { }, |
| 6201 | { { 0, 1 } }, |
| 6202 | }, |
| 6203 | { |
| 6204 | "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1", |
| 6205 | .u.insns_int = { |
| 6206 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6207 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 6208 | BPF_JMP_IMM(BPF_JSGE, R1, -1, 1), |
| 6209 | BPF_EXIT_INSN(), |
| 6210 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6211 | BPF_EXIT_INSN(), |
| 6212 | }, |
| 6213 | INTERNAL, |
| 6214 | { }, |
| 6215 | { { 0, 1 } }, |
| 6216 | }, |
David Daney | 791caeb | 2017-05-24 16:35:49 -0700 | [diff] [blame] | 6217 | { |
| 6218 | "JMP_JSGE_K: Signed jump: value walk 1", |
| 6219 | .u.insns_int = { |
| 6220 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6221 | BPF_LD_IMM64(R1, -3), |
| 6222 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 6), |
| 6223 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 6224 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 4), |
| 6225 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 6226 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 2), |
| 6227 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 6228 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 1), |
| 6229 | BPF_EXIT_INSN(), /* bad exit */ |
| 6230 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 6231 | BPF_EXIT_INSN(), |
| 6232 | }, |
| 6233 | INTERNAL, |
| 6234 | { }, |
| 6235 | { { 0, 1 } }, |
| 6236 | }, |
| 6237 | { |
| 6238 | "JMP_JSGE_K: Signed jump: value walk 2", |
| 6239 | .u.insns_int = { |
| 6240 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6241 | BPF_LD_IMM64(R1, -3), |
| 6242 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 4), |
| 6243 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 6244 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 2), |
| 6245 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 6246 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 1), |
| 6247 | BPF_EXIT_INSN(), /* bad exit */ |
| 6248 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 6249 | BPF_EXIT_INSN(), |
| 6250 | }, |
| 6251 | INTERNAL, |
| 6252 | { }, |
| 6253 | { { 0, 1 } }, |
| 6254 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6255 | /* BPF_JMP | BPF_JGT | BPF_K */ |
| 6256 | { |
| 6257 | "JMP_JGT_K: if (3 > 2) return 1", |
| 6258 | .u.insns_int = { |
| 6259 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6260 | BPF_LD_IMM64(R1, 3), |
| 6261 | BPF_JMP_IMM(BPF_JGT, R1, 2, 1), |
| 6262 | BPF_EXIT_INSN(), |
| 6263 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6264 | BPF_EXIT_INSN(), |
| 6265 | }, |
| 6266 | INTERNAL, |
| 6267 | { }, |
| 6268 | { { 0, 1 } }, |
| 6269 | }, |
Naveen N. Rao | c7395d6 | 2016-04-05 15:32:54 +0530 | [diff] [blame] | 6270 | { |
| 6271 | "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1", |
| 6272 | .u.insns_int = { |
| 6273 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6274 | BPF_LD_IMM64(R1, -1), |
| 6275 | BPF_JMP_IMM(BPF_JGT, R1, 1, 1), |
| 6276 | BPF_EXIT_INSN(), |
| 6277 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6278 | BPF_EXIT_INSN(), |
| 6279 | }, |
| 6280 | INTERNAL, |
| 6281 | { }, |
| 6282 | { { 0, 1 } }, |
| 6283 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6284 | /* BPF_JMP | BPF_JLT | BPF_K */ |
| 6285 | { |
| 6286 | "JMP_JLT_K: if (2 < 3) return 1", |
| 6287 | .u.insns_int = { |
| 6288 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6289 | BPF_LD_IMM64(R1, 2), |
| 6290 | BPF_JMP_IMM(BPF_JLT, R1, 3, 1), |
| 6291 | BPF_EXIT_INSN(), |
| 6292 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6293 | BPF_EXIT_INSN(), |
| 6294 | }, |
| 6295 | INTERNAL, |
| 6296 | { }, |
| 6297 | { { 0, 1 } }, |
| 6298 | }, |
| 6299 | { |
| 6300 | "JMP_JGT_K: Unsigned jump: if (1 < -1) return 1", |
| 6301 | .u.insns_int = { |
| 6302 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6303 | BPF_LD_IMM64(R1, 1), |
| 6304 | BPF_JMP_IMM(BPF_JLT, R1, -1, 1), |
| 6305 | BPF_EXIT_INSN(), |
| 6306 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6307 | BPF_EXIT_INSN(), |
| 6308 | }, |
| 6309 | INTERNAL, |
| 6310 | { }, |
| 6311 | { { 0, 1 } }, |
| 6312 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6313 | /* BPF_JMP | BPF_JGE | BPF_K */ |
| 6314 | { |
| 6315 | "JMP_JGE_K: if (3 >= 2) return 1", |
| 6316 | .u.insns_int = { |
| 6317 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6318 | BPF_LD_IMM64(R1, 3), |
| 6319 | BPF_JMP_IMM(BPF_JGE, R1, 2, 1), |
| 6320 | BPF_EXIT_INSN(), |
| 6321 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6322 | BPF_EXIT_INSN(), |
| 6323 | }, |
| 6324 | INTERNAL, |
| 6325 | { }, |
| 6326 | { { 0, 1 } }, |
| 6327 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6328 | /* BPF_JMP | BPF_JLE | BPF_K */ |
| 6329 | { |
| 6330 | "JMP_JLE_K: if (2 <= 3) return 1", |
| 6331 | .u.insns_int = { |
| 6332 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6333 | BPF_LD_IMM64(R1, 2), |
| 6334 | BPF_JMP_IMM(BPF_JLE, R1, 3, 1), |
| 6335 | BPF_EXIT_INSN(), |
| 6336 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6337 | BPF_EXIT_INSN(), |
| 6338 | }, |
| 6339 | INTERNAL, |
| 6340 | { }, |
| 6341 | { { 0, 1 } }, |
| 6342 | }, |
Michael Holzheu | fe59384 | 2015-05-22 08:36:40 -0700 | [diff] [blame] | 6343 | /* BPF_JMP | BPF_JGT | BPF_K jump backwards */ |
| 6344 | { |
| 6345 | "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)", |
| 6346 | .u.insns_int = { |
| 6347 | BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */ |
| 6348 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */ |
| 6349 | BPF_EXIT_INSN(), |
| 6350 | BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */ |
| 6351 | BPF_LD_IMM64(R1, 3), /* note: this takes 2 insns */ |
| 6352 | BPF_JMP_IMM(BPF_JGT, R1, 2, -6), /* goto out */ |
| 6353 | BPF_EXIT_INSN(), |
| 6354 | }, |
| 6355 | INTERNAL, |
| 6356 | { }, |
| 6357 | { { 0, 1 } }, |
| 6358 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6359 | { |
| 6360 | "JMP_JGE_K: if (3 >= 3) return 1", |
| 6361 | .u.insns_int = { |
| 6362 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6363 | BPF_LD_IMM64(R1, 3), |
| 6364 | BPF_JMP_IMM(BPF_JGE, R1, 3, 1), |
| 6365 | BPF_EXIT_INSN(), |
| 6366 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6367 | BPF_EXIT_INSN(), |
| 6368 | }, |
| 6369 | INTERNAL, |
| 6370 | { }, |
| 6371 | { { 0, 1 } }, |
| 6372 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6373 | /* BPF_JMP | BPF_JLT | BPF_K jump backwards */ |
| 6374 | { |
| 6375 | "JMP_JGT_K: if (2 < 3) return 1 (jump backwards)", |
| 6376 | .u.insns_int = { |
| 6377 | BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */ |
| 6378 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */ |
| 6379 | BPF_EXIT_INSN(), |
| 6380 | BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */ |
| 6381 | BPF_LD_IMM64(R1, 2), /* note: this takes 2 insns */ |
| 6382 | BPF_JMP_IMM(BPF_JLT, R1, 3, -6), /* goto out */ |
| 6383 | BPF_EXIT_INSN(), |
| 6384 | }, |
| 6385 | INTERNAL, |
| 6386 | { }, |
| 6387 | { { 0, 1 } }, |
| 6388 | }, |
| 6389 | { |
| 6390 | "JMP_JLE_K: if (3 <= 3) return 1", |
| 6391 | .u.insns_int = { |
| 6392 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6393 | BPF_LD_IMM64(R1, 3), |
| 6394 | BPF_JMP_IMM(BPF_JLE, R1, 3, 1), |
| 6395 | BPF_EXIT_INSN(), |
| 6396 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6397 | BPF_EXIT_INSN(), |
| 6398 | }, |
| 6399 | INTERNAL, |
| 6400 | { }, |
| 6401 | { { 0, 1 } }, |
| 6402 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6403 | /* BPF_JMP | BPF_JNE | BPF_K */ |
| 6404 | { |
| 6405 | "JMP_JNE_K: if (3 != 2) return 1", |
| 6406 | .u.insns_int = { |
| 6407 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6408 | BPF_LD_IMM64(R1, 3), |
| 6409 | BPF_JMP_IMM(BPF_JNE, R1, 2, 1), |
| 6410 | BPF_EXIT_INSN(), |
| 6411 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6412 | BPF_EXIT_INSN(), |
| 6413 | }, |
| 6414 | INTERNAL, |
| 6415 | { }, |
| 6416 | { { 0, 1 } }, |
| 6417 | }, |
| 6418 | /* BPF_JMP | BPF_JEQ | BPF_K */ |
| 6419 | { |
| 6420 | "JMP_JEQ_K: if (3 == 3) return 1", |
| 6421 | .u.insns_int = { |
| 6422 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6423 | BPF_LD_IMM64(R1, 3), |
| 6424 | BPF_JMP_IMM(BPF_JEQ, R1, 3, 1), |
| 6425 | BPF_EXIT_INSN(), |
| 6426 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6427 | BPF_EXIT_INSN(), |
| 6428 | }, |
| 6429 | INTERNAL, |
| 6430 | { }, |
| 6431 | { { 0, 1 } }, |
| 6432 | }, |
| 6433 | /* BPF_JMP | BPF_JSET | BPF_K */ |
| 6434 | { |
| 6435 | "JMP_JSET_K: if (0x3 & 0x2) return 1", |
| 6436 | .u.insns_int = { |
| 6437 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6438 | BPF_LD_IMM64(R1, 3), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 6439 | BPF_JMP_IMM(BPF_JSET, R1, 2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6440 | BPF_EXIT_INSN(), |
| 6441 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6442 | BPF_EXIT_INSN(), |
| 6443 | }, |
| 6444 | INTERNAL, |
| 6445 | { }, |
| 6446 | { { 0, 1 } }, |
| 6447 | }, |
| 6448 | { |
| 6449 | "JMP_JSET_K: if (0x3 & 0xffffffff) return 1", |
| 6450 | .u.insns_int = { |
| 6451 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6452 | BPF_LD_IMM64(R1, 3), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 6453 | BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6454 | BPF_EXIT_INSN(), |
| 6455 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6456 | BPF_EXIT_INSN(), |
| 6457 | }, |
| 6458 | INTERNAL, |
| 6459 | { }, |
| 6460 | { { 0, 1 } }, |
| 6461 | }, |
| 6462 | /* BPF_JMP | BPF_JSGT | BPF_X */ |
| 6463 | { |
| 6464 | "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1", |
| 6465 | .u.insns_int = { |
| 6466 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6467 | BPF_LD_IMM64(R1, -1), |
| 6468 | BPF_LD_IMM64(R2, -2), |
| 6469 | BPF_JMP_REG(BPF_JSGT, R1, R2, 1), |
| 6470 | BPF_EXIT_INSN(), |
| 6471 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6472 | BPF_EXIT_INSN(), |
| 6473 | }, |
| 6474 | INTERNAL, |
| 6475 | { }, |
| 6476 | { { 0, 1 } }, |
| 6477 | }, |
| 6478 | { |
| 6479 | "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0", |
| 6480 | .u.insns_int = { |
| 6481 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6482 | BPF_LD_IMM64(R1, -1), |
| 6483 | BPF_LD_IMM64(R2, -1), |
| 6484 | BPF_JMP_REG(BPF_JSGT, R1, R2, 1), |
| 6485 | BPF_EXIT_INSN(), |
| 6486 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6487 | BPF_EXIT_INSN(), |
| 6488 | }, |
| 6489 | INTERNAL, |
| 6490 | { }, |
| 6491 | { { 0, 1 } }, |
| 6492 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6493 | /* BPF_JMP | BPF_JSLT | BPF_X */ |
| 6494 | { |
| 6495 | "JMP_JSLT_X: Signed jump: if (-2 < -1) return 1", |
| 6496 | .u.insns_int = { |
| 6497 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6498 | BPF_LD_IMM64(R1, -1), |
| 6499 | BPF_LD_IMM64(R2, -2), |
| 6500 | BPF_JMP_REG(BPF_JSLT, R2, R1, 1), |
| 6501 | BPF_EXIT_INSN(), |
| 6502 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6503 | BPF_EXIT_INSN(), |
| 6504 | }, |
| 6505 | INTERNAL, |
| 6506 | { }, |
| 6507 | { { 0, 1 } }, |
| 6508 | }, |
| 6509 | { |
| 6510 | "JMP_JSLT_X: Signed jump: if (-1 < -1) return 0", |
| 6511 | .u.insns_int = { |
| 6512 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6513 | BPF_LD_IMM64(R1, -1), |
| 6514 | BPF_LD_IMM64(R2, -1), |
| 6515 | BPF_JMP_REG(BPF_JSLT, R1, R2, 1), |
| 6516 | BPF_EXIT_INSN(), |
| 6517 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6518 | BPF_EXIT_INSN(), |
| 6519 | }, |
| 6520 | INTERNAL, |
| 6521 | { }, |
| 6522 | { { 0, 1 } }, |
| 6523 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6524 | /* BPF_JMP | BPF_JSGE | BPF_X */ |
| 6525 | { |
| 6526 | "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1", |
| 6527 | .u.insns_int = { |
| 6528 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6529 | BPF_LD_IMM64(R1, -1), |
| 6530 | BPF_LD_IMM64(R2, -2), |
| 6531 | BPF_JMP_REG(BPF_JSGE, R1, R2, 1), |
| 6532 | BPF_EXIT_INSN(), |
| 6533 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6534 | BPF_EXIT_INSN(), |
| 6535 | }, |
| 6536 | INTERNAL, |
| 6537 | { }, |
| 6538 | { { 0, 1 } }, |
| 6539 | }, |
| 6540 | { |
| 6541 | "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1", |
| 6542 | .u.insns_int = { |
| 6543 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6544 | BPF_LD_IMM64(R1, -1), |
| 6545 | BPF_LD_IMM64(R2, -1), |
| 6546 | BPF_JMP_REG(BPF_JSGE, R1, R2, 1), |
| 6547 | BPF_EXIT_INSN(), |
| 6548 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6549 | BPF_EXIT_INSN(), |
| 6550 | }, |
| 6551 | INTERNAL, |
| 6552 | { }, |
| 6553 | { { 0, 1 } }, |
| 6554 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6555 | /* BPF_JMP | BPF_JSLE | BPF_X */ |
| 6556 | { |
| 6557 | "JMP_JSLE_X: Signed jump: if (-2 <= -1) return 1", |
| 6558 | .u.insns_int = { |
| 6559 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6560 | BPF_LD_IMM64(R1, -1), |
| 6561 | BPF_LD_IMM64(R2, -2), |
| 6562 | BPF_JMP_REG(BPF_JSLE, R2, R1, 1), |
| 6563 | BPF_EXIT_INSN(), |
| 6564 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6565 | BPF_EXIT_INSN(), |
| 6566 | }, |
| 6567 | INTERNAL, |
| 6568 | { }, |
| 6569 | { { 0, 1 } }, |
| 6570 | }, |
| 6571 | { |
| 6572 | "JMP_JSLE_X: Signed jump: if (-1 <= -1) return 1", |
| 6573 | .u.insns_int = { |
| 6574 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6575 | BPF_LD_IMM64(R1, -1), |
| 6576 | BPF_LD_IMM64(R2, -1), |
| 6577 | BPF_JMP_REG(BPF_JSLE, R1, R2, 1), |
| 6578 | BPF_EXIT_INSN(), |
| 6579 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6580 | BPF_EXIT_INSN(), |
| 6581 | }, |
| 6582 | INTERNAL, |
| 6583 | { }, |
| 6584 | { { 0, 1 } }, |
| 6585 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6586 | /* BPF_JMP | BPF_JGT | BPF_X */ |
| 6587 | { |
| 6588 | "JMP_JGT_X: if (3 > 2) return 1", |
| 6589 | .u.insns_int = { |
| 6590 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6591 | BPF_LD_IMM64(R1, 3), |
| 6592 | BPF_LD_IMM64(R2, 2), |
| 6593 | BPF_JMP_REG(BPF_JGT, R1, R2, 1), |
| 6594 | BPF_EXIT_INSN(), |
| 6595 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6596 | BPF_EXIT_INSN(), |
| 6597 | }, |
| 6598 | INTERNAL, |
| 6599 | { }, |
| 6600 | { { 0, 1 } }, |
| 6601 | }, |
Naveen N. Rao | c7395d6 | 2016-04-05 15:32:54 +0530 | [diff] [blame] | 6602 | { |
| 6603 | "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1", |
| 6604 | .u.insns_int = { |
| 6605 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6606 | BPF_LD_IMM64(R1, -1), |
| 6607 | BPF_LD_IMM64(R2, 1), |
| 6608 | BPF_JMP_REG(BPF_JGT, R1, R2, 1), |
| 6609 | BPF_EXIT_INSN(), |
| 6610 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6611 | BPF_EXIT_INSN(), |
| 6612 | }, |
| 6613 | INTERNAL, |
| 6614 | { }, |
| 6615 | { { 0, 1 } }, |
| 6616 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6617 | /* BPF_JMP | BPF_JLT | BPF_X */ |
| 6618 | { |
| 6619 | "JMP_JLT_X: if (2 < 3) return 1", |
| 6620 | .u.insns_int = { |
| 6621 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6622 | BPF_LD_IMM64(R1, 3), |
| 6623 | BPF_LD_IMM64(R2, 2), |
| 6624 | BPF_JMP_REG(BPF_JLT, R2, R1, 1), |
| 6625 | BPF_EXIT_INSN(), |
| 6626 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6627 | BPF_EXIT_INSN(), |
| 6628 | }, |
| 6629 | INTERNAL, |
| 6630 | { }, |
| 6631 | { { 0, 1 } }, |
| 6632 | }, |
| 6633 | { |
| 6634 | "JMP_JLT_X: Unsigned jump: if (1 < -1) return 1", |
| 6635 | .u.insns_int = { |
| 6636 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6637 | BPF_LD_IMM64(R1, -1), |
| 6638 | BPF_LD_IMM64(R2, 1), |
| 6639 | BPF_JMP_REG(BPF_JLT, R2, R1, 1), |
| 6640 | BPF_EXIT_INSN(), |
| 6641 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6642 | BPF_EXIT_INSN(), |
| 6643 | }, |
| 6644 | INTERNAL, |
| 6645 | { }, |
| 6646 | { { 0, 1 } }, |
| 6647 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6648 | /* BPF_JMP | BPF_JGE | BPF_X */ |
| 6649 | { |
| 6650 | "JMP_JGE_X: if (3 >= 2) return 1", |
| 6651 | .u.insns_int = { |
| 6652 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6653 | BPF_LD_IMM64(R1, 3), |
| 6654 | BPF_LD_IMM64(R2, 2), |
| 6655 | BPF_JMP_REG(BPF_JGE, R1, R2, 1), |
| 6656 | BPF_EXIT_INSN(), |
| 6657 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6658 | BPF_EXIT_INSN(), |
| 6659 | }, |
| 6660 | INTERNAL, |
| 6661 | { }, |
| 6662 | { { 0, 1 } }, |
| 6663 | }, |
| 6664 | { |
| 6665 | "JMP_JGE_X: if (3 >= 3) return 1", |
| 6666 | .u.insns_int = { |
| 6667 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6668 | BPF_LD_IMM64(R1, 3), |
| 6669 | BPF_LD_IMM64(R2, 3), |
| 6670 | BPF_JMP_REG(BPF_JGE, R1, R2, 1), |
| 6671 | BPF_EXIT_INSN(), |
| 6672 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6673 | BPF_EXIT_INSN(), |
| 6674 | }, |
| 6675 | INTERNAL, |
| 6676 | { }, |
| 6677 | { { 0, 1 } }, |
| 6678 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6679 | /* BPF_JMP | BPF_JLE | BPF_X */ |
| 6680 | { |
| 6681 | "JMP_JLE_X: if (2 <= 3) return 1", |
| 6682 | .u.insns_int = { |
| 6683 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6684 | BPF_LD_IMM64(R1, 3), |
| 6685 | BPF_LD_IMM64(R2, 2), |
| 6686 | BPF_JMP_REG(BPF_JLE, R2, R1, 1), |
| 6687 | BPF_EXIT_INSN(), |
| 6688 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6689 | BPF_EXIT_INSN(), |
| 6690 | }, |
| 6691 | INTERNAL, |
| 6692 | { }, |
| 6693 | { { 0, 1 } }, |
| 6694 | }, |
| 6695 | { |
| 6696 | "JMP_JLE_X: if (3 <= 3) return 1", |
| 6697 | .u.insns_int = { |
| 6698 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6699 | BPF_LD_IMM64(R1, 3), |
| 6700 | BPF_LD_IMM64(R2, 3), |
| 6701 | BPF_JMP_REG(BPF_JLE, R1, R2, 1), |
| 6702 | BPF_EXIT_INSN(), |
| 6703 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6704 | BPF_EXIT_INSN(), |
| 6705 | }, |
| 6706 | INTERNAL, |
| 6707 | { }, |
| 6708 | { { 0, 1 } }, |
| 6709 | }, |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 6710 | { |
| 6711 | /* Mainly testing JIT + imm64 here. */ |
| 6712 | "JMP_JGE_X: ldimm64 test 1", |
| 6713 | .u.insns_int = { |
| 6714 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6715 | BPF_LD_IMM64(R1, 3), |
| 6716 | BPF_LD_IMM64(R2, 2), |
| 6717 | BPF_JMP_REG(BPF_JGE, R1, R2, 2), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 6718 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 6719 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 6720 | BPF_EXIT_INSN(), |
| 6721 | }, |
| 6722 | INTERNAL, |
| 6723 | { }, |
| 6724 | { { 0, 0xeeeeeeeeU } }, |
| 6725 | }, |
| 6726 | { |
| 6727 | "JMP_JGE_X: ldimm64 test 2", |
| 6728 | .u.insns_int = { |
| 6729 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6730 | BPF_LD_IMM64(R1, 3), |
| 6731 | BPF_LD_IMM64(R2, 2), |
| 6732 | BPF_JMP_REG(BPF_JGE, R1, R2, 0), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 6733 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 6734 | BPF_EXIT_INSN(), |
| 6735 | }, |
| 6736 | INTERNAL, |
| 6737 | { }, |
| 6738 | { { 0, 0xffffffffU } }, |
| 6739 | }, |
| 6740 | { |
| 6741 | "JMP_JGE_X: ldimm64 test 3", |
| 6742 | .u.insns_int = { |
| 6743 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6744 | BPF_LD_IMM64(R1, 3), |
| 6745 | BPF_LD_IMM64(R2, 2), |
| 6746 | BPF_JMP_REG(BPF_JGE, R1, R2, 4), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 6747 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 6748 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 6749 | BPF_EXIT_INSN(), |
| 6750 | }, |
| 6751 | INTERNAL, |
| 6752 | { }, |
| 6753 | { { 0, 1 } }, |
| 6754 | }, |
Daniel Borkmann | 92b31a9 | 2017-08-10 01:39:55 +0200 | [diff] [blame] | 6755 | { |
| 6756 | "JMP_JLE_X: ldimm64 test 1", |
| 6757 | .u.insns_int = { |
| 6758 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6759 | BPF_LD_IMM64(R1, 3), |
| 6760 | BPF_LD_IMM64(R2, 2), |
| 6761 | BPF_JMP_REG(BPF_JLE, R2, R1, 2), |
| 6762 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 6763 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
| 6764 | BPF_EXIT_INSN(), |
| 6765 | }, |
| 6766 | INTERNAL, |
| 6767 | { }, |
| 6768 | { { 0, 0xeeeeeeeeU } }, |
| 6769 | }, |
| 6770 | { |
| 6771 | "JMP_JLE_X: ldimm64 test 2", |
| 6772 | .u.insns_int = { |
| 6773 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6774 | BPF_LD_IMM64(R1, 3), |
| 6775 | BPF_LD_IMM64(R2, 2), |
| 6776 | BPF_JMP_REG(BPF_JLE, R2, R1, 0), |
| 6777 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 6778 | BPF_EXIT_INSN(), |
| 6779 | }, |
| 6780 | INTERNAL, |
| 6781 | { }, |
| 6782 | { { 0, 0xffffffffU } }, |
| 6783 | }, |
| 6784 | { |
| 6785 | "JMP_JLE_X: ldimm64 test 3", |
| 6786 | .u.insns_int = { |
| 6787 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6788 | BPF_LD_IMM64(R1, 3), |
| 6789 | BPF_LD_IMM64(R2, 2), |
| 6790 | BPF_JMP_REG(BPF_JLE, R2, R1, 4), |
| 6791 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 6792 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
| 6793 | BPF_EXIT_INSN(), |
| 6794 | }, |
| 6795 | INTERNAL, |
| 6796 | { }, |
| 6797 | { { 0, 1 } }, |
| 6798 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6799 | /* BPF_JMP | BPF_JNE | BPF_X */ |
| 6800 | { |
| 6801 | "JMP_JNE_X: if (3 != 2) return 1", |
| 6802 | .u.insns_int = { |
| 6803 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6804 | BPF_LD_IMM64(R1, 3), |
| 6805 | BPF_LD_IMM64(R2, 2), |
| 6806 | BPF_JMP_REG(BPF_JNE, R1, R2, 1), |
| 6807 | BPF_EXIT_INSN(), |
| 6808 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6809 | BPF_EXIT_INSN(), |
| 6810 | }, |
| 6811 | INTERNAL, |
| 6812 | { }, |
| 6813 | { { 0, 1 } }, |
| 6814 | }, |
| 6815 | /* BPF_JMP | BPF_JEQ | BPF_X */ |
| 6816 | { |
| 6817 | "JMP_JEQ_X: if (3 == 3) return 1", |
| 6818 | .u.insns_int = { |
| 6819 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6820 | BPF_LD_IMM64(R1, 3), |
| 6821 | BPF_LD_IMM64(R2, 3), |
| 6822 | BPF_JMP_REG(BPF_JEQ, R1, R2, 1), |
| 6823 | BPF_EXIT_INSN(), |
| 6824 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6825 | BPF_EXIT_INSN(), |
| 6826 | }, |
| 6827 | INTERNAL, |
| 6828 | { }, |
| 6829 | { { 0, 1 } }, |
| 6830 | }, |
| 6831 | /* BPF_JMP | BPF_JSET | BPF_X */ |
| 6832 | { |
| 6833 | "JMP_JSET_X: if (0x3 & 0x2) return 1", |
| 6834 | .u.insns_int = { |
| 6835 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6836 | BPF_LD_IMM64(R1, 3), |
| 6837 | BPF_LD_IMM64(R2, 2), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 6838 | BPF_JMP_REG(BPF_JSET, R1, R2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6839 | BPF_EXIT_INSN(), |
| 6840 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6841 | BPF_EXIT_INSN(), |
| 6842 | }, |
| 6843 | INTERNAL, |
| 6844 | { }, |
| 6845 | { { 0, 1 } }, |
| 6846 | }, |
| 6847 | { |
| 6848 | "JMP_JSET_X: if (0x3 & 0xffffffff) return 1", |
| 6849 | .u.insns_int = { |
| 6850 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 6851 | BPF_LD_IMM64(R1, 3), |
| 6852 | BPF_LD_IMM64(R2, 0xffffffff), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 6853 | BPF_JMP_REG(BPF_JSET, R1, R2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 6854 | BPF_EXIT_INSN(), |
| 6855 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 6856 | BPF_EXIT_INSN(), |
| 6857 | }, |
| 6858 | INTERNAL, |
| 6859 | { }, |
| 6860 | { { 0, 1 } }, |
| 6861 | }, |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 6862 | { |
| 6863 | "JMP_JA: Jump, gap, jump, ...", |
| 6864 | { }, |
| 6865 | CLASSIC | FLAG_NO_DATA, |
| 6866 | { }, |
| 6867 | { { 0, 0xababcbac } }, |
| 6868 | .fill_helper = bpf_fill_ja, |
| 6869 | }, |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 6870 | { /* Mainly checking JIT here. */ |
| 6871 | "BPF_MAXINSNS: Maximum possible literals", |
| 6872 | { }, |
| 6873 | CLASSIC | FLAG_NO_DATA, |
| 6874 | { }, |
| 6875 | { { 0, 0xffffffff } }, |
| 6876 | .fill_helper = bpf_fill_maxinsns1, |
| 6877 | }, |
| 6878 | { /* Mainly checking JIT here. */ |
| 6879 | "BPF_MAXINSNS: Single literal", |
| 6880 | { }, |
| 6881 | CLASSIC | FLAG_NO_DATA, |
| 6882 | { }, |
| 6883 | { { 0, 0xfefefefe } }, |
| 6884 | .fill_helper = bpf_fill_maxinsns2, |
| 6885 | }, |
| 6886 | { /* Mainly checking JIT here. */ |
| 6887 | "BPF_MAXINSNS: Run/add until end", |
| 6888 | { }, |
| 6889 | CLASSIC | FLAG_NO_DATA, |
| 6890 | { }, |
| 6891 | { { 0, 0x947bf368 } }, |
| 6892 | .fill_helper = bpf_fill_maxinsns3, |
| 6893 | }, |
| 6894 | { |
| 6895 | "BPF_MAXINSNS: Too many instructions", |
| 6896 | { }, |
| 6897 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 6898 | { }, |
| 6899 | { }, |
| 6900 | .fill_helper = bpf_fill_maxinsns4, |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 6901 | .expected_errcode = -EINVAL, |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 6902 | }, |
| 6903 | { /* Mainly checking JIT here. */ |
| 6904 | "BPF_MAXINSNS: Very long jump", |
| 6905 | { }, |
| 6906 | CLASSIC | FLAG_NO_DATA, |
| 6907 | { }, |
| 6908 | { { 0, 0xabababab } }, |
| 6909 | .fill_helper = bpf_fill_maxinsns5, |
| 6910 | }, |
| 6911 | { /* Mainly checking JIT here. */ |
| 6912 | "BPF_MAXINSNS: Ctx heavy transformations", |
| 6913 | { }, |
| 6914 | CLASSIC, |
| 6915 | { }, |
| 6916 | { |
Michał Mirosław | 0c4b2d3 | 2018-11-10 19:58:36 +0100 | [diff] [blame] | 6917 | { 1, SKB_VLAN_PRESENT }, |
| 6918 | { 10, SKB_VLAN_PRESENT } |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 6919 | }, |
| 6920 | .fill_helper = bpf_fill_maxinsns6, |
| 6921 | }, |
| 6922 | { /* Mainly checking JIT here. */ |
| 6923 | "BPF_MAXINSNS: Call heavy transformations", |
| 6924 | { }, |
| 6925 | CLASSIC | FLAG_NO_DATA, |
| 6926 | { }, |
| 6927 | { { 1, 0 }, { 10, 0 } }, |
| 6928 | .fill_helper = bpf_fill_maxinsns7, |
| 6929 | }, |
| 6930 | { /* Mainly checking JIT here. */ |
| 6931 | "BPF_MAXINSNS: Jump heavy test", |
| 6932 | { }, |
| 6933 | CLASSIC | FLAG_NO_DATA, |
| 6934 | { }, |
| 6935 | { { 0, 0xffffffff } }, |
| 6936 | .fill_helper = bpf_fill_maxinsns8, |
| 6937 | }, |
Daniel Borkmann | 3b52960 | 2015-05-23 01:10:07 +0200 | [diff] [blame] | 6938 | { /* Mainly checking JIT here. */ |
| 6939 | "BPF_MAXINSNS: Very long jump backwards", |
| 6940 | { }, |
| 6941 | INTERNAL | FLAG_NO_DATA, |
| 6942 | { }, |
| 6943 | { { 0, 0xcbababab } }, |
| 6944 | .fill_helper = bpf_fill_maxinsns9, |
| 6945 | }, |
| 6946 | { /* Mainly checking JIT here. */ |
| 6947 | "BPF_MAXINSNS: Edge hopping nuthouse", |
| 6948 | { }, |
| 6949 | INTERNAL | FLAG_NO_DATA, |
| 6950 | { }, |
| 6951 | { { 0, 0xabababac } }, |
| 6952 | .fill_helper = bpf_fill_maxinsns10, |
| 6953 | }, |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 6954 | { |
| 6955 | "BPF_MAXINSNS: Jump, gap, jump, ...", |
| 6956 | { }, |
| 6957 | CLASSIC | FLAG_NO_DATA, |
| 6958 | { }, |
| 6959 | { { 0, 0xababcbac } }, |
| 6960 | .fill_helper = bpf_fill_maxinsns11, |
| 6961 | }, |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 6962 | { |
Daniel Borkmann | be08815 | 2018-06-02 23:06:32 +0200 | [diff] [blame] | 6963 | "BPF_MAXINSNS: jump over MSH", |
| 6964 | { }, |
| 6965 | CLASSIC | FLAG_EXPECTED_FAIL, |
| 6966 | { 0xfa, 0xfb, 0xfc, 0xfd, }, |
| 6967 | { { 4, 0xabababab } }, |
| 6968 | .fill_helper = bpf_fill_maxinsns12, |
| 6969 | .expected_errcode = -EINVAL, |
| 6970 | }, |
| 6971 | { |
| 6972 | "BPF_MAXINSNS: exec all MSH", |
| 6973 | { }, |
| 6974 | CLASSIC, |
| 6975 | { 0xfa, 0xfb, 0xfc, 0xfd, }, |
| 6976 | { { 4, 0xababab83 } }, |
| 6977 | .fill_helper = bpf_fill_maxinsns13, |
| 6978 | }, |
| 6979 | { |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 6980 | "BPF_MAXINSNS: ld_abs+get_processor_id", |
| 6981 | { }, |
| 6982 | CLASSIC, |
| 6983 | { }, |
| 6984 | { { 1, 0xbee } }, |
| 6985 | .fill_helper = bpf_fill_ld_abs_get_processor_id, |
| 6986 | }, |
Nicolas Schichan | 2cf1ad7 | 2015-08-04 15:19:09 +0200 | [diff] [blame] | 6987 | /* |
| 6988 | * LD_IND / LD_ABS on fragmented SKBs |
| 6989 | */ |
| 6990 | { |
| 6991 | "LD_IND byte frag", |
| 6992 | .u.insns = { |
| 6993 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 6994 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x0), |
| 6995 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 6996 | }, |
| 6997 | CLASSIC | FLAG_SKB_FRAG, |
| 6998 | { }, |
| 6999 | { {0x40, 0x42} }, |
| 7000 | .frag_data = { |
| 7001 | 0x42, 0x00, 0x00, 0x00, |
| 7002 | 0x43, 0x44, 0x00, 0x00, |
| 7003 | 0x21, 0x07, 0x19, 0x83, |
| 7004 | }, |
| 7005 | }, |
| 7006 | { |
| 7007 | "LD_IND halfword frag", |
| 7008 | .u.insns = { |
| 7009 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 7010 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x4), |
| 7011 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7012 | }, |
| 7013 | CLASSIC | FLAG_SKB_FRAG, |
| 7014 | { }, |
| 7015 | { {0x40, 0x4344} }, |
| 7016 | .frag_data = { |
| 7017 | 0x42, 0x00, 0x00, 0x00, |
| 7018 | 0x43, 0x44, 0x00, 0x00, |
| 7019 | 0x21, 0x07, 0x19, 0x83, |
| 7020 | }, |
| 7021 | }, |
| 7022 | { |
| 7023 | "LD_IND word frag", |
| 7024 | .u.insns = { |
| 7025 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 7026 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x8), |
| 7027 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7028 | }, |
| 7029 | CLASSIC | FLAG_SKB_FRAG, |
| 7030 | { }, |
| 7031 | { {0x40, 0x21071983} }, |
| 7032 | .frag_data = { |
| 7033 | 0x42, 0x00, 0x00, 0x00, |
| 7034 | 0x43, 0x44, 0x00, 0x00, |
| 7035 | 0x21, 0x07, 0x19, 0x83, |
| 7036 | }, |
| 7037 | }, |
| 7038 | { |
| 7039 | "LD_IND halfword mixed head/frag", |
| 7040 | .u.insns = { |
| 7041 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 7042 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1), |
| 7043 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7044 | }, |
| 7045 | CLASSIC | FLAG_SKB_FRAG, |
| 7046 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 7047 | { {0x40, 0x0519} }, |
| 7048 | .frag_data = { 0x19, 0x82 }, |
| 7049 | }, |
| 7050 | { |
| 7051 | "LD_IND word mixed head/frag", |
| 7052 | .u.insns = { |
| 7053 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 7054 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2), |
| 7055 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7056 | }, |
| 7057 | CLASSIC | FLAG_SKB_FRAG, |
| 7058 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 7059 | { {0x40, 0x25051982} }, |
| 7060 | .frag_data = { 0x19, 0x82 }, |
| 7061 | }, |
| 7062 | { |
| 7063 | "LD_ABS byte frag", |
| 7064 | .u.insns = { |
| 7065 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x40), |
| 7066 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7067 | }, |
| 7068 | CLASSIC | FLAG_SKB_FRAG, |
| 7069 | { }, |
| 7070 | { {0x40, 0x42} }, |
| 7071 | .frag_data = { |
| 7072 | 0x42, 0x00, 0x00, 0x00, |
| 7073 | 0x43, 0x44, 0x00, 0x00, |
| 7074 | 0x21, 0x07, 0x19, 0x83, |
| 7075 | }, |
| 7076 | }, |
| 7077 | { |
| 7078 | "LD_ABS halfword frag", |
| 7079 | .u.insns = { |
| 7080 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x44), |
| 7081 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7082 | }, |
| 7083 | CLASSIC | FLAG_SKB_FRAG, |
| 7084 | { }, |
| 7085 | { {0x40, 0x4344} }, |
| 7086 | .frag_data = { |
| 7087 | 0x42, 0x00, 0x00, 0x00, |
| 7088 | 0x43, 0x44, 0x00, 0x00, |
| 7089 | 0x21, 0x07, 0x19, 0x83, |
| 7090 | }, |
| 7091 | }, |
| 7092 | { |
| 7093 | "LD_ABS word frag", |
| 7094 | .u.insns = { |
| 7095 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x48), |
| 7096 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7097 | }, |
| 7098 | CLASSIC | FLAG_SKB_FRAG, |
| 7099 | { }, |
| 7100 | { {0x40, 0x21071983} }, |
| 7101 | .frag_data = { |
| 7102 | 0x42, 0x00, 0x00, 0x00, |
| 7103 | 0x43, 0x44, 0x00, 0x00, |
| 7104 | 0x21, 0x07, 0x19, 0x83, |
| 7105 | }, |
| 7106 | }, |
| 7107 | { |
| 7108 | "LD_ABS halfword mixed head/frag", |
| 7109 | .u.insns = { |
| 7110 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f), |
| 7111 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7112 | }, |
| 7113 | CLASSIC | FLAG_SKB_FRAG, |
| 7114 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 7115 | { {0x40, 0x0519} }, |
| 7116 | .frag_data = { 0x19, 0x82 }, |
| 7117 | }, |
| 7118 | { |
| 7119 | "LD_ABS word mixed head/frag", |
| 7120 | .u.insns = { |
| 7121 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3e), |
| 7122 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7123 | }, |
| 7124 | CLASSIC | FLAG_SKB_FRAG, |
| 7125 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 7126 | { {0x40, 0x25051982} }, |
| 7127 | .frag_data = { 0x19, 0x82 }, |
| 7128 | }, |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7129 | /* |
| 7130 | * LD_IND / LD_ABS on non fragmented SKBs |
| 7131 | */ |
| 7132 | { |
| 7133 | /* |
| 7134 | * this tests that the JIT/interpreter correctly resets X |
| 7135 | * before using it in an LD_IND instruction. |
| 7136 | */ |
| 7137 | "LD_IND byte default X", |
| 7138 | .u.insns = { |
| 7139 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 7140 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7141 | }, |
| 7142 | CLASSIC, |
| 7143 | { [0x1] = 0x42 }, |
| 7144 | { {0x40, 0x42 } }, |
| 7145 | }, |
| 7146 | { |
| 7147 | "LD_IND byte positive offset", |
| 7148 | .u.insns = { |
| 7149 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7150 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 7151 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7152 | }, |
| 7153 | CLASSIC, |
| 7154 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7155 | { {0x40, 0x82 } }, |
| 7156 | }, |
| 7157 | { |
| 7158 | "LD_IND byte negative offset", |
| 7159 | .u.insns = { |
| 7160 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7161 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x1), |
| 7162 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7163 | }, |
| 7164 | CLASSIC, |
| 7165 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7166 | { {0x40, 0x05 } }, |
| 7167 | }, |
| 7168 | { |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7169 | "LD_IND byte positive offset, all ff", |
| 7170 | .u.insns = { |
| 7171 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7172 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 7173 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7174 | }, |
| 7175 | CLASSIC, |
| 7176 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7177 | { {0x40, 0xff } }, |
| 7178 | }, |
| 7179 | { |
| 7180 | "LD_IND byte positive offset, out of bounds", |
| 7181 | .u.insns = { |
| 7182 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7183 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 7184 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7185 | }, |
| 7186 | CLASSIC, |
| 7187 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7188 | { {0x3f, 0 }, }, |
| 7189 | }, |
| 7190 | { |
| 7191 | "LD_IND byte negative offset, out of bounds", |
| 7192 | .u.insns = { |
| 7193 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7194 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x3f), |
| 7195 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7196 | }, |
| 7197 | CLASSIC, |
| 7198 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7199 | { {0x3f, 0 } }, |
| 7200 | }, |
| 7201 | { |
| 7202 | "LD_IND byte negative offset, multiple calls", |
| 7203 | .u.insns = { |
| 7204 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3b), |
| 7205 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 1), |
| 7206 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 2), |
| 7207 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 3), |
| 7208 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 4), |
| 7209 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7210 | }, |
| 7211 | CLASSIC, |
| 7212 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7213 | { {0x40, 0x82 }, }, |
| 7214 | }, |
| 7215 | { |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7216 | "LD_IND halfword positive offset", |
| 7217 | .u.insns = { |
| 7218 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7219 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x2), |
| 7220 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7221 | }, |
| 7222 | CLASSIC, |
| 7223 | { |
| 7224 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7225 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7226 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7227 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7228 | }, |
| 7229 | { {0x40, 0xdd88 } }, |
| 7230 | }, |
| 7231 | { |
| 7232 | "LD_IND halfword negative offset", |
| 7233 | .u.insns = { |
| 7234 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7235 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x2), |
| 7236 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7237 | }, |
| 7238 | CLASSIC, |
| 7239 | { |
| 7240 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7241 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7242 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7243 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7244 | }, |
| 7245 | { {0x40, 0xbb66 } }, |
| 7246 | }, |
| 7247 | { |
| 7248 | "LD_IND halfword unaligned", |
| 7249 | .u.insns = { |
| 7250 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7251 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1), |
| 7252 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7253 | }, |
| 7254 | CLASSIC, |
| 7255 | { |
| 7256 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7257 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7258 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7259 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7260 | }, |
| 7261 | { {0x40, 0x66cc } }, |
| 7262 | }, |
| 7263 | { |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7264 | "LD_IND halfword positive offset, all ff", |
| 7265 | .u.insns = { |
| 7266 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3d), |
| 7267 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x1), |
| 7268 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7269 | }, |
| 7270 | CLASSIC, |
| 7271 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7272 | { {0x40, 0xffff } }, |
| 7273 | }, |
| 7274 | { |
| 7275 | "LD_IND halfword positive offset, out of bounds", |
| 7276 | .u.insns = { |
| 7277 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7278 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x1), |
| 7279 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7280 | }, |
| 7281 | CLASSIC, |
| 7282 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7283 | { {0x3f, 0 }, }, |
| 7284 | }, |
| 7285 | { |
| 7286 | "LD_IND halfword negative offset, out of bounds", |
| 7287 | .u.insns = { |
| 7288 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7289 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x3f), |
| 7290 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7291 | }, |
| 7292 | CLASSIC, |
| 7293 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7294 | { {0x3f, 0 } }, |
| 7295 | }, |
| 7296 | { |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7297 | "LD_IND word positive offset", |
| 7298 | .u.insns = { |
| 7299 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7300 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x4), |
| 7301 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7302 | }, |
| 7303 | CLASSIC, |
| 7304 | { |
| 7305 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7306 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7307 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7308 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7309 | [0x24] = 0xee, [0x25] = 0x99, |
| 7310 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7311 | }, |
| 7312 | { {0x40, 0xee99ffaa } }, |
| 7313 | }, |
| 7314 | { |
| 7315 | "LD_IND word negative offset", |
| 7316 | .u.insns = { |
| 7317 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7318 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x4), |
| 7319 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7320 | }, |
| 7321 | CLASSIC, |
| 7322 | { |
| 7323 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7324 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7325 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7326 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7327 | [0x24] = 0xee, [0x25] = 0x99, |
| 7328 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7329 | }, |
| 7330 | { {0x40, 0xaa55bb66 } }, |
| 7331 | }, |
| 7332 | { |
| 7333 | "LD_IND word unaligned (addr & 3 == 2)", |
| 7334 | .u.insns = { |
| 7335 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7336 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2), |
| 7337 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7338 | }, |
| 7339 | CLASSIC, |
| 7340 | { |
| 7341 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7342 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7343 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7344 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7345 | [0x24] = 0xee, [0x25] = 0x99, |
| 7346 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7347 | }, |
| 7348 | { {0x40, 0xbb66cc77 } }, |
| 7349 | }, |
| 7350 | { |
| 7351 | "LD_IND word unaligned (addr & 3 == 1)", |
| 7352 | .u.insns = { |
| 7353 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7354 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3), |
| 7355 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7356 | }, |
| 7357 | CLASSIC, |
| 7358 | { |
| 7359 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7360 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7361 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7362 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7363 | [0x24] = 0xee, [0x25] = 0x99, |
| 7364 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7365 | }, |
| 7366 | { {0x40, 0x55bb66cc } }, |
| 7367 | }, |
| 7368 | { |
| 7369 | "LD_IND word unaligned (addr & 3 == 3)", |
| 7370 | .u.insns = { |
| 7371 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 7372 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x1), |
| 7373 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7374 | }, |
| 7375 | CLASSIC, |
| 7376 | { |
| 7377 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7378 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7379 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7380 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7381 | [0x24] = 0xee, [0x25] = 0x99, |
| 7382 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7383 | }, |
| 7384 | { {0x40, 0x66cc77dd } }, |
| 7385 | }, |
| 7386 | { |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7387 | "LD_IND word positive offset, all ff", |
| 7388 | .u.insns = { |
| 7389 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3b), |
| 7390 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x1), |
| 7391 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7392 | }, |
| 7393 | CLASSIC, |
| 7394 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7395 | { {0x40, 0xffffffff } }, |
| 7396 | }, |
| 7397 | { |
| 7398 | "LD_IND word positive offset, out of bounds", |
| 7399 | .u.insns = { |
| 7400 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7401 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x1), |
| 7402 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7403 | }, |
| 7404 | CLASSIC, |
| 7405 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7406 | { {0x3f, 0 }, }, |
| 7407 | }, |
| 7408 | { |
| 7409 | "LD_IND word negative offset, out of bounds", |
| 7410 | .u.insns = { |
| 7411 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 7412 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3f), |
| 7413 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7414 | }, |
| 7415 | CLASSIC, |
| 7416 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7417 | { {0x3f, 0 } }, |
| 7418 | }, |
| 7419 | { |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7420 | "LD_ABS byte", |
| 7421 | .u.insns = { |
| 7422 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x20), |
| 7423 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7424 | }, |
| 7425 | CLASSIC, |
| 7426 | { |
| 7427 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7428 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7429 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7430 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7431 | [0x24] = 0xee, [0x25] = 0x99, |
| 7432 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7433 | }, |
| 7434 | { {0x40, 0xcc } }, |
| 7435 | }, |
| 7436 | { |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7437 | "LD_ABS byte positive offset, all ff", |
| 7438 | .u.insns = { |
| 7439 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x3f), |
| 7440 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7441 | }, |
| 7442 | CLASSIC, |
| 7443 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7444 | { {0x40, 0xff } }, |
| 7445 | }, |
| 7446 | { |
| 7447 | "LD_ABS byte positive offset, out of bounds", |
| 7448 | .u.insns = { |
| 7449 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x3f), |
| 7450 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7451 | }, |
| 7452 | CLASSIC, |
| 7453 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7454 | { {0x3f, 0 }, }, |
| 7455 | }, |
| 7456 | { |
| 7457 | "LD_ABS byte negative offset, out of bounds load", |
| 7458 | .u.insns = { |
| 7459 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, -1), |
| 7460 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7461 | }, |
| 7462 | CLASSIC | FLAG_EXPECTED_FAIL, |
| 7463 | .expected_errcode = -EINVAL, |
| 7464 | }, |
| 7465 | { |
| 7466 | "LD_ABS byte negative offset, in bounds", |
| 7467 | .u.insns = { |
| 7468 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f), |
| 7469 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7470 | }, |
| 7471 | CLASSIC, |
| 7472 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7473 | { {0x40, 0x82 }, }, |
| 7474 | }, |
| 7475 | { |
| 7476 | "LD_ABS byte negative offset, out of bounds", |
| 7477 | .u.insns = { |
| 7478 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f), |
| 7479 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7480 | }, |
| 7481 | CLASSIC, |
| 7482 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7483 | { {0x3f, 0 }, }, |
| 7484 | }, |
| 7485 | { |
| 7486 | "LD_ABS byte negative offset, multiple calls", |
| 7487 | .u.insns = { |
| 7488 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3c), |
| 7489 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3d), |
| 7490 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3e), |
| 7491 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f), |
| 7492 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7493 | }, |
| 7494 | CLASSIC, |
| 7495 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7496 | { {0x40, 0x82 }, }, |
| 7497 | }, |
| 7498 | { |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7499 | "LD_ABS halfword", |
| 7500 | .u.insns = { |
| 7501 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x22), |
| 7502 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7503 | }, |
| 7504 | CLASSIC, |
| 7505 | { |
| 7506 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7507 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7508 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7509 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7510 | [0x24] = 0xee, [0x25] = 0x99, |
| 7511 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7512 | }, |
| 7513 | { {0x40, 0xdd88 } }, |
| 7514 | }, |
| 7515 | { |
| 7516 | "LD_ABS halfword unaligned", |
| 7517 | .u.insns = { |
| 7518 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x25), |
| 7519 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7520 | }, |
| 7521 | CLASSIC, |
| 7522 | { |
| 7523 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7524 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7525 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7526 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7527 | [0x24] = 0xee, [0x25] = 0x99, |
| 7528 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7529 | }, |
| 7530 | { {0x40, 0x99ff } }, |
| 7531 | }, |
| 7532 | { |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7533 | "LD_ABS halfword positive offset, all ff", |
| 7534 | .u.insns = { |
| 7535 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3e), |
| 7536 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7537 | }, |
| 7538 | CLASSIC, |
| 7539 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7540 | { {0x40, 0xffff } }, |
| 7541 | }, |
| 7542 | { |
| 7543 | "LD_ABS halfword positive offset, out of bounds", |
| 7544 | .u.insns = { |
| 7545 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f), |
| 7546 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7547 | }, |
| 7548 | CLASSIC, |
| 7549 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7550 | { {0x3f, 0 }, }, |
| 7551 | }, |
| 7552 | { |
| 7553 | "LD_ABS halfword negative offset, out of bounds load", |
| 7554 | .u.insns = { |
| 7555 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, -1), |
| 7556 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7557 | }, |
| 7558 | CLASSIC | FLAG_EXPECTED_FAIL, |
| 7559 | .expected_errcode = -EINVAL, |
| 7560 | }, |
| 7561 | { |
| 7562 | "LD_ABS halfword negative offset, in bounds", |
| 7563 | .u.insns = { |
| 7564 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, SKF_LL_OFF + 0x3e), |
| 7565 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7566 | }, |
| 7567 | CLASSIC, |
| 7568 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7569 | { {0x40, 0x1982 }, }, |
| 7570 | }, |
| 7571 | { |
| 7572 | "LD_ABS halfword negative offset, out of bounds", |
| 7573 | .u.insns = { |
| 7574 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, SKF_LL_OFF + 0x3e), |
| 7575 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7576 | }, |
| 7577 | CLASSIC, |
| 7578 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7579 | { {0x3f, 0 }, }, |
| 7580 | }, |
| 7581 | { |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 7582 | "LD_ABS word", |
| 7583 | .u.insns = { |
| 7584 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x1c), |
| 7585 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7586 | }, |
| 7587 | CLASSIC, |
| 7588 | { |
| 7589 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7590 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7591 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7592 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7593 | [0x24] = 0xee, [0x25] = 0x99, |
| 7594 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7595 | }, |
| 7596 | { {0x40, 0xaa55bb66 } }, |
| 7597 | }, |
| 7598 | { |
| 7599 | "LD_ABS word unaligned (addr & 3 == 2)", |
| 7600 | .u.insns = { |
| 7601 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x22), |
| 7602 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7603 | }, |
| 7604 | CLASSIC, |
| 7605 | { |
| 7606 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7607 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7608 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7609 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7610 | [0x24] = 0xee, [0x25] = 0x99, |
| 7611 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7612 | }, |
| 7613 | { {0x40, 0xdd88ee99 } }, |
| 7614 | }, |
| 7615 | { |
| 7616 | "LD_ABS word unaligned (addr & 3 == 1)", |
| 7617 | .u.insns = { |
| 7618 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x21), |
| 7619 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7620 | }, |
| 7621 | CLASSIC, |
| 7622 | { |
| 7623 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7624 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7625 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7626 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7627 | [0x24] = 0xee, [0x25] = 0x99, |
| 7628 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7629 | }, |
| 7630 | { {0x40, 0x77dd88ee } }, |
| 7631 | }, |
| 7632 | { |
| 7633 | "LD_ABS word unaligned (addr & 3 == 3)", |
| 7634 | .u.insns = { |
| 7635 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x23), |
| 7636 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7637 | }, |
| 7638 | CLASSIC, |
| 7639 | { |
| 7640 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 7641 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 7642 | [0x20] = 0xcc, [0x21] = 0x77, |
| 7643 | [0x22] = 0xdd, [0x23] = 0x88, |
| 7644 | [0x24] = 0xee, [0x25] = 0x99, |
| 7645 | [0x26] = 0xff, [0x27] = 0xaa, |
| 7646 | }, |
| 7647 | { {0x40, 0x88ee99ff } }, |
| 7648 | }, |
Daniel Borkmann | 93731ef | 2018-05-04 01:08:13 +0200 | [diff] [blame] | 7649 | { |
| 7650 | "LD_ABS word positive offset, all ff", |
| 7651 | .u.insns = { |
| 7652 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3c), |
| 7653 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7654 | }, |
| 7655 | CLASSIC, |
| 7656 | { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff }, |
| 7657 | { {0x40, 0xffffffff } }, |
| 7658 | }, |
| 7659 | { |
| 7660 | "LD_ABS word positive offset, out of bounds", |
| 7661 | .u.insns = { |
| 7662 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3f), |
| 7663 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7664 | }, |
| 7665 | CLASSIC, |
| 7666 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7667 | { {0x3f, 0 }, }, |
| 7668 | }, |
| 7669 | { |
| 7670 | "LD_ABS word negative offset, out of bounds load", |
| 7671 | .u.insns = { |
| 7672 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, -1), |
| 7673 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7674 | }, |
| 7675 | CLASSIC | FLAG_EXPECTED_FAIL, |
| 7676 | .expected_errcode = -EINVAL, |
| 7677 | }, |
| 7678 | { |
| 7679 | "LD_ABS word negative offset, in bounds", |
| 7680 | .u.insns = { |
| 7681 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, SKF_LL_OFF + 0x3c), |
| 7682 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7683 | }, |
| 7684 | CLASSIC, |
| 7685 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7686 | { {0x40, 0x25051982 }, }, |
| 7687 | }, |
| 7688 | { |
| 7689 | "LD_ABS word negative offset, out of bounds", |
| 7690 | .u.insns = { |
| 7691 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, SKF_LL_OFF + 0x3c), |
| 7692 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7693 | }, |
| 7694 | CLASSIC, |
| 7695 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7696 | { {0x3f, 0 }, }, |
| 7697 | }, |
| 7698 | { |
| 7699 | "LDX_MSH standalone, preserved A", |
| 7700 | .u.insns = { |
| 7701 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7702 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c), |
| 7703 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7704 | }, |
| 7705 | CLASSIC, |
| 7706 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7707 | { {0x40, 0xffeebbaa }, }, |
| 7708 | }, |
| 7709 | { |
| 7710 | "LDX_MSH standalone, preserved A 2", |
| 7711 | .u.insns = { |
| 7712 | BPF_STMT(BPF_LD | BPF_IMM, 0x175e9d63), |
| 7713 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c), |
| 7714 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3d), |
| 7715 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3e), |
| 7716 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3f), |
| 7717 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7718 | }, |
| 7719 | CLASSIC, |
| 7720 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7721 | { {0x40, 0x175e9d63 }, }, |
| 7722 | }, |
| 7723 | { |
| 7724 | "LDX_MSH standalone, test result 1", |
| 7725 | .u.insns = { |
| 7726 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7727 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c), |
| 7728 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 7729 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7730 | }, |
| 7731 | CLASSIC, |
| 7732 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7733 | { {0x40, 0x14 }, }, |
| 7734 | }, |
| 7735 | { |
| 7736 | "LDX_MSH standalone, test result 2", |
| 7737 | .u.insns = { |
| 7738 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7739 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3e), |
| 7740 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 7741 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7742 | }, |
| 7743 | CLASSIC, |
| 7744 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7745 | { {0x40, 0x24 }, }, |
| 7746 | }, |
| 7747 | { |
| 7748 | "LDX_MSH standalone, negative offset", |
| 7749 | .u.insns = { |
| 7750 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7751 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, -1), |
| 7752 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 7753 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7754 | }, |
| 7755 | CLASSIC, |
| 7756 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7757 | { {0x40, 0 }, }, |
| 7758 | }, |
| 7759 | { |
| 7760 | "LDX_MSH standalone, negative offset 2", |
| 7761 | .u.insns = { |
| 7762 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7763 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, SKF_LL_OFF + 0x3e), |
| 7764 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 7765 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7766 | }, |
| 7767 | CLASSIC, |
| 7768 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7769 | { {0x40, 0x24 }, }, |
| 7770 | }, |
| 7771 | { |
| 7772 | "LDX_MSH standalone, out of bounds", |
| 7773 | .u.insns = { |
| 7774 | BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa), |
| 7775 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x40), |
| 7776 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 7777 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7778 | }, |
| 7779 | CLASSIC, |
| 7780 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 7781 | { {0x40, 0 }, }, |
| 7782 | }, |
Nicolas Schichan | 86bf172 | 2015-08-04 15:19:12 +0200 | [diff] [blame] | 7783 | /* |
| 7784 | * verify that the interpreter or JIT correctly sets A and X |
| 7785 | * to 0. |
| 7786 | */ |
| 7787 | { |
| 7788 | "ADD default X", |
| 7789 | .u.insns = { |
| 7790 | /* |
| 7791 | * A = 0x42 |
| 7792 | * A = A + X |
| 7793 | * ret A |
| 7794 | */ |
| 7795 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 7796 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 7797 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7798 | }, |
| 7799 | CLASSIC | FLAG_NO_DATA, |
| 7800 | {}, |
| 7801 | { {0x1, 0x42 } }, |
| 7802 | }, |
| 7803 | { |
| 7804 | "ADD default A", |
| 7805 | .u.insns = { |
| 7806 | /* |
| 7807 | * A = A + 0x42 |
| 7808 | * ret A |
| 7809 | */ |
| 7810 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0x42), |
| 7811 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7812 | }, |
| 7813 | CLASSIC | FLAG_NO_DATA, |
| 7814 | {}, |
| 7815 | { {0x1, 0x42 } }, |
| 7816 | }, |
| 7817 | { |
| 7818 | "SUB default X", |
| 7819 | .u.insns = { |
| 7820 | /* |
| 7821 | * A = 0x66 |
| 7822 | * A = A - X |
| 7823 | * ret A |
| 7824 | */ |
| 7825 | BPF_STMT(BPF_LD | BPF_IMM, 0x66), |
| 7826 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 7827 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7828 | }, |
| 7829 | CLASSIC | FLAG_NO_DATA, |
| 7830 | {}, |
| 7831 | { {0x1, 0x66 } }, |
| 7832 | }, |
| 7833 | { |
| 7834 | "SUB default A", |
| 7835 | .u.insns = { |
| 7836 | /* |
| 7837 | * A = A - -0x66 |
| 7838 | * ret A |
| 7839 | */ |
| 7840 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, -0x66), |
| 7841 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7842 | }, |
| 7843 | CLASSIC | FLAG_NO_DATA, |
| 7844 | {}, |
| 7845 | { {0x1, 0x66 } }, |
| 7846 | }, |
| 7847 | { |
| 7848 | "MUL default X", |
| 7849 | .u.insns = { |
| 7850 | /* |
| 7851 | * A = 0x42 |
| 7852 | * A = A * X |
| 7853 | * ret A |
| 7854 | */ |
| 7855 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 7856 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_X, 0), |
| 7857 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7858 | }, |
| 7859 | CLASSIC | FLAG_NO_DATA, |
| 7860 | {}, |
| 7861 | { {0x1, 0x0 } }, |
| 7862 | }, |
| 7863 | { |
| 7864 | "MUL default A", |
| 7865 | .u.insns = { |
| 7866 | /* |
| 7867 | * A = A * 0x66 |
| 7868 | * ret A |
| 7869 | */ |
| 7870 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 0x66), |
| 7871 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7872 | }, |
| 7873 | CLASSIC | FLAG_NO_DATA, |
| 7874 | {}, |
| 7875 | { {0x1, 0x0 } }, |
| 7876 | }, |
| 7877 | { |
| 7878 | "DIV default X", |
| 7879 | .u.insns = { |
| 7880 | /* |
| 7881 | * A = 0x42 |
| 7882 | * A = A / X ; this halt the filter execution if X is 0 |
| 7883 | * ret 0x42 |
| 7884 | */ |
| 7885 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 7886 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0), |
| 7887 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 7888 | }, |
| 7889 | CLASSIC | FLAG_NO_DATA, |
| 7890 | {}, |
| 7891 | { {0x1, 0x0 } }, |
| 7892 | }, |
| 7893 | { |
| 7894 | "DIV default A", |
| 7895 | .u.insns = { |
| 7896 | /* |
| 7897 | * A = A / 1 |
| 7898 | * ret A |
| 7899 | */ |
| 7900 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x1), |
| 7901 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7902 | }, |
| 7903 | CLASSIC | FLAG_NO_DATA, |
| 7904 | {}, |
| 7905 | { {0x1, 0x0 } }, |
| 7906 | }, |
| 7907 | { |
Yang Shi | d4e4bc1 | 2015-11-04 11:36:37 -0800 | [diff] [blame] | 7908 | "MOD default X", |
| 7909 | .u.insns = { |
| 7910 | /* |
| 7911 | * A = 0x42 |
| 7912 | * A = A mod X ; this halt the filter execution if X is 0 |
| 7913 | * ret 0x42 |
| 7914 | */ |
| 7915 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 7916 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), |
| 7917 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 7918 | }, |
| 7919 | CLASSIC | FLAG_NO_DATA, |
| 7920 | {}, |
| 7921 | { {0x1, 0x0 } }, |
| 7922 | }, |
| 7923 | { |
| 7924 | "MOD default A", |
| 7925 | .u.insns = { |
| 7926 | /* |
| 7927 | * A = A mod 1 |
| 7928 | * ret A |
| 7929 | */ |
| 7930 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1), |
| 7931 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 7932 | }, |
| 7933 | CLASSIC | FLAG_NO_DATA, |
| 7934 | {}, |
| 7935 | { {0x1, 0x0 } }, |
| 7936 | }, |
| 7937 | { |
Nicolas Schichan | 86bf172 | 2015-08-04 15:19:12 +0200 | [diff] [blame] | 7938 | "JMP EQ default A", |
| 7939 | .u.insns = { |
| 7940 | /* |
| 7941 | * cmp A, 0x0, 0, 1 |
| 7942 | * ret 0x42 |
| 7943 | * ret 0x66 |
| 7944 | */ |
| 7945 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0, 0, 1), |
| 7946 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 7947 | BPF_STMT(BPF_RET | BPF_K, 0x66), |
| 7948 | }, |
| 7949 | CLASSIC | FLAG_NO_DATA, |
| 7950 | {}, |
| 7951 | { {0x1, 0x42 } }, |
| 7952 | }, |
| 7953 | { |
| 7954 | "JMP EQ default X", |
| 7955 | .u.insns = { |
| 7956 | /* |
| 7957 | * A = 0x0 |
| 7958 | * cmp A, X, 0, 1 |
| 7959 | * ret 0x42 |
| 7960 | * ret 0x66 |
| 7961 | */ |
| 7962 | BPF_STMT(BPF_LD | BPF_IMM, 0x0), |
| 7963 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0x0, 0, 1), |
| 7964 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 7965 | BPF_STMT(BPF_RET | BPF_K, 0x66), |
| 7966 | }, |
| 7967 | CLASSIC | FLAG_NO_DATA, |
| 7968 | {}, |
| 7969 | { {0x1, 0x42 } }, |
| 7970 | }, |
Daniel Borkmann | fcd1c91 | 2018-01-20 01:24:31 +0100 | [diff] [blame] | 7971 | /* Checking interpreter vs JIT wrt signed extended imms. */ |
| 7972 | { |
| 7973 | "JNE signed compare, test 1", |
| 7974 | .u.insns_int = { |
| 7975 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12), |
| 7976 | BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000), |
| 7977 | BPF_MOV64_REG(R2, R1), |
| 7978 | BPF_ALU64_REG(BPF_AND, R2, R3), |
| 7979 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 7980 | BPF_JMP_IMM(BPF_JNE, R2, -17104896, 1), |
| 7981 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 7982 | BPF_EXIT_INSN(), |
| 7983 | }, |
| 7984 | INTERNAL, |
| 7985 | { }, |
| 7986 | { { 0, 1 } }, |
| 7987 | }, |
| 7988 | { |
| 7989 | "JNE signed compare, test 2", |
| 7990 | .u.insns_int = { |
| 7991 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12), |
| 7992 | BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000), |
| 7993 | BPF_MOV64_REG(R2, R1), |
| 7994 | BPF_ALU64_REG(BPF_AND, R2, R3), |
| 7995 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 7996 | BPF_JMP_IMM(BPF_JNE, R2, 0xfefb0000, 1), |
| 7997 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 7998 | BPF_EXIT_INSN(), |
| 7999 | }, |
| 8000 | INTERNAL, |
| 8001 | { }, |
| 8002 | { { 0, 1 } }, |
| 8003 | }, |
| 8004 | { |
| 8005 | "JNE signed compare, test 3", |
| 8006 | .u.insns_int = { |
| 8007 | BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12), |
| 8008 | BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000), |
| 8009 | BPF_ALU32_IMM(BPF_MOV, R4, 0xfefb0000), |
| 8010 | BPF_MOV64_REG(R2, R1), |
| 8011 | BPF_ALU64_REG(BPF_AND, R2, R3), |
| 8012 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 8013 | BPF_JMP_REG(BPF_JNE, R2, R4, 1), |
| 8014 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 8015 | BPF_EXIT_INSN(), |
| 8016 | }, |
| 8017 | INTERNAL, |
| 8018 | { }, |
| 8019 | { { 0, 2 } }, |
| 8020 | }, |
| 8021 | { |
| 8022 | "JNE signed compare, test 4", |
| 8023 | .u.insns_int = { |
| 8024 | BPF_LD_IMM64(R1, -17104896), |
| 8025 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 8026 | BPF_JMP_IMM(BPF_JNE, R1, -17104896, 1), |
| 8027 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 8028 | BPF_EXIT_INSN(), |
| 8029 | }, |
| 8030 | INTERNAL, |
| 8031 | { }, |
| 8032 | { { 0, 2 } }, |
| 8033 | }, |
| 8034 | { |
| 8035 | "JNE signed compare, test 5", |
| 8036 | .u.insns_int = { |
| 8037 | BPF_LD_IMM64(R1, 0xfefb0000), |
| 8038 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 8039 | BPF_JMP_IMM(BPF_JNE, R1, 0xfefb0000, 1), |
| 8040 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 8041 | BPF_EXIT_INSN(), |
| 8042 | }, |
| 8043 | INTERNAL, |
| 8044 | { }, |
| 8045 | { { 0, 1 } }, |
| 8046 | }, |
| 8047 | { |
| 8048 | "JNE signed compare, test 6", |
| 8049 | .u.insns_int = { |
| 8050 | BPF_LD_IMM64(R1, 0x7efb0000), |
| 8051 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 8052 | BPF_JMP_IMM(BPF_JNE, R1, 0x7efb0000, 1), |
| 8053 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 8054 | BPF_EXIT_INSN(), |
| 8055 | }, |
| 8056 | INTERNAL, |
| 8057 | { }, |
| 8058 | { { 0, 2 } }, |
| 8059 | }, |
| 8060 | { |
| 8061 | "JNE signed compare, test 7", |
| 8062 | .u.insns = { |
| 8063 | BPF_STMT(BPF_LD | BPF_IMM, 0xffff0000), |
| 8064 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 8065 | BPF_STMT(BPF_LD | BPF_IMM, 0xfefbbc12), |
| 8066 | BPF_STMT(BPF_ALU | BPF_AND | BPF_X, 0), |
| 8067 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0xfefb0000, 1, 0), |
| 8068 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 8069 | BPF_STMT(BPF_RET | BPF_K, 2), |
| 8070 | }, |
| 8071 | CLASSIC | FLAG_NO_DATA, |
| 8072 | {}, |
| 8073 | { { 0, 2 } }, |
| 8074 | }, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8075 | }; |
| 8076 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8077 | static struct net_device dev; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8078 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8079 | static struct sk_buff *populate_skb(char *buf, int size) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8080 | { |
| 8081 | struct sk_buff *skb; |
| 8082 | |
| 8083 | if (size >= MAX_DATA) |
| 8084 | return NULL; |
| 8085 | |
| 8086 | skb = alloc_skb(MAX_DATA, GFP_KERNEL); |
| 8087 | if (!skb) |
| 8088 | return NULL; |
| 8089 | |
yuan linyu | de77b96 | 2017-06-18 22:48:17 +0800 | [diff] [blame] | 8090 | __skb_put_data(skb, buf, size); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8091 | |
| 8092 | /* Initialize a fake skb with test pattern. */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8093 | skb_reset_mac_header(skb); |
| 8094 | skb->protocol = htons(ETH_P_IP); |
| 8095 | skb->pkt_type = SKB_TYPE; |
| 8096 | skb->mark = SKB_MARK; |
| 8097 | skb->hash = SKB_HASH; |
| 8098 | skb->queue_mapping = SKB_QUEUE_MAP; |
| 8099 | skb->vlan_tci = SKB_VLAN_TCI; |
Michał Mirosław | 0c4b2d3 | 2018-11-10 19:58:36 +0100 | [diff] [blame] | 8100 | skb->vlan_present = SKB_VLAN_PRESENT; |
Jakub Kicinski | 5c0ca3f | 2016-09-12 13:04:57 +0100 | [diff] [blame] | 8101 | skb->vlan_proto = htons(ETH_P_IP); |
Song Liu | 10081193 | 2018-09-27 09:34:41 -0700 | [diff] [blame] | 8102 | dev_net_set(&dev, &init_net); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8103 | skb->dev = &dev; |
| 8104 | skb->dev->ifindex = SKB_DEV_IFINDEX; |
| 8105 | skb->dev->type = SKB_DEV_TYPE; |
| 8106 | skb_set_network_header(skb, min(size, ETH_HLEN)); |
| 8107 | |
| 8108 | return skb; |
| 8109 | } |
| 8110 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8111 | static void *generate_test_data(struct bpf_test *test, int sub) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8112 | { |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 8113 | struct sk_buff *skb; |
| 8114 | struct page *page; |
| 8115 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8116 | if (test->aux & FLAG_NO_DATA) |
| 8117 | return NULL; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8118 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8119 | /* Test case expects an skb, so populate one. Various |
| 8120 | * subtests generate skbs of different sizes based on |
| 8121 | * the same data. |
| 8122 | */ |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 8123 | skb = populate_skb(test->data, test->test[sub].data_size); |
| 8124 | if (!skb) |
| 8125 | return NULL; |
| 8126 | |
| 8127 | if (test->aux & FLAG_SKB_FRAG) { |
| 8128 | /* |
| 8129 | * when the test requires a fragmented skb, add a |
| 8130 | * single fragment to the skb, filled with |
| 8131 | * test->frag_data. |
| 8132 | */ |
| 8133 | void *ptr; |
| 8134 | |
| 8135 | page = alloc_page(GFP_KERNEL); |
| 8136 | |
| 8137 | if (!page) |
| 8138 | goto err_kfree_skb; |
| 8139 | |
| 8140 | ptr = kmap(page); |
| 8141 | if (!ptr) |
| 8142 | goto err_free_page; |
| 8143 | memcpy(ptr, test->frag_data, MAX_DATA); |
| 8144 | kunmap(page); |
| 8145 | skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA); |
| 8146 | } |
| 8147 | |
| 8148 | return skb; |
| 8149 | |
| 8150 | err_free_page: |
| 8151 | __free_page(page); |
| 8152 | err_kfree_skb: |
| 8153 | kfree_skb(skb); |
| 8154 | return NULL; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8155 | } |
| 8156 | |
| 8157 | static void release_test_data(const struct bpf_test *test, void *data) |
| 8158 | { |
| 8159 | if (test->aux & FLAG_NO_DATA) |
| 8160 | return; |
| 8161 | |
| 8162 | kfree_skb(data); |
| 8163 | } |
| 8164 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8165 | static int filter_length(int which) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8166 | { |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8167 | struct sock_filter *fp; |
| 8168 | int len; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8169 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8170 | if (tests[which].fill_helper) |
| 8171 | return tests[which].u.ptr.len; |
| 8172 | |
| 8173 | fp = tests[which].u.insns; |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 8174 | for (len = MAX_INSNS - 1; len > 0; --len) |
| 8175 | if (fp[len].code != 0 || fp[len].k != 0) |
| 8176 | break; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8177 | |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 8178 | return len + 1; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8179 | } |
| 8180 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8181 | static void *filter_pointer(int which) |
| 8182 | { |
| 8183 | if (tests[which].fill_helper) |
| 8184 | return tests[which].u.ptr.insns; |
| 8185 | else |
| 8186 | return tests[which].u.insns; |
| 8187 | } |
| 8188 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8189 | static struct bpf_prog *generate_filter(int which, int *err) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8190 | { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8191 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8192 | unsigned int flen = filter_length(which); |
| 8193 | void *fptr = filter_pointer(which); |
| 8194 | struct sock_fprog_kern fprog; |
| 8195 | struct bpf_prog *fp; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8196 | |
| 8197 | switch (test_type) { |
| 8198 | case CLASSIC: |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8199 | fprog.filter = fptr; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8200 | fprog.len = flen; |
| 8201 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8202 | *err = bpf_prog_create(&fp, &fprog); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8203 | if (tests[which].aux & FLAG_EXPECTED_FAIL) { |
Yonghong Song | 09584b4 | 2018-02-02 22:37:15 -0800 | [diff] [blame] | 8204 | if (*err == tests[which].expected_errcode) { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8205 | pr_cont("PASS\n"); |
| 8206 | /* Verifier rejected filter as expected. */ |
| 8207 | *err = 0; |
| 8208 | return NULL; |
| 8209 | } else { |
| 8210 | pr_cont("UNEXPECTED_PASS\n"); |
| 8211 | /* Verifier didn't reject the test that's |
| 8212 | * bad enough, just return! |
| 8213 | */ |
| 8214 | *err = -EINVAL; |
| 8215 | return NULL; |
| 8216 | } |
| 8217 | } |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8218 | if (*err) { |
Alexei Starovoitov | 290af86 | 2018-01-09 10:04:29 -0800 | [diff] [blame] | 8219 | pr_cont("FAIL to prog_create err=%d len=%d\n", |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8220 | *err, fprog.len); |
| 8221 | return NULL; |
| 8222 | } |
| 8223 | break; |
| 8224 | |
| 8225 | case INTERNAL: |
Daniel Borkmann | 60a3b22 | 2014-09-02 22:53:44 +0200 | [diff] [blame] | 8226 | fp = bpf_prog_alloc(bpf_prog_size(flen), 0); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8227 | if (fp == NULL) { |
| 8228 | pr_cont("UNEXPECTED_FAIL no memory left\n"); |
| 8229 | *err = -ENOMEM; |
| 8230 | return NULL; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8231 | } |
| 8232 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8233 | fp->len = flen; |
Daniel Borkmann | 4962fa1 | 2015-07-30 12:42:46 +0200 | [diff] [blame] | 8234 | /* Type doesn't really matter here as long as it's not unspec. */ |
| 8235 | fp->type = BPF_PROG_TYPE_SOCKET_FILTER; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8236 | memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn)); |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 8237 | fp->aux->stack_depth = tests[which].stack_depth; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8238 | |
Daniel Borkmann | d1c55ab | 2016-05-13 19:08:31 +0200 | [diff] [blame] | 8239 | /* We cannot error here as we don't need type compatibility |
| 8240 | * checks. |
| 8241 | */ |
| 8242 | fp = bpf_prog_select_runtime(fp, err); |
Alexei Starovoitov | 290af86 | 2018-01-09 10:04:29 -0800 | [diff] [blame] | 8243 | if (*err) { |
| 8244 | pr_cont("FAIL to select_runtime err=%d\n", *err); |
| 8245 | return NULL; |
| 8246 | } |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8247 | break; |
| 8248 | } |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8249 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8250 | *err = 0; |
| 8251 | return fp; |
| 8252 | } |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8253 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8254 | static void release_filter(struct bpf_prog *fp, int which) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8255 | { |
| 8256 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8257 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8258 | switch (test_type) { |
| 8259 | case CLASSIC: |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8260 | bpf_prog_destroy(fp); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8261 | break; |
| 8262 | case INTERNAL: |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8263 | bpf_prog_free(fp); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8264 | break; |
| 8265 | } |
| 8266 | } |
| 8267 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8268 | static int __run_one(const struct bpf_prog *fp, const void *data, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8269 | int runs, u64 *duration) |
| 8270 | { |
| 8271 | u64 start, finish; |
Alexei Starovoitov | 25ee732 | 2014-09-19 13:53:51 -0700 | [diff] [blame] | 8272 | int ret = 0, i; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8273 | |
David Miller | 6eac779 | 2020-02-24 15:01:44 +0100 | [diff] [blame] | 8274 | migrate_disable(); |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 8275 | start = ktime_get_ns(); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8276 | |
| 8277 | for (i = 0; i < runs; i++) |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8278 | ret = BPF_PROG_RUN(fp, data); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8279 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 8280 | finish = ktime_get_ns(); |
David Miller | 6eac779 | 2020-02-24 15:01:44 +0100 | [diff] [blame] | 8281 | migrate_enable(); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8282 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 8283 | *duration = finish - start; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8284 | do_div(*duration, runs); |
| 8285 | |
| 8286 | return ret; |
| 8287 | } |
| 8288 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8289 | static int run_one(const struct bpf_prog *fp, struct bpf_test *test) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8290 | { |
| 8291 | int err_cnt = 0, i, runs = MAX_TESTRUNS; |
| 8292 | |
| 8293 | for (i = 0; i < MAX_SUBTESTS; i++) { |
| 8294 | void *data; |
| 8295 | u64 duration; |
| 8296 | u32 ret; |
| 8297 | |
Johan Almbladh | 2b7e9f2 | 2021-07-21 12:38:22 +0200 | [diff] [blame] | 8298 | /* |
| 8299 | * NOTE: Several sub-tests may be present, in which case |
| 8300 | * a zero {data_size, result} tuple indicates the end of |
| 8301 | * the sub-test array. The first test is always run, |
| 8302 | * even if both data_size and result happen to be zero. |
| 8303 | */ |
| 8304 | if (i > 0 && |
| 8305 | test->test[i].data_size == 0 && |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8306 | test->test[i].result == 0) |
| 8307 | break; |
| 8308 | |
| 8309 | data = generate_test_data(test, i); |
Nicolas Schichan | e34684f | 2015-08-04 15:19:07 +0200 | [diff] [blame] | 8310 | if (!data && !(test->aux & FLAG_NO_DATA)) { |
| 8311 | pr_cont("data generation failed "); |
| 8312 | err_cnt++; |
| 8313 | break; |
| 8314 | } |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8315 | ret = __run_one(fp, data, runs, &duration); |
| 8316 | release_test_data(test, data); |
| 8317 | |
| 8318 | if (ret == test->test[i].result) { |
| 8319 | pr_cont("%lld ", duration); |
| 8320 | } else { |
| 8321 | pr_cont("ret %d != %d ", ret, |
| 8322 | test->test[i].result); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8323 | err_cnt++; |
| 8324 | } |
| 8325 | } |
| 8326 | |
| 8327 | return err_cnt; |
| 8328 | } |
| 8329 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 8330 | static char test_name[64]; |
| 8331 | module_param_string(test_name, test_name, sizeof(test_name), 0); |
| 8332 | |
| 8333 | static int test_id = -1; |
| 8334 | module_param(test_id, int, 0); |
| 8335 | |
| 8336 | static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 }; |
| 8337 | module_param_array(test_range, int, NULL, 0); |
| 8338 | |
| 8339 | static __init int find_test_index(const char *test_name) |
| 8340 | { |
| 8341 | int i; |
| 8342 | |
| 8343 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 8344 | if (!strcmp(tests[i].descr, test_name)) |
| 8345 | return i; |
| 8346 | } |
| 8347 | return -1; |
| 8348 | } |
| 8349 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8350 | static __init int prepare_bpf_tests(void) |
| 8351 | { |
| 8352 | int i; |
| 8353 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 8354 | if (test_id >= 0) { |
| 8355 | /* |
| 8356 | * if a test_id was specified, use test_range to |
| 8357 | * cover only that test. |
| 8358 | */ |
| 8359 | if (test_id >= ARRAY_SIZE(tests)) { |
| 8360 | pr_err("test_bpf: invalid test_id specified.\n"); |
| 8361 | return -EINVAL; |
| 8362 | } |
| 8363 | |
| 8364 | test_range[0] = test_id; |
| 8365 | test_range[1] = test_id; |
| 8366 | } else if (*test_name) { |
| 8367 | /* |
| 8368 | * if a test_name was specified, find it and setup |
| 8369 | * test_range to cover only that test. |
| 8370 | */ |
| 8371 | int idx = find_test_index(test_name); |
| 8372 | |
| 8373 | if (idx < 0) { |
| 8374 | pr_err("test_bpf: no test named '%s' found.\n", |
| 8375 | test_name); |
| 8376 | return -EINVAL; |
| 8377 | } |
| 8378 | test_range[0] = idx; |
| 8379 | test_range[1] = idx; |
| 8380 | } else { |
| 8381 | /* |
| 8382 | * check that the supplied test_range is valid. |
| 8383 | */ |
| 8384 | if (test_range[0] >= ARRAY_SIZE(tests) || |
| 8385 | test_range[1] >= ARRAY_SIZE(tests) || |
| 8386 | test_range[0] < 0 || test_range[1] < 0) { |
| 8387 | pr_err("test_bpf: test_range is out of bound.\n"); |
| 8388 | return -EINVAL; |
| 8389 | } |
| 8390 | |
| 8391 | if (test_range[1] < test_range[0]) { |
| 8392 | pr_err("test_bpf: test_range is ending before it starts.\n"); |
| 8393 | return -EINVAL; |
| 8394 | } |
| 8395 | } |
| 8396 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8397 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 8398 | if (tests[i].fill_helper && |
| 8399 | tests[i].fill_helper(&tests[i]) < 0) |
| 8400 | return -ENOMEM; |
| 8401 | } |
| 8402 | |
| 8403 | return 0; |
| 8404 | } |
| 8405 | |
| 8406 | static __init void destroy_bpf_tests(void) |
| 8407 | { |
| 8408 | int i; |
| 8409 | |
| 8410 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 8411 | if (tests[i].fill_helper) |
| 8412 | kfree(tests[i].u.ptr.insns); |
| 8413 | } |
| 8414 | } |
| 8415 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 8416 | static bool exclude_test(int test_id) |
| 8417 | { |
| 8418 | return test_id < test_range[0] || test_id > test_range[1]; |
| 8419 | } |
| 8420 | |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8421 | static __init struct sk_buff *build_test_skb(void) |
| 8422 | { |
| 8423 | u32 headroom = NET_SKB_PAD + NET_IP_ALIGN + ETH_HLEN; |
| 8424 | struct sk_buff *skb[2]; |
| 8425 | struct page *page[2]; |
| 8426 | int i, data_size = 8; |
| 8427 | |
| 8428 | for (i = 0; i < 2; i++) { |
| 8429 | page[i] = alloc_page(GFP_KERNEL); |
| 8430 | if (!page[i]) { |
| 8431 | if (i == 0) |
| 8432 | goto err_page0; |
| 8433 | else |
| 8434 | goto err_page1; |
| 8435 | } |
| 8436 | |
| 8437 | /* this will set skb[i]->head_frag */ |
| 8438 | skb[i] = dev_alloc_skb(headroom + data_size); |
| 8439 | if (!skb[i]) { |
| 8440 | if (i == 0) |
| 8441 | goto err_skb0; |
| 8442 | else |
| 8443 | goto err_skb1; |
| 8444 | } |
| 8445 | |
| 8446 | skb_reserve(skb[i], headroom); |
| 8447 | skb_put(skb[i], data_size); |
| 8448 | skb[i]->protocol = htons(ETH_P_IP); |
| 8449 | skb_reset_network_header(skb[i]); |
| 8450 | skb_set_mac_header(skb[i], -ETH_HLEN); |
| 8451 | |
| 8452 | skb_add_rx_frag(skb[i], 0, page[i], 0, 64, 64); |
| 8453 | // skb_headlen(skb[i]): 8, skb[i]->head_frag = 1 |
| 8454 | } |
| 8455 | |
| 8456 | /* setup shinfo */ |
| 8457 | skb_shinfo(skb[0])->gso_size = 1448; |
| 8458 | skb_shinfo(skb[0])->gso_type = SKB_GSO_TCPV4; |
| 8459 | skb_shinfo(skb[0])->gso_type |= SKB_GSO_DODGY; |
| 8460 | skb_shinfo(skb[0])->gso_segs = 0; |
| 8461 | skb_shinfo(skb[0])->frag_list = skb[1]; |
| 8462 | |
| 8463 | /* adjust skb[0]'s len */ |
| 8464 | skb[0]->len += skb[1]->len; |
| 8465 | skb[0]->data_len += skb[1]->data_len; |
| 8466 | skb[0]->truesize += skb[1]->truesize; |
| 8467 | |
| 8468 | return skb[0]; |
| 8469 | |
| 8470 | err_skb1: |
| 8471 | __free_page(page[1]); |
| 8472 | err_page1: |
| 8473 | kfree_skb(skb[0]); |
| 8474 | err_skb0: |
| 8475 | __free_page(page[0]); |
| 8476 | err_page0: |
| 8477 | return NULL; |
| 8478 | } |
| 8479 | |
Shmulik Ladkani | cf204a7 | 2019-10-25 16:42:23 +0300 | [diff] [blame] | 8480 | static __init struct sk_buff *build_test_skb_linear_no_head_frag(void) |
| 8481 | { |
| 8482 | unsigned int alloc_size = 2000; |
| 8483 | unsigned int headroom = 102, doffset = 72, data_size = 1308; |
| 8484 | struct sk_buff *skb[2]; |
| 8485 | int i; |
| 8486 | |
| 8487 | /* skbs linked in a frag_list, both with linear data, with head_frag=0 |
| 8488 | * (data allocated by kmalloc), both have tcp data of 1308 bytes |
| 8489 | * (total payload is 2616 bytes). |
| 8490 | * Data offset is 72 bytes (40 ipv6 hdr, 32 tcp hdr). Some headroom. |
| 8491 | */ |
| 8492 | for (i = 0; i < 2; i++) { |
| 8493 | skb[i] = alloc_skb(alloc_size, GFP_KERNEL); |
| 8494 | if (!skb[i]) { |
| 8495 | if (i == 0) |
| 8496 | goto err_skb0; |
| 8497 | else |
| 8498 | goto err_skb1; |
| 8499 | } |
| 8500 | |
| 8501 | skb[i]->protocol = htons(ETH_P_IPV6); |
| 8502 | skb_reserve(skb[i], headroom); |
| 8503 | skb_put(skb[i], doffset + data_size); |
| 8504 | skb_reset_network_header(skb[i]); |
| 8505 | if (i == 0) |
| 8506 | skb_reset_mac_header(skb[i]); |
| 8507 | else |
| 8508 | skb_set_mac_header(skb[i], -ETH_HLEN); |
| 8509 | __skb_pull(skb[i], doffset); |
| 8510 | } |
| 8511 | |
| 8512 | /* setup shinfo. |
| 8513 | * mimic bpf_skb_proto_4_to_6, which resets gso_segs and assigns a |
| 8514 | * reduced gso_size. |
| 8515 | */ |
| 8516 | skb_shinfo(skb[0])->gso_size = 1288; |
| 8517 | skb_shinfo(skb[0])->gso_type = SKB_GSO_TCPV6 | SKB_GSO_DODGY; |
| 8518 | skb_shinfo(skb[0])->gso_segs = 0; |
| 8519 | skb_shinfo(skb[0])->frag_list = skb[1]; |
| 8520 | |
| 8521 | /* adjust skb[0]'s len */ |
| 8522 | skb[0]->len += skb[1]->len; |
| 8523 | skb[0]->data_len += skb[1]->len; |
| 8524 | skb[0]->truesize += skb[1]->truesize; |
| 8525 | |
| 8526 | return skb[0]; |
| 8527 | |
| 8528 | err_skb1: |
| 8529 | kfree_skb(skb[0]); |
| 8530 | err_skb0: |
| 8531 | return NULL; |
| 8532 | } |
| 8533 | |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8534 | struct skb_segment_test { |
| 8535 | const char *descr; |
| 8536 | struct sk_buff *(*build_skb)(void); |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8537 | netdev_features_t features; |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8538 | }; |
| 8539 | |
| 8540 | static struct skb_segment_test skb_segment_tests[] __initconst = { |
| 8541 | { |
| 8542 | .descr = "gso_with_rx_frags", |
| 8543 | .build_skb = build_test_skb, |
| 8544 | .features = NETIF_F_SG | NETIF_F_GSO_PARTIAL | NETIF_F_IP_CSUM | |
| 8545 | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
Shmulik Ladkani | cf204a7 | 2019-10-25 16:42:23 +0300 | [diff] [blame] | 8546 | }, |
| 8547 | { |
| 8548 | .descr = "gso_linear_no_head_frag", |
| 8549 | .build_skb = build_test_skb_linear_no_head_frag, |
| 8550 | .features = NETIF_F_SG | NETIF_F_FRAGLIST | |
| 8551 | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_GSO | |
| 8552 | NETIF_F_LLTX_BIT | NETIF_F_GRO | |
| 8553 | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | |
| 8554 | NETIF_F_HW_VLAN_STAG_TX_BIT |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8555 | } |
| 8556 | }; |
| 8557 | |
| 8558 | static __init int test_skb_segment_single(const struct skb_segment_test *test) |
| 8559 | { |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8560 | struct sk_buff *skb, *segs; |
| 8561 | int ret = -1; |
| 8562 | |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8563 | skb = test->build_skb(); |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8564 | if (!skb) { |
| 8565 | pr_info("%s: failed to build_test_skb", __func__); |
| 8566 | goto done; |
| 8567 | } |
| 8568 | |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8569 | segs = skb_segment(skb, test->features); |
Dan Carpenter | 99fe29d | 2018-03-28 14:48:36 +0300 | [diff] [blame] | 8570 | if (!IS_ERR(segs)) { |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8571 | kfree_skb_list(segs); |
| 8572 | ret = 0; |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8573 | } |
| 8574 | kfree_skb(skb); |
| 8575 | done: |
| 8576 | return ret; |
| 8577 | } |
| 8578 | |
Shmulik Ladkani | af21c71 | 2019-10-25 16:42:22 +0300 | [diff] [blame] | 8579 | static __init int test_skb_segment(void) |
| 8580 | { |
| 8581 | int i, err_cnt = 0, pass_cnt = 0; |
| 8582 | |
| 8583 | for (i = 0; i < ARRAY_SIZE(skb_segment_tests); i++) { |
| 8584 | const struct skb_segment_test *test = &skb_segment_tests[i]; |
| 8585 | |
| 8586 | pr_info("#%d %s ", i, test->descr); |
| 8587 | |
| 8588 | if (test_skb_segment_single(test)) { |
| 8589 | pr_cont("FAIL\n"); |
| 8590 | err_cnt++; |
| 8591 | } else { |
| 8592 | pr_cont("PASS\n"); |
| 8593 | pass_cnt++; |
| 8594 | } |
| 8595 | } |
| 8596 | |
| 8597 | pr_info("%s: Summary: %d PASSED, %d FAILED\n", __func__, |
| 8598 | pass_cnt, err_cnt); |
| 8599 | return err_cnt ? -EINVAL : 0; |
| 8600 | } |
| 8601 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8602 | static __init int test_bpf(void) |
| 8603 | { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8604 | int i, err_cnt = 0, pass_cnt = 0; |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 8605 | int jit_cnt = 0, run_cnt = 0; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8606 | |
| 8607 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 8608 | struct bpf_prog *fp; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8609 | int err; |
| 8610 | |
Eric Dumazet | d40bc96 | 2018-02-26 10:52:46 -0800 | [diff] [blame] | 8611 | cond_resched(); |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 8612 | if (exclude_test(i)) |
| 8613 | continue; |
| 8614 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8615 | pr_info("#%d %s ", i, tests[i].descr); |
| 8616 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8617 | fp = generate_filter(i, &err); |
| 8618 | if (fp == NULL) { |
| 8619 | if (err == 0) { |
| 8620 | pass_cnt++; |
| 8621 | continue; |
| 8622 | } |
Alexei Starovoitov | 290af86 | 2018-01-09 10:04:29 -0800 | [diff] [blame] | 8623 | err_cnt++; |
| 8624 | continue; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8625 | } |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 8626 | |
| 8627 | pr_cont("jited:%u ", fp->jited); |
| 8628 | |
| 8629 | run_cnt++; |
| 8630 | if (fp->jited) |
| 8631 | jit_cnt++; |
| 8632 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8633 | err = run_one(fp, &tests[i]); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8634 | release_filter(fp, i); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8635 | |
| 8636 | if (err) { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8637 | pr_cont("FAIL (%d times)\n", err); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8638 | err_cnt++; |
| 8639 | } else { |
| 8640 | pr_cont("PASS\n"); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8641 | pass_cnt++; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8642 | } |
| 8643 | } |
| 8644 | |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 8645 | pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n", |
| 8646 | pass_cnt, err_cnt, jit_cnt, run_cnt); |
| 8647 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8648 | return err_cnt ? -EINVAL : 0; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8649 | } |
| 8650 | |
| 8651 | static int __init test_bpf_init(void) |
| 8652 | { |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8653 | int ret; |
| 8654 | |
| 8655 | ret = prepare_bpf_tests(); |
| 8656 | if (ret < 0) |
| 8657 | return ret; |
| 8658 | |
| 8659 | ret = test_bpf(); |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 8660 | destroy_bpf_tests(); |
Yonghong Song | 76db808 | 2018-03-21 16:31:04 -0700 | [diff] [blame] | 8661 | if (ret) |
| 8662 | return ret; |
| 8663 | |
| 8664 | return test_skb_segment(); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8665 | } |
| 8666 | |
| 8667 | static void __exit test_bpf_exit(void) |
| 8668 | { |
| 8669 | } |
| 8670 | |
| 8671 | module_init(test_bpf_init); |
| 8672 | module_exit(test_bpf_exit); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 8673 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 8674 | MODULE_LICENSE("GPL"); |