Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Testsuite for BPF interpreter and BPF JIT compiler |
| 3 | * |
| 4 | * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of version 2 of the GNU General Public |
| 8 | * License as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 17 | |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/filter.h> |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 21 | #include <linux/bpf.h> |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 22 | #include <linux/skbuff.h> |
| 23 | #include <linux/netdevice.h> |
| 24 | #include <linux/if_vlan.h> |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 25 | #include <linux/random.h> |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 26 | #include <linux/highmem.h> |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 27 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 28 | /* General test specific settings */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 29 | #define MAX_SUBTESTS 3 |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 30 | #define MAX_TESTRUNS 10000 |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 31 | #define MAX_DATA 128 |
| 32 | #define MAX_INSNS 512 |
| 33 | #define MAX_K 0xffffFFFF |
| 34 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 35 | /* Few constants used to init test 'skb' */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 36 | #define SKB_TYPE 3 |
| 37 | #define SKB_MARK 0x1234aaaa |
| 38 | #define SKB_HASH 0x1234aaab |
| 39 | #define SKB_QUEUE_MAP 123 |
| 40 | #define SKB_VLAN_TCI 0xffff |
| 41 | #define SKB_DEV_IFINDEX 577 |
| 42 | #define SKB_DEV_TYPE 588 |
| 43 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 44 | /* Redefine REGs to make tests less verbose */ |
| 45 | #define R0 BPF_REG_0 |
| 46 | #define R1 BPF_REG_1 |
| 47 | #define R2 BPF_REG_2 |
| 48 | #define R3 BPF_REG_3 |
| 49 | #define R4 BPF_REG_4 |
| 50 | #define R5 BPF_REG_5 |
| 51 | #define R6 BPF_REG_6 |
| 52 | #define R7 BPF_REG_7 |
| 53 | #define R8 BPF_REG_8 |
| 54 | #define R9 BPF_REG_9 |
| 55 | #define R10 BPF_REG_10 |
| 56 | |
| 57 | /* Flags that can be passed to test cases */ |
| 58 | #define FLAG_NO_DATA BIT(0) |
| 59 | #define FLAG_EXPECTED_FAIL BIT(1) |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 60 | #define FLAG_SKB_FRAG BIT(2) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 61 | |
| 62 | enum { |
| 63 | CLASSIC = BIT(6), /* Old BPF instructions only. */ |
| 64 | INTERNAL = BIT(7), /* Extended instruction set. */ |
| 65 | }; |
| 66 | |
| 67 | #define TEST_TYPE_MASK (CLASSIC | INTERNAL) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 68 | |
| 69 | struct bpf_test { |
| 70 | const char *descr; |
| 71 | union { |
| 72 | struct sock_filter insns[MAX_INSNS]; |
Alexei Starovoitov | 2695fb5 | 2014-07-24 16:38:21 -0700 | [diff] [blame] | 73 | struct bpf_insn insns_int[MAX_INSNS]; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 74 | struct { |
| 75 | void *insns; |
| 76 | unsigned int len; |
| 77 | } ptr; |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 78 | } u; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 79 | __u8 aux; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 80 | __u8 data[MAX_DATA]; |
| 81 | struct { |
| 82 | int data_size; |
| 83 | __u32 result; |
| 84 | } test[MAX_SUBTESTS]; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 85 | int (*fill_helper)(struct bpf_test *self); |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 86 | __u8 frag_data[MAX_DATA]; |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 87 | int stack_depth; /* for eBPF only, since tests don't call verifier */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 90 | /* Large test cases need separate allocation and fill handler. */ |
| 91 | |
| 92 | static int bpf_fill_maxinsns1(struct bpf_test *self) |
| 93 | { |
| 94 | unsigned int len = BPF_MAXINSNS; |
| 95 | struct sock_filter *insn; |
| 96 | __u32 k = ~0; |
| 97 | int i; |
| 98 | |
| 99 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 100 | if (!insn) |
| 101 | return -ENOMEM; |
| 102 | |
| 103 | for (i = 0; i < len; i++, k--) |
| 104 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, k); |
| 105 | |
| 106 | self->u.ptr.insns = insn; |
| 107 | self->u.ptr.len = len; |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static int bpf_fill_maxinsns2(struct bpf_test *self) |
| 113 | { |
| 114 | unsigned int len = BPF_MAXINSNS; |
| 115 | struct sock_filter *insn; |
| 116 | int i; |
| 117 | |
| 118 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 119 | if (!insn) |
| 120 | return -ENOMEM; |
| 121 | |
| 122 | for (i = 0; i < len; i++) |
| 123 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 124 | |
| 125 | self->u.ptr.insns = insn; |
| 126 | self->u.ptr.len = len; |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | static int bpf_fill_maxinsns3(struct bpf_test *self) |
| 132 | { |
| 133 | unsigned int len = BPF_MAXINSNS; |
| 134 | struct sock_filter *insn; |
| 135 | struct rnd_state rnd; |
| 136 | int i; |
| 137 | |
| 138 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 139 | if (!insn) |
| 140 | return -ENOMEM; |
| 141 | |
| 142 | prandom_seed_state(&rnd, 3141592653589793238ULL); |
| 143 | |
| 144 | for (i = 0; i < len - 1; i++) { |
| 145 | __u32 k = prandom_u32_state(&rnd); |
| 146 | |
| 147 | insn[i] = __BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, k); |
| 148 | } |
| 149 | |
| 150 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 151 | |
| 152 | self->u.ptr.insns = insn; |
| 153 | self->u.ptr.len = len; |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | static int bpf_fill_maxinsns4(struct bpf_test *self) |
| 159 | { |
| 160 | unsigned int len = BPF_MAXINSNS + 1; |
| 161 | struct sock_filter *insn; |
| 162 | int i; |
| 163 | |
| 164 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 165 | if (!insn) |
| 166 | return -ENOMEM; |
| 167 | |
| 168 | for (i = 0; i < len; i++) |
| 169 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 170 | |
| 171 | self->u.ptr.insns = insn; |
| 172 | self->u.ptr.len = len; |
| 173 | |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | static int bpf_fill_maxinsns5(struct bpf_test *self) |
| 178 | { |
| 179 | unsigned int len = BPF_MAXINSNS; |
| 180 | struct sock_filter *insn; |
| 181 | int i; |
| 182 | |
| 183 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 184 | if (!insn) |
| 185 | return -ENOMEM; |
| 186 | |
| 187 | insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0); |
| 188 | |
| 189 | for (i = 1; i < len - 1; i++) |
| 190 | insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); |
| 191 | |
| 192 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab); |
| 193 | |
| 194 | self->u.ptr.insns = insn; |
| 195 | self->u.ptr.len = len; |
| 196 | |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | static int bpf_fill_maxinsns6(struct bpf_test *self) |
| 201 | { |
| 202 | unsigned int len = BPF_MAXINSNS; |
| 203 | struct sock_filter *insn; |
| 204 | int i; |
| 205 | |
| 206 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 207 | if (!insn) |
| 208 | return -ENOMEM; |
| 209 | |
| 210 | for (i = 0; i < len - 1; i++) |
| 211 | insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 212 | SKF_AD_VLAN_TAG_PRESENT); |
| 213 | |
| 214 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 215 | |
| 216 | self->u.ptr.insns = insn; |
| 217 | self->u.ptr.len = len; |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static int bpf_fill_maxinsns7(struct bpf_test *self) |
| 223 | { |
| 224 | unsigned int len = BPF_MAXINSNS; |
| 225 | struct sock_filter *insn; |
| 226 | int i; |
| 227 | |
| 228 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 229 | if (!insn) |
| 230 | return -ENOMEM; |
| 231 | |
| 232 | for (i = 0; i < len - 4; i++) |
| 233 | insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 234 | SKF_AD_CPU); |
| 235 | |
| 236 | insn[len - 4] = __BPF_STMT(BPF_MISC | BPF_TAX, 0); |
| 237 | insn[len - 3] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + |
| 238 | SKF_AD_CPU); |
| 239 | insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0); |
| 240 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 241 | |
| 242 | self->u.ptr.insns = insn; |
| 243 | self->u.ptr.len = len; |
| 244 | |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | static int bpf_fill_maxinsns8(struct bpf_test *self) |
| 249 | { |
| 250 | unsigned int len = BPF_MAXINSNS; |
| 251 | struct sock_filter *insn; |
| 252 | int i, jmp_off = len - 3; |
| 253 | |
| 254 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 255 | if (!insn) |
| 256 | return -ENOMEM; |
| 257 | |
| 258 | insn[0] = __BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff); |
| 259 | |
| 260 | for (i = 1; i < len - 1; i++) |
| 261 | insn[i] = __BPF_JUMP(BPF_JMP | BPF_JGT, 0xffffffff, jmp_off--, 0); |
| 262 | |
| 263 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); |
| 264 | |
| 265 | self->u.ptr.insns = insn; |
| 266 | self->u.ptr.len = len; |
| 267 | |
| 268 | return 0; |
| 269 | } |
| 270 | |
Daniel Borkmann | 3b52960 | 2015-05-23 01:10:07 +0200 | [diff] [blame] | 271 | static int bpf_fill_maxinsns9(struct bpf_test *self) |
| 272 | { |
| 273 | unsigned int len = BPF_MAXINSNS; |
| 274 | struct bpf_insn *insn; |
| 275 | int i; |
| 276 | |
| 277 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 278 | if (!insn) |
| 279 | return -ENOMEM; |
| 280 | |
| 281 | insn[0] = BPF_JMP_IMM(BPF_JA, 0, 0, len - 2); |
| 282 | insn[1] = BPF_ALU32_IMM(BPF_MOV, R0, 0xcbababab); |
| 283 | insn[2] = BPF_EXIT_INSN(); |
| 284 | |
| 285 | for (i = 3; i < len - 2; i++) |
| 286 | insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xfefefefe); |
| 287 | |
| 288 | insn[len - 2] = BPF_EXIT_INSN(); |
| 289 | insn[len - 1] = BPF_JMP_IMM(BPF_JA, 0, 0, -(len - 1)); |
| 290 | |
| 291 | self->u.ptr.insns = insn; |
| 292 | self->u.ptr.len = len; |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int bpf_fill_maxinsns10(struct bpf_test *self) |
| 298 | { |
| 299 | unsigned int len = BPF_MAXINSNS, hlen = len - 2; |
| 300 | struct bpf_insn *insn; |
| 301 | int i; |
| 302 | |
| 303 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 304 | if (!insn) |
| 305 | return -ENOMEM; |
| 306 | |
| 307 | for (i = 0; i < hlen / 2; i++) |
| 308 | insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 2 - 2 * i); |
| 309 | for (i = hlen - 1; i > hlen / 2; i--) |
| 310 | insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 1 - 2 * i); |
| 311 | |
| 312 | insn[hlen / 2] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen / 2 - 1); |
| 313 | insn[hlen] = BPF_ALU32_IMM(BPF_MOV, R0, 0xabababac); |
| 314 | insn[hlen + 1] = BPF_EXIT_INSN(); |
| 315 | |
| 316 | self->u.ptr.insns = insn; |
| 317 | self->u.ptr.len = len; |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 322 | static int __bpf_fill_ja(struct bpf_test *self, unsigned int len, |
| 323 | unsigned int plen) |
| 324 | { |
| 325 | struct sock_filter *insn; |
| 326 | unsigned int rlen; |
| 327 | int i, j; |
| 328 | |
| 329 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 330 | if (!insn) |
| 331 | return -ENOMEM; |
| 332 | |
| 333 | rlen = (len % plen) - 1; |
| 334 | |
| 335 | for (i = 0; i + plen < len; i += plen) |
| 336 | for (j = 0; j < plen; j++) |
| 337 | insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, |
| 338 | plen - 1 - j, 0, 0); |
| 339 | for (j = 0; j < rlen; j++) |
| 340 | insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, rlen - 1 - j, |
| 341 | 0, 0); |
| 342 | |
| 343 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xababcbac); |
| 344 | |
| 345 | self->u.ptr.insns = insn; |
| 346 | self->u.ptr.len = len; |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | static int bpf_fill_maxinsns11(struct bpf_test *self) |
| 352 | { |
| 353 | /* Hits 70 passes on x86_64, so cannot get JITed there. */ |
| 354 | return __bpf_fill_ja(self, BPF_MAXINSNS, 68); |
| 355 | } |
| 356 | |
| 357 | static int bpf_fill_ja(struct bpf_test *self) |
| 358 | { |
| 359 | /* Hits exactly 11 passes on x86_64 JIT. */ |
| 360 | return __bpf_fill_ja(self, 12, 9); |
| 361 | } |
| 362 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 363 | static int bpf_fill_ld_abs_get_processor_id(struct bpf_test *self) |
| 364 | { |
| 365 | unsigned int len = BPF_MAXINSNS; |
| 366 | struct sock_filter *insn; |
| 367 | int i; |
| 368 | |
| 369 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 370 | if (!insn) |
| 371 | return -ENOMEM; |
| 372 | |
| 373 | for (i = 0; i < len - 1; i += 2) { |
| 374 | insn[i] = __BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 0); |
| 375 | insn[i + 1] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 376 | SKF_AD_OFF + SKF_AD_CPU); |
| 377 | } |
| 378 | |
| 379 | insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xbee); |
| 380 | |
| 381 | self->u.ptr.insns = insn; |
| 382 | self->u.ptr.len = len; |
| 383 | |
| 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | #define PUSH_CNT 68 |
| 388 | /* test: {skb->data[0], vlan_push} x 68 + {skb->data[0], vlan_pop} x 68 */ |
| 389 | static int bpf_fill_ld_abs_vlan_push_pop(struct bpf_test *self) |
| 390 | { |
| 391 | unsigned int len = BPF_MAXINSNS; |
| 392 | struct bpf_insn *insn; |
| 393 | int i = 0, j, k = 0; |
| 394 | |
| 395 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 396 | if (!insn) |
| 397 | return -ENOMEM; |
| 398 | |
| 399 | insn[i++] = BPF_MOV64_REG(R6, R1); |
| 400 | loop: |
| 401 | for (j = 0; j < PUSH_CNT; j++) { |
| 402 | insn[i++] = BPF_LD_ABS(BPF_B, 0); |
| 403 | insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0x34, len - i - 2); |
| 404 | i++; |
| 405 | insn[i++] = BPF_MOV64_REG(R1, R6); |
| 406 | insn[i++] = BPF_MOV64_IMM(R2, 1); |
| 407 | insn[i++] = BPF_MOV64_IMM(R3, 2); |
| 408 | insn[i++] = BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, |
| 409 | bpf_skb_vlan_push_proto.func - __bpf_call_base); |
| 410 | insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0, len - i - 2); |
| 411 | i++; |
| 412 | } |
| 413 | |
| 414 | for (j = 0; j < PUSH_CNT; j++) { |
| 415 | insn[i++] = BPF_LD_ABS(BPF_B, 0); |
| 416 | insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0x34, len - i - 2); |
| 417 | i++; |
| 418 | insn[i++] = BPF_MOV64_REG(R1, R6); |
| 419 | insn[i++] = BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, |
| 420 | bpf_skb_vlan_pop_proto.func - __bpf_call_base); |
| 421 | insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0, len - i - 2); |
| 422 | i++; |
| 423 | } |
| 424 | if (++k < 5) |
| 425 | goto loop; |
| 426 | |
| 427 | for (; i < len - 1; i++) |
| 428 | insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xbef); |
| 429 | |
| 430 | insn[len - 1] = BPF_EXIT_INSN(); |
| 431 | |
| 432 | self->u.ptr.insns = insn; |
| 433 | self->u.ptr.len = len; |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
David Daney | b7127cf | 2017-06-13 16:49:36 -0700 | [diff] [blame] | 438 | static int bpf_fill_jump_around_ld_abs(struct bpf_test *self) |
| 439 | { |
| 440 | unsigned int len = BPF_MAXINSNS; |
| 441 | struct bpf_insn *insn; |
| 442 | int i = 0; |
| 443 | |
| 444 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 445 | if (!insn) |
| 446 | return -ENOMEM; |
| 447 | |
| 448 | insn[i++] = BPF_MOV64_REG(R6, R1); |
| 449 | insn[i++] = BPF_LD_ABS(BPF_B, 0); |
| 450 | insn[i] = BPF_JMP_IMM(BPF_JEQ, R0, 10, len - i - 2); |
| 451 | i++; |
| 452 | while (i < len - 1) |
| 453 | insn[i++] = BPF_LD_ABS(BPF_B, 1); |
| 454 | insn[i] = BPF_EXIT_INSN(); |
| 455 | |
| 456 | self->u.ptr.insns = insn; |
| 457 | self->u.ptr.len = len; |
| 458 | |
| 459 | return 0; |
| 460 | } |
| 461 | |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 462 | static int __bpf_fill_stxdw(struct bpf_test *self, int size) |
| 463 | { |
| 464 | unsigned int len = BPF_MAXINSNS; |
| 465 | struct bpf_insn *insn; |
| 466 | int i; |
| 467 | |
| 468 | insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); |
| 469 | if (!insn) |
| 470 | return -ENOMEM; |
| 471 | |
| 472 | insn[0] = BPF_ALU32_IMM(BPF_MOV, R0, 1); |
| 473 | insn[1] = BPF_ST_MEM(size, R10, -40, 42); |
| 474 | |
| 475 | for (i = 2; i < len - 2; i++) |
| 476 | insn[i] = BPF_STX_XADD(size, R10, R0, -40); |
| 477 | |
| 478 | insn[len - 2] = BPF_LDX_MEM(size, R0, R10, -40); |
| 479 | insn[len - 1] = BPF_EXIT_INSN(); |
| 480 | |
| 481 | self->u.ptr.insns = insn; |
| 482 | self->u.ptr.len = len; |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 483 | self->stack_depth = 40; |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 484 | |
| 485 | return 0; |
| 486 | } |
| 487 | |
| 488 | static int bpf_fill_stxw(struct bpf_test *self) |
| 489 | { |
| 490 | return __bpf_fill_stxdw(self, BPF_W); |
| 491 | } |
| 492 | |
| 493 | static int bpf_fill_stxdw(struct bpf_test *self) |
| 494 | { |
| 495 | return __bpf_fill_stxdw(self, BPF_DW); |
| 496 | } |
| 497 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 498 | static struct bpf_test tests[] = { |
| 499 | { |
| 500 | "TAX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 501 | .u.insns = { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 502 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 503 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 504 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
| 505 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 506 | BPF_STMT(BPF_ALU | BPF_NEG, 0), /* A == -3 */ |
| 507 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 508 | BPF_STMT(BPF_LD | BPF_LEN, 0), |
| 509 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 510 | BPF_STMT(BPF_MISC | BPF_TAX, 0), /* X == len - 3 */ |
| 511 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 1), |
| 512 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 513 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 514 | CLASSIC, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 515 | { 10, 20, 30, 40, 50 }, |
| 516 | { { 2, 10 }, { 3, 20 }, { 4, 30 } }, |
| 517 | }, |
| 518 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 519 | "TXA", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 520 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 521 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 522 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 523 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 524 | BPF_STMT(BPF_RET | BPF_A, 0) /* A == len * 2 */ |
| 525 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 526 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 527 | { 10, 20, 30, 40, 50 }, |
| 528 | { { 1, 2 }, { 3, 6 }, { 4, 8 } }, |
| 529 | }, |
| 530 | { |
| 531 | "ADD_SUB_MUL_K", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 532 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 533 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 534 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2), |
| 535 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 536 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 537 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xffffffff), |
| 538 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 3), |
| 539 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 540 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 541 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 542 | { }, |
| 543 | { { 0, 0xfffffffd } } |
| 544 | }, |
| 545 | { |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 546 | "DIV_MOD_KX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 547 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 548 | BPF_STMT(BPF_LD | BPF_IMM, 8), |
| 549 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2), |
| 550 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 551 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 552 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0), |
| 553 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 554 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 555 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000), |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 556 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 557 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 558 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), |
| 559 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 560 | BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), |
| 561 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 562 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 563 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 564 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 565 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 566 | { }, |
Denis Kirjanov | 6867b17 | 2014-12-01 13:12:25 +0300 | [diff] [blame] | 567 | { { 0, 0x20000000 } } |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 568 | }, |
| 569 | { |
| 570 | "AND_OR_LSH_K", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 571 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 572 | BPF_STMT(BPF_LD | BPF_IMM, 0xff), |
| 573 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), |
| 574 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27), |
| 575 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 576 | BPF_STMT(BPF_LD | BPF_IMM, 0xf), |
| 577 | BPF_STMT(BPF_ALU | BPF_OR | BPF_K, 0xf0), |
| 578 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 579 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 580 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 581 | CLASSIC | FLAG_NO_DATA, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 582 | { }, |
| 583 | { { 0, 0x800000ff }, { 1, 0x800000ff } }, |
| 584 | }, |
| 585 | { |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 586 | "LD_IMM_0", |
| 587 | .u.insns = { |
| 588 | BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */ |
| 589 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0), |
| 590 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 591 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 592 | }, |
| 593 | CLASSIC, |
| 594 | { }, |
| 595 | { { 1, 1 } }, |
| 596 | }, |
| 597 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 598 | "LD_IND", |
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_LDX | BPF_LEN, 0), |
| 601 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K), |
| 602 | BPF_STMT(BPF_RET | BPF_K, 1) |
| 603 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 604 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 605 | { }, |
| 606 | { { 1, 0 }, { 10, 0 }, { 60, 0 } }, |
| 607 | }, |
| 608 | { |
| 609 | "LD_ABS", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 610 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 611 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000), |
| 612 | BPF_STMT(BPF_RET | BPF_K, 1) |
| 613 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 614 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 615 | { }, |
| 616 | { { 1, 0 }, { 10, 0 }, { 60, 0 } }, |
| 617 | }, |
| 618 | { |
| 619 | "LD_ABS_LL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 620 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 621 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF), |
| 622 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 623 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1), |
| 624 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 625 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 626 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 627 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 628 | { 1, 2, 3 }, |
| 629 | { { 1, 0 }, { 2, 3 } }, |
| 630 | }, |
| 631 | { |
| 632 | "LD_IND_LL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 633 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 634 | BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1), |
| 635 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 636 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 637 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 638 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), |
| 639 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 640 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 641 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 642 | { 1, 2, 3, 0xff }, |
| 643 | { { 1, 1 }, { 3, 3 }, { 4, 0xff } }, |
| 644 | }, |
| 645 | { |
| 646 | "LD_ABS_NET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 647 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 648 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF), |
| 649 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 650 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1), |
| 651 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 652 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 653 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 654 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 655 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, |
| 656 | { { 15, 0 }, { 16, 3 } }, |
| 657 | }, |
| 658 | { |
| 659 | "LD_IND_NET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 660 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 661 | BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15), |
| 662 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 663 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 664 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 665 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), |
| 666 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 667 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 668 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 669 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, |
| 670 | { { 14, 0 }, { 15, 1 }, { 17, 3 } }, |
| 671 | }, |
| 672 | { |
| 673 | "LD_PKTTYPE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 674 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 675 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 676 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 677 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 678 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 679 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 680 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 681 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 682 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 683 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 684 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
| 685 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
| 686 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 687 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 688 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 689 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 690 | { }, |
| 691 | { { 1, 3 }, { 10, 3 } }, |
| 692 | }, |
| 693 | { |
| 694 | "LD_MARK", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 695 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 696 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 697 | SKF_AD_OFF + SKF_AD_MARK), |
| 698 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 699 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 700 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 701 | { }, |
| 702 | { { 1, SKB_MARK}, { 10, SKB_MARK} }, |
| 703 | }, |
| 704 | { |
| 705 | "LD_RXHASH", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 706 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 707 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 708 | SKF_AD_OFF + SKF_AD_RXHASH), |
| 709 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 710 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 711 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 712 | { }, |
| 713 | { { 1, SKB_HASH}, { 10, SKB_HASH} }, |
| 714 | }, |
| 715 | { |
| 716 | "LD_QUEUE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 717 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 718 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 719 | SKF_AD_OFF + SKF_AD_QUEUE), |
| 720 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 721 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 722 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 723 | { }, |
| 724 | { { 1, SKB_QUEUE_MAP }, { 10, SKB_QUEUE_MAP } }, |
| 725 | }, |
| 726 | { |
| 727 | "LD_PROTOCOL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 728 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 729 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1), |
| 730 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0), |
| 731 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 732 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 733 | SKF_AD_OFF + SKF_AD_PROTOCOL), |
| 734 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 735 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 736 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 30, 1, 0), |
| 737 | BPF_STMT(BPF_RET | BPF_K, 0), |
| 738 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 739 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 740 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 741 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 742 | { 10, 20, 30 }, |
| 743 | { { 10, ETH_P_IP }, { 100, ETH_P_IP } }, |
| 744 | }, |
| 745 | { |
| 746 | "LD_VLAN_TAG", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 747 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 748 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 749 | SKF_AD_OFF + SKF_AD_VLAN_TAG), |
| 750 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 751 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 752 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 753 | { }, |
| 754 | { |
| 755 | { 1, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT }, |
| 756 | { 10, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT } |
| 757 | }, |
| 758 | }, |
| 759 | { |
| 760 | "LD_VLAN_TAG_PRESENT", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 761 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 762 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 763 | SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), |
| 764 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 765 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 766 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 767 | { }, |
| 768 | { |
| 769 | { 1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }, |
| 770 | { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) } |
| 771 | }, |
| 772 | }, |
| 773 | { |
| 774 | "LD_IFINDEX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 775 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 776 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 777 | SKF_AD_OFF + SKF_AD_IFINDEX), |
| 778 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 779 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 780 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 781 | { }, |
| 782 | { { 1, SKB_DEV_IFINDEX }, { 10, SKB_DEV_IFINDEX } }, |
| 783 | }, |
| 784 | { |
| 785 | "LD_HATYPE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 786 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 787 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 788 | SKF_AD_OFF + SKF_AD_HATYPE), |
| 789 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 790 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 791 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 792 | { }, |
| 793 | { { 1, SKB_DEV_TYPE }, { 10, SKB_DEV_TYPE } }, |
| 794 | }, |
| 795 | { |
| 796 | "LD_CPU", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 797 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 798 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 799 | SKF_AD_OFF + SKF_AD_CPU), |
| 800 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 801 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 802 | SKF_AD_OFF + SKF_AD_CPU), |
| 803 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 804 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 805 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 806 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 807 | { }, |
| 808 | { { 1, 0 }, { 10, 0 } }, |
| 809 | }, |
| 810 | { |
| 811 | "LD_NLATTR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 812 | .u.insns = { |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 813 | BPF_STMT(BPF_LDX | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 814 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 815 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 816 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 817 | SKF_AD_OFF + SKF_AD_NLATTR), |
| 818 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 819 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 820 | CLASSIC, |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 821 | #ifdef __BIG_ENDIAN |
| 822 | { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 }, |
| 823 | #else |
| 824 | { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 }, |
| 825 | #endif |
| 826 | { { 4, 0 }, { 20, 6 } }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 827 | }, |
| 828 | { |
| 829 | "LD_NLATTR_NEST", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 830 | .u.insns = { |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 831 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 832 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
| 833 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 834 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 835 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 836 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 837 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 838 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 839 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 840 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 841 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 842 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 843 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 844 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 845 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 846 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 847 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 848 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 849 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 850 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 851 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 852 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 853 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 854 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 855 | SKF_AD_OFF + SKF_AD_NLATTR_NEST), |
| 856 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 857 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 858 | CLASSIC, |
Alexei Starovoitov | df6d0f983 | 2014-06-06 17:48:20 -0700 | [diff] [blame] | 859 | #ifdef __BIG_ENDIAN |
| 860 | { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 }, |
| 861 | #else |
| 862 | { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 }, |
| 863 | #endif |
| 864 | { { 4, 0 }, { 20, 10 } }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 865 | }, |
| 866 | { |
| 867 | "LD_PAYLOAD_OFF", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 868 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 869 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 870 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 871 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 872 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 873 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 874 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 875 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 876 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 877 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 878 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
| 879 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 880 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 881 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 882 | /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800), |
| 883 | * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request, |
| 884 | * id 9737, seq 1, length 64 |
| 885 | */ |
| 886 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 887 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 888 | 0x08, 0x00, |
| 889 | 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40, |
| 890 | 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 }, |
| 891 | { { 30, 0 }, { 100, 42 } }, |
| 892 | }, |
| 893 | { |
| 894 | "LD_ANC_XOR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 895 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 896 | BPF_STMT(BPF_LD | BPF_IMM, 10), |
| 897 | BPF_STMT(BPF_LDX | BPF_IMM, 300), |
| 898 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 899 | SKF_AD_OFF + SKF_AD_ALU_XOR_X), |
| 900 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 901 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 902 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 903 | { }, |
| 904 | { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } }, |
| 905 | }, |
| 906 | { |
| 907 | "SPILL_FILL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 908 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 909 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 910 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
| 911 | BPF_STMT(BPF_ALU | BPF_RSH, 1), |
| 912 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 913 | BPF_STMT(BPF_ST, 1), /* M1 = 1 ^ len */ |
| 914 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_K, 0x80000000), |
| 915 | BPF_STMT(BPF_ST, 2), /* M2 = 1 ^ len ^ 0x80000000 */ |
| 916 | BPF_STMT(BPF_STX, 15), /* M3 = len */ |
| 917 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 918 | BPF_STMT(BPF_LD | BPF_MEM, 2), |
| 919 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 920 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 921 | BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), |
| 922 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 923 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 924 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 925 | { }, |
| 926 | { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } } |
| 927 | }, |
| 928 | { |
| 929 | "JEQ", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 930 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 931 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 932 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 933 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1), |
| 934 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 935 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 936 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 937 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 938 | { 3, 3, 3, 3, 3 }, |
| 939 | { { 1, 0 }, { 3, 1 }, { 4, MAX_K } }, |
| 940 | }, |
| 941 | { |
| 942 | "JGT", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 943 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 944 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 945 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
| 946 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1), |
| 947 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 948 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 949 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 950 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 951 | { 4, 4, 4, 3, 3 }, |
| 952 | { { 2, 0 }, { 3, 1 }, { 4, MAX_K } }, |
| 953 | }, |
| 954 | { |
| 955 | "JGE", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 956 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 957 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 958 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K), |
| 959 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0), |
| 960 | BPF_STMT(BPF_RET | BPF_K, 10), |
| 961 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 2, 1, 0), |
| 962 | BPF_STMT(BPF_RET | BPF_K, 20), |
| 963 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 3, 1, 0), |
| 964 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 965 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 4, 1, 0), |
| 966 | BPF_STMT(BPF_RET | BPF_K, 40), |
| 967 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 968 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 969 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 970 | { 1, 2, 3, 4, 5 }, |
| 971 | { { 1, 20 }, { 3, 40 }, { 5, MAX_K } }, |
| 972 | }, |
| 973 | { |
| 974 | "JSET", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 975 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 976 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 977 | BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1), |
| 978 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 979 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
| 980 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
| 981 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 982 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, 4), |
| 983 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 984 | BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0), |
| 985 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 1, 0, 1), |
| 986 | BPF_STMT(BPF_RET | BPF_K, 10), |
| 987 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x80000000, 0, 1), |
| 988 | BPF_STMT(BPF_RET | BPF_K, 20), |
| 989 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 990 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 991 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 992 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 993 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 994 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 995 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 996 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 997 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), |
| 998 | BPF_STMT(BPF_RET | BPF_K, 30), |
| 999 | BPF_STMT(BPF_RET | BPF_K, MAX_K) |
| 1000 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1001 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1002 | { 0, 0xAA, 0x55, 1 }, |
| 1003 | { { 4, 10 }, { 5, 20 }, { 6, MAX_K } }, |
| 1004 | }, |
| 1005 | { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1006 | "tcpdump port 22", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1007 | .u.insns = { |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 1008 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), |
| 1009 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 0, 8), /* IPv6 */ |
| 1010 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 20), |
| 1011 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), |
| 1012 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), |
| 1013 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 17), |
| 1014 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 54), |
| 1015 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 14, 0), |
| 1016 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 56), |
| 1017 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 12, 13), |
| 1018 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0800, 0, 12), /* IPv4 */ |
| 1019 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), |
| 1020 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), |
| 1021 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), |
| 1022 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 8), |
| 1023 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), |
| 1024 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 6, 0), |
| 1025 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1026 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), |
| 1027 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), |
| 1028 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), |
| 1029 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 1), |
| 1030 | BPF_STMT(BPF_RET | BPF_K, 0xffff), |
| 1031 | BPF_STMT(BPF_RET | BPF_K, 0), |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1032 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1033 | CLASSIC, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1034 | /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800) |
| 1035 | * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.], |
| 1036 | * seq 1305692979:1305693027, ack 3650467037, win 65535, |
| 1037 | * options [nop,nop,TS val 2502645400 ecr 3971138], length 48 |
| 1038 | */ |
| 1039 | { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, |
| 1040 | 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, |
| 1041 | 0x08, 0x00, |
| 1042 | 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, |
| 1043 | 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ |
| 1044 | 0x0a, 0x01, 0x01, 0x95, /* ip src */ |
| 1045 | 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ |
| 1046 | 0xc2, 0x24, |
| 1047 | 0x00, 0x16 /* dst port */ }, |
| 1048 | { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, |
| 1049 | }, |
| 1050 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1051 | "tcpdump complex", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1052 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1053 | /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] - |
| 1054 | * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and |
| 1055 | * (len > 115 or len < 30000000000)' -d |
| 1056 | */ |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 1057 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), |
| 1058 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 30, 0), |
| 1059 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x800, 0, 29), |
| 1060 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), |
| 1061 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 0, 27), |
| 1062 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), |
| 1063 | BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 25, 0), |
| 1064 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1065 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), |
| 1066 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), |
| 1067 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), |
| 1068 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 20), |
| 1069 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 16), |
| 1070 | BPF_STMT(BPF_ST, 1), |
| 1071 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 14), |
| 1072 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf), |
| 1073 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 2), |
| 1074 | BPF_STMT(BPF_MISC | BPF_TAX, 0x5), /* libpcap emits K on TAX */ |
| 1075 | BPF_STMT(BPF_LD | BPF_MEM, 1), |
| 1076 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 1077 | BPF_STMT(BPF_ST, 5), |
| 1078 | BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), |
| 1079 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, 26), |
| 1080 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), |
| 1081 | BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 2), |
| 1082 | BPF_STMT(BPF_MISC | BPF_TAX, 0x9), /* libpcap emits K on TAX */ |
| 1083 | BPF_STMT(BPF_LD | BPF_MEM, 5), |
| 1084 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 4, 0), |
| 1085 | BPF_STMT(BPF_LD | BPF_LEN, 0), |
| 1086 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_K, 0x73, 1, 0), |
| 1087 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 0xfc23ac00, 1, 0), |
| 1088 | BPF_STMT(BPF_RET | BPF_K, 0xffff), |
| 1089 | BPF_STMT(BPF_RET | BPF_K, 0), |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1090 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1091 | CLASSIC, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1092 | { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, |
| 1093 | 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, |
| 1094 | 0x08, 0x00, |
| 1095 | 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, |
| 1096 | 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ |
| 1097 | 0x0a, 0x01, 0x01, 0x95, /* ip src */ |
| 1098 | 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ |
| 1099 | 0xc2, 0x24, |
| 1100 | 0x00, 0x16 /* dst port */ }, |
| 1101 | { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, |
| 1102 | }, |
| 1103 | { |
| 1104 | "RET_A", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1105 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1106 | /* check that unitialized X and A contain zeros */ |
| 1107 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 1108 | BPF_STMT(BPF_RET | BPF_A, 0) |
| 1109 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1110 | CLASSIC, |
| 1111 | { }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1112 | { {1, 0}, {2, 0} }, |
| 1113 | }, |
| 1114 | { |
| 1115 | "INT: ADD trivial", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1116 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1117 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1118 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 1119 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
| 1120 | BPF_ALU64_REG(BPF_SUB, R1, R2), |
| 1121 | BPF_ALU64_IMM(BPF_ADD, R1, -1), |
| 1122 | BPF_ALU64_IMM(BPF_MUL, R1, 3), |
| 1123 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 1124 | BPF_EXIT_INSN(), |
| 1125 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1126 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1127 | { }, |
| 1128 | { { 0, 0xfffffffd } } |
| 1129 | }, |
| 1130 | { |
| 1131 | "INT: MUL_X", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1132 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1133 | BPF_ALU64_IMM(BPF_MOV, R0, -1), |
| 1134 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1135 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
| 1136 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1137 | BPF_JMP_IMM(BPF_JEQ, R1, 0xfffffffd, 1), |
| 1138 | BPF_EXIT_INSN(), |
| 1139 | BPF_ALU64_IMM(BPF_MOV, R0, 1), |
| 1140 | BPF_EXIT_INSN(), |
| 1141 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1142 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1143 | { }, |
| 1144 | { { 0, 1 } } |
| 1145 | }, |
| 1146 | { |
| 1147 | "INT: MUL_X2", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1148 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1149 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
| 1150 | BPF_ALU32_IMM(BPF_MOV, R1, -1), |
| 1151 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
| 1152 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1153 | BPF_ALU64_IMM(BPF_RSH, R1, 8), |
| 1154 | BPF_JMP_IMM(BPF_JEQ, R1, 0x2ffffff, 1), |
| 1155 | BPF_EXIT_INSN(), |
| 1156 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1157 | BPF_EXIT_INSN(), |
| 1158 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1159 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1160 | { }, |
| 1161 | { { 0, 1 } } |
| 1162 | }, |
| 1163 | { |
| 1164 | "INT: MUL32_X", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1165 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1166 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
| 1167 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1168 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
| 1169 | BPF_ALU32_REG(BPF_MUL, R1, R2), |
| 1170 | BPF_ALU64_IMM(BPF_RSH, R1, 8), |
| 1171 | BPF_JMP_IMM(BPF_JEQ, R1, 0xffffff, 1), |
| 1172 | BPF_EXIT_INSN(), |
| 1173 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 1174 | BPF_EXIT_INSN(), |
| 1175 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1176 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1177 | { }, |
| 1178 | { { 0, 1 } } |
| 1179 | }, |
| 1180 | { |
| 1181 | /* Have to test all register combinations, since |
| 1182 | * JITing of different registers will produce |
| 1183 | * different asm code. |
| 1184 | */ |
| 1185 | "INT: ADD 64-bit", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1186 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1187 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1188 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1189 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1190 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1191 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1192 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1193 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1194 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1195 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1196 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1197 | BPF_ALU64_IMM(BPF_ADD, R0, 20), |
| 1198 | BPF_ALU64_IMM(BPF_ADD, R1, 20), |
| 1199 | BPF_ALU64_IMM(BPF_ADD, R2, 20), |
| 1200 | BPF_ALU64_IMM(BPF_ADD, R3, 20), |
| 1201 | BPF_ALU64_IMM(BPF_ADD, R4, 20), |
| 1202 | BPF_ALU64_IMM(BPF_ADD, R5, 20), |
| 1203 | BPF_ALU64_IMM(BPF_ADD, R6, 20), |
| 1204 | BPF_ALU64_IMM(BPF_ADD, R7, 20), |
| 1205 | BPF_ALU64_IMM(BPF_ADD, R8, 20), |
| 1206 | BPF_ALU64_IMM(BPF_ADD, R9, 20), |
| 1207 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1208 | BPF_ALU64_IMM(BPF_SUB, R1, 10), |
| 1209 | BPF_ALU64_IMM(BPF_SUB, R2, 10), |
| 1210 | BPF_ALU64_IMM(BPF_SUB, R3, 10), |
| 1211 | BPF_ALU64_IMM(BPF_SUB, R4, 10), |
| 1212 | BPF_ALU64_IMM(BPF_SUB, R5, 10), |
| 1213 | BPF_ALU64_IMM(BPF_SUB, R6, 10), |
| 1214 | BPF_ALU64_IMM(BPF_SUB, R7, 10), |
| 1215 | BPF_ALU64_IMM(BPF_SUB, R8, 10), |
| 1216 | BPF_ALU64_IMM(BPF_SUB, R9, 10), |
| 1217 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1218 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1219 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1220 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1221 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1222 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1223 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1224 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1225 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1226 | BPF_ALU64_REG(BPF_ADD, R0, R9), /* R0 == 155 */ |
| 1227 | BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), |
| 1228 | BPF_EXIT_INSN(), |
| 1229 | BPF_ALU64_REG(BPF_ADD, R1, R0), |
| 1230 | BPF_ALU64_REG(BPF_ADD, R1, R1), |
| 1231 | BPF_ALU64_REG(BPF_ADD, R1, R2), |
| 1232 | BPF_ALU64_REG(BPF_ADD, R1, R3), |
| 1233 | BPF_ALU64_REG(BPF_ADD, R1, R4), |
| 1234 | BPF_ALU64_REG(BPF_ADD, R1, R5), |
| 1235 | BPF_ALU64_REG(BPF_ADD, R1, R6), |
| 1236 | BPF_ALU64_REG(BPF_ADD, R1, R7), |
| 1237 | BPF_ALU64_REG(BPF_ADD, R1, R8), |
| 1238 | BPF_ALU64_REG(BPF_ADD, R1, R9), /* R1 == 456 */ |
| 1239 | BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), |
| 1240 | BPF_EXIT_INSN(), |
| 1241 | BPF_ALU64_REG(BPF_ADD, R2, R0), |
| 1242 | BPF_ALU64_REG(BPF_ADD, R2, R1), |
| 1243 | BPF_ALU64_REG(BPF_ADD, R2, R2), |
| 1244 | BPF_ALU64_REG(BPF_ADD, R2, R3), |
| 1245 | BPF_ALU64_REG(BPF_ADD, R2, R4), |
| 1246 | BPF_ALU64_REG(BPF_ADD, R2, R5), |
| 1247 | BPF_ALU64_REG(BPF_ADD, R2, R6), |
| 1248 | BPF_ALU64_REG(BPF_ADD, R2, R7), |
| 1249 | BPF_ALU64_REG(BPF_ADD, R2, R8), |
| 1250 | BPF_ALU64_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ |
| 1251 | BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), |
| 1252 | BPF_EXIT_INSN(), |
| 1253 | BPF_ALU64_REG(BPF_ADD, R3, R0), |
| 1254 | BPF_ALU64_REG(BPF_ADD, R3, R1), |
| 1255 | BPF_ALU64_REG(BPF_ADD, R3, R2), |
| 1256 | BPF_ALU64_REG(BPF_ADD, R3, R3), |
| 1257 | BPF_ALU64_REG(BPF_ADD, R3, R4), |
| 1258 | BPF_ALU64_REG(BPF_ADD, R3, R5), |
| 1259 | BPF_ALU64_REG(BPF_ADD, R3, R6), |
| 1260 | BPF_ALU64_REG(BPF_ADD, R3, R7), |
| 1261 | BPF_ALU64_REG(BPF_ADD, R3, R8), |
| 1262 | BPF_ALU64_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ |
| 1263 | BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), |
| 1264 | BPF_EXIT_INSN(), |
| 1265 | BPF_ALU64_REG(BPF_ADD, R4, R0), |
| 1266 | BPF_ALU64_REG(BPF_ADD, R4, R1), |
| 1267 | BPF_ALU64_REG(BPF_ADD, R4, R2), |
| 1268 | BPF_ALU64_REG(BPF_ADD, R4, R3), |
| 1269 | BPF_ALU64_REG(BPF_ADD, R4, R4), |
| 1270 | BPF_ALU64_REG(BPF_ADD, R4, R5), |
| 1271 | BPF_ALU64_REG(BPF_ADD, R4, R6), |
| 1272 | BPF_ALU64_REG(BPF_ADD, R4, R7), |
| 1273 | BPF_ALU64_REG(BPF_ADD, R4, R8), |
| 1274 | BPF_ALU64_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ |
| 1275 | BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), |
| 1276 | BPF_EXIT_INSN(), |
| 1277 | BPF_ALU64_REG(BPF_ADD, R5, R0), |
| 1278 | BPF_ALU64_REG(BPF_ADD, R5, R1), |
| 1279 | BPF_ALU64_REG(BPF_ADD, R5, R2), |
| 1280 | BPF_ALU64_REG(BPF_ADD, R5, R3), |
| 1281 | BPF_ALU64_REG(BPF_ADD, R5, R4), |
| 1282 | BPF_ALU64_REG(BPF_ADD, R5, R5), |
| 1283 | BPF_ALU64_REG(BPF_ADD, R5, R6), |
| 1284 | BPF_ALU64_REG(BPF_ADD, R5, R7), |
| 1285 | BPF_ALU64_REG(BPF_ADD, R5, R8), |
| 1286 | BPF_ALU64_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ |
| 1287 | BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), |
| 1288 | BPF_EXIT_INSN(), |
| 1289 | BPF_ALU64_REG(BPF_ADD, R6, R0), |
| 1290 | BPF_ALU64_REG(BPF_ADD, R6, R1), |
| 1291 | BPF_ALU64_REG(BPF_ADD, R6, R2), |
| 1292 | BPF_ALU64_REG(BPF_ADD, R6, R3), |
| 1293 | BPF_ALU64_REG(BPF_ADD, R6, R4), |
| 1294 | BPF_ALU64_REG(BPF_ADD, R6, R5), |
| 1295 | BPF_ALU64_REG(BPF_ADD, R6, R6), |
| 1296 | BPF_ALU64_REG(BPF_ADD, R6, R7), |
| 1297 | BPF_ALU64_REG(BPF_ADD, R6, R8), |
| 1298 | BPF_ALU64_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ |
| 1299 | BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), |
| 1300 | BPF_EXIT_INSN(), |
| 1301 | BPF_ALU64_REG(BPF_ADD, R7, R0), |
| 1302 | BPF_ALU64_REG(BPF_ADD, R7, R1), |
| 1303 | BPF_ALU64_REG(BPF_ADD, R7, R2), |
| 1304 | BPF_ALU64_REG(BPF_ADD, R7, R3), |
| 1305 | BPF_ALU64_REG(BPF_ADD, R7, R4), |
| 1306 | BPF_ALU64_REG(BPF_ADD, R7, R5), |
| 1307 | BPF_ALU64_REG(BPF_ADD, R7, R6), |
| 1308 | BPF_ALU64_REG(BPF_ADD, R7, R7), |
| 1309 | BPF_ALU64_REG(BPF_ADD, R7, R8), |
| 1310 | BPF_ALU64_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ |
| 1311 | BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), |
| 1312 | BPF_EXIT_INSN(), |
| 1313 | BPF_ALU64_REG(BPF_ADD, R8, R0), |
| 1314 | BPF_ALU64_REG(BPF_ADD, R8, R1), |
| 1315 | BPF_ALU64_REG(BPF_ADD, R8, R2), |
| 1316 | BPF_ALU64_REG(BPF_ADD, R8, R3), |
| 1317 | BPF_ALU64_REG(BPF_ADD, R8, R4), |
| 1318 | BPF_ALU64_REG(BPF_ADD, R8, R5), |
| 1319 | BPF_ALU64_REG(BPF_ADD, R8, R6), |
| 1320 | BPF_ALU64_REG(BPF_ADD, R8, R7), |
| 1321 | BPF_ALU64_REG(BPF_ADD, R8, R8), |
| 1322 | BPF_ALU64_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ |
| 1323 | BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), |
| 1324 | BPF_EXIT_INSN(), |
| 1325 | BPF_ALU64_REG(BPF_ADD, R9, R0), |
| 1326 | BPF_ALU64_REG(BPF_ADD, R9, R1), |
| 1327 | BPF_ALU64_REG(BPF_ADD, R9, R2), |
| 1328 | BPF_ALU64_REG(BPF_ADD, R9, R3), |
| 1329 | BPF_ALU64_REG(BPF_ADD, R9, R4), |
| 1330 | BPF_ALU64_REG(BPF_ADD, R9, R5), |
| 1331 | BPF_ALU64_REG(BPF_ADD, R9, R6), |
| 1332 | BPF_ALU64_REG(BPF_ADD, R9, R7), |
| 1333 | BPF_ALU64_REG(BPF_ADD, R9, R8), |
| 1334 | BPF_ALU64_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ |
| 1335 | BPF_ALU64_REG(BPF_MOV, R0, R9), |
| 1336 | BPF_EXIT_INSN(), |
| 1337 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1338 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1339 | { }, |
| 1340 | { { 0, 2957380 } } |
| 1341 | }, |
| 1342 | { |
| 1343 | "INT: ADD 32-bit", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1344 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1345 | BPF_ALU32_IMM(BPF_MOV, R0, 20), |
| 1346 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 1347 | BPF_ALU32_IMM(BPF_MOV, R2, 2), |
| 1348 | BPF_ALU32_IMM(BPF_MOV, R3, 3), |
| 1349 | BPF_ALU32_IMM(BPF_MOV, R4, 4), |
| 1350 | BPF_ALU32_IMM(BPF_MOV, R5, 5), |
| 1351 | BPF_ALU32_IMM(BPF_MOV, R6, 6), |
| 1352 | BPF_ALU32_IMM(BPF_MOV, R7, 7), |
| 1353 | BPF_ALU32_IMM(BPF_MOV, R8, 8), |
| 1354 | BPF_ALU32_IMM(BPF_MOV, R9, 9), |
| 1355 | BPF_ALU64_IMM(BPF_ADD, R1, 10), |
| 1356 | BPF_ALU64_IMM(BPF_ADD, R2, 10), |
| 1357 | BPF_ALU64_IMM(BPF_ADD, R3, 10), |
| 1358 | BPF_ALU64_IMM(BPF_ADD, R4, 10), |
| 1359 | BPF_ALU64_IMM(BPF_ADD, R5, 10), |
| 1360 | BPF_ALU64_IMM(BPF_ADD, R6, 10), |
| 1361 | BPF_ALU64_IMM(BPF_ADD, R7, 10), |
| 1362 | BPF_ALU64_IMM(BPF_ADD, R8, 10), |
| 1363 | BPF_ALU64_IMM(BPF_ADD, R9, 10), |
| 1364 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 1365 | BPF_ALU32_REG(BPF_ADD, R0, R2), |
| 1366 | BPF_ALU32_REG(BPF_ADD, R0, R3), |
| 1367 | BPF_ALU32_REG(BPF_ADD, R0, R4), |
| 1368 | BPF_ALU32_REG(BPF_ADD, R0, R5), |
| 1369 | BPF_ALU32_REG(BPF_ADD, R0, R6), |
| 1370 | BPF_ALU32_REG(BPF_ADD, R0, R7), |
| 1371 | BPF_ALU32_REG(BPF_ADD, R0, R8), |
| 1372 | BPF_ALU32_REG(BPF_ADD, R0, R9), /* R0 == 155 */ |
| 1373 | BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), |
| 1374 | BPF_EXIT_INSN(), |
| 1375 | BPF_ALU32_REG(BPF_ADD, R1, R0), |
| 1376 | BPF_ALU32_REG(BPF_ADD, R1, R1), |
| 1377 | BPF_ALU32_REG(BPF_ADD, R1, R2), |
| 1378 | BPF_ALU32_REG(BPF_ADD, R1, R3), |
| 1379 | BPF_ALU32_REG(BPF_ADD, R1, R4), |
| 1380 | BPF_ALU32_REG(BPF_ADD, R1, R5), |
| 1381 | BPF_ALU32_REG(BPF_ADD, R1, R6), |
| 1382 | BPF_ALU32_REG(BPF_ADD, R1, R7), |
| 1383 | BPF_ALU32_REG(BPF_ADD, R1, R8), |
| 1384 | BPF_ALU32_REG(BPF_ADD, R1, R9), /* R1 == 456 */ |
| 1385 | BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), |
| 1386 | BPF_EXIT_INSN(), |
| 1387 | BPF_ALU32_REG(BPF_ADD, R2, R0), |
| 1388 | BPF_ALU32_REG(BPF_ADD, R2, R1), |
| 1389 | BPF_ALU32_REG(BPF_ADD, R2, R2), |
| 1390 | BPF_ALU32_REG(BPF_ADD, R2, R3), |
| 1391 | BPF_ALU32_REG(BPF_ADD, R2, R4), |
| 1392 | BPF_ALU32_REG(BPF_ADD, R2, R5), |
| 1393 | BPF_ALU32_REG(BPF_ADD, R2, R6), |
| 1394 | BPF_ALU32_REG(BPF_ADD, R2, R7), |
| 1395 | BPF_ALU32_REG(BPF_ADD, R2, R8), |
| 1396 | BPF_ALU32_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ |
| 1397 | BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), |
| 1398 | BPF_EXIT_INSN(), |
| 1399 | BPF_ALU32_REG(BPF_ADD, R3, R0), |
| 1400 | BPF_ALU32_REG(BPF_ADD, R3, R1), |
| 1401 | BPF_ALU32_REG(BPF_ADD, R3, R2), |
| 1402 | BPF_ALU32_REG(BPF_ADD, R3, R3), |
| 1403 | BPF_ALU32_REG(BPF_ADD, R3, R4), |
| 1404 | BPF_ALU32_REG(BPF_ADD, R3, R5), |
| 1405 | BPF_ALU32_REG(BPF_ADD, R3, R6), |
| 1406 | BPF_ALU32_REG(BPF_ADD, R3, R7), |
| 1407 | BPF_ALU32_REG(BPF_ADD, R3, R8), |
| 1408 | BPF_ALU32_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ |
| 1409 | BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), |
| 1410 | BPF_EXIT_INSN(), |
| 1411 | BPF_ALU32_REG(BPF_ADD, R4, R0), |
| 1412 | BPF_ALU32_REG(BPF_ADD, R4, R1), |
| 1413 | BPF_ALU32_REG(BPF_ADD, R4, R2), |
| 1414 | BPF_ALU32_REG(BPF_ADD, R4, R3), |
| 1415 | BPF_ALU32_REG(BPF_ADD, R4, R4), |
| 1416 | BPF_ALU32_REG(BPF_ADD, R4, R5), |
| 1417 | BPF_ALU32_REG(BPF_ADD, R4, R6), |
| 1418 | BPF_ALU32_REG(BPF_ADD, R4, R7), |
| 1419 | BPF_ALU32_REG(BPF_ADD, R4, R8), |
| 1420 | BPF_ALU32_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ |
| 1421 | BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), |
| 1422 | BPF_EXIT_INSN(), |
| 1423 | BPF_ALU32_REG(BPF_ADD, R5, R0), |
| 1424 | BPF_ALU32_REG(BPF_ADD, R5, R1), |
| 1425 | BPF_ALU32_REG(BPF_ADD, R5, R2), |
| 1426 | BPF_ALU32_REG(BPF_ADD, R5, R3), |
| 1427 | BPF_ALU32_REG(BPF_ADD, R5, R4), |
| 1428 | BPF_ALU32_REG(BPF_ADD, R5, R5), |
| 1429 | BPF_ALU32_REG(BPF_ADD, R5, R6), |
| 1430 | BPF_ALU32_REG(BPF_ADD, R5, R7), |
| 1431 | BPF_ALU32_REG(BPF_ADD, R5, R8), |
| 1432 | BPF_ALU32_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ |
| 1433 | BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), |
| 1434 | BPF_EXIT_INSN(), |
| 1435 | BPF_ALU32_REG(BPF_ADD, R6, R0), |
| 1436 | BPF_ALU32_REG(BPF_ADD, R6, R1), |
| 1437 | BPF_ALU32_REG(BPF_ADD, R6, R2), |
| 1438 | BPF_ALU32_REG(BPF_ADD, R6, R3), |
| 1439 | BPF_ALU32_REG(BPF_ADD, R6, R4), |
| 1440 | BPF_ALU32_REG(BPF_ADD, R6, R5), |
| 1441 | BPF_ALU32_REG(BPF_ADD, R6, R6), |
| 1442 | BPF_ALU32_REG(BPF_ADD, R6, R7), |
| 1443 | BPF_ALU32_REG(BPF_ADD, R6, R8), |
| 1444 | BPF_ALU32_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ |
| 1445 | BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), |
| 1446 | BPF_EXIT_INSN(), |
| 1447 | BPF_ALU32_REG(BPF_ADD, R7, R0), |
| 1448 | BPF_ALU32_REG(BPF_ADD, R7, R1), |
| 1449 | BPF_ALU32_REG(BPF_ADD, R7, R2), |
| 1450 | BPF_ALU32_REG(BPF_ADD, R7, R3), |
| 1451 | BPF_ALU32_REG(BPF_ADD, R7, R4), |
| 1452 | BPF_ALU32_REG(BPF_ADD, R7, R5), |
| 1453 | BPF_ALU32_REG(BPF_ADD, R7, R6), |
| 1454 | BPF_ALU32_REG(BPF_ADD, R7, R7), |
| 1455 | BPF_ALU32_REG(BPF_ADD, R7, R8), |
| 1456 | BPF_ALU32_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ |
| 1457 | BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), |
| 1458 | BPF_EXIT_INSN(), |
| 1459 | BPF_ALU32_REG(BPF_ADD, R8, R0), |
| 1460 | BPF_ALU32_REG(BPF_ADD, R8, R1), |
| 1461 | BPF_ALU32_REG(BPF_ADD, R8, R2), |
| 1462 | BPF_ALU32_REG(BPF_ADD, R8, R3), |
| 1463 | BPF_ALU32_REG(BPF_ADD, R8, R4), |
| 1464 | BPF_ALU32_REG(BPF_ADD, R8, R5), |
| 1465 | BPF_ALU32_REG(BPF_ADD, R8, R6), |
| 1466 | BPF_ALU32_REG(BPF_ADD, R8, R7), |
| 1467 | BPF_ALU32_REG(BPF_ADD, R8, R8), |
| 1468 | BPF_ALU32_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ |
| 1469 | BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), |
| 1470 | BPF_EXIT_INSN(), |
| 1471 | BPF_ALU32_REG(BPF_ADD, R9, R0), |
| 1472 | BPF_ALU32_REG(BPF_ADD, R9, R1), |
| 1473 | BPF_ALU32_REG(BPF_ADD, R9, R2), |
| 1474 | BPF_ALU32_REG(BPF_ADD, R9, R3), |
| 1475 | BPF_ALU32_REG(BPF_ADD, R9, R4), |
| 1476 | BPF_ALU32_REG(BPF_ADD, R9, R5), |
| 1477 | BPF_ALU32_REG(BPF_ADD, R9, R6), |
| 1478 | BPF_ALU32_REG(BPF_ADD, R9, R7), |
| 1479 | BPF_ALU32_REG(BPF_ADD, R9, R8), |
| 1480 | BPF_ALU32_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ |
| 1481 | BPF_ALU32_REG(BPF_MOV, R0, R9), |
| 1482 | BPF_EXIT_INSN(), |
| 1483 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1484 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1485 | { }, |
| 1486 | { { 0, 2957380 } } |
| 1487 | }, |
| 1488 | { /* Mainly checking JIT here. */ |
| 1489 | "INT: SUB", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1490 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1491 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1492 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1493 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1494 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1495 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1496 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1497 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1498 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1499 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1500 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1501 | BPF_ALU64_REG(BPF_SUB, R0, R0), |
| 1502 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 1503 | BPF_ALU64_REG(BPF_SUB, R0, R2), |
| 1504 | BPF_ALU64_REG(BPF_SUB, R0, R3), |
| 1505 | BPF_ALU64_REG(BPF_SUB, R0, R4), |
| 1506 | BPF_ALU64_REG(BPF_SUB, R0, R5), |
| 1507 | BPF_ALU64_REG(BPF_SUB, R0, R6), |
| 1508 | BPF_ALU64_REG(BPF_SUB, R0, R7), |
| 1509 | BPF_ALU64_REG(BPF_SUB, R0, R8), |
| 1510 | BPF_ALU64_REG(BPF_SUB, R0, R9), |
| 1511 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1512 | BPF_JMP_IMM(BPF_JEQ, R0, -55, 1), |
| 1513 | BPF_EXIT_INSN(), |
| 1514 | BPF_ALU64_REG(BPF_SUB, R1, R0), |
| 1515 | BPF_ALU64_REG(BPF_SUB, R1, R2), |
| 1516 | BPF_ALU64_REG(BPF_SUB, R1, R3), |
| 1517 | BPF_ALU64_REG(BPF_SUB, R1, R4), |
| 1518 | BPF_ALU64_REG(BPF_SUB, R1, R5), |
| 1519 | BPF_ALU64_REG(BPF_SUB, R1, R6), |
| 1520 | BPF_ALU64_REG(BPF_SUB, R1, R7), |
| 1521 | BPF_ALU64_REG(BPF_SUB, R1, R8), |
| 1522 | BPF_ALU64_REG(BPF_SUB, R1, R9), |
| 1523 | BPF_ALU64_IMM(BPF_SUB, R1, 10), |
| 1524 | BPF_ALU64_REG(BPF_SUB, R2, R0), |
| 1525 | BPF_ALU64_REG(BPF_SUB, R2, R1), |
| 1526 | BPF_ALU64_REG(BPF_SUB, R2, R3), |
| 1527 | BPF_ALU64_REG(BPF_SUB, R2, R4), |
| 1528 | BPF_ALU64_REG(BPF_SUB, R2, R5), |
| 1529 | BPF_ALU64_REG(BPF_SUB, R2, R6), |
| 1530 | BPF_ALU64_REG(BPF_SUB, R2, R7), |
| 1531 | BPF_ALU64_REG(BPF_SUB, R2, R8), |
| 1532 | BPF_ALU64_REG(BPF_SUB, R2, R9), |
| 1533 | BPF_ALU64_IMM(BPF_SUB, R2, 10), |
| 1534 | BPF_ALU64_REG(BPF_SUB, R3, R0), |
| 1535 | BPF_ALU64_REG(BPF_SUB, R3, R1), |
| 1536 | BPF_ALU64_REG(BPF_SUB, R3, R2), |
| 1537 | BPF_ALU64_REG(BPF_SUB, R3, R4), |
| 1538 | BPF_ALU64_REG(BPF_SUB, R3, R5), |
| 1539 | BPF_ALU64_REG(BPF_SUB, R3, R6), |
| 1540 | BPF_ALU64_REG(BPF_SUB, R3, R7), |
| 1541 | BPF_ALU64_REG(BPF_SUB, R3, R8), |
| 1542 | BPF_ALU64_REG(BPF_SUB, R3, R9), |
| 1543 | BPF_ALU64_IMM(BPF_SUB, R3, 10), |
| 1544 | BPF_ALU64_REG(BPF_SUB, R4, R0), |
| 1545 | BPF_ALU64_REG(BPF_SUB, R4, R1), |
| 1546 | BPF_ALU64_REG(BPF_SUB, R4, R2), |
| 1547 | BPF_ALU64_REG(BPF_SUB, R4, R3), |
| 1548 | BPF_ALU64_REG(BPF_SUB, R4, R5), |
| 1549 | BPF_ALU64_REG(BPF_SUB, R4, R6), |
| 1550 | BPF_ALU64_REG(BPF_SUB, R4, R7), |
| 1551 | BPF_ALU64_REG(BPF_SUB, R4, R8), |
| 1552 | BPF_ALU64_REG(BPF_SUB, R4, R9), |
| 1553 | BPF_ALU64_IMM(BPF_SUB, R4, 10), |
| 1554 | BPF_ALU64_REG(BPF_SUB, R5, R0), |
| 1555 | BPF_ALU64_REG(BPF_SUB, R5, R1), |
| 1556 | BPF_ALU64_REG(BPF_SUB, R5, R2), |
| 1557 | BPF_ALU64_REG(BPF_SUB, R5, R3), |
| 1558 | BPF_ALU64_REG(BPF_SUB, R5, R4), |
| 1559 | BPF_ALU64_REG(BPF_SUB, R5, R6), |
| 1560 | BPF_ALU64_REG(BPF_SUB, R5, R7), |
| 1561 | BPF_ALU64_REG(BPF_SUB, R5, R8), |
| 1562 | BPF_ALU64_REG(BPF_SUB, R5, R9), |
| 1563 | BPF_ALU64_IMM(BPF_SUB, R5, 10), |
| 1564 | BPF_ALU64_REG(BPF_SUB, R6, R0), |
| 1565 | BPF_ALU64_REG(BPF_SUB, R6, R1), |
| 1566 | BPF_ALU64_REG(BPF_SUB, R6, R2), |
| 1567 | BPF_ALU64_REG(BPF_SUB, R6, R3), |
| 1568 | BPF_ALU64_REG(BPF_SUB, R6, R4), |
| 1569 | BPF_ALU64_REG(BPF_SUB, R6, R5), |
| 1570 | BPF_ALU64_REG(BPF_SUB, R6, R7), |
| 1571 | BPF_ALU64_REG(BPF_SUB, R6, R8), |
| 1572 | BPF_ALU64_REG(BPF_SUB, R6, R9), |
| 1573 | BPF_ALU64_IMM(BPF_SUB, R6, 10), |
| 1574 | BPF_ALU64_REG(BPF_SUB, R7, R0), |
| 1575 | BPF_ALU64_REG(BPF_SUB, R7, R1), |
| 1576 | BPF_ALU64_REG(BPF_SUB, R7, R2), |
| 1577 | BPF_ALU64_REG(BPF_SUB, R7, R3), |
| 1578 | BPF_ALU64_REG(BPF_SUB, R7, R4), |
| 1579 | BPF_ALU64_REG(BPF_SUB, R7, R5), |
| 1580 | BPF_ALU64_REG(BPF_SUB, R7, R6), |
| 1581 | BPF_ALU64_REG(BPF_SUB, R7, R8), |
| 1582 | BPF_ALU64_REG(BPF_SUB, R7, R9), |
| 1583 | BPF_ALU64_IMM(BPF_SUB, R7, 10), |
| 1584 | BPF_ALU64_REG(BPF_SUB, R8, R0), |
| 1585 | BPF_ALU64_REG(BPF_SUB, R8, R1), |
| 1586 | BPF_ALU64_REG(BPF_SUB, R8, R2), |
| 1587 | BPF_ALU64_REG(BPF_SUB, R8, R3), |
| 1588 | BPF_ALU64_REG(BPF_SUB, R8, R4), |
| 1589 | BPF_ALU64_REG(BPF_SUB, R8, R5), |
| 1590 | BPF_ALU64_REG(BPF_SUB, R8, R6), |
| 1591 | BPF_ALU64_REG(BPF_SUB, R8, R7), |
| 1592 | BPF_ALU64_REG(BPF_SUB, R8, R9), |
| 1593 | BPF_ALU64_IMM(BPF_SUB, R8, 10), |
| 1594 | BPF_ALU64_REG(BPF_SUB, R9, R0), |
| 1595 | BPF_ALU64_REG(BPF_SUB, R9, R1), |
| 1596 | BPF_ALU64_REG(BPF_SUB, R9, R2), |
| 1597 | BPF_ALU64_REG(BPF_SUB, R9, R3), |
| 1598 | BPF_ALU64_REG(BPF_SUB, R9, R4), |
| 1599 | BPF_ALU64_REG(BPF_SUB, R9, R5), |
| 1600 | BPF_ALU64_REG(BPF_SUB, R9, R6), |
| 1601 | BPF_ALU64_REG(BPF_SUB, R9, R7), |
| 1602 | BPF_ALU64_REG(BPF_SUB, R9, R8), |
| 1603 | BPF_ALU64_IMM(BPF_SUB, R9, 10), |
| 1604 | BPF_ALU64_IMM(BPF_SUB, R0, 10), |
| 1605 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 1606 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 1607 | BPF_ALU64_REG(BPF_SUB, R0, R2), |
| 1608 | BPF_ALU64_REG(BPF_SUB, R0, R3), |
| 1609 | BPF_ALU64_REG(BPF_SUB, R0, R4), |
| 1610 | BPF_ALU64_REG(BPF_SUB, R0, R5), |
| 1611 | BPF_ALU64_REG(BPF_SUB, R0, R6), |
| 1612 | BPF_ALU64_REG(BPF_SUB, R0, R7), |
| 1613 | BPF_ALU64_REG(BPF_SUB, R0, R8), |
| 1614 | BPF_ALU64_REG(BPF_SUB, R0, R9), |
| 1615 | BPF_EXIT_INSN(), |
| 1616 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1617 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1618 | { }, |
| 1619 | { { 0, 11 } } |
| 1620 | }, |
| 1621 | { /* Mainly checking JIT here. */ |
| 1622 | "INT: XOR", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1623 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1624 | BPF_ALU64_REG(BPF_SUB, R0, R0), |
| 1625 | BPF_ALU64_REG(BPF_XOR, R1, R1), |
| 1626 | BPF_JMP_REG(BPF_JEQ, R0, R1, 1), |
| 1627 | BPF_EXIT_INSN(), |
| 1628 | BPF_ALU64_IMM(BPF_MOV, R0, 10), |
| 1629 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1630 | BPF_ALU64_REG(BPF_SUB, R1, R1), |
| 1631 | BPF_ALU64_REG(BPF_XOR, R2, R2), |
| 1632 | BPF_JMP_REG(BPF_JEQ, R1, R2, 1), |
| 1633 | BPF_EXIT_INSN(), |
| 1634 | BPF_ALU64_REG(BPF_SUB, R2, R2), |
| 1635 | BPF_ALU64_REG(BPF_XOR, R3, R3), |
| 1636 | BPF_ALU64_IMM(BPF_MOV, R0, 10), |
| 1637 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
| 1638 | BPF_JMP_REG(BPF_JEQ, R2, R3, 1), |
| 1639 | BPF_EXIT_INSN(), |
| 1640 | BPF_ALU64_REG(BPF_SUB, R3, R3), |
| 1641 | BPF_ALU64_REG(BPF_XOR, R4, R4), |
| 1642 | BPF_ALU64_IMM(BPF_MOV, R2, 1), |
| 1643 | BPF_ALU64_IMM(BPF_MOV, R5, -1), |
| 1644 | BPF_JMP_REG(BPF_JEQ, R3, R4, 1), |
| 1645 | BPF_EXIT_INSN(), |
| 1646 | BPF_ALU64_REG(BPF_SUB, R4, R4), |
| 1647 | BPF_ALU64_REG(BPF_XOR, R5, R5), |
| 1648 | BPF_ALU64_IMM(BPF_MOV, R3, 1), |
| 1649 | BPF_ALU64_IMM(BPF_MOV, R7, -1), |
| 1650 | BPF_JMP_REG(BPF_JEQ, R5, R4, 1), |
| 1651 | BPF_EXIT_INSN(), |
| 1652 | BPF_ALU64_IMM(BPF_MOV, R5, 1), |
| 1653 | BPF_ALU64_REG(BPF_SUB, R5, R5), |
| 1654 | BPF_ALU64_REG(BPF_XOR, R6, R6), |
| 1655 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1656 | BPF_ALU64_IMM(BPF_MOV, R8, -1), |
| 1657 | BPF_JMP_REG(BPF_JEQ, R5, R6, 1), |
| 1658 | BPF_EXIT_INSN(), |
| 1659 | BPF_ALU64_REG(BPF_SUB, R6, R6), |
| 1660 | BPF_ALU64_REG(BPF_XOR, R7, R7), |
| 1661 | BPF_JMP_REG(BPF_JEQ, R7, R6, 1), |
| 1662 | BPF_EXIT_INSN(), |
| 1663 | BPF_ALU64_REG(BPF_SUB, R7, R7), |
| 1664 | BPF_ALU64_REG(BPF_XOR, R8, R8), |
| 1665 | BPF_JMP_REG(BPF_JEQ, R7, R8, 1), |
| 1666 | BPF_EXIT_INSN(), |
| 1667 | BPF_ALU64_REG(BPF_SUB, R8, R8), |
| 1668 | BPF_ALU64_REG(BPF_XOR, R9, R9), |
| 1669 | BPF_JMP_REG(BPF_JEQ, R9, R8, 1), |
| 1670 | BPF_EXIT_INSN(), |
| 1671 | BPF_ALU64_REG(BPF_SUB, R9, R9), |
| 1672 | BPF_ALU64_REG(BPF_XOR, R0, R0), |
| 1673 | BPF_JMP_REG(BPF_JEQ, R9, R0, 1), |
| 1674 | BPF_EXIT_INSN(), |
| 1675 | BPF_ALU64_REG(BPF_SUB, R1, R1), |
| 1676 | BPF_ALU64_REG(BPF_XOR, R0, R0), |
| 1677 | BPF_JMP_REG(BPF_JEQ, R9, R0, 2), |
| 1678 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1679 | BPF_EXIT_INSN(), |
| 1680 | BPF_ALU64_IMM(BPF_MOV, R0, 1), |
| 1681 | BPF_EXIT_INSN(), |
| 1682 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1683 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1684 | { }, |
| 1685 | { { 0, 1 } } |
| 1686 | }, |
| 1687 | { /* Mainly checking JIT here. */ |
| 1688 | "INT: MUL", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1689 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1690 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
| 1691 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
| 1692 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1693 | BPF_ALU64_IMM(BPF_MOV, R3, 3), |
| 1694 | BPF_ALU64_IMM(BPF_MOV, R4, 4), |
| 1695 | BPF_ALU64_IMM(BPF_MOV, R5, 5), |
| 1696 | BPF_ALU64_IMM(BPF_MOV, R6, 6), |
| 1697 | BPF_ALU64_IMM(BPF_MOV, R7, 7), |
| 1698 | BPF_ALU64_IMM(BPF_MOV, R8, 8), |
| 1699 | BPF_ALU64_IMM(BPF_MOV, R9, 9), |
| 1700 | BPF_ALU64_REG(BPF_MUL, R0, R0), |
| 1701 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 1702 | BPF_ALU64_REG(BPF_MUL, R0, R2), |
| 1703 | BPF_ALU64_REG(BPF_MUL, R0, R3), |
| 1704 | BPF_ALU64_REG(BPF_MUL, R0, R4), |
| 1705 | BPF_ALU64_REG(BPF_MUL, R0, R5), |
| 1706 | BPF_ALU64_REG(BPF_MUL, R0, R6), |
| 1707 | BPF_ALU64_REG(BPF_MUL, R0, R7), |
| 1708 | BPF_ALU64_REG(BPF_MUL, R0, R8), |
| 1709 | BPF_ALU64_REG(BPF_MUL, R0, R9), |
| 1710 | BPF_ALU64_IMM(BPF_MUL, R0, 10), |
| 1711 | BPF_JMP_IMM(BPF_JEQ, R0, 439084800, 1), |
| 1712 | BPF_EXIT_INSN(), |
| 1713 | BPF_ALU64_REG(BPF_MUL, R1, R0), |
| 1714 | BPF_ALU64_REG(BPF_MUL, R1, R2), |
| 1715 | BPF_ALU64_REG(BPF_MUL, R1, R3), |
| 1716 | BPF_ALU64_REG(BPF_MUL, R1, R4), |
| 1717 | BPF_ALU64_REG(BPF_MUL, R1, R5), |
| 1718 | BPF_ALU64_REG(BPF_MUL, R1, R6), |
| 1719 | BPF_ALU64_REG(BPF_MUL, R1, R7), |
| 1720 | BPF_ALU64_REG(BPF_MUL, R1, R8), |
| 1721 | BPF_ALU64_REG(BPF_MUL, R1, R9), |
| 1722 | BPF_ALU64_IMM(BPF_MUL, R1, 10), |
| 1723 | BPF_ALU64_REG(BPF_MOV, R2, R1), |
| 1724 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 1725 | BPF_JMP_IMM(BPF_JEQ, R2, 0x5a924, 1), |
| 1726 | BPF_EXIT_INSN(), |
| 1727 | BPF_ALU64_IMM(BPF_LSH, R1, 32), |
| 1728 | BPF_ALU64_IMM(BPF_ARSH, R1, 32), |
| 1729 | BPF_JMP_IMM(BPF_JEQ, R1, 0xebb90000, 1), |
| 1730 | BPF_EXIT_INSN(), |
| 1731 | BPF_ALU64_REG(BPF_MUL, R2, R0), |
| 1732 | BPF_ALU64_REG(BPF_MUL, R2, R1), |
| 1733 | BPF_ALU64_REG(BPF_MUL, R2, R3), |
| 1734 | BPF_ALU64_REG(BPF_MUL, R2, R4), |
| 1735 | BPF_ALU64_REG(BPF_MUL, R2, R5), |
| 1736 | BPF_ALU64_REG(BPF_MUL, R2, R6), |
| 1737 | BPF_ALU64_REG(BPF_MUL, R2, R7), |
| 1738 | BPF_ALU64_REG(BPF_MUL, R2, R8), |
| 1739 | BPF_ALU64_REG(BPF_MUL, R2, R9), |
| 1740 | BPF_ALU64_IMM(BPF_MUL, R2, 10), |
| 1741 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 1742 | BPF_ALU64_REG(BPF_MOV, R0, R2), |
| 1743 | BPF_EXIT_INSN(), |
| 1744 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1745 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1746 | { }, |
| 1747 | { { 0, 0x35d97ef2 } } |
| 1748 | }, |
Daniel Borkmann | 9dd2af8 | 2015-12-17 23:51:57 +0100 | [diff] [blame] | 1749 | { /* Mainly checking JIT here. */ |
| 1750 | "MOV REG64", |
| 1751 | .u.insns_int = { |
| 1752 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1753 | BPF_MOV64_REG(R1, R0), |
| 1754 | BPF_MOV64_REG(R2, R1), |
| 1755 | BPF_MOV64_REG(R3, R2), |
| 1756 | BPF_MOV64_REG(R4, R3), |
| 1757 | BPF_MOV64_REG(R5, R4), |
| 1758 | BPF_MOV64_REG(R6, R5), |
| 1759 | BPF_MOV64_REG(R7, R6), |
| 1760 | BPF_MOV64_REG(R8, R7), |
| 1761 | BPF_MOV64_REG(R9, R8), |
| 1762 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 1763 | BPF_ALU64_IMM(BPF_MOV, R1, 0), |
| 1764 | BPF_ALU64_IMM(BPF_MOV, R2, 0), |
| 1765 | BPF_ALU64_IMM(BPF_MOV, R3, 0), |
| 1766 | BPF_ALU64_IMM(BPF_MOV, R4, 0), |
| 1767 | BPF_ALU64_IMM(BPF_MOV, R5, 0), |
| 1768 | BPF_ALU64_IMM(BPF_MOV, R6, 0), |
| 1769 | BPF_ALU64_IMM(BPF_MOV, R7, 0), |
| 1770 | BPF_ALU64_IMM(BPF_MOV, R8, 0), |
| 1771 | BPF_ALU64_IMM(BPF_MOV, R9, 0), |
| 1772 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1773 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1774 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1775 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1776 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1777 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1778 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1779 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1780 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1781 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1782 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1783 | BPF_EXIT_INSN(), |
| 1784 | }, |
| 1785 | INTERNAL, |
| 1786 | { }, |
| 1787 | { { 0, 0xfefe } } |
| 1788 | }, |
| 1789 | { /* Mainly checking JIT here. */ |
| 1790 | "MOV REG32", |
| 1791 | .u.insns_int = { |
| 1792 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1793 | BPF_MOV64_REG(R1, R0), |
| 1794 | BPF_MOV64_REG(R2, R1), |
| 1795 | BPF_MOV64_REG(R3, R2), |
| 1796 | BPF_MOV64_REG(R4, R3), |
| 1797 | BPF_MOV64_REG(R5, R4), |
| 1798 | BPF_MOV64_REG(R6, R5), |
| 1799 | BPF_MOV64_REG(R7, R6), |
| 1800 | BPF_MOV64_REG(R8, R7), |
| 1801 | BPF_MOV64_REG(R9, R8), |
| 1802 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 1803 | BPF_ALU32_IMM(BPF_MOV, R1, 0), |
| 1804 | BPF_ALU32_IMM(BPF_MOV, R2, 0), |
| 1805 | BPF_ALU32_IMM(BPF_MOV, R3, 0), |
| 1806 | BPF_ALU32_IMM(BPF_MOV, R4, 0), |
| 1807 | BPF_ALU32_IMM(BPF_MOV, R5, 0), |
| 1808 | BPF_ALU32_IMM(BPF_MOV, R6, 0), |
| 1809 | BPF_ALU32_IMM(BPF_MOV, R7, 0), |
| 1810 | BPF_ALU32_IMM(BPF_MOV, R8, 0), |
| 1811 | BPF_ALU32_IMM(BPF_MOV, R9, 0), |
| 1812 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1813 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1814 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1815 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1816 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1817 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1818 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1819 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1820 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1821 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1822 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1823 | BPF_EXIT_INSN(), |
| 1824 | }, |
| 1825 | INTERNAL, |
| 1826 | { }, |
| 1827 | { { 0, 0xfefe } } |
| 1828 | }, |
| 1829 | { /* Mainly checking JIT here. */ |
| 1830 | "LD IMM64", |
| 1831 | .u.insns_int = { |
| 1832 | BPF_LD_IMM64(R0, 0xffffffffffffffffLL), |
| 1833 | BPF_MOV64_REG(R1, R0), |
| 1834 | BPF_MOV64_REG(R2, R1), |
| 1835 | BPF_MOV64_REG(R3, R2), |
| 1836 | BPF_MOV64_REG(R4, R3), |
| 1837 | BPF_MOV64_REG(R5, R4), |
| 1838 | BPF_MOV64_REG(R6, R5), |
| 1839 | BPF_MOV64_REG(R7, R6), |
| 1840 | BPF_MOV64_REG(R8, R7), |
| 1841 | BPF_MOV64_REG(R9, R8), |
| 1842 | BPF_LD_IMM64(R0, 0x0LL), |
| 1843 | BPF_LD_IMM64(R1, 0x0LL), |
| 1844 | BPF_LD_IMM64(R2, 0x0LL), |
| 1845 | BPF_LD_IMM64(R3, 0x0LL), |
| 1846 | BPF_LD_IMM64(R4, 0x0LL), |
| 1847 | BPF_LD_IMM64(R5, 0x0LL), |
| 1848 | BPF_LD_IMM64(R6, 0x0LL), |
| 1849 | BPF_LD_IMM64(R7, 0x0LL), |
| 1850 | BPF_LD_IMM64(R8, 0x0LL), |
| 1851 | BPF_LD_IMM64(R9, 0x0LL), |
| 1852 | BPF_ALU64_REG(BPF_ADD, R0, R0), |
| 1853 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 1854 | BPF_ALU64_REG(BPF_ADD, R0, R2), |
| 1855 | BPF_ALU64_REG(BPF_ADD, R0, R3), |
| 1856 | BPF_ALU64_REG(BPF_ADD, R0, R4), |
| 1857 | BPF_ALU64_REG(BPF_ADD, R0, R5), |
| 1858 | BPF_ALU64_REG(BPF_ADD, R0, R6), |
| 1859 | BPF_ALU64_REG(BPF_ADD, R0, R7), |
| 1860 | BPF_ALU64_REG(BPF_ADD, R0, R8), |
| 1861 | BPF_ALU64_REG(BPF_ADD, R0, R9), |
| 1862 | BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe), |
| 1863 | BPF_EXIT_INSN(), |
| 1864 | }, |
| 1865 | INTERNAL, |
| 1866 | { }, |
| 1867 | { { 0, 0xfefe } } |
| 1868 | }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1869 | { |
| 1870 | "INT: ALU MIX", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1871 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1872 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
| 1873 | BPF_ALU64_IMM(BPF_ADD, R0, -1), |
| 1874 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1875 | BPF_ALU64_IMM(BPF_XOR, R2, 3), |
| 1876 | BPF_ALU64_REG(BPF_DIV, R0, R2), |
| 1877 | BPF_JMP_IMM(BPF_JEQ, R0, 10, 1), |
| 1878 | BPF_EXIT_INSN(), |
| 1879 | BPF_ALU64_IMM(BPF_MOD, R0, 3), |
| 1880 | BPF_JMP_IMM(BPF_JEQ, R0, 1, 1), |
| 1881 | BPF_EXIT_INSN(), |
| 1882 | BPF_ALU64_IMM(BPF_MOV, R0, -1), |
| 1883 | BPF_EXIT_INSN(), |
| 1884 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1885 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1886 | { }, |
| 1887 | { { 0, -1 } } |
| 1888 | }, |
| 1889 | { |
Alexei Starovoitov | 72b603e | 2014-08-25 12:27:02 -0700 | [diff] [blame] | 1890 | "INT: shifts by register", |
| 1891 | .u.insns_int = { |
| 1892 | BPF_MOV64_IMM(R0, -1234), |
| 1893 | BPF_MOV64_IMM(R1, 1), |
| 1894 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 1895 | BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1), |
| 1896 | BPF_EXIT_INSN(), |
| 1897 | BPF_MOV64_IMM(R2, 1), |
| 1898 | BPF_ALU64_REG(BPF_LSH, R0, R2), |
| 1899 | BPF_MOV32_IMM(R4, -1234), |
| 1900 | BPF_JMP_REG(BPF_JEQ, R0, R4, 1), |
| 1901 | BPF_EXIT_INSN(), |
| 1902 | BPF_ALU64_IMM(BPF_AND, R4, 63), |
| 1903 | BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */ |
| 1904 | BPF_MOV64_IMM(R3, 47), |
| 1905 | BPF_ALU64_REG(BPF_ARSH, R0, R3), |
| 1906 | BPF_JMP_IMM(BPF_JEQ, R0, -617, 1), |
| 1907 | BPF_EXIT_INSN(), |
| 1908 | BPF_MOV64_IMM(R2, 1), |
| 1909 | BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */ |
| 1910 | BPF_JMP_IMM(BPF_JEQ, R4, 92, 1), |
| 1911 | BPF_EXIT_INSN(), |
| 1912 | BPF_MOV64_IMM(R4, 4), |
| 1913 | BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */ |
| 1914 | BPF_JMP_IMM(BPF_JEQ, R4, 64, 1), |
| 1915 | BPF_EXIT_INSN(), |
| 1916 | BPF_MOV64_IMM(R4, 5), |
| 1917 | BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */ |
| 1918 | BPF_JMP_IMM(BPF_JEQ, R4, 160, 1), |
| 1919 | BPF_EXIT_INSN(), |
| 1920 | BPF_MOV64_IMM(R0, -1), |
| 1921 | BPF_EXIT_INSN(), |
| 1922 | }, |
| 1923 | INTERNAL, |
| 1924 | { }, |
| 1925 | { { 0, -1 } } |
| 1926 | }, |
| 1927 | { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1928 | "INT: DIV + ABS", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1929 | .u.insns_int = { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1930 | BPF_ALU64_REG(BPF_MOV, R6, R1), |
| 1931 | BPF_LD_ABS(BPF_B, 3), |
| 1932 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
| 1933 | BPF_ALU32_REG(BPF_DIV, R0, R2), |
| 1934 | BPF_ALU64_REG(BPF_MOV, R8, R0), |
| 1935 | BPF_LD_ABS(BPF_B, 4), |
| 1936 | BPF_ALU64_REG(BPF_ADD, R8, R0), |
| 1937 | BPF_LD_IND(BPF_B, R8, -70), |
| 1938 | BPF_EXIT_INSN(), |
| 1939 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1940 | INTERNAL, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1941 | { 10, 20, 30, 40, 50 }, |
| 1942 | { { 4, 0 }, { 5, 10 } } |
| 1943 | }, |
| 1944 | { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1945 | "INT: DIV by zero", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1946 | .u.insns_int = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1947 | BPF_ALU64_REG(BPF_MOV, R6, R1), |
| 1948 | BPF_ALU64_IMM(BPF_MOV, R7, 0), |
| 1949 | BPF_LD_ABS(BPF_B, 3), |
| 1950 | BPF_ALU32_REG(BPF_DIV, R0, R7), |
| 1951 | BPF_EXIT_INSN(), |
| 1952 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1953 | INTERNAL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1954 | { 10, 20, 30, 40, 50 }, |
| 1955 | { { 3, 0 }, { 4, 0 } } |
| 1956 | }, |
| 1957 | { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1958 | "check: missing ret", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1959 | .u.insns = { |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1960 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
| 1961 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1962 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 1963 | { }, |
| 1964 | { } |
| 1965 | }, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1966 | { |
| 1967 | "check: div_k_0", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1968 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1969 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0), |
| 1970 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 1971 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1972 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1973 | { }, |
| 1974 | { } |
| 1975 | }, |
| 1976 | { |
| 1977 | "check: unknown insn", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1978 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1979 | /* seccomp insn, rejected in socket filter */ |
| 1980 | BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0), |
| 1981 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 1982 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1983 | CLASSIC | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1984 | { }, |
| 1985 | { } |
| 1986 | }, |
| 1987 | { |
| 1988 | "check: out of range spill/fill", |
Andrew Morton | ece8049 | 2014-05-22 10:16:46 -0700 | [diff] [blame] | 1989 | .u.insns = { |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1990 | BPF_STMT(BPF_STX, 16), |
| 1991 | BPF_STMT(BPF_RET | BPF_K, 0) |
| 1992 | }, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 1993 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
Alexei Starovoitov | 9def624 | 2014-05-08 14:10:53 -0700 | [diff] [blame] | 1994 | { }, |
| 1995 | { } |
| 1996 | }, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 1997 | { |
| 1998 | "JUMPS + HOLES", |
| 1999 | .u.insns = { |
| 2000 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2001 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 15), |
| 2002 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2003 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2004 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2005 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2006 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2007 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2008 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2009 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2010 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2011 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2012 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2013 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2014 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2015 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 3, 4), |
| 2016 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2017 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 1, 2), |
| 2018 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2019 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), |
| 2020 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), |
| 2021 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2022 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2023 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2024 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2025 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2026 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2027 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2028 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2029 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2030 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2031 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2032 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2033 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2034 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 2, 3), |
| 2035 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 1, 2), |
| 2036 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2037 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), |
| 2038 | BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), |
| 2039 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2040 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2041 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2042 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2043 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2044 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2045 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2046 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2047 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2048 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2049 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2050 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2051 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2052 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 2, 3), |
| 2053 | BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 1, 2), |
| 2054 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), |
| 2055 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2056 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2057 | }, |
| 2058 | CLASSIC, |
Daniel Borkmann | ce25b68 | 2014-05-26 20:17:35 +0200 | [diff] [blame] | 2059 | { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8, |
| 2060 | 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4, |
| 2061 | 0x08, 0x00, |
| 2062 | 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, |
| 2063 | 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */ |
| 2064 | 0xc0, 0xa8, 0x33, 0x01, |
| 2065 | 0xc0, 0xa8, 0x33, 0x02, |
| 2066 | 0xbb, 0xb6, |
| 2067 | 0xa9, 0xfa, |
| 2068 | 0x00, 0x14, 0x00, 0x00, |
| 2069 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2070 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2071 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2072 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2073 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2074 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2075 | 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, |
| 2076 | 0xcc, 0xcc, 0xcc, 0xcc }, |
Daniel Borkmann | 2e8a83c | 2014-05-23 18:44:01 +0200 | [diff] [blame] | 2077 | { { 88, 0x001b } } |
| 2078 | }, |
| 2079 | { |
| 2080 | "check: RET X", |
| 2081 | .u.insns = { |
| 2082 | BPF_STMT(BPF_RET | BPF_X, 0), |
| 2083 | }, |
| 2084 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2085 | { }, |
| 2086 | { }, |
| 2087 | }, |
| 2088 | { |
| 2089 | "check: LDX + RET X", |
| 2090 | .u.insns = { |
| 2091 | BPF_STMT(BPF_LDX | BPF_IMM, 42), |
| 2092 | BPF_STMT(BPF_RET | BPF_X, 0), |
| 2093 | }, |
| 2094 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2095 | { }, |
| 2096 | { }, |
| 2097 | }, |
Daniel Borkmann | 108cc22 | 2014-05-26 20:17:34 +0200 | [diff] [blame] | 2098 | { /* Mainly checking JIT here. */ |
Daniel Borkmann | 9fe13ba | 2014-05-29 10:22:48 +0200 | [diff] [blame] | 2099 | "M[]: alt STX + LDX", |
Daniel Borkmann | 108cc22 | 2014-05-26 20:17:34 +0200 | [diff] [blame] | 2100 | .u.insns = { |
| 2101 | BPF_STMT(BPF_LDX | BPF_IMM, 100), |
| 2102 | BPF_STMT(BPF_STX, 0), |
| 2103 | BPF_STMT(BPF_LDX | BPF_MEM, 0), |
| 2104 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2105 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2106 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2107 | BPF_STMT(BPF_STX, 1), |
| 2108 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 2109 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2110 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2111 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2112 | BPF_STMT(BPF_STX, 2), |
| 2113 | BPF_STMT(BPF_LDX | BPF_MEM, 2), |
| 2114 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2115 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2116 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2117 | BPF_STMT(BPF_STX, 3), |
| 2118 | BPF_STMT(BPF_LDX | BPF_MEM, 3), |
| 2119 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2120 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2121 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2122 | BPF_STMT(BPF_STX, 4), |
| 2123 | BPF_STMT(BPF_LDX | BPF_MEM, 4), |
| 2124 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2125 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2126 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2127 | BPF_STMT(BPF_STX, 5), |
| 2128 | BPF_STMT(BPF_LDX | BPF_MEM, 5), |
| 2129 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2130 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2131 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2132 | BPF_STMT(BPF_STX, 6), |
| 2133 | BPF_STMT(BPF_LDX | BPF_MEM, 6), |
| 2134 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2135 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2136 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2137 | BPF_STMT(BPF_STX, 7), |
| 2138 | BPF_STMT(BPF_LDX | BPF_MEM, 7), |
| 2139 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2140 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2141 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2142 | BPF_STMT(BPF_STX, 8), |
| 2143 | BPF_STMT(BPF_LDX | BPF_MEM, 8), |
| 2144 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2145 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2146 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2147 | BPF_STMT(BPF_STX, 9), |
| 2148 | BPF_STMT(BPF_LDX | BPF_MEM, 9), |
| 2149 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2150 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2151 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2152 | BPF_STMT(BPF_STX, 10), |
| 2153 | BPF_STMT(BPF_LDX | BPF_MEM, 10), |
| 2154 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2155 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2156 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2157 | BPF_STMT(BPF_STX, 11), |
| 2158 | BPF_STMT(BPF_LDX | BPF_MEM, 11), |
| 2159 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2160 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2161 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2162 | BPF_STMT(BPF_STX, 12), |
| 2163 | BPF_STMT(BPF_LDX | BPF_MEM, 12), |
| 2164 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2165 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2166 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2167 | BPF_STMT(BPF_STX, 13), |
| 2168 | BPF_STMT(BPF_LDX | BPF_MEM, 13), |
| 2169 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2170 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2171 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2172 | BPF_STMT(BPF_STX, 14), |
| 2173 | BPF_STMT(BPF_LDX | BPF_MEM, 14), |
| 2174 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2175 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2176 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2177 | BPF_STMT(BPF_STX, 15), |
| 2178 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 2179 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2180 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), |
| 2181 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
| 2182 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2183 | }, |
| 2184 | CLASSIC | FLAG_NO_DATA, |
| 2185 | { }, |
| 2186 | { { 0, 116 } }, |
| 2187 | }, |
Daniel Borkmann | 9fe13ba | 2014-05-29 10:22:48 +0200 | [diff] [blame] | 2188 | { /* Mainly checking JIT here. */ |
| 2189 | "M[]: full STX + full LDX", |
| 2190 | .u.insns = { |
| 2191 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb), |
| 2192 | BPF_STMT(BPF_STX, 0), |
| 2193 | BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae), |
| 2194 | BPF_STMT(BPF_STX, 1), |
| 2195 | BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf), |
| 2196 | BPF_STMT(BPF_STX, 2), |
| 2197 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc), |
| 2198 | BPF_STMT(BPF_STX, 3), |
| 2199 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb), |
| 2200 | BPF_STMT(BPF_STX, 4), |
| 2201 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda), |
| 2202 | BPF_STMT(BPF_STX, 5), |
| 2203 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb), |
| 2204 | BPF_STMT(BPF_STX, 6), |
| 2205 | BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade), |
| 2206 | BPF_STMT(BPF_STX, 7), |
| 2207 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec), |
| 2208 | BPF_STMT(BPF_STX, 8), |
| 2209 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc), |
| 2210 | BPF_STMT(BPF_STX, 9), |
| 2211 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac), |
| 2212 | BPF_STMT(BPF_STX, 10), |
| 2213 | BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea), |
| 2214 | BPF_STMT(BPF_STX, 11), |
| 2215 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb), |
| 2216 | BPF_STMT(BPF_STX, 12), |
| 2217 | BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf), |
| 2218 | BPF_STMT(BPF_STX, 13), |
| 2219 | BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde), |
| 2220 | BPF_STMT(BPF_STX, 14), |
| 2221 | BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad), |
| 2222 | BPF_STMT(BPF_STX, 15), |
| 2223 | BPF_STMT(BPF_LDX | BPF_MEM, 0), |
| 2224 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
| 2225 | BPF_STMT(BPF_LDX | BPF_MEM, 1), |
| 2226 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2227 | BPF_STMT(BPF_LDX | BPF_MEM, 2), |
| 2228 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2229 | BPF_STMT(BPF_LDX | BPF_MEM, 3), |
| 2230 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2231 | BPF_STMT(BPF_LDX | BPF_MEM, 4), |
| 2232 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2233 | BPF_STMT(BPF_LDX | BPF_MEM, 5), |
| 2234 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2235 | BPF_STMT(BPF_LDX | BPF_MEM, 6), |
| 2236 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2237 | BPF_STMT(BPF_LDX | BPF_MEM, 7), |
| 2238 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2239 | BPF_STMT(BPF_LDX | BPF_MEM, 8), |
| 2240 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2241 | BPF_STMT(BPF_LDX | BPF_MEM, 9), |
| 2242 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2243 | BPF_STMT(BPF_LDX | BPF_MEM, 10), |
| 2244 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2245 | BPF_STMT(BPF_LDX | BPF_MEM, 11), |
| 2246 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2247 | BPF_STMT(BPF_LDX | BPF_MEM, 12), |
| 2248 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2249 | BPF_STMT(BPF_LDX | BPF_MEM, 13), |
| 2250 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2251 | BPF_STMT(BPF_LDX | BPF_MEM, 14), |
| 2252 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2253 | BPF_STMT(BPF_LDX | BPF_MEM, 15), |
| 2254 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 2255 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2256 | }, |
| 2257 | CLASSIC | FLAG_NO_DATA, |
| 2258 | { }, |
| 2259 | { { 0, 0x2a5a5e5 } }, |
| 2260 | }, |
Daniel Borkmann | d50bc15 | 2014-05-29 10:22:49 +0200 | [diff] [blame] | 2261 | { |
| 2262 | "check: SKF_AD_MAX", |
| 2263 | .u.insns = { |
| 2264 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 2265 | SKF_AD_OFF + SKF_AD_MAX), |
| 2266 | BPF_STMT(BPF_RET | BPF_A, 0), |
| 2267 | }, |
| 2268 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 2269 | { }, |
| 2270 | { }, |
| 2271 | }, |
| 2272 | { /* Passes checker but fails during runtime. */ |
| 2273 | "LD [SKF_AD_OFF-1]", |
| 2274 | .u.insns = { |
| 2275 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
| 2276 | SKF_AD_OFF - 1), |
| 2277 | BPF_STMT(BPF_RET | BPF_K, 1), |
| 2278 | }, |
| 2279 | CLASSIC, |
| 2280 | { }, |
| 2281 | { { 1, 0 } }, |
| 2282 | }, |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2283 | { |
| 2284 | "load 64-bit immediate", |
| 2285 | .u.insns_int = { |
Alexei Starovoitov | 25ee732 | 2014-09-19 13:53:51 -0700 | [diff] [blame] | 2286 | BPF_LD_IMM64(R1, 0x567800001234LL), |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2287 | BPF_MOV64_REG(R2, R1), |
| 2288 | BPF_MOV64_REG(R3, R2), |
| 2289 | BPF_ALU64_IMM(BPF_RSH, R2, 32), |
| 2290 | BPF_ALU64_IMM(BPF_LSH, R3, 32), |
| 2291 | BPF_ALU64_IMM(BPF_RSH, R3, 32), |
| 2292 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
| 2293 | BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1), |
| 2294 | BPF_EXIT_INSN(), |
| 2295 | BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1), |
| 2296 | BPF_EXIT_INSN(), |
Xi Wang | 986ccfd | 2015-05-09 04:14:30 -0400 | [diff] [blame] | 2297 | BPF_LD_IMM64(R0, 0x1ffffffffLL), |
| 2298 | BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */ |
Alexei Starovoitov | 02ab695 | 2014-09-04 22:17:17 -0700 | [diff] [blame] | 2299 | BPF_EXIT_INSN(), |
| 2300 | }, |
| 2301 | INTERNAL, |
| 2302 | { }, |
| 2303 | { { 0, 1 } } |
| 2304 | }, |
Alexei Starovoitov | e21ab36 | 2014-10-28 15:11:43 -0700 | [diff] [blame] | 2305 | { |
| 2306 | "nmap reduced", |
| 2307 | .u.insns_int = { |
| 2308 | BPF_MOV64_REG(R6, R1), |
| 2309 | BPF_LD_ABS(BPF_H, 12), |
| 2310 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 28), |
| 2311 | BPF_LD_ABS(BPF_H, 12), |
| 2312 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 26), |
| 2313 | BPF_MOV32_IMM(R0, 18), |
| 2314 | BPF_STX_MEM(BPF_W, R10, R0, -64), |
| 2315 | BPF_LDX_MEM(BPF_W, R7, R10, -64), |
| 2316 | BPF_LD_IND(BPF_W, R7, 14), |
| 2317 | BPF_STX_MEM(BPF_W, R10, R0, -60), |
| 2318 | BPF_MOV32_IMM(R0, 280971478), |
| 2319 | BPF_STX_MEM(BPF_W, R10, R0, -56), |
| 2320 | BPF_LDX_MEM(BPF_W, R7, R10, -56), |
| 2321 | BPF_LDX_MEM(BPF_W, R0, R10, -60), |
| 2322 | BPF_ALU32_REG(BPF_SUB, R0, R7), |
| 2323 | BPF_JMP_IMM(BPF_JNE, R0, 0, 15), |
| 2324 | BPF_LD_ABS(BPF_H, 12), |
| 2325 | BPF_JMP_IMM(BPF_JNE, R0, 0x806, 13), |
| 2326 | BPF_MOV32_IMM(R0, 22), |
| 2327 | BPF_STX_MEM(BPF_W, R10, R0, -56), |
| 2328 | BPF_LDX_MEM(BPF_W, R7, R10, -56), |
| 2329 | BPF_LD_IND(BPF_H, R7, 14), |
| 2330 | BPF_STX_MEM(BPF_W, R10, R0, -52), |
| 2331 | BPF_MOV32_IMM(R0, 17366), |
| 2332 | BPF_STX_MEM(BPF_W, R10, R0, -48), |
| 2333 | BPF_LDX_MEM(BPF_W, R7, R10, -48), |
| 2334 | BPF_LDX_MEM(BPF_W, R0, R10, -52), |
| 2335 | BPF_ALU32_REG(BPF_SUB, R0, R7), |
| 2336 | BPF_JMP_IMM(BPF_JNE, R0, 0, 2), |
| 2337 | BPF_MOV32_IMM(R0, 256), |
| 2338 | BPF_EXIT_INSN(), |
| 2339 | BPF_MOV32_IMM(R0, 0), |
| 2340 | BPF_EXIT_INSN(), |
| 2341 | }, |
| 2342 | INTERNAL, |
| 2343 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0, |
| 2344 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2345 | 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6}, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 2346 | { { 38, 256 } }, |
| 2347 | .stack_depth = 64, |
Alexei Starovoitov | e21ab36 | 2014-10-28 15:11:43 -0700 | [diff] [blame] | 2348 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2349 | /* BPF_ALU | BPF_MOV | BPF_X */ |
| 2350 | { |
| 2351 | "ALU_MOV_X: dst = 2", |
| 2352 | .u.insns_int = { |
| 2353 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2354 | BPF_ALU32_REG(BPF_MOV, R0, R1), |
| 2355 | BPF_EXIT_INSN(), |
| 2356 | }, |
| 2357 | INTERNAL, |
| 2358 | { }, |
| 2359 | { { 0, 2 } }, |
| 2360 | }, |
| 2361 | { |
| 2362 | "ALU_MOV_X: dst = 4294967295", |
| 2363 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2364 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2365 | BPF_ALU32_REG(BPF_MOV, R0, R1), |
| 2366 | BPF_EXIT_INSN(), |
| 2367 | }, |
| 2368 | INTERNAL, |
| 2369 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2370 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2371 | }, |
| 2372 | { |
| 2373 | "ALU64_MOV_X: dst = 2", |
| 2374 | .u.insns_int = { |
| 2375 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2376 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 2377 | BPF_EXIT_INSN(), |
| 2378 | }, |
| 2379 | INTERNAL, |
| 2380 | { }, |
| 2381 | { { 0, 2 } }, |
| 2382 | }, |
| 2383 | { |
| 2384 | "ALU64_MOV_X: dst = 4294967295", |
| 2385 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2386 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2387 | BPF_ALU64_REG(BPF_MOV, R0, R1), |
| 2388 | BPF_EXIT_INSN(), |
| 2389 | }, |
| 2390 | INTERNAL, |
| 2391 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2392 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2393 | }, |
| 2394 | /* BPF_ALU | BPF_MOV | BPF_K */ |
| 2395 | { |
| 2396 | "ALU_MOV_K: dst = 2", |
| 2397 | .u.insns_int = { |
| 2398 | BPF_ALU32_IMM(BPF_MOV, R0, 2), |
| 2399 | BPF_EXIT_INSN(), |
| 2400 | }, |
| 2401 | INTERNAL, |
| 2402 | { }, |
| 2403 | { { 0, 2 } }, |
| 2404 | }, |
| 2405 | { |
| 2406 | "ALU_MOV_K: dst = 4294967295", |
| 2407 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2408 | BPF_ALU32_IMM(BPF_MOV, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2409 | BPF_EXIT_INSN(), |
| 2410 | }, |
| 2411 | INTERNAL, |
| 2412 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2413 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2414 | }, |
| 2415 | { |
| 2416 | "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff", |
| 2417 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2418 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 2419 | BPF_LD_IMM64(R3, 0x00000000ffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2420 | BPF_ALU32_IMM(BPF_MOV, R2, 0xffffffff), |
| 2421 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2422 | BPF_MOV32_IMM(R0, 2), |
| 2423 | BPF_EXIT_INSN(), |
| 2424 | BPF_MOV32_IMM(R0, 1), |
| 2425 | BPF_EXIT_INSN(), |
| 2426 | }, |
| 2427 | INTERNAL, |
| 2428 | { }, |
| 2429 | { { 0, 0x1 } }, |
| 2430 | }, |
| 2431 | { |
| 2432 | "ALU64_MOV_K: dst = 2", |
| 2433 | .u.insns_int = { |
| 2434 | BPF_ALU64_IMM(BPF_MOV, R0, 2), |
| 2435 | BPF_EXIT_INSN(), |
| 2436 | }, |
| 2437 | INTERNAL, |
| 2438 | { }, |
| 2439 | { { 0, 2 } }, |
| 2440 | }, |
| 2441 | { |
| 2442 | "ALU64_MOV_K: dst = 2147483647", |
| 2443 | .u.insns_int = { |
| 2444 | BPF_ALU64_IMM(BPF_MOV, R0, 2147483647), |
| 2445 | BPF_EXIT_INSN(), |
| 2446 | }, |
| 2447 | INTERNAL, |
| 2448 | { }, |
| 2449 | { { 0, 2147483647 } }, |
| 2450 | }, |
| 2451 | { |
| 2452 | "ALU64_OR_K: dst = 0x0", |
| 2453 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2454 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2455 | BPF_LD_IMM64(R3, 0x0), |
| 2456 | BPF_ALU64_IMM(BPF_MOV, R2, 0x0), |
| 2457 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2458 | BPF_MOV32_IMM(R0, 2), |
| 2459 | BPF_EXIT_INSN(), |
| 2460 | BPF_MOV32_IMM(R0, 1), |
| 2461 | BPF_EXIT_INSN(), |
| 2462 | }, |
| 2463 | INTERNAL, |
| 2464 | { }, |
| 2465 | { { 0, 0x1 } }, |
| 2466 | }, |
| 2467 | { |
| 2468 | "ALU64_MOV_K: dst = -1", |
| 2469 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2470 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 2471 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2472 | BPF_ALU64_IMM(BPF_MOV, R2, 0xffffffff), |
| 2473 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2474 | BPF_MOV32_IMM(R0, 2), |
| 2475 | BPF_EXIT_INSN(), |
| 2476 | BPF_MOV32_IMM(R0, 1), |
| 2477 | BPF_EXIT_INSN(), |
| 2478 | }, |
| 2479 | INTERNAL, |
| 2480 | { }, |
| 2481 | { { 0, 0x1 } }, |
| 2482 | }, |
| 2483 | /* BPF_ALU | BPF_ADD | BPF_X */ |
| 2484 | { |
| 2485 | "ALU_ADD_X: 1 + 2 = 3", |
| 2486 | .u.insns_int = { |
| 2487 | BPF_LD_IMM64(R0, 1), |
| 2488 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2489 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2490 | BPF_EXIT_INSN(), |
| 2491 | }, |
| 2492 | INTERNAL, |
| 2493 | { }, |
| 2494 | { { 0, 3 } }, |
| 2495 | }, |
| 2496 | { |
| 2497 | "ALU_ADD_X: 1 + 4294967294 = 4294967295", |
| 2498 | .u.insns_int = { |
| 2499 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2500 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2501 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2502 | BPF_EXIT_INSN(), |
| 2503 | }, |
| 2504 | INTERNAL, |
| 2505 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2506 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2507 | }, |
| 2508 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2509 | "ALU_ADD_X: 2 + 4294967294 = 0", |
| 2510 | .u.insns_int = { |
| 2511 | BPF_LD_IMM64(R0, 2), |
| 2512 | BPF_LD_IMM64(R1, 4294967294U), |
| 2513 | BPF_ALU32_REG(BPF_ADD, R0, R1), |
| 2514 | BPF_JMP_IMM(BPF_JEQ, R0, 0, 2), |
| 2515 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2516 | BPF_EXIT_INSN(), |
| 2517 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2518 | BPF_EXIT_INSN(), |
| 2519 | }, |
| 2520 | INTERNAL, |
| 2521 | { }, |
| 2522 | { { 0, 1 } }, |
| 2523 | }, |
| 2524 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2525 | "ALU64_ADD_X: 1 + 2 = 3", |
| 2526 | .u.insns_int = { |
| 2527 | BPF_LD_IMM64(R0, 1), |
| 2528 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 2529 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2530 | BPF_EXIT_INSN(), |
| 2531 | }, |
| 2532 | INTERNAL, |
| 2533 | { }, |
| 2534 | { { 0, 3 } }, |
| 2535 | }, |
| 2536 | { |
| 2537 | "ALU64_ADD_X: 1 + 4294967294 = 4294967295", |
| 2538 | .u.insns_int = { |
| 2539 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2540 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2541 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2542 | BPF_EXIT_INSN(), |
| 2543 | }, |
| 2544 | INTERNAL, |
| 2545 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2546 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2547 | }, |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2548 | { |
| 2549 | "ALU64_ADD_X: 2 + 4294967294 = 4294967296", |
| 2550 | .u.insns_int = { |
| 2551 | BPF_LD_IMM64(R0, 2), |
| 2552 | BPF_LD_IMM64(R1, 4294967294U), |
| 2553 | BPF_LD_IMM64(R2, 4294967296ULL), |
| 2554 | BPF_ALU64_REG(BPF_ADD, R0, R1), |
| 2555 | BPF_JMP_REG(BPF_JEQ, R0, R2, 2), |
| 2556 | BPF_MOV32_IMM(R0, 0), |
| 2557 | BPF_EXIT_INSN(), |
| 2558 | BPF_MOV32_IMM(R0, 1), |
| 2559 | BPF_EXIT_INSN(), |
| 2560 | }, |
| 2561 | INTERNAL, |
| 2562 | { }, |
| 2563 | { { 0, 1 } }, |
| 2564 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2565 | /* BPF_ALU | BPF_ADD | BPF_K */ |
| 2566 | { |
| 2567 | "ALU_ADD_K: 1 + 2 = 3", |
| 2568 | .u.insns_int = { |
| 2569 | BPF_LD_IMM64(R0, 1), |
| 2570 | BPF_ALU32_IMM(BPF_ADD, R0, 2), |
| 2571 | BPF_EXIT_INSN(), |
| 2572 | }, |
| 2573 | INTERNAL, |
| 2574 | { }, |
| 2575 | { { 0, 3 } }, |
| 2576 | }, |
| 2577 | { |
| 2578 | "ALU_ADD_K: 3 + 0 = 3", |
| 2579 | .u.insns_int = { |
| 2580 | BPF_LD_IMM64(R0, 3), |
| 2581 | BPF_ALU32_IMM(BPF_ADD, R0, 0), |
| 2582 | BPF_EXIT_INSN(), |
| 2583 | }, |
| 2584 | INTERNAL, |
| 2585 | { }, |
| 2586 | { { 0, 3 } }, |
| 2587 | }, |
| 2588 | { |
| 2589 | "ALU_ADD_K: 1 + 4294967294 = 4294967295", |
| 2590 | .u.insns_int = { |
| 2591 | BPF_LD_IMM64(R0, 1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2592 | BPF_ALU32_IMM(BPF_ADD, R0, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2593 | BPF_EXIT_INSN(), |
| 2594 | }, |
| 2595 | INTERNAL, |
| 2596 | { }, |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2597 | { { 0, 4294967295U } }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2598 | }, |
| 2599 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2600 | "ALU_ADD_K: 4294967294 + 2 = 0", |
| 2601 | .u.insns_int = { |
| 2602 | BPF_LD_IMM64(R0, 4294967294U), |
| 2603 | BPF_ALU32_IMM(BPF_ADD, R0, 2), |
| 2604 | BPF_JMP_IMM(BPF_JEQ, R0, 0, 2), |
| 2605 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2606 | BPF_EXIT_INSN(), |
| 2607 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2608 | BPF_EXIT_INSN(), |
| 2609 | }, |
| 2610 | INTERNAL, |
| 2611 | { }, |
| 2612 | { { 0, 1 } }, |
| 2613 | }, |
| 2614 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2615 | "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff", |
| 2616 | .u.insns_int = { |
| 2617 | BPF_LD_IMM64(R2, 0x0), |
| 2618 | BPF_LD_IMM64(R3, 0x00000000ffffffff), |
| 2619 | BPF_ALU32_IMM(BPF_ADD, R2, 0xffffffff), |
| 2620 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2621 | BPF_MOV32_IMM(R0, 2), |
| 2622 | BPF_EXIT_INSN(), |
| 2623 | BPF_MOV32_IMM(R0, 1), |
| 2624 | BPF_EXIT_INSN(), |
| 2625 | }, |
| 2626 | INTERNAL, |
| 2627 | { }, |
| 2628 | { { 0, 0x1 } }, |
| 2629 | }, |
| 2630 | { |
Naveen N. Rao | 9c94f6c | 2016-04-05 15:32:56 +0530 | [diff] [blame] | 2631 | "ALU_ADD_K: 0 + 0xffff = 0xffff", |
| 2632 | .u.insns_int = { |
| 2633 | BPF_LD_IMM64(R2, 0x0), |
| 2634 | BPF_LD_IMM64(R3, 0xffff), |
| 2635 | BPF_ALU32_IMM(BPF_ADD, R2, 0xffff), |
| 2636 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2637 | BPF_MOV32_IMM(R0, 2), |
| 2638 | BPF_EXIT_INSN(), |
| 2639 | BPF_MOV32_IMM(R0, 1), |
| 2640 | BPF_EXIT_INSN(), |
| 2641 | }, |
| 2642 | INTERNAL, |
| 2643 | { }, |
| 2644 | { { 0, 0x1 } }, |
| 2645 | }, |
| 2646 | { |
| 2647 | "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff", |
| 2648 | .u.insns_int = { |
| 2649 | BPF_LD_IMM64(R2, 0x0), |
| 2650 | BPF_LD_IMM64(R3, 0x7fffffff), |
| 2651 | BPF_ALU32_IMM(BPF_ADD, R2, 0x7fffffff), |
| 2652 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2653 | BPF_MOV32_IMM(R0, 2), |
| 2654 | BPF_EXIT_INSN(), |
| 2655 | BPF_MOV32_IMM(R0, 1), |
| 2656 | BPF_EXIT_INSN(), |
| 2657 | }, |
| 2658 | INTERNAL, |
| 2659 | { }, |
| 2660 | { { 0, 0x1 } }, |
| 2661 | }, |
| 2662 | { |
| 2663 | "ALU_ADD_K: 0 + 0x80000000 = 0x80000000", |
| 2664 | .u.insns_int = { |
| 2665 | BPF_LD_IMM64(R2, 0x0), |
| 2666 | BPF_LD_IMM64(R3, 0x80000000), |
| 2667 | BPF_ALU32_IMM(BPF_ADD, R2, 0x80000000), |
| 2668 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2669 | BPF_MOV32_IMM(R0, 2), |
| 2670 | BPF_EXIT_INSN(), |
| 2671 | BPF_MOV32_IMM(R0, 1), |
| 2672 | BPF_EXIT_INSN(), |
| 2673 | }, |
| 2674 | INTERNAL, |
| 2675 | { }, |
| 2676 | { { 0, 0x1 } }, |
| 2677 | }, |
| 2678 | { |
| 2679 | "ALU_ADD_K: 0 + 0x80008000 = 0x80008000", |
| 2680 | .u.insns_int = { |
| 2681 | BPF_LD_IMM64(R2, 0x0), |
| 2682 | BPF_LD_IMM64(R3, 0x80008000), |
| 2683 | BPF_ALU32_IMM(BPF_ADD, R2, 0x80008000), |
| 2684 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2685 | BPF_MOV32_IMM(R0, 2), |
| 2686 | BPF_EXIT_INSN(), |
| 2687 | BPF_MOV32_IMM(R0, 1), |
| 2688 | BPF_EXIT_INSN(), |
| 2689 | }, |
| 2690 | INTERNAL, |
| 2691 | { }, |
| 2692 | { { 0, 0x1 } }, |
| 2693 | }, |
| 2694 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2695 | "ALU64_ADD_K: 1 + 2 = 3", |
| 2696 | .u.insns_int = { |
| 2697 | BPF_LD_IMM64(R0, 1), |
| 2698 | BPF_ALU64_IMM(BPF_ADD, R0, 2), |
| 2699 | BPF_EXIT_INSN(), |
| 2700 | }, |
| 2701 | INTERNAL, |
| 2702 | { }, |
| 2703 | { { 0, 3 } }, |
| 2704 | }, |
| 2705 | { |
| 2706 | "ALU64_ADD_K: 3 + 0 = 3", |
| 2707 | .u.insns_int = { |
| 2708 | BPF_LD_IMM64(R0, 3), |
| 2709 | BPF_ALU64_IMM(BPF_ADD, R0, 0), |
| 2710 | BPF_EXIT_INSN(), |
| 2711 | }, |
| 2712 | INTERNAL, |
| 2713 | { }, |
| 2714 | { { 0, 3 } }, |
| 2715 | }, |
| 2716 | { |
| 2717 | "ALU64_ADD_K: 1 + 2147483646 = 2147483647", |
| 2718 | .u.insns_int = { |
| 2719 | BPF_LD_IMM64(R0, 1), |
| 2720 | BPF_ALU64_IMM(BPF_ADD, R0, 2147483646), |
| 2721 | BPF_EXIT_INSN(), |
| 2722 | }, |
| 2723 | INTERNAL, |
| 2724 | { }, |
| 2725 | { { 0, 2147483647 } }, |
| 2726 | }, |
| 2727 | { |
Naveen N. Rao | b64b50e | 2016-04-05 15:32:55 +0530 | [diff] [blame] | 2728 | "ALU64_ADD_K: 4294967294 + 2 = 4294967296", |
| 2729 | .u.insns_int = { |
| 2730 | BPF_LD_IMM64(R0, 4294967294U), |
| 2731 | BPF_LD_IMM64(R1, 4294967296ULL), |
| 2732 | BPF_ALU64_IMM(BPF_ADD, R0, 2), |
| 2733 | BPF_JMP_REG(BPF_JEQ, R0, R1, 2), |
| 2734 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 2735 | BPF_EXIT_INSN(), |
| 2736 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 2737 | BPF_EXIT_INSN(), |
| 2738 | }, |
| 2739 | INTERNAL, |
| 2740 | { }, |
| 2741 | { { 0, 1 } }, |
| 2742 | }, |
| 2743 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2744 | "ALU64_ADD_K: 2147483646 + -2147483647 = -1", |
| 2745 | .u.insns_int = { |
| 2746 | BPF_LD_IMM64(R0, 2147483646), |
| 2747 | BPF_ALU64_IMM(BPF_ADD, R0, -2147483647), |
| 2748 | BPF_EXIT_INSN(), |
| 2749 | }, |
| 2750 | INTERNAL, |
| 2751 | { }, |
| 2752 | { { 0, -1 } }, |
| 2753 | }, |
| 2754 | { |
| 2755 | "ALU64_ADD_K: 1 + 0 = 1", |
| 2756 | .u.insns_int = { |
| 2757 | BPF_LD_IMM64(R2, 0x1), |
| 2758 | BPF_LD_IMM64(R3, 0x1), |
| 2759 | BPF_ALU64_IMM(BPF_ADD, R2, 0x0), |
| 2760 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2761 | BPF_MOV32_IMM(R0, 2), |
| 2762 | BPF_EXIT_INSN(), |
| 2763 | BPF_MOV32_IMM(R0, 1), |
| 2764 | BPF_EXIT_INSN(), |
| 2765 | }, |
| 2766 | INTERNAL, |
| 2767 | { }, |
| 2768 | { { 0, 0x1 } }, |
| 2769 | }, |
| 2770 | { |
| 2771 | "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff", |
| 2772 | .u.insns_int = { |
| 2773 | BPF_LD_IMM64(R2, 0x0), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2774 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2775 | BPF_ALU64_IMM(BPF_ADD, R2, 0xffffffff), |
| 2776 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2777 | BPF_MOV32_IMM(R0, 2), |
| 2778 | BPF_EXIT_INSN(), |
| 2779 | BPF_MOV32_IMM(R0, 1), |
| 2780 | BPF_EXIT_INSN(), |
| 2781 | }, |
| 2782 | INTERNAL, |
| 2783 | { }, |
| 2784 | { { 0, 0x1 } }, |
| 2785 | }, |
Naveen N. Rao | 9c94f6c | 2016-04-05 15:32:56 +0530 | [diff] [blame] | 2786 | { |
| 2787 | "ALU64_ADD_K: 0 + 0xffff = 0xffff", |
| 2788 | .u.insns_int = { |
| 2789 | BPF_LD_IMM64(R2, 0x0), |
| 2790 | BPF_LD_IMM64(R3, 0xffff), |
| 2791 | BPF_ALU64_IMM(BPF_ADD, R2, 0xffff), |
| 2792 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2793 | BPF_MOV32_IMM(R0, 2), |
| 2794 | BPF_EXIT_INSN(), |
| 2795 | BPF_MOV32_IMM(R0, 1), |
| 2796 | BPF_EXIT_INSN(), |
| 2797 | }, |
| 2798 | INTERNAL, |
| 2799 | { }, |
| 2800 | { { 0, 0x1 } }, |
| 2801 | }, |
| 2802 | { |
| 2803 | "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff", |
| 2804 | .u.insns_int = { |
| 2805 | BPF_LD_IMM64(R2, 0x0), |
| 2806 | BPF_LD_IMM64(R3, 0x7fffffff), |
| 2807 | BPF_ALU64_IMM(BPF_ADD, R2, 0x7fffffff), |
| 2808 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2809 | BPF_MOV32_IMM(R0, 2), |
| 2810 | BPF_EXIT_INSN(), |
| 2811 | BPF_MOV32_IMM(R0, 1), |
| 2812 | BPF_EXIT_INSN(), |
| 2813 | }, |
| 2814 | INTERNAL, |
| 2815 | { }, |
| 2816 | { { 0, 0x1 } }, |
| 2817 | }, |
| 2818 | { |
| 2819 | "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000", |
| 2820 | .u.insns_int = { |
| 2821 | BPF_LD_IMM64(R2, 0x0), |
| 2822 | BPF_LD_IMM64(R3, 0xffffffff80000000LL), |
| 2823 | BPF_ALU64_IMM(BPF_ADD, R2, 0x80000000), |
| 2824 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2825 | BPF_MOV32_IMM(R0, 2), |
| 2826 | BPF_EXIT_INSN(), |
| 2827 | BPF_MOV32_IMM(R0, 1), |
| 2828 | BPF_EXIT_INSN(), |
| 2829 | }, |
| 2830 | INTERNAL, |
| 2831 | { }, |
| 2832 | { { 0, 0x1 } }, |
| 2833 | }, |
| 2834 | { |
| 2835 | "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000", |
| 2836 | .u.insns_int = { |
| 2837 | BPF_LD_IMM64(R2, 0x0), |
| 2838 | BPF_LD_IMM64(R3, 0xffffffff80008000LL), |
| 2839 | BPF_ALU64_IMM(BPF_ADD, R2, 0x80008000), |
| 2840 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 2841 | BPF_MOV32_IMM(R0, 2), |
| 2842 | BPF_EXIT_INSN(), |
| 2843 | BPF_MOV32_IMM(R0, 1), |
| 2844 | BPF_EXIT_INSN(), |
| 2845 | }, |
| 2846 | INTERNAL, |
| 2847 | { }, |
| 2848 | { { 0, 0x1 } }, |
| 2849 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2850 | /* BPF_ALU | BPF_SUB | BPF_X */ |
| 2851 | { |
| 2852 | "ALU_SUB_X: 3 - 1 = 2", |
| 2853 | .u.insns_int = { |
| 2854 | BPF_LD_IMM64(R0, 3), |
| 2855 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 2856 | BPF_ALU32_REG(BPF_SUB, R0, R1), |
| 2857 | BPF_EXIT_INSN(), |
| 2858 | }, |
| 2859 | INTERNAL, |
| 2860 | { }, |
| 2861 | { { 0, 2 } }, |
| 2862 | }, |
| 2863 | { |
| 2864 | "ALU_SUB_X: 4294967295 - 4294967294 = 1", |
| 2865 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2866 | BPF_LD_IMM64(R0, 4294967295U), |
| 2867 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2868 | BPF_ALU32_REG(BPF_SUB, R0, R1), |
| 2869 | BPF_EXIT_INSN(), |
| 2870 | }, |
| 2871 | INTERNAL, |
| 2872 | { }, |
| 2873 | { { 0, 1 } }, |
| 2874 | }, |
| 2875 | { |
| 2876 | "ALU64_SUB_X: 3 - 1 = 2", |
| 2877 | .u.insns_int = { |
| 2878 | BPF_LD_IMM64(R0, 3), |
| 2879 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 2880 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 2881 | BPF_EXIT_INSN(), |
| 2882 | }, |
| 2883 | INTERNAL, |
| 2884 | { }, |
| 2885 | { { 0, 2 } }, |
| 2886 | }, |
| 2887 | { |
| 2888 | "ALU64_SUB_X: 4294967295 - 4294967294 = 1", |
| 2889 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2890 | BPF_LD_IMM64(R0, 4294967295U), |
| 2891 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2892 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 2893 | BPF_EXIT_INSN(), |
| 2894 | }, |
| 2895 | INTERNAL, |
| 2896 | { }, |
| 2897 | { { 0, 1 } }, |
| 2898 | }, |
| 2899 | /* BPF_ALU | BPF_SUB | BPF_K */ |
| 2900 | { |
| 2901 | "ALU_SUB_K: 3 - 1 = 2", |
| 2902 | .u.insns_int = { |
| 2903 | BPF_LD_IMM64(R0, 3), |
| 2904 | BPF_ALU32_IMM(BPF_SUB, R0, 1), |
| 2905 | BPF_EXIT_INSN(), |
| 2906 | }, |
| 2907 | INTERNAL, |
| 2908 | { }, |
| 2909 | { { 0, 2 } }, |
| 2910 | }, |
| 2911 | { |
| 2912 | "ALU_SUB_K: 3 - 0 = 3", |
| 2913 | .u.insns_int = { |
| 2914 | BPF_LD_IMM64(R0, 3), |
| 2915 | BPF_ALU32_IMM(BPF_SUB, R0, 0), |
| 2916 | BPF_EXIT_INSN(), |
| 2917 | }, |
| 2918 | INTERNAL, |
| 2919 | { }, |
| 2920 | { { 0, 3 } }, |
| 2921 | }, |
| 2922 | { |
| 2923 | "ALU_SUB_K: 4294967295 - 4294967294 = 1", |
| 2924 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2925 | BPF_LD_IMM64(R0, 4294967295U), |
| 2926 | BPF_ALU32_IMM(BPF_SUB, R0, 4294967294U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2927 | BPF_EXIT_INSN(), |
| 2928 | }, |
| 2929 | INTERNAL, |
| 2930 | { }, |
| 2931 | { { 0, 1 } }, |
| 2932 | }, |
| 2933 | { |
| 2934 | "ALU64_SUB_K: 3 - 1 = 2", |
| 2935 | .u.insns_int = { |
| 2936 | BPF_LD_IMM64(R0, 3), |
| 2937 | BPF_ALU64_IMM(BPF_SUB, R0, 1), |
| 2938 | BPF_EXIT_INSN(), |
| 2939 | }, |
| 2940 | INTERNAL, |
| 2941 | { }, |
| 2942 | { { 0, 2 } }, |
| 2943 | }, |
| 2944 | { |
| 2945 | "ALU64_SUB_K: 3 - 0 = 3", |
| 2946 | .u.insns_int = { |
| 2947 | BPF_LD_IMM64(R0, 3), |
| 2948 | BPF_ALU64_IMM(BPF_SUB, R0, 0), |
| 2949 | BPF_EXIT_INSN(), |
| 2950 | }, |
| 2951 | INTERNAL, |
| 2952 | { }, |
| 2953 | { { 0, 3 } }, |
| 2954 | }, |
| 2955 | { |
| 2956 | "ALU64_SUB_K: 4294967294 - 4294967295 = -1", |
| 2957 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 2958 | BPF_LD_IMM64(R0, 4294967294U), |
| 2959 | BPF_ALU64_IMM(BPF_SUB, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 2960 | BPF_EXIT_INSN(), |
| 2961 | }, |
| 2962 | INTERNAL, |
| 2963 | { }, |
| 2964 | { { 0, -1 } }, |
| 2965 | }, |
| 2966 | { |
| 2967 | "ALU64_ADD_K: 2147483646 - 2147483647 = -1", |
| 2968 | .u.insns_int = { |
| 2969 | BPF_LD_IMM64(R0, 2147483646), |
| 2970 | BPF_ALU64_IMM(BPF_SUB, R0, 2147483647), |
| 2971 | BPF_EXIT_INSN(), |
| 2972 | }, |
| 2973 | INTERNAL, |
| 2974 | { }, |
| 2975 | { { 0, -1 } }, |
| 2976 | }, |
| 2977 | /* BPF_ALU | BPF_MUL | BPF_X */ |
| 2978 | { |
| 2979 | "ALU_MUL_X: 2 * 3 = 6", |
| 2980 | .u.insns_int = { |
| 2981 | BPF_LD_IMM64(R0, 2), |
| 2982 | BPF_ALU32_IMM(BPF_MOV, R1, 3), |
| 2983 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 2984 | BPF_EXIT_INSN(), |
| 2985 | }, |
| 2986 | INTERNAL, |
| 2987 | { }, |
| 2988 | { { 0, 6 } }, |
| 2989 | }, |
| 2990 | { |
| 2991 | "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", |
| 2992 | .u.insns_int = { |
| 2993 | BPF_LD_IMM64(R0, 2), |
| 2994 | BPF_ALU32_IMM(BPF_MOV, R1, 0x7FFFFFF8), |
| 2995 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 2996 | BPF_EXIT_INSN(), |
| 2997 | }, |
| 2998 | INTERNAL, |
| 2999 | { }, |
| 3000 | { { 0, 0xFFFFFFF0 } }, |
| 3001 | }, |
| 3002 | { |
| 3003 | "ALU_MUL_X: -1 * -1 = 1", |
| 3004 | .u.insns_int = { |
| 3005 | BPF_LD_IMM64(R0, -1), |
| 3006 | BPF_ALU32_IMM(BPF_MOV, R1, -1), |
| 3007 | BPF_ALU32_REG(BPF_MUL, R0, R1), |
| 3008 | BPF_EXIT_INSN(), |
| 3009 | }, |
| 3010 | INTERNAL, |
| 3011 | { }, |
| 3012 | { { 0, 1 } }, |
| 3013 | }, |
| 3014 | { |
| 3015 | "ALU64_MUL_X: 2 * 3 = 6", |
| 3016 | .u.insns_int = { |
| 3017 | BPF_LD_IMM64(R0, 2), |
| 3018 | BPF_ALU32_IMM(BPF_MOV, R1, 3), |
| 3019 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3020 | BPF_EXIT_INSN(), |
| 3021 | }, |
| 3022 | INTERNAL, |
| 3023 | { }, |
| 3024 | { { 0, 6 } }, |
| 3025 | }, |
| 3026 | { |
| 3027 | "ALU64_MUL_X: 1 * 2147483647 = 2147483647", |
| 3028 | .u.insns_int = { |
| 3029 | BPF_LD_IMM64(R0, 1), |
| 3030 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), |
| 3031 | BPF_ALU64_REG(BPF_MUL, R0, R1), |
| 3032 | BPF_EXIT_INSN(), |
| 3033 | }, |
| 3034 | INTERNAL, |
| 3035 | { }, |
| 3036 | { { 0, 2147483647 } }, |
| 3037 | }, |
| 3038 | /* BPF_ALU | BPF_MUL | BPF_K */ |
| 3039 | { |
| 3040 | "ALU_MUL_K: 2 * 3 = 6", |
| 3041 | .u.insns_int = { |
| 3042 | BPF_LD_IMM64(R0, 2), |
| 3043 | BPF_ALU32_IMM(BPF_MUL, R0, 3), |
| 3044 | BPF_EXIT_INSN(), |
| 3045 | }, |
| 3046 | INTERNAL, |
| 3047 | { }, |
| 3048 | { { 0, 6 } }, |
| 3049 | }, |
| 3050 | { |
| 3051 | "ALU_MUL_K: 3 * 1 = 3", |
| 3052 | .u.insns_int = { |
| 3053 | BPF_LD_IMM64(R0, 3), |
| 3054 | BPF_ALU32_IMM(BPF_MUL, R0, 1), |
| 3055 | BPF_EXIT_INSN(), |
| 3056 | }, |
| 3057 | INTERNAL, |
| 3058 | { }, |
| 3059 | { { 0, 3 } }, |
| 3060 | }, |
| 3061 | { |
| 3062 | "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", |
| 3063 | .u.insns_int = { |
| 3064 | BPF_LD_IMM64(R0, 2), |
| 3065 | BPF_ALU32_IMM(BPF_MUL, R0, 0x7FFFFFF8), |
| 3066 | BPF_EXIT_INSN(), |
| 3067 | }, |
| 3068 | INTERNAL, |
| 3069 | { }, |
| 3070 | { { 0, 0xFFFFFFF0 } }, |
| 3071 | }, |
| 3072 | { |
| 3073 | "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff", |
| 3074 | .u.insns_int = { |
| 3075 | BPF_LD_IMM64(R2, 0x1), |
| 3076 | BPF_LD_IMM64(R3, 0x00000000ffffffff), |
| 3077 | BPF_ALU32_IMM(BPF_MUL, R2, 0xffffffff), |
| 3078 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3079 | BPF_MOV32_IMM(R0, 2), |
| 3080 | BPF_EXIT_INSN(), |
| 3081 | BPF_MOV32_IMM(R0, 1), |
| 3082 | BPF_EXIT_INSN(), |
| 3083 | }, |
| 3084 | INTERNAL, |
| 3085 | { }, |
| 3086 | { { 0, 0x1 } }, |
| 3087 | }, |
| 3088 | { |
| 3089 | "ALU64_MUL_K: 2 * 3 = 6", |
| 3090 | .u.insns_int = { |
| 3091 | BPF_LD_IMM64(R0, 2), |
| 3092 | BPF_ALU64_IMM(BPF_MUL, R0, 3), |
| 3093 | BPF_EXIT_INSN(), |
| 3094 | }, |
| 3095 | INTERNAL, |
| 3096 | { }, |
| 3097 | { { 0, 6 } }, |
| 3098 | }, |
| 3099 | { |
| 3100 | "ALU64_MUL_K: 3 * 1 = 3", |
| 3101 | .u.insns_int = { |
| 3102 | BPF_LD_IMM64(R0, 3), |
| 3103 | BPF_ALU64_IMM(BPF_MUL, R0, 1), |
| 3104 | BPF_EXIT_INSN(), |
| 3105 | }, |
| 3106 | INTERNAL, |
| 3107 | { }, |
| 3108 | { { 0, 3 } }, |
| 3109 | }, |
| 3110 | { |
| 3111 | "ALU64_MUL_K: 1 * 2147483647 = 2147483647", |
| 3112 | .u.insns_int = { |
| 3113 | BPF_LD_IMM64(R0, 1), |
| 3114 | BPF_ALU64_IMM(BPF_MUL, R0, 2147483647), |
| 3115 | BPF_EXIT_INSN(), |
| 3116 | }, |
| 3117 | INTERNAL, |
| 3118 | { }, |
| 3119 | { { 0, 2147483647 } }, |
| 3120 | }, |
| 3121 | { |
| 3122 | "ALU64_MUL_K: 1 * -2147483647 = -2147483647", |
| 3123 | .u.insns_int = { |
| 3124 | BPF_LD_IMM64(R0, 1), |
| 3125 | BPF_ALU64_IMM(BPF_MUL, R0, -2147483647), |
| 3126 | BPF_EXIT_INSN(), |
| 3127 | }, |
| 3128 | INTERNAL, |
| 3129 | { }, |
| 3130 | { { 0, -2147483647 } }, |
| 3131 | }, |
| 3132 | { |
| 3133 | "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff", |
| 3134 | .u.insns_int = { |
| 3135 | BPF_LD_IMM64(R2, 0x1), |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3136 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3137 | BPF_ALU64_IMM(BPF_MUL, R2, 0xffffffff), |
| 3138 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3139 | BPF_MOV32_IMM(R0, 2), |
| 3140 | BPF_EXIT_INSN(), |
| 3141 | BPF_MOV32_IMM(R0, 1), |
| 3142 | BPF_EXIT_INSN(), |
| 3143 | }, |
| 3144 | INTERNAL, |
| 3145 | { }, |
| 3146 | { { 0, 0x1 } }, |
| 3147 | }, |
| 3148 | /* BPF_ALU | BPF_DIV | BPF_X */ |
| 3149 | { |
| 3150 | "ALU_DIV_X: 6 / 2 = 3", |
| 3151 | .u.insns_int = { |
| 3152 | BPF_LD_IMM64(R0, 6), |
| 3153 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3154 | BPF_ALU32_REG(BPF_DIV, R0, R1), |
| 3155 | BPF_EXIT_INSN(), |
| 3156 | }, |
| 3157 | INTERNAL, |
| 3158 | { }, |
| 3159 | { { 0, 3 } }, |
| 3160 | }, |
| 3161 | { |
| 3162 | "ALU_DIV_X: 4294967295 / 4294967295 = 1", |
| 3163 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3164 | BPF_LD_IMM64(R0, 4294967295U), |
| 3165 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3166 | BPF_ALU32_REG(BPF_DIV, R0, R1), |
| 3167 | BPF_EXIT_INSN(), |
| 3168 | }, |
| 3169 | INTERNAL, |
| 3170 | { }, |
| 3171 | { { 0, 1 } }, |
| 3172 | }, |
| 3173 | { |
| 3174 | "ALU64_DIV_X: 6 / 2 = 3", |
| 3175 | .u.insns_int = { |
| 3176 | BPF_LD_IMM64(R0, 6), |
| 3177 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3178 | BPF_ALU64_REG(BPF_DIV, R0, R1), |
| 3179 | BPF_EXIT_INSN(), |
| 3180 | }, |
| 3181 | INTERNAL, |
| 3182 | { }, |
| 3183 | { { 0, 3 } }, |
| 3184 | }, |
| 3185 | { |
| 3186 | "ALU64_DIV_X: 2147483647 / 2147483647 = 1", |
| 3187 | .u.insns_int = { |
| 3188 | BPF_LD_IMM64(R0, 2147483647), |
| 3189 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), |
| 3190 | BPF_ALU64_REG(BPF_DIV, R0, R1), |
| 3191 | BPF_EXIT_INSN(), |
| 3192 | }, |
| 3193 | INTERNAL, |
| 3194 | { }, |
| 3195 | { { 0, 1 } }, |
| 3196 | }, |
| 3197 | { |
| 3198 | "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001", |
| 3199 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3200 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3201 | BPF_LD_IMM64(R4, 0xffffffffffffffffLL), |
| 3202 | BPF_LD_IMM64(R3, 0x0000000000000001LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3203 | BPF_ALU64_REG(BPF_DIV, R2, R4), |
| 3204 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3205 | BPF_MOV32_IMM(R0, 2), |
| 3206 | BPF_EXIT_INSN(), |
| 3207 | BPF_MOV32_IMM(R0, 1), |
| 3208 | BPF_EXIT_INSN(), |
| 3209 | }, |
| 3210 | INTERNAL, |
| 3211 | { }, |
| 3212 | { { 0, 0x1 } }, |
| 3213 | }, |
| 3214 | /* BPF_ALU | BPF_DIV | BPF_K */ |
| 3215 | { |
| 3216 | "ALU_DIV_K: 6 / 2 = 3", |
| 3217 | .u.insns_int = { |
| 3218 | BPF_LD_IMM64(R0, 6), |
| 3219 | BPF_ALU32_IMM(BPF_DIV, R0, 2), |
| 3220 | BPF_EXIT_INSN(), |
| 3221 | }, |
| 3222 | INTERNAL, |
| 3223 | { }, |
| 3224 | { { 0, 3 } }, |
| 3225 | }, |
| 3226 | { |
| 3227 | "ALU_DIV_K: 3 / 1 = 3", |
| 3228 | .u.insns_int = { |
| 3229 | BPF_LD_IMM64(R0, 3), |
| 3230 | BPF_ALU32_IMM(BPF_DIV, R0, 1), |
| 3231 | BPF_EXIT_INSN(), |
| 3232 | }, |
| 3233 | INTERNAL, |
| 3234 | { }, |
| 3235 | { { 0, 3 } }, |
| 3236 | }, |
| 3237 | { |
| 3238 | "ALU_DIV_K: 4294967295 / 4294967295 = 1", |
| 3239 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3240 | BPF_LD_IMM64(R0, 4294967295U), |
| 3241 | BPF_ALU32_IMM(BPF_DIV, R0, 4294967295U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3242 | BPF_EXIT_INSN(), |
| 3243 | }, |
| 3244 | INTERNAL, |
| 3245 | { }, |
| 3246 | { { 0, 1 } }, |
| 3247 | }, |
| 3248 | { |
| 3249 | "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1", |
| 3250 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3251 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3252 | BPF_LD_IMM64(R3, 0x1UL), |
| 3253 | BPF_ALU32_IMM(BPF_DIV, R2, 0xffffffff), |
| 3254 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3255 | BPF_MOV32_IMM(R0, 2), |
| 3256 | BPF_EXIT_INSN(), |
| 3257 | BPF_MOV32_IMM(R0, 1), |
| 3258 | BPF_EXIT_INSN(), |
| 3259 | }, |
| 3260 | INTERNAL, |
| 3261 | { }, |
| 3262 | { { 0, 0x1 } }, |
| 3263 | }, |
| 3264 | { |
| 3265 | "ALU64_DIV_K: 6 / 2 = 3", |
| 3266 | .u.insns_int = { |
| 3267 | BPF_LD_IMM64(R0, 6), |
| 3268 | BPF_ALU64_IMM(BPF_DIV, R0, 2), |
| 3269 | BPF_EXIT_INSN(), |
| 3270 | }, |
| 3271 | INTERNAL, |
| 3272 | { }, |
| 3273 | { { 0, 3 } }, |
| 3274 | }, |
| 3275 | { |
| 3276 | "ALU64_DIV_K: 3 / 1 = 3", |
| 3277 | .u.insns_int = { |
| 3278 | BPF_LD_IMM64(R0, 3), |
| 3279 | BPF_ALU64_IMM(BPF_DIV, R0, 1), |
| 3280 | BPF_EXIT_INSN(), |
| 3281 | }, |
| 3282 | INTERNAL, |
| 3283 | { }, |
| 3284 | { { 0, 3 } }, |
| 3285 | }, |
| 3286 | { |
| 3287 | "ALU64_DIV_K: 2147483647 / 2147483647 = 1", |
| 3288 | .u.insns_int = { |
| 3289 | BPF_LD_IMM64(R0, 2147483647), |
| 3290 | BPF_ALU64_IMM(BPF_DIV, R0, 2147483647), |
| 3291 | BPF_EXIT_INSN(), |
| 3292 | }, |
| 3293 | INTERNAL, |
| 3294 | { }, |
| 3295 | { { 0, 1 } }, |
| 3296 | }, |
| 3297 | { |
| 3298 | "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001", |
| 3299 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3300 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3301 | BPF_LD_IMM64(R3, 0x0000000000000001LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3302 | BPF_ALU64_IMM(BPF_DIV, R2, 0xffffffff), |
| 3303 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3304 | BPF_MOV32_IMM(R0, 2), |
| 3305 | BPF_EXIT_INSN(), |
| 3306 | BPF_MOV32_IMM(R0, 1), |
| 3307 | BPF_EXIT_INSN(), |
| 3308 | }, |
| 3309 | INTERNAL, |
| 3310 | { }, |
| 3311 | { { 0, 0x1 } }, |
| 3312 | }, |
| 3313 | /* BPF_ALU | BPF_MOD | BPF_X */ |
| 3314 | { |
| 3315 | "ALU_MOD_X: 3 % 2 = 1", |
| 3316 | .u.insns_int = { |
| 3317 | BPF_LD_IMM64(R0, 3), |
| 3318 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3319 | BPF_ALU32_REG(BPF_MOD, R0, R1), |
| 3320 | BPF_EXIT_INSN(), |
| 3321 | }, |
| 3322 | INTERNAL, |
| 3323 | { }, |
| 3324 | { { 0, 1 } }, |
| 3325 | }, |
| 3326 | { |
| 3327 | "ALU_MOD_X: 4294967295 % 4294967293 = 2", |
| 3328 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3329 | BPF_LD_IMM64(R0, 4294967295U), |
| 3330 | BPF_ALU32_IMM(BPF_MOV, R1, 4294967293U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3331 | BPF_ALU32_REG(BPF_MOD, R0, R1), |
| 3332 | BPF_EXIT_INSN(), |
| 3333 | }, |
| 3334 | INTERNAL, |
| 3335 | { }, |
| 3336 | { { 0, 2 } }, |
| 3337 | }, |
| 3338 | { |
| 3339 | "ALU64_MOD_X: 3 % 2 = 1", |
| 3340 | .u.insns_int = { |
| 3341 | BPF_LD_IMM64(R0, 3), |
| 3342 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3343 | BPF_ALU64_REG(BPF_MOD, R0, R1), |
| 3344 | BPF_EXIT_INSN(), |
| 3345 | }, |
| 3346 | INTERNAL, |
| 3347 | { }, |
| 3348 | { { 0, 1 } }, |
| 3349 | }, |
| 3350 | { |
| 3351 | "ALU64_MOD_X: 2147483647 % 2147483645 = 2", |
| 3352 | .u.insns_int = { |
| 3353 | BPF_LD_IMM64(R0, 2147483647), |
| 3354 | BPF_ALU32_IMM(BPF_MOV, R1, 2147483645), |
| 3355 | BPF_ALU64_REG(BPF_MOD, R0, R1), |
| 3356 | BPF_EXIT_INSN(), |
| 3357 | }, |
| 3358 | INTERNAL, |
| 3359 | { }, |
| 3360 | { { 0, 2 } }, |
| 3361 | }, |
| 3362 | /* BPF_ALU | BPF_MOD | BPF_K */ |
| 3363 | { |
| 3364 | "ALU_MOD_K: 3 % 2 = 1", |
| 3365 | .u.insns_int = { |
| 3366 | BPF_LD_IMM64(R0, 3), |
| 3367 | BPF_ALU32_IMM(BPF_MOD, R0, 2), |
| 3368 | BPF_EXIT_INSN(), |
| 3369 | }, |
| 3370 | INTERNAL, |
| 3371 | { }, |
| 3372 | { { 0, 1 } }, |
| 3373 | }, |
| 3374 | { |
| 3375 | "ALU_MOD_K: 3 % 1 = 0", |
| 3376 | .u.insns_int = { |
| 3377 | BPF_LD_IMM64(R0, 3), |
| 3378 | BPF_ALU32_IMM(BPF_MOD, R0, 1), |
| 3379 | BPF_EXIT_INSN(), |
| 3380 | }, |
| 3381 | INTERNAL, |
| 3382 | { }, |
| 3383 | { { 0, 0 } }, |
| 3384 | }, |
| 3385 | { |
| 3386 | "ALU_MOD_K: 4294967295 % 4294967293 = 2", |
| 3387 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3388 | BPF_LD_IMM64(R0, 4294967295U), |
| 3389 | BPF_ALU32_IMM(BPF_MOD, R0, 4294967293U), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3390 | BPF_EXIT_INSN(), |
| 3391 | }, |
| 3392 | INTERNAL, |
| 3393 | { }, |
| 3394 | { { 0, 2 } }, |
| 3395 | }, |
| 3396 | { |
| 3397 | "ALU64_MOD_K: 3 % 2 = 1", |
| 3398 | .u.insns_int = { |
| 3399 | BPF_LD_IMM64(R0, 3), |
| 3400 | BPF_ALU64_IMM(BPF_MOD, R0, 2), |
| 3401 | BPF_EXIT_INSN(), |
| 3402 | }, |
| 3403 | INTERNAL, |
| 3404 | { }, |
| 3405 | { { 0, 1 } }, |
| 3406 | }, |
| 3407 | { |
| 3408 | "ALU64_MOD_K: 3 % 1 = 0", |
| 3409 | .u.insns_int = { |
| 3410 | BPF_LD_IMM64(R0, 3), |
| 3411 | BPF_ALU64_IMM(BPF_MOD, R0, 1), |
| 3412 | BPF_EXIT_INSN(), |
| 3413 | }, |
| 3414 | INTERNAL, |
| 3415 | { }, |
| 3416 | { { 0, 0 } }, |
| 3417 | }, |
| 3418 | { |
| 3419 | "ALU64_MOD_K: 2147483647 % 2147483645 = 2", |
| 3420 | .u.insns_int = { |
| 3421 | BPF_LD_IMM64(R0, 2147483647), |
| 3422 | BPF_ALU64_IMM(BPF_MOD, R0, 2147483645), |
| 3423 | BPF_EXIT_INSN(), |
| 3424 | }, |
| 3425 | INTERNAL, |
| 3426 | { }, |
| 3427 | { { 0, 2 } }, |
| 3428 | }, |
| 3429 | /* BPF_ALU | BPF_AND | BPF_X */ |
| 3430 | { |
| 3431 | "ALU_AND_X: 3 & 2 = 2", |
| 3432 | .u.insns_int = { |
| 3433 | BPF_LD_IMM64(R0, 3), |
| 3434 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3435 | BPF_ALU32_REG(BPF_AND, R0, R1), |
| 3436 | BPF_EXIT_INSN(), |
| 3437 | }, |
| 3438 | INTERNAL, |
| 3439 | { }, |
| 3440 | { { 0, 2 } }, |
| 3441 | }, |
| 3442 | { |
| 3443 | "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3444 | .u.insns_int = { |
| 3445 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3446 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3447 | BPF_ALU32_REG(BPF_AND, R0, R1), |
| 3448 | BPF_EXIT_INSN(), |
| 3449 | }, |
| 3450 | INTERNAL, |
| 3451 | { }, |
| 3452 | { { 0, 0xffffffff } }, |
| 3453 | }, |
| 3454 | { |
| 3455 | "ALU64_AND_X: 3 & 2 = 2", |
| 3456 | .u.insns_int = { |
| 3457 | BPF_LD_IMM64(R0, 3), |
| 3458 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3459 | BPF_ALU64_REG(BPF_AND, R0, R1), |
| 3460 | BPF_EXIT_INSN(), |
| 3461 | }, |
| 3462 | INTERNAL, |
| 3463 | { }, |
| 3464 | { { 0, 2 } }, |
| 3465 | }, |
| 3466 | { |
| 3467 | "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3468 | .u.insns_int = { |
| 3469 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3470 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3471 | BPF_ALU64_REG(BPF_AND, R0, R1), |
| 3472 | BPF_EXIT_INSN(), |
| 3473 | }, |
| 3474 | INTERNAL, |
| 3475 | { }, |
| 3476 | { { 0, 0xffffffff } }, |
| 3477 | }, |
| 3478 | /* BPF_ALU | BPF_AND | BPF_K */ |
| 3479 | { |
| 3480 | "ALU_AND_K: 3 & 2 = 2", |
| 3481 | .u.insns_int = { |
| 3482 | BPF_LD_IMM64(R0, 3), |
| 3483 | BPF_ALU32_IMM(BPF_AND, R0, 2), |
| 3484 | BPF_EXIT_INSN(), |
| 3485 | }, |
| 3486 | INTERNAL, |
| 3487 | { }, |
| 3488 | { { 0, 2 } }, |
| 3489 | }, |
| 3490 | { |
| 3491 | "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3492 | .u.insns_int = { |
| 3493 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3494 | BPF_ALU32_IMM(BPF_AND, R0, 0xffffffff), |
| 3495 | BPF_EXIT_INSN(), |
| 3496 | }, |
| 3497 | INTERNAL, |
| 3498 | { }, |
| 3499 | { { 0, 0xffffffff } }, |
| 3500 | }, |
| 3501 | { |
| 3502 | "ALU64_AND_K: 3 & 2 = 2", |
| 3503 | .u.insns_int = { |
| 3504 | BPF_LD_IMM64(R0, 3), |
| 3505 | BPF_ALU64_IMM(BPF_AND, R0, 2), |
| 3506 | BPF_EXIT_INSN(), |
| 3507 | }, |
| 3508 | INTERNAL, |
| 3509 | { }, |
| 3510 | { { 0, 2 } }, |
| 3511 | }, |
| 3512 | { |
| 3513 | "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", |
| 3514 | .u.insns_int = { |
| 3515 | BPF_LD_IMM64(R0, 0xffffffff), |
| 3516 | BPF_ALU64_IMM(BPF_AND, R0, 0xffffffff), |
| 3517 | BPF_EXIT_INSN(), |
| 3518 | }, |
| 3519 | INTERNAL, |
| 3520 | { }, |
| 3521 | { { 0, 0xffffffff } }, |
| 3522 | }, |
| 3523 | { |
| 3524 | "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000", |
| 3525 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3526 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3527 | BPF_LD_IMM64(R3, 0x0000000000000000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3528 | BPF_ALU64_IMM(BPF_AND, R2, 0x0), |
| 3529 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3530 | BPF_MOV32_IMM(R0, 2), |
| 3531 | BPF_EXIT_INSN(), |
| 3532 | BPF_MOV32_IMM(R0, 1), |
| 3533 | BPF_EXIT_INSN(), |
| 3534 | }, |
| 3535 | INTERNAL, |
| 3536 | { }, |
| 3537 | { { 0, 0x1 } }, |
| 3538 | }, |
| 3539 | { |
| 3540 | "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff", |
| 3541 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3542 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3543 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3544 | BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), |
| 3545 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3546 | BPF_MOV32_IMM(R0, 2), |
| 3547 | BPF_EXIT_INSN(), |
| 3548 | BPF_MOV32_IMM(R0, 1), |
| 3549 | BPF_EXIT_INSN(), |
| 3550 | }, |
| 3551 | INTERNAL, |
| 3552 | { }, |
| 3553 | { { 0, 0x1 } }, |
| 3554 | }, |
| 3555 | { |
| 3556 | "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff", |
| 3557 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3558 | BPF_LD_IMM64(R2, 0xffffffffffffffffLL), |
| 3559 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3560 | BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), |
| 3561 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3562 | BPF_MOV32_IMM(R0, 2), |
| 3563 | BPF_EXIT_INSN(), |
| 3564 | BPF_MOV32_IMM(R0, 1), |
| 3565 | BPF_EXIT_INSN(), |
| 3566 | }, |
| 3567 | INTERNAL, |
| 3568 | { }, |
| 3569 | { { 0, 0x1 } }, |
| 3570 | }, |
| 3571 | /* BPF_ALU | BPF_OR | BPF_X */ |
| 3572 | { |
| 3573 | "ALU_OR_X: 1 | 2 = 3", |
| 3574 | .u.insns_int = { |
| 3575 | BPF_LD_IMM64(R0, 1), |
| 3576 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3577 | BPF_ALU32_REG(BPF_OR, R0, R1), |
| 3578 | BPF_EXIT_INSN(), |
| 3579 | }, |
| 3580 | INTERNAL, |
| 3581 | { }, |
| 3582 | { { 0, 3 } }, |
| 3583 | }, |
| 3584 | { |
| 3585 | "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff", |
| 3586 | .u.insns_int = { |
| 3587 | BPF_LD_IMM64(R0, 0), |
| 3588 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3589 | BPF_ALU32_REG(BPF_OR, R0, R1), |
| 3590 | BPF_EXIT_INSN(), |
| 3591 | }, |
| 3592 | INTERNAL, |
| 3593 | { }, |
| 3594 | { { 0, 0xffffffff } }, |
| 3595 | }, |
| 3596 | { |
| 3597 | "ALU64_OR_X: 1 | 2 = 3", |
| 3598 | .u.insns_int = { |
| 3599 | BPF_LD_IMM64(R0, 1), |
| 3600 | BPF_ALU32_IMM(BPF_MOV, R1, 2), |
| 3601 | BPF_ALU64_REG(BPF_OR, R0, R1), |
| 3602 | BPF_EXIT_INSN(), |
| 3603 | }, |
| 3604 | INTERNAL, |
| 3605 | { }, |
| 3606 | { { 0, 3 } }, |
| 3607 | }, |
| 3608 | { |
| 3609 | "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff", |
| 3610 | .u.insns_int = { |
| 3611 | BPF_LD_IMM64(R0, 0), |
| 3612 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3613 | BPF_ALU64_REG(BPF_OR, R0, R1), |
| 3614 | BPF_EXIT_INSN(), |
| 3615 | }, |
| 3616 | INTERNAL, |
| 3617 | { }, |
| 3618 | { { 0, 0xffffffff } }, |
| 3619 | }, |
| 3620 | /* BPF_ALU | BPF_OR | BPF_K */ |
| 3621 | { |
| 3622 | "ALU_OR_K: 1 | 2 = 3", |
| 3623 | .u.insns_int = { |
| 3624 | BPF_LD_IMM64(R0, 1), |
| 3625 | BPF_ALU32_IMM(BPF_OR, R0, 2), |
| 3626 | BPF_EXIT_INSN(), |
| 3627 | }, |
| 3628 | INTERNAL, |
| 3629 | { }, |
| 3630 | { { 0, 3 } }, |
| 3631 | }, |
| 3632 | { |
| 3633 | "ALU_OR_K: 0 & 0xffffffff = 0xffffffff", |
| 3634 | .u.insns_int = { |
| 3635 | BPF_LD_IMM64(R0, 0), |
| 3636 | BPF_ALU32_IMM(BPF_OR, R0, 0xffffffff), |
| 3637 | BPF_EXIT_INSN(), |
| 3638 | }, |
| 3639 | INTERNAL, |
| 3640 | { }, |
| 3641 | { { 0, 0xffffffff } }, |
| 3642 | }, |
| 3643 | { |
| 3644 | "ALU64_OR_K: 1 | 2 = 3", |
| 3645 | .u.insns_int = { |
| 3646 | BPF_LD_IMM64(R0, 1), |
| 3647 | BPF_ALU64_IMM(BPF_OR, R0, 2), |
| 3648 | BPF_EXIT_INSN(), |
| 3649 | }, |
| 3650 | INTERNAL, |
| 3651 | { }, |
| 3652 | { { 0, 3 } }, |
| 3653 | }, |
| 3654 | { |
| 3655 | "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff", |
| 3656 | .u.insns_int = { |
| 3657 | BPF_LD_IMM64(R0, 0), |
| 3658 | BPF_ALU64_IMM(BPF_OR, R0, 0xffffffff), |
| 3659 | BPF_EXIT_INSN(), |
| 3660 | }, |
| 3661 | INTERNAL, |
| 3662 | { }, |
| 3663 | { { 0, 0xffffffff } }, |
| 3664 | }, |
| 3665 | { |
| 3666 | "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000", |
| 3667 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3668 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3669 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3670 | BPF_ALU64_IMM(BPF_OR, R2, 0x0), |
| 3671 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3672 | BPF_MOV32_IMM(R0, 2), |
| 3673 | BPF_EXIT_INSN(), |
| 3674 | BPF_MOV32_IMM(R0, 1), |
| 3675 | BPF_EXIT_INSN(), |
| 3676 | }, |
| 3677 | INTERNAL, |
| 3678 | { }, |
| 3679 | { { 0, 0x1 } }, |
| 3680 | }, |
| 3681 | { |
| 3682 | "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff", |
| 3683 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3684 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3685 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3686 | BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), |
| 3687 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3688 | BPF_MOV32_IMM(R0, 2), |
| 3689 | BPF_EXIT_INSN(), |
| 3690 | BPF_MOV32_IMM(R0, 1), |
| 3691 | BPF_EXIT_INSN(), |
| 3692 | }, |
| 3693 | INTERNAL, |
| 3694 | { }, |
| 3695 | { { 0, 0x1 } }, |
| 3696 | }, |
| 3697 | { |
| 3698 | "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff", |
| 3699 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3700 | BPF_LD_IMM64(R2, 0x0000000000000000LL), |
| 3701 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3702 | BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), |
| 3703 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3704 | BPF_MOV32_IMM(R0, 2), |
| 3705 | BPF_EXIT_INSN(), |
| 3706 | BPF_MOV32_IMM(R0, 1), |
| 3707 | BPF_EXIT_INSN(), |
| 3708 | }, |
| 3709 | INTERNAL, |
| 3710 | { }, |
| 3711 | { { 0, 0x1 } }, |
| 3712 | }, |
| 3713 | /* BPF_ALU | BPF_XOR | BPF_X */ |
| 3714 | { |
| 3715 | "ALU_XOR_X: 5 ^ 6 = 3", |
| 3716 | .u.insns_int = { |
| 3717 | BPF_LD_IMM64(R0, 5), |
| 3718 | BPF_ALU32_IMM(BPF_MOV, R1, 6), |
| 3719 | BPF_ALU32_REG(BPF_XOR, R0, R1), |
| 3720 | BPF_EXIT_INSN(), |
| 3721 | }, |
| 3722 | INTERNAL, |
| 3723 | { }, |
| 3724 | { { 0, 3 } }, |
| 3725 | }, |
| 3726 | { |
| 3727 | "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe", |
| 3728 | .u.insns_int = { |
| 3729 | BPF_LD_IMM64(R0, 1), |
| 3730 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3731 | BPF_ALU32_REG(BPF_XOR, R0, R1), |
| 3732 | BPF_EXIT_INSN(), |
| 3733 | }, |
| 3734 | INTERNAL, |
| 3735 | { }, |
| 3736 | { { 0, 0xfffffffe } }, |
| 3737 | }, |
| 3738 | { |
| 3739 | "ALU64_XOR_X: 5 ^ 6 = 3", |
| 3740 | .u.insns_int = { |
| 3741 | BPF_LD_IMM64(R0, 5), |
| 3742 | BPF_ALU32_IMM(BPF_MOV, R1, 6), |
| 3743 | BPF_ALU64_REG(BPF_XOR, R0, R1), |
| 3744 | BPF_EXIT_INSN(), |
| 3745 | }, |
| 3746 | INTERNAL, |
| 3747 | { }, |
| 3748 | { { 0, 3 } }, |
| 3749 | }, |
| 3750 | { |
| 3751 | "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe", |
| 3752 | .u.insns_int = { |
| 3753 | BPF_LD_IMM64(R0, 1), |
| 3754 | BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), |
| 3755 | BPF_ALU64_REG(BPF_XOR, R0, R1), |
| 3756 | BPF_EXIT_INSN(), |
| 3757 | }, |
| 3758 | INTERNAL, |
| 3759 | { }, |
| 3760 | { { 0, 0xfffffffe } }, |
| 3761 | }, |
| 3762 | /* BPF_ALU | BPF_XOR | BPF_K */ |
| 3763 | { |
| 3764 | "ALU_XOR_K: 5 ^ 6 = 3", |
| 3765 | .u.insns_int = { |
| 3766 | BPF_LD_IMM64(R0, 5), |
| 3767 | BPF_ALU32_IMM(BPF_XOR, R0, 6), |
| 3768 | BPF_EXIT_INSN(), |
| 3769 | }, |
| 3770 | INTERNAL, |
| 3771 | { }, |
| 3772 | { { 0, 3 } }, |
| 3773 | }, |
| 3774 | { |
| 3775 | "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe", |
| 3776 | .u.insns_int = { |
| 3777 | BPF_LD_IMM64(R0, 1), |
| 3778 | BPF_ALU32_IMM(BPF_XOR, R0, 0xffffffff), |
| 3779 | BPF_EXIT_INSN(), |
| 3780 | }, |
| 3781 | INTERNAL, |
| 3782 | { }, |
| 3783 | { { 0, 0xfffffffe } }, |
| 3784 | }, |
| 3785 | { |
| 3786 | "ALU64_XOR_K: 5 ^ 6 = 3", |
| 3787 | .u.insns_int = { |
| 3788 | BPF_LD_IMM64(R0, 5), |
| 3789 | BPF_ALU64_IMM(BPF_XOR, R0, 6), |
| 3790 | BPF_EXIT_INSN(), |
| 3791 | }, |
| 3792 | INTERNAL, |
| 3793 | { }, |
| 3794 | { { 0, 3 } }, |
| 3795 | }, |
| 3796 | { |
| 3797 | "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe", |
| 3798 | .u.insns_int = { |
| 3799 | BPF_LD_IMM64(R0, 1), |
| 3800 | BPF_ALU64_IMM(BPF_XOR, R0, 0xffffffff), |
| 3801 | BPF_EXIT_INSN(), |
| 3802 | }, |
| 3803 | INTERNAL, |
| 3804 | { }, |
| 3805 | { { 0, 0xfffffffe } }, |
| 3806 | }, |
| 3807 | { |
| 3808 | "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000", |
| 3809 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3810 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3811 | BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3812 | BPF_ALU64_IMM(BPF_XOR, R2, 0x0), |
| 3813 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3814 | BPF_MOV32_IMM(R0, 2), |
| 3815 | BPF_EXIT_INSN(), |
| 3816 | BPF_MOV32_IMM(R0, 1), |
| 3817 | BPF_EXIT_INSN(), |
| 3818 | }, |
| 3819 | INTERNAL, |
| 3820 | { }, |
| 3821 | { { 0, 0x1 } }, |
| 3822 | }, |
| 3823 | { |
| 3824 | "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff", |
| 3825 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3826 | BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), |
| 3827 | BPF_LD_IMM64(R3, 0xffff00000000ffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3828 | BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), |
| 3829 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3830 | BPF_MOV32_IMM(R0, 2), |
| 3831 | BPF_EXIT_INSN(), |
| 3832 | BPF_MOV32_IMM(R0, 1), |
| 3833 | BPF_EXIT_INSN(), |
| 3834 | }, |
| 3835 | INTERNAL, |
| 3836 | { }, |
| 3837 | { { 0, 0x1 } }, |
| 3838 | }, |
| 3839 | { |
| 3840 | "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff", |
| 3841 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 3842 | BPF_LD_IMM64(R2, 0x0000000000000000LL), |
| 3843 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 3844 | BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), |
| 3845 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 3846 | BPF_MOV32_IMM(R0, 2), |
| 3847 | BPF_EXIT_INSN(), |
| 3848 | BPF_MOV32_IMM(R0, 1), |
| 3849 | BPF_EXIT_INSN(), |
| 3850 | }, |
| 3851 | INTERNAL, |
| 3852 | { }, |
| 3853 | { { 0, 0x1 } }, |
| 3854 | }, |
| 3855 | /* BPF_ALU | BPF_LSH | BPF_X */ |
| 3856 | { |
| 3857 | "ALU_LSH_X: 1 << 1 = 2", |
| 3858 | .u.insns_int = { |
| 3859 | BPF_LD_IMM64(R0, 1), |
| 3860 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3861 | BPF_ALU32_REG(BPF_LSH, R0, R1), |
| 3862 | BPF_EXIT_INSN(), |
| 3863 | }, |
| 3864 | INTERNAL, |
| 3865 | { }, |
| 3866 | { { 0, 2 } }, |
| 3867 | }, |
| 3868 | { |
| 3869 | "ALU_LSH_X: 1 << 31 = 0x80000000", |
| 3870 | .u.insns_int = { |
| 3871 | BPF_LD_IMM64(R0, 1), |
| 3872 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 3873 | BPF_ALU32_REG(BPF_LSH, R0, R1), |
| 3874 | BPF_EXIT_INSN(), |
| 3875 | }, |
| 3876 | INTERNAL, |
| 3877 | { }, |
| 3878 | { { 0, 0x80000000 } }, |
| 3879 | }, |
| 3880 | { |
| 3881 | "ALU64_LSH_X: 1 << 1 = 2", |
| 3882 | .u.insns_int = { |
| 3883 | BPF_LD_IMM64(R0, 1), |
| 3884 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3885 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 3886 | BPF_EXIT_INSN(), |
| 3887 | }, |
| 3888 | INTERNAL, |
| 3889 | { }, |
| 3890 | { { 0, 2 } }, |
| 3891 | }, |
| 3892 | { |
| 3893 | "ALU64_LSH_X: 1 << 31 = 0x80000000", |
| 3894 | .u.insns_int = { |
| 3895 | BPF_LD_IMM64(R0, 1), |
| 3896 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 3897 | BPF_ALU64_REG(BPF_LSH, R0, R1), |
| 3898 | BPF_EXIT_INSN(), |
| 3899 | }, |
| 3900 | INTERNAL, |
| 3901 | { }, |
| 3902 | { { 0, 0x80000000 } }, |
| 3903 | }, |
| 3904 | /* BPF_ALU | BPF_LSH | BPF_K */ |
| 3905 | { |
| 3906 | "ALU_LSH_K: 1 << 1 = 2", |
| 3907 | .u.insns_int = { |
| 3908 | BPF_LD_IMM64(R0, 1), |
| 3909 | BPF_ALU32_IMM(BPF_LSH, R0, 1), |
| 3910 | BPF_EXIT_INSN(), |
| 3911 | }, |
| 3912 | INTERNAL, |
| 3913 | { }, |
| 3914 | { { 0, 2 } }, |
| 3915 | }, |
| 3916 | { |
| 3917 | "ALU_LSH_K: 1 << 31 = 0x80000000", |
| 3918 | .u.insns_int = { |
| 3919 | BPF_LD_IMM64(R0, 1), |
| 3920 | BPF_ALU32_IMM(BPF_LSH, R0, 31), |
| 3921 | BPF_EXIT_INSN(), |
| 3922 | }, |
| 3923 | INTERNAL, |
| 3924 | { }, |
| 3925 | { { 0, 0x80000000 } }, |
| 3926 | }, |
| 3927 | { |
| 3928 | "ALU64_LSH_K: 1 << 1 = 2", |
| 3929 | .u.insns_int = { |
| 3930 | BPF_LD_IMM64(R0, 1), |
| 3931 | BPF_ALU64_IMM(BPF_LSH, R0, 1), |
| 3932 | BPF_EXIT_INSN(), |
| 3933 | }, |
| 3934 | INTERNAL, |
| 3935 | { }, |
| 3936 | { { 0, 2 } }, |
| 3937 | }, |
| 3938 | { |
| 3939 | "ALU64_LSH_K: 1 << 31 = 0x80000000", |
| 3940 | .u.insns_int = { |
| 3941 | BPF_LD_IMM64(R0, 1), |
| 3942 | BPF_ALU64_IMM(BPF_LSH, R0, 31), |
| 3943 | BPF_EXIT_INSN(), |
| 3944 | }, |
| 3945 | INTERNAL, |
| 3946 | { }, |
| 3947 | { { 0, 0x80000000 } }, |
| 3948 | }, |
| 3949 | /* BPF_ALU | BPF_RSH | BPF_X */ |
| 3950 | { |
| 3951 | "ALU_RSH_X: 2 >> 1 = 1", |
| 3952 | .u.insns_int = { |
| 3953 | BPF_LD_IMM64(R0, 2), |
| 3954 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3955 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 3956 | BPF_EXIT_INSN(), |
| 3957 | }, |
| 3958 | INTERNAL, |
| 3959 | { }, |
| 3960 | { { 0, 1 } }, |
| 3961 | }, |
| 3962 | { |
| 3963 | "ALU_RSH_X: 0x80000000 >> 31 = 1", |
| 3964 | .u.insns_int = { |
| 3965 | BPF_LD_IMM64(R0, 0x80000000), |
| 3966 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 3967 | BPF_ALU32_REG(BPF_RSH, R0, R1), |
| 3968 | BPF_EXIT_INSN(), |
| 3969 | }, |
| 3970 | INTERNAL, |
| 3971 | { }, |
| 3972 | { { 0, 1 } }, |
| 3973 | }, |
| 3974 | { |
| 3975 | "ALU64_RSH_X: 2 >> 1 = 1", |
| 3976 | .u.insns_int = { |
| 3977 | BPF_LD_IMM64(R0, 2), |
| 3978 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
| 3979 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 3980 | BPF_EXIT_INSN(), |
| 3981 | }, |
| 3982 | INTERNAL, |
| 3983 | { }, |
| 3984 | { { 0, 1 } }, |
| 3985 | }, |
| 3986 | { |
| 3987 | "ALU64_RSH_X: 0x80000000 >> 31 = 1", |
| 3988 | .u.insns_int = { |
| 3989 | BPF_LD_IMM64(R0, 0x80000000), |
| 3990 | BPF_ALU32_IMM(BPF_MOV, R1, 31), |
| 3991 | BPF_ALU64_REG(BPF_RSH, R0, R1), |
| 3992 | BPF_EXIT_INSN(), |
| 3993 | }, |
| 3994 | INTERNAL, |
| 3995 | { }, |
| 3996 | { { 0, 1 } }, |
| 3997 | }, |
| 3998 | /* BPF_ALU | BPF_RSH | BPF_K */ |
| 3999 | { |
| 4000 | "ALU_RSH_K: 2 >> 1 = 1", |
| 4001 | .u.insns_int = { |
| 4002 | BPF_LD_IMM64(R0, 2), |
| 4003 | BPF_ALU32_IMM(BPF_RSH, R0, 1), |
| 4004 | BPF_EXIT_INSN(), |
| 4005 | }, |
| 4006 | INTERNAL, |
| 4007 | { }, |
| 4008 | { { 0, 1 } }, |
| 4009 | }, |
| 4010 | { |
| 4011 | "ALU_RSH_K: 0x80000000 >> 31 = 1", |
| 4012 | .u.insns_int = { |
| 4013 | BPF_LD_IMM64(R0, 0x80000000), |
| 4014 | BPF_ALU32_IMM(BPF_RSH, R0, 31), |
| 4015 | BPF_EXIT_INSN(), |
| 4016 | }, |
| 4017 | INTERNAL, |
| 4018 | { }, |
| 4019 | { { 0, 1 } }, |
| 4020 | }, |
| 4021 | { |
| 4022 | "ALU64_RSH_K: 2 >> 1 = 1", |
| 4023 | .u.insns_int = { |
| 4024 | BPF_LD_IMM64(R0, 2), |
| 4025 | BPF_ALU64_IMM(BPF_RSH, R0, 1), |
| 4026 | BPF_EXIT_INSN(), |
| 4027 | }, |
| 4028 | INTERNAL, |
| 4029 | { }, |
| 4030 | { { 0, 1 } }, |
| 4031 | }, |
| 4032 | { |
| 4033 | "ALU64_RSH_K: 0x80000000 >> 31 = 1", |
| 4034 | .u.insns_int = { |
| 4035 | BPF_LD_IMM64(R0, 0x80000000), |
| 4036 | BPF_ALU64_IMM(BPF_RSH, R0, 31), |
| 4037 | BPF_EXIT_INSN(), |
| 4038 | }, |
| 4039 | INTERNAL, |
| 4040 | { }, |
| 4041 | { { 0, 1 } }, |
| 4042 | }, |
| 4043 | /* BPF_ALU | BPF_ARSH | BPF_X */ |
| 4044 | { |
| 4045 | "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", |
| 4046 | .u.insns_int = { |
| 4047 | BPF_LD_IMM64(R0, 0xff00ff0000000000LL), |
| 4048 | BPF_ALU32_IMM(BPF_MOV, R1, 40), |
| 4049 | BPF_ALU64_REG(BPF_ARSH, R0, R1), |
| 4050 | BPF_EXIT_INSN(), |
| 4051 | }, |
| 4052 | INTERNAL, |
| 4053 | { }, |
| 4054 | { { 0, 0xffff00ff } }, |
| 4055 | }, |
| 4056 | /* BPF_ALU | BPF_ARSH | BPF_K */ |
| 4057 | { |
| 4058 | "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", |
| 4059 | .u.insns_int = { |
| 4060 | BPF_LD_IMM64(R0, 0xff00ff0000000000LL), |
| 4061 | BPF_ALU64_IMM(BPF_ARSH, R0, 40), |
| 4062 | BPF_EXIT_INSN(), |
| 4063 | }, |
| 4064 | INTERNAL, |
| 4065 | { }, |
| 4066 | { { 0, 0xffff00ff } }, |
| 4067 | }, |
| 4068 | /* BPF_ALU | BPF_NEG */ |
| 4069 | { |
| 4070 | "ALU_NEG: -(3) = -3", |
| 4071 | .u.insns_int = { |
| 4072 | BPF_ALU32_IMM(BPF_MOV, R0, 3), |
| 4073 | BPF_ALU32_IMM(BPF_NEG, R0, 0), |
| 4074 | BPF_EXIT_INSN(), |
| 4075 | }, |
| 4076 | INTERNAL, |
| 4077 | { }, |
| 4078 | { { 0, -3 } }, |
| 4079 | }, |
| 4080 | { |
| 4081 | "ALU_NEG: -(-3) = 3", |
| 4082 | .u.insns_int = { |
| 4083 | BPF_ALU32_IMM(BPF_MOV, R0, -3), |
| 4084 | BPF_ALU32_IMM(BPF_NEG, R0, 0), |
| 4085 | BPF_EXIT_INSN(), |
| 4086 | }, |
| 4087 | INTERNAL, |
| 4088 | { }, |
| 4089 | { { 0, 3 } }, |
| 4090 | }, |
| 4091 | { |
| 4092 | "ALU64_NEG: -(3) = -3", |
| 4093 | .u.insns_int = { |
| 4094 | BPF_LD_IMM64(R0, 3), |
| 4095 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 4096 | BPF_EXIT_INSN(), |
| 4097 | }, |
| 4098 | INTERNAL, |
| 4099 | { }, |
| 4100 | { { 0, -3 } }, |
| 4101 | }, |
| 4102 | { |
| 4103 | "ALU64_NEG: -(-3) = 3", |
| 4104 | .u.insns_int = { |
| 4105 | BPF_LD_IMM64(R0, -3), |
| 4106 | BPF_ALU64_IMM(BPF_NEG, R0, 0), |
| 4107 | BPF_EXIT_INSN(), |
| 4108 | }, |
| 4109 | INTERNAL, |
| 4110 | { }, |
| 4111 | { { 0, 3 } }, |
| 4112 | }, |
| 4113 | /* BPF_ALU | BPF_END | BPF_FROM_BE */ |
| 4114 | { |
| 4115 | "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef", |
| 4116 | .u.insns_int = { |
| 4117 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4118 | BPF_ENDIAN(BPF_FROM_BE, R0, 16), |
| 4119 | BPF_EXIT_INSN(), |
| 4120 | }, |
| 4121 | INTERNAL, |
| 4122 | { }, |
| 4123 | { { 0, cpu_to_be16(0xcdef) } }, |
| 4124 | }, |
| 4125 | { |
| 4126 | "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef", |
| 4127 | .u.insns_int = { |
| 4128 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4129 | BPF_ENDIAN(BPF_FROM_BE, R0, 32), |
Xi Wang | ba29bec | 2015-07-08 14:00:56 -0700 | [diff] [blame] | 4130 | BPF_ALU64_REG(BPF_MOV, R1, R0), |
| 4131 | BPF_ALU64_IMM(BPF_RSH, R1, 32), |
| 4132 | BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */ |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4133 | BPF_EXIT_INSN(), |
| 4134 | }, |
| 4135 | INTERNAL, |
| 4136 | { }, |
| 4137 | { { 0, cpu_to_be32(0x89abcdef) } }, |
| 4138 | }, |
| 4139 | { |
| 4140 | "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef", |
| 4141 | .u.insns_int = { |
| 4142 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4143 | BPF_ENDIAN(BPF_FROM_BE, R0, 64), |
| 4144 | BPF_EXIT_INSN(), |
| 4145 | }, |
| 4146 | INTERNAL, |
| 4147 | { }, |
| 4148 | { { 0, (u32) cpu_to_be64(0x0123456789abcdefLL) } }, |
| 4149 | }, |
| 4150 | /* BPF_ALU | BPF_END | BPF_FROM_LE */ |
| 4151 | { |
| 4152 | "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd", |
| 4153 | .u.insns_int = { |
| 4154 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4155 | BPF_ENDIAN(BPF_FROM_LE, R0, 16), |
| 4156 | BPF_EXIT_INSN(), |
| 4157 | }, |
| 4158 | INTERNAL, |
| 4159 | { }, |
| 4160 | { { 0, cpu_to_le16(0xcdef) } }, |
| 4161 | }, |
| 4162 | { |
| 4163 | "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89", |
| 4164 | .u.insns_int = { |
| 4165 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4166 | BPF_ENDIAN(BPF_FROM_LE, R0, 32), |
Xi Wang | ba29bec | 2015-07-08 14:00:56 -0700 | [diff] [blame] | 4167 | BPF_ALU64_REG(BPF_MOV, R1, R0), |
| 4168 | BPF_ALU64_IMM(BPF_RSH, R1, 32), |
| 4169 | BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */ |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4170 | BPF_EXIT_INSN(), |
| 4171 | }, |
| 4172 | INTERNAL, |
| 4173 | { }, |
| 4174 | { { 0, cpu_to_le32(0x89abcdef) } }, |
| 4175 | }, |
| 4176 | { |
| 4177 | "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301", |
| 4178 | .u.insns_int = { |
| 4179 | BPF_LD_IMM64(R0, 0x0123456789abcdefLL), |
| 4180 | BPF_ENDIAN(BPF_FROM_LE, R0, 64), |
| 4181 | BPF_EXIT_INSN(), |
| 4182 | }, |
| 4183 | INTERNAL, |
| 4184 | { }, |
| 4185 | { { 0, (u32) cpu_to_le64(0x0123456789abcdefLL) } }, |
| 4186 | }, |
| 4187 | /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */ |
| 4188 | { |
| 4189 | "ST_MEM_B: Store/Load byte: max negative", |
| 4190 | .u.insns_int = { |
| 4191 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4192 | BPF_ST_MEM(BPF_B, R10, -40, 0xff), |
| 4193 | BPF_LDX_MEM(BPF_B, R0, R10, -40), |
| 4194 | BPF_EXIT_INSN(), |
| 4195 | }, |
| 4196 | INTERNAL, |
| 4197 | { }, |
| 4198 | { { 0, 0xff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4199 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4200 | }, |
| 4201 | { |
| 4202 | "ST_MEM_B: Store/Load byte: max positive", |
| 4203 | .u.insns_int = { |
| 4204 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4205 | BPF_ST_MEM(BPF_H, R10, -40, 0x7f), |
| 4206 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 4207 | BPF_EXIT_INSN(), |
| 4208 | }, |
| 4209 | INTERNAL, |
| 4210 | { }, |
| 4211 | { { 0, 0x7f } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4212 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4213 | }, |
| 4214 | { |
| 4215 | "STX_MEM_B: Store/Load byte: max negative", |
| 4216 | .u.insns_int = { |
| 4217 | BPF_LD_IMM64(R0, 0), |
| 4218 | BPF_LD_IMM64(R1, 0xffLL), |
| 4219 | BPF_STX_MEM(BPF_B, R10, R1, -40), |
| 4220 | BPF_LDX_MEM(BPF_B, R0, R10, -40), |
| 4221 | BPF_EXIT_INSN(), |
| 4222 | }, |
| 4223 | INTERNAL, |
| 4224 | { }, |
| 4225 | { { 0, 0xff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4226 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4227 | }, |
| 4228 | { |
| 4229 | "ST_MEM_H: Store/Load half word: max negative", |
| 4230 | .u.insns_int = { |
| 4231 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4232 | BPF_ST_MEM(BPF_H, R10, -40, 0xffff), |
| 4233 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 4234 | BPF_EXIT_INSN(), |
| 4235 | }, |
| 4236 | INTERNAL, |
| 4237 | { }, |
| 4238 | { { 0, 0xffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4239 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4240 | }, |
| 4241 | { |
| 4242 | "ST_MEM_H: Store/Load half word: max positive", |
| 4243 | .u.insns_int = { |
| 4244 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4245 | BPF_ST_MEM(BPF_H, R10, -40, 0x7fff), |
| 4246 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 4247 | BPF_EXIT_INSN(), |
| 4248 | }, |
| 4249 | INTERNAL, |
| 4250 | { }, |
| 4251 | { { 0, 0x7fff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4252 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4253 | }, |
| 4254 | { |
| 4255 | "STX_MEM_H: Store/Load half word: max negative", |
| 4256 | .u.insns_int = { |
| 4257 | BPF_LD_IMM64(R0, 0), |
| 4258 | BPF_LD_IMM64(R1, 0xffffLL), |
| 4259 | BPF_STX_MEM(BPF_H, R10, R1, -40), |
| 4260 | BPF_LDX_MEM(BPF_H, R0, R10, -40), |
| 4261 | BPF_EXIT_INSN(), |
| 4262 | }, |
| 4263 | INTERNAL, |
| 4264 | { }, |
| 4265 | { { 0, 0xffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4266 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4267 | }, |
| 4268 | { |
| 4269 | "ST_MEM_W: Store/Load word: max negative", |
| 4270 | .u.insns_int = { |
| 4271 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4272 | BPF_ST_MEM(BPF_W, R10, -40, 0xffffffff), |
| 4273 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 4274 | BPF_EXIT_INSN(), |
| 4275 | }, |
| 4276 | INTERNAL, |
| 4277 | { }, |
| 4278 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4279 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4280 | }, |
| 4281 | { |
| 4282 | "ST_MEM_W: Store/Load word: max positive", |
| 4283 | .u.insns_int = { |
| 4284 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4285 | BPF_ST_MEM(BPF_W, R10, -40, 0x7fffffff), |
| 4286 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 4287 | BPF_EXIT_INSN(), |
| 4288 | }, |
| 4289 | INTERNAL, |
| 4290 | { }, |
| 4291 | { { 0, 0x7fffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4292 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4293 | }, |
| 4294 | { |
| 4295 | "STX_MEM_W: Store/Load word: max negative", |
| 4296 | .u.insns_int = { |
| 4297 | BPF_LD_IMM64(R0, 0), |
| 4298 | BPF_LD_IMM64(R1, 0xffffffffLL), |
| 4299 | BPF_STX_MEM(BPF_W, R10, R1, -40), |
| 4300 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 4301 | BPF_EXIT_INSN(), |
| 4302 | }, |
| 4303 | INTERNAL, |
| 4304 | { }, |
| 4305 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4306 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4307 | }, |
| 4308 | { |
| 4309 | "ST_MEM_DW: Store/Load double word: max negative", |
| 4310 | .u.insns_int = { |
| 4311 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4312 | BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), |
| 4313 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 4314 | BPF_EXIT_INSN(), |
| 4315 | }, |
| 4316 | INTERNAL, |
| 4317 | { }, |
| 4318 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4319 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4320 | }, |
| 4321 | { |
| 4322 | "ST_MEM_DW: Store/Load double word: max negative 2", |
| 4323 | .u.insns_int = { |
Michael Holzheu | 56cbaa4 | 2015-05-13 20:40:39 -0700 | [diff] [blame] | 4324 | BPF_LD_IMM64(R2, 0xffff00000000ffffLL), |
| 4325 | BPF_LD_IMM64(R3, 0xffffffffffffffffLL), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4326 | BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), |
| 4327 | BPF_LDX_MEM(BPF_DW, R2, R10, -40), |
| 4328 | BPF_JMP_REG(BPF_JEQ, R2, R3, 2), |
| 4329 | BPF_MOV32_IMM(R0, 2), |
| 4330 | BPF_EXIT_INSN(), |
| 4331 | BPF_MOV32_IMM(R0, 1), |
| 4332 | BPF_EXIT_INSN(), |
| 4333 | }, |
| 4334 | INTERNAL, |
| 4335 | { }, |
| 4336 | { { 0, 0x1 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4337 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4338 | }, |
| 4339 | { |
| 4340 | "ST_MEM_DW: Store/Load double word: max positive", |
| 4341 | .u.insns_int = { |
| 4342 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4343 | BPF_ST_MEM(BPF_DW, R10, -40, 0x7fffffff), |
| 4344 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 4345 | BPF_EXIT_INSN(), |
| 4346 | }, |
| 4347 | INTERNAL, |
| 4348 | { }, |
| 4349 | { { 0, 0x7fffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4350 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4351 | }, |
| 4352 | { |
| 4353 | "STX_MEM_DW: Store/Load double word: max negative", |
| 4354 | .u.insns_int = { |
| 4355 | BPF_LD_IMM64(R0, 0), |
| 4356 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 4357 | BPF_STX_MEM(BPF_W, R10, R1, -40), |
| 4358 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 4359 | BPF_EXIT_INSN(), |
| 4360 | }, |
| 4361 | INTERNAL, |
| 4362 | { }, |
| 4363 | { { 0, 0xffffffff } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4364 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4365 | }, |
| 4366 | /* BPF_STX | BPF_XADD | BPF_W/DW */ |
| 4367 | { |
| 4368 | "STX_XADD_W: Test: 0x12 + 0x10 = 0x22", |
| 4369 | .u.insns_int = { |
| 4370 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4371 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
| 4372 | BPF_STX_XADD(BPF_W, R10, R0, -40), |
| 4373 | BPF_LDX_MEM(BPF_W, R0, R10, -40), |
| 4374 | BPF_EXIT_INSN(), |
| 4375 | }, |
| 4376 | INTERNAL, |
| 4377 | { }, |
| 4378 | { { 0, 0x22 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4379 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4380 | }, |
| 4381 | { |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4382 | "STX_XADD_W: Test side-effects, r10: 0x12 + 0x10 = 0x22", |
| 4383 | .u.insns_int = { |
| 4384 | BPF_ALU64_REG(BPF_MOV, R1, R10), |
| 4385 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4386 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
| 4387 | BPF_STX_XADD(BPF_W, R10, R0, -40), |
| 4388 | BPF_ALU64_REG(BPF_MOV, R0, R10), |
| 4389 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 4390 | BPF_EXIT_INSN(), |
| 4391 | }, |
| 4392 | INTERNAL, |
| 4393 | { }, |
| 4394 | { { 0, 0 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4395 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4396 | }, |
| 4397 | { |
| 4398 | "STX_XADD_W: Test side-effects, r0: 0x12 + 0x10 = 0x22", |
| 4399 | .u.insns_int = { |
| 4400 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4401 | BPF_ST_MEM(BPF_W, R10, -40, 0x10), |
| 4402 | BPF_STX_XADD(BPF_W, R10, R0, -40), |
| 4403 | BPF_EXIT_INSN(), |
| 4404 | }, |
| 4405 | INTERNAL, |
| 4406 | { }, |
| 4407 | { { 0, 0x12 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4408 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4409 | }, |
| 4410 | { |
| 4411 | "STX_XADD_W: X + 1 + 1 + 1 + ...", |
| 4412 | { }, |
| 4413 | INTERNAL, |
| 4414 | { }, |
| 4415 | { { 0, 4134 } }, |
| 4416 | .fill_helper = bpf_fill_stxw, |
| 4417 | }, |
| 4418 | { |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4419 | "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22", |
| 4420 | .u.insns_int = { |
| 4421 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4422 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
| 4423 | BPF_STX_XADD(BPF_DW, R10, R0, -40), |
| 4424 | BPF_LDX_MEM(BPF_DW, R0, R10, -40), |
| 4425 | BPF_EXIT_INSN(), |
| 4426 | }, |
| 4427 | INTERNAL, |
| 4428 | { }, |
| 4429 | { { 0, 0x22 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4430 | .stack_depth = 40, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4431 | }, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4432 | { |
| 4433 | "STX_XADD_DW: Test side-effects, r10: 0x12 + 0x10 = 0x22", |
| 4434 | .u.insns_int = { |
| 4435 | BPF_ALU64_REG(BPF_MOV, R1, R10), |
| 4436 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4437 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
| 4438 | BPF_STX_XADD(BPF_DW, R10, R0, -40), |
| 4439 | BPF_ALU64_REG(BPF_MOV, R0, R10), |
| 4440 | BPF_ALU64_REG(BPF_SUB, R0, R1), |
| 4441 | BPF_EXIT_INSN(), |
| 4442 | }, |
| 4443 | INTERNAL, |
| 4444 | { }, |
| 4445 | { { 0, 0 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4446 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4447 | }, |
| 4448 | { |
| 4449 | "STX_XADD_DW: Test side-effects, r0: 0x12 + 0x10 = 0x22", |
| 4450 | .u.insns_int = { |
| 4451 | BPF_ALU32_IMM(BPF_MOV, R0, 0x12), |
| 4452 | BPF_ST_MEM(BPF_DW, R10, -40, 0x10), |
| 4453 | BPF_STX_XADD(BPF_DW, R10, R0, -40), |
| 4454 | BPF_EXIT_INSN(), |
| 4455 | }, |
| 4456 | INTERNAL, |
| 4457 | { }, |
| 4458 | { { 0, 0x12 } }, |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 4459 | .stack_depth = 40, |
Daniel Borkmann | 85f68fe | 2017-05-01 02:57:20 +0200 | [diff] [blame] | 4460 | }, |
| 4461 | { |
| 4462 | "STX_XADD_DW: X + 1 + 1 + 1 + ...", |
| 4463 | { }, |
| 4464 | INTERNAL, |
| 4465 | { }, |
| 4466 | { { 0, 4134 } }, |
| 4467 | .fill_helper = bpf_fill_stxdw, |
| 4468 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4469 | /* BPF_JMP | BPF_EXIT */ |
| 4470 | { |
| 4471 | "JMP_EXIT", |
| 4472 | .u.insns_int = { |
| 4473 | BPF_ALU32_IMM(BPF_MOV, R0, 0x4711), |
| 4474 | BPF_EXIT_INSN(), |
| 4475 | BPF_ALU32_IMM(BPF_MOV, R0, 0x4712), |
| 4476 | }, |
| 4477 | INTERNAL, |
| 4478 | { }, |
| 4479 | { { 0, 0x4711 } }, |
| 4480 | }, |
| 4481 | /* BPF_JMP | BPF_JA */ |
| 4482 | { |
| 4483 | "JMP_JA: Unconditional jump: if (true) return 1", |
| 4484 | .u.insns_int = { |
| 4485 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4486 | BPF_JMP_IMM(BPF_JA, 0, 0, 1), |
| 4487 | BPF_EXIT_INSN(), |
| 4488 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4489 | BPF_EXIT_INSN(), |
| 4490 | }, |
| 4491 | INTERNAL, |
| 4492 | { }, |
| 4493 | { { 0, 1 } }, |
| 4494 | }, |
| 4495 | /* BPF_JMP | BPF_JSGT | BPF_K */ |
| 4496 | { |
| 4497 | "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1", |
| 4498 | .u.insns_int = { |
| 4499 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4500 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 4501 | BPF_JMP_IMM(BPF_JSGT, R1, -2, 1), |
| 4502 | BPF_EXIT_INSN(), |
| 4503 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4504 | BPF_EXIT_INSN(), |
| 4505 | }, |
| 4506 | INTERNAL, |
| 4507 | { }, |
| 4508 | { { 0, 1 } }, |
| 4509 | }, |
| 4510 | { |
| 4511 | "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0", |
| 4512 | .u.insns_int = { |
| 4513 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4514 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 4515 | BPF_JMP_IMM(BPF_JSGT, R1, -1, 1), |
| 4516 | BPF_EXIT_INSN(), |
| 4517 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4518 | BPF_EXIT_INSN(), |
| 4519 | }, |
| 4520 | INTERNAL, |
| 4521 | { }, |
| 4522 | { { 0, 1 } }, |
| 4523 | }, |
| 4524 | /* BPF_JMP | BPF_JSGE | BPF_K */ |
| 4525 | { |
| 4526 | "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1", |
| 4527 | .u.insns_int = { |
| 4528 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4529 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 4530 | BPF_JMP_IMM(BPF_JSGE, R1, -2, 1), |
| 4531 | BPF_EXIT_INSN(), |
| 4532 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4533 | BPF_EXIT_INSN(), |
| 4534 | }, |
| 4535 | INTERNAL, |
| 4536 | { }, |
| 4537 | { { 0, 1 } }, |
| 4538 | }, |
| 4539 | { |
| 4540 | "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1", |
| 4541 | .u.insns_int = { |
| 4542 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4543 | BPF_LD_IMM64(R1, 0xffffffffffffffffLL), |
| 4544 | BPF_JMP_IMM(BPF_JSGE, R1, -1, 1), |
| 4545 | BPF_EXIT_INSN(), |
| 4546 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4547 | BPF_EXIT_INSN(), |
| 4548 | }, |
| 4549 | INTERNAL, |
| 4550 | { }, |
| 4551 | { { 0, 1 } }, |
| 4552 | }, |
David Daney | 791caeb | 2017-05-24 16:35:49 -0700 | [diff] [blame] | 4553 | { |
| 4554 | "JMP_JSGE_K: Signed jump: value walk 1", |
| 4555 | .u.insns_int = { |
| 4556 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4557 | BPF_LD_IMM64(R1, -3), |
| 4558 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 6), |
| 4559 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 4560 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 4), |
| 4561 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 4562 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 2), |
| 4563 | BPF_ALU64_IMM(BPF_ADD, R1, 1), |
| 4564 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 1), |
| 4565 | BPF_EXIT_INSN(), /* bad exit */ |
| 4566 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 4567 | BPF_EXIT_INSN(), |
| 4568 | }, |
| 4569 | INTERNAL, |
| 4570 | { }, |
| 4571 | { { 0, 1 } }, |
| 4572 | }, |
| 4573 | { |
| 4574 | "JMP_JSGE_K: Signed jump: value walk 2", |
| 4575 | .u.insns_int = { |
| 4576 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4577 | BPF_LD_IMM64(R1, -3), |
| 4578 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 4), |
| 4579 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 4580 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 2), |
| 4581 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
| 4582 | BPF_JMP_IMM(BPF_JSGE, R1, 0, 1), |
| 4583 | BPF_EXIT_INSN(), /* bad exit */ |
| 4584 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */ |
| 4585 | BPF_EXIT_INSN(), |
| 4586 | }, |
| 4587 | INTERNAL, |
| 4588 | { }, |
| 4589 | { { 0, 1 } }, |
| 4590 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4591 | /* BPF_JMP | BPF_JGT | BPF_K */ |
| 4592 | { |
| 4593 | "JMP_JGT_K: if (3 > 2) return 1", |
| 4594 | .u.insns_int = { |
| 4595 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4596 | BPF_LD_IMM64(R1, 3), |
| 4597 | BPF_JMP_IMM(BPF_JGT, R1, 2, 1), |
| 4598 | BPF_EXIT_INSN(), |
| 4599 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4600 | BPF_EXIT_INSN(), |
| 4601 | }, |
| 4602 | INTERNAL, |
| 4603 | { }, |
| 4604 | { { 0, 1 } }, |
| 4605 | }, |
Naveen N. Rao | c7395d6 | 2016-04-05 15:32:54 +0530 | [diff] [blame] | 4606 | { |
| 4607 | "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1", |
| 4608 | .u.insns_int = { |
| 4609 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4610 | BPF_LD_IMM64(R1, -1), |
| 4611 | BPF_JMP_IMM(BPF_JGT, R1, 1, 1), |
| 4612 | BPF_EXIT_INSN(), |
| 4613 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4614 | BPF_EXIT_INSN(), |
| 4615 | }, |
| 4616 | INTERNAL, |
| 4617 | { }, |
| 4618 | { { 0, 1 } }, |
| 4619 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4620 | /* BPF_JMP | BPF_JGE | BPF_K */ |
| 4621 | { |
| 4622 | "JMP_JGE_K: if (3 >= 2) return 1", |
| 4623 | .u.insns_int = { |
| 4624 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4625 | BPF_LD_IMM64(R1, 3), |
| 4626 | BPF_JMP_IMM(BPF_JGE, R1, 2, 1), |
| 4627 | BPF_EXIT_INSN(), |
| 4628 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4629 | BPF_EXIT_INSN(), |
| 4630 | }, |
| 4631 | INTERNAL, |
| 4632 | { }, |
| 4633 | { { 0, 1 } }, |
| 4634 | }, |
Michael Holzheu | fe59384 | 2015-05-22 08:36:40 -0700 | [diff] [blame] | 4635 | /* BPF_JMP | BPF_JGT | BPF_K jump backwards */ |
| 4636 | { |
| 4637 | "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)", |
| 4638 | .u.insns_int = { |
| 4639 | BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */ |
| 4640 | BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */ |
| 4641 | BPF_EXIT_INSN(), |
| 4642 | BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */ |
| 4643 | BPF_LD_IMM64(R1, 3), /* note: this takes 2 insns */ |
| 4644 | BPF_JMP_IMM(BPF_JGT, R1, 2, -6), /* goto out */ |
| 4645 | BPF_EXIT_INSN(), |
| 4646 | }, |
| 4647 | INTERNAL, |
| 4648 | { }, |
| 4649 | { { 0, 1 } }, |
| 4650 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4651 | { |
| 4652 | "JMP_JGE_K: if (3 >= 3) return 1", |
| 4653 | .u.insns_int = { |
| 4654 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4655 | BPF_LD_IMM64(R1, 3), |
| 4656 | BPF_JMP_IMM(BPF_JGE, R1, 3, 1), |
| 4657 | BPF_EXIT_INSN(), |
| 4658 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4659 | BPF_EXIT_INSN(), |
| 4660 | }, |
| 4661 | INTERNAL, |
| 4662 | { }, |
| 4663 | { { 0, 1 } }, |
| 4664 | }, |
| 4665 | /* BPF_JMP | BPF_JNE | BPF_K */ |
| 4666 | { |
| 4667 | "JMP_JNE_K: if (3 != 2) return 1", |
| 4668 | .u.insns_int = { |
| 4669 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4670 | BPF_LD_IMM64(R1, 3), |
| 4671 | BPF_JMP_IMM(BPF_JNE, R1, 2, 1), |
| 4672 | BPF_EXIT_INSN(), |
| 4673 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4674 | BPF_EXIT_INSN(), |
| 4675 | }, |
| 4676 | INTERNAL, |
| 4677 | { }, |
| 4678 | { { 0, 1 } }, |
| 4679 | }, |
| 4680 | /* BPF_JMP | BPF_JEQ | BPF_K */ |
| 4681 | { |
| 4682 | "JMP_JEQ_K: if (3 == 3) return 1", |
| 4683 | .u.insns_int = { |
| 4684 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4685 | BPF_LD_IMM64(R1, 3), |
| 4686 | BPF_JMP_IMM(BPF_JEQ, R1, 3, 1), |
| 4687 | BPF_EXIT_INSN(), |
| 4688 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4689 | BPF_EXIT_INSN(), |
| 4690 | }, |
| 4691 | INTERNAL, |
| 4692 | { }, |
| 4693 | { { 0, 1 } }, |
| 4694 | }, |
| 4695 | /* BPF_JMP | BPF_JSET | BPF_K */ |
| 4696 | { |
| 4697 | "JMP_JSET_K: if (0x3 & 0x2) return 1", |
| 4698 | .u.insns_int = { |
| 4699 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4700 | BPF_LD_IMM64(R1, 3), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 4701 | BPF_JMP_IMM(BPF_JSET, R1, 2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4702 | BPF_EXIT_INSN(), |
| 4703 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4704 | BPF_EXIT_INSN(), |
| 4705 | }, |
| 4706 | INTERNAL, |
| 4707 | { }, |
| 4708 | { { 0, 1 } }, |
| 4709 | }, |
| 4710 | { |
| 4711 | "JMP_JSET_K: if (0x3 & 0xffffffff) return 1", |
| 4712 | .u.insns_int = { |
| 4713 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4714 | BPF_LD_IMM64(R1, 3), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 4715 | BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4716 | BPF_EXIT_INSN(), |
| 4717 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4718 | BPF_EXIT_INSN(), |
| 4719 | }, |
| 4720 | INTERNAL, |
| 4721 | { }, |
| 4722 | { { 0, 1 } }, |
| 4723 | }, |
| 4724 | /* BPF_JMP | BPF_JSGT | BPF_X */ |
| 4725 | { |
| 4726 | "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1", |
| 4727 | .u.insns_int = { |
| 4728 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4729 | BPF_LD_IMM64(R1, -1), |
| 4730 | BPF_LD_IMM64(R2, -2), |
| 4731 | BPF_JMP_REG(BPF_JSGT, R1, R2, 1), |
| 4732 | BPF_EXIT_INSN(), |
| 4733 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4734 | BPF_EXIT_INSN(), |
| 4735 | }, |
| 4736 | INTERNAL, |
| 4737 | { }, |
| 4738 | { { 0, 1 } }, |
| 4739 | }, |
| 4740 | { |
| 4741 | "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0", |
| 4742 | .u.insns_int = { |
| 4743 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4744 | BPF_LD_IMM64(R1, -1), |
| 4745 | BPF_LD_IMM64(R2, -1), |
| 4746 | BPF_JMP_REG(BPF_JSGT, R1, R2, 1), |
| 4747 | BPF_EXIT_INSN(), |
| 4748 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4749 | BPF_EXIT_INSN(), |
| 4750 | }, |
| 4751 | INTERNAL, |
| 4752 | { }, |
| 4753 | { { 0, 1 } }, |
| 4754 | }, |
| 4755 | /* BPF_JMP | BPF_JSGE | BPF_X */ |
| 4756 | { |
| 4757 | "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1", |
| 4758 | .u.insns_int = { |
| 4759 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4760 | BPF_LD_IMM64(R1, -1), |
| 4761 | BPF_LD_IMM64(R2, -2), |
| 4762 | BPF_JMP_REG(BPF_JSGE, R1, R2, 1), |
| 4763 | BPF_EXIT_INSN(), |
| 4764 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4765 | BPF_EXIT_INSN(), |
| 4766 | }, |
| 4767 | INTERNAL, |
| 4768 | { }, |
| 4769 | { { 0, 1 } }, |
| 4770 | }, |
| 4771 | { |
| 4772 | "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1", |
| 4773 | .u.insns_int = { |
| 4774 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4775 | BPF_LD_IMM64(R1, -1), |
| 4776 | BPF_LD_IMM64(R2, -1), |
| 4777 | BPF_JMP_REG(BPF_JSGE, R1, R2, 1), |
| 4778 | BPF_EXIT_INSN(), |
| 4779 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4780 | BPF_EXIT_INSN(), |
| 4781 | }, |
| 4782 | INTERNAL, |
| 4783 | { }, |
| 4784 | { { 0, 1 } }, |
| 4785 | }, |
| 4786 | /* BPF_JMP | BPF_JGT | BPF_X */ |
| 4787 | { |
| 4788 | "JMP_JGT_X: if (3 > 2) return 1", |
| 4789 | .u.insns_int = { |
| 4790 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4791 | BPF_LD_IMM64(R1, 3), |
| 4792 | BPF_LD_IMM64(R2, 2), |
| 4793 | BPF_JMP_REG(BPF_JGT, R1, R2, 1), |
| 4794 | BPF_EXIT_INSN(), |
| 4795 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4796 | BPF_EXIT_INSN(), |
| 4797 | }, |
| 4798 | INTERNAL, |
| 4799 | { }, |
| 4800 | { { 0, 1 } }, |
| 4801 | }, |
Naveen N. Rao | c7395d6 | 2016-04-05 15:32:54 +0530 | [diff] [blame] | 4802 | { |
| 4803 | "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1", |
| 4804 | .u.insns_int = { |
| 4805 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4806 | BPF_LD_IMM64(R1, -1), |
| 4807 | BPF_LD_IMM64(R2, 1), |
| 4808 | BPF_JMP_REG(BPF_JGT, R1, R2, 1), |
| 4809 | BPF_EXIT_INSN(), |
| 4810 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4811 | BPF_EXIT_INSN(), |
| 4812 | }, |
| 4813 | INTERNAL, |
| 4814 | { }, |
| 4815 | { { 0, 1 } }, |
| 4816 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4817 | /* BPF_JMP | BPF_JGE | BPF_X */ |
| 4818 | { |
| 4819 | "JMP_JGE_X: if (3 >= 2) return 1", |
| 4820 | .u.insns_int = { |
| 4821 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4822 | BPF_LD_IMM64(R1, 3), |
| 4823 | BPF_LD_IMM64(R2, 2), |
| 4824 | BPF_JMP_REG(BPF_JGE, R1, R2, 1), |
| 4825 | BPF_EXIT_INSN(), |
| 4826 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4827 | BPF_EXIT_INSN(), |
| 4828 | }, |
| 4829 | INTERNAL, |
| 4830 | { }, |
| 4831 | { { 0, 1 } }, |
| 4832 | }, |
| 4833 | { |
| 4834 | "JMP_JGE_X: if (3 >= 3) return 1", |
| 4835 | .u.insns_int = { |
| 4836 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4837 | BPF_LD_IMM64(R1, 3), |
| 4838 | BPF_LD_IMM64(R2, 3), |
| 4839 | BPF_JMP_REG(BPF_JGE, R1, R2, 1), |
| 4840 | BPF_EXIT_INSN(), |
| 4841 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4842 | BPF_EXIT_INSN(), |
| 4843 | }, |
| 4844 | INTERNAL, |
| 4845 | { }, |
| 4846 | { { 0, 1 } }, |
| 4847 | }, |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 4848 | { |
| 4849 | /* Mainly testing JIT + imm64 here. */ |
| 4850 | "JMP_JGE_X: ldimm64 test 1", |
| 4851 | .u.insns_int = { |
| 4852 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4853 | BPF_LD_IMM64(R1, 3), |
| 4854 | BPF_LD_IMM64(R2, 2), |
| 4855 | BPF_JMP_REG(BPF_JGE, R1, R2, 2), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 4856 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 4857 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 4858 | BPF_EXIT_INSN(), |
| 4859 | }, |
| 4860 | INTERNAL, |
| 4861 | { }, |
| 4862 | { { 0, 0xeeeeeeeeU } }, |
| 4863 | }, |
| 4864 | { |
| 4865 | "JMP_JGE_X: ldimm64 test 2", |
| 4866 | .u.insns_int = { |
| 4867 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4868 | BPF_LD_IMM64(R1, 3), |
| 4869 | BPF_LD_IMM64(R2, 2), |
| 4870 | BPF_JMP_REG(BPF_JGE, R1, R2, 0), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 4871 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 4872 | BPF_EXIT_INSN(), |
| 4873 | }, |
| 4874 | INTERNAL, |
| 4875 | { }, |
| 4876 | { { 0, 0xffffffffU } }, |
| 4877 | }, |
| 4878 | { |
| 4879 | "JMP_JGE_X: ldimm64 test 3", |
| 4880 | .u.insns_int = { |
| 4881 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4882 | BPF_LD_IMM64(R1, 3), |
| 4883 | BPF_LD_IMM64(R2, 2), |
| 4884 | BPF_JMP_REG(BPF_JGE, R1, R2, 4), |
Geert Uytterhoeven | 86f8e24 | 2017-05-03 13:31:04 +0200 | [diff] [blame] | 4885 | BPF_LD_IMM64(R0, 0xffffffffffffffffULL), |
| 4886 | BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL), |
Daniel Borkmann | ddc665a | 2017-05-02 20:34:54 +0200 | [diff] [blame] | 4887 | BPF_EXIT_INSN(), |
| 4888 | }, |
| 4889 | INTERNAL, |
| 4890 | { }, |
| 4891 | { { 0, 1 } }, |
| 4892 | }, |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4893 | /* BPF_JMP | BPF_JNE | BPF_X */ |
| 4894 | { |
| 4895 | "JMP_JNE_X: if (3 != 2) return 1", |
| 4896 | .u.insns_int = { |
| 4897 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4898 | BPF_LD_IMM64(R1, 3), |
| 4899 | BPF_LD_IMM64(R2, 2), |
| 4900 | BPF_JMP_REG(BPF_JNE, R1, R2, 1), |
| 4901 | BPF_EXIT_INSN(), |
| 4902 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4903 | BPF_EXIT_INSN(), |
| 4904 | }, |
| 4905 | INTERNAL, |
| 4906 | { }, |
| 4907 | { { 0, 1 } }, |
| 4908 | }, |
| 4909 | /* BPF_JMP | BPF_JEQ | BPF_X */ |
| 4910 | { |
| 4911 | "JMP_JEQ_X: if (3 == 3) return 1", |
| 4912 | .u.insns_int = { |
| 4913 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4914 | BPF_LD_IMM64(R1, 3), |
| 4915 | BPF_LD_IMM64(R2, 3), |
| 4916 | BPF_JMP_REG(BPF_JEQ, R1, R2, 1), |
| 4917 | BPF_EXIT_INSN(), |
| 4918 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4919 | BPF_EXIT_INSN(), |
| 4920 | }, |
| 4921 | INTERNAL, |
| 4922 | { }, |
| 4923 | { { 0, 1 } }, |
| 4924 | }, |
| 4925 | /* BPF_JMP | BPF_JSET | BPF_X */ |
| 4926 | { |
| 4927 | "JMP_JSET_X: if (0x3 & 0x2) return 1", |
| 4928 | .u.insns_int = { |
| 4929 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4930 | BPF_LD_IMM64(R1, 3), |
| 4931 | BPF_LD_IMM64(R2, 2), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 4932 | BPF_JMP_REG(BPF_JSET, R1, R2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4933 | BPF_EXIT_INSN(), |
| 4934 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4935 | BPF_EXIT_INSN(), |
| 4936 | }, |
| 4937 | INTERNAL, |
| 4938 | { }, |
| 4939 | { { 0, 1 } }, |
| 4940 | }, |
| 4941 | { |
| 4942 | "JMP_JSET_X: if (0x3 & 0xffffffff) return 1", |
| 4943 | .u.insns_int = { |
| 4944 | BPF_ALU32_IMM(BPF_MOV, R0, 0), |
| 4945 | BPF_LD_IMM64(R1, 3), |
| 4946 | BPF_LD_IMM64(R2, 0xffffffff), |
Naveen N. Rao | 9f134c3 | 2016-04-05 15:32:53 +0530 | [diff] [blame] | 4947 | BPF_JMP_REG(BPF_JSET, R1, R2, 1), |
Michael Holzheu | cffc642 | 2015-05-11 22:22:44 -0700 | [diff] [blame] | 4948 | BPF_EXIT_INSN(), |
| 4949 | BPF_ALU32_IMM(BPF_MOV, R0, 1), |
| 4950 | BPF_EXIT_INSN(), |
| 4951 | }, |
| 4952 | INTERNAL, |
| 4953 | { }, |
| 4954 | { { 0, 1 } }, |
| 4955 | }, |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 4956 | { |
| 4957 | "JMP_JA: Jump, gap, jump, ...", |
| 4958 | { }, |
| 4959 | CLASSIC | FLAG_NO_DATA, |
| 4960 | { }, |
| 4961 | { { 0, 0xababcbac } }, |
| 4962 | .fill_helper = bpf_fill_ja, |
| 4963 | }, |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 4964 | { /* Mainly checking JIT here. */ |
| 4965 | "BPF_MAXINSNS: Maximum possible literals", |
| 4966 | { }, |
| 4967 | CLASSIC | FLAG_NO_DATA, |
| 4968 | { }, |
| 4969 | { { 0, 0xffffffff } }, |
| 4970 | .fill_helper = bpf_fill_maxinsns1, |
| 4971 | }, |
| 4972 | { /* Mainly checking JIT here. */ |
| 4973 | "BPF_MAXINSNS: Single literal", |
| 4974 | { }, |
| 4975 | CLASSIC | FLAG_NO_DATA, |
| 4976 | { }, |
| 4977 | { { 0, 0xfefefefe } }, |
| 4978 | .fill_helper = bpf_fill_maxinsns2, |
| 4979 | }, |
| 4980 | { /* Mainly checking JIT here. */ |
| 4981 | "BPF_MAXINSNS: Run/add until end", |
| 4982 | { }, |
| 4983 | CLASSIC | FLAG_NO_DATA, |
| 4984 | { }, |
| 4985 | { { 0, 0x947bf368 } }, |
| 4986 | .fill_helper = bpf_fill_maxinsns3, |
| 4987 | }, |
| 4988 | { |
| 4989 | "BPF_MAXINSNS: Too many instructions", |
| 4990 | { }, |
| 4991 | CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, |
| 4992 | { }, |
| 4993 | { }, |
| 4994 | .fill_helper = bpf_fill_maxinsns4, |
| 4995 | }, |
| 4996 | { /* Mainly checking JIT here. */ |
| 4997 | "BPF_MAXINSNS: Very long jump", |
| 4998 | { }, |
| 4999 | CLASSIC | FLAG_NO_DATA, |
| 5000 | { }, |
| 5001 | { { 0, 0xabababab } }, |
| 5002 | .fill_helper = bpf_fill_maxinsns5, |
| 5003 | }, |
| 5004 | { /* Mainly checking JIT here. */ |
| 5005 | "BPF_MAXINSNS: Ctx heavy transformations", |
| 5006 | { }, |
| 5007 | CLASSIC, |
| 5008 | { }, |
| 5009 | { |
| 5010 | { 1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }, |
| 5011 | { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) } |
| 5012 | }, |
| 5013 | .fill_helper = bpf_fill_maxinsns6, |
| 5014 | }, |
| 5015 | { /* Mainly checking JIT here. */ |
| 5016 | "BPF_MAXINSNS: Call heavy transformations", |
| 5017 | { }, |
| 5018 | CLASSIC | FLAG_NO_DATA, |
| 5019 | { }, |
| 5020 | { { 1, 0 }, { 10, 0 } }, |
| 5021 | .fill_helper = bpf_fill_maxinsns7, |
| 5022 | }, |
| 5023 | { /* Mainly checking JIT here. */ |
| 5024 | "BPF_MAXINSNS: Jump heavy test", |
| 5025 | { }, |
| 5026 | CLASSIC | FLAG_NO_DATA, |
| 5027 | { }, |
| 5028 | { { 0, 0xffffffff } }, |
| 5029 | .fill_helper = bpf_fill_maxinsns8, |
| 5030 | }, |
Daniel Borkmann | 3b52960 | 2015-05-23 01:10:07 +0200 | [diff] [blame] | 5031 | { /* Mainly checking JIT here. */ |
| 5032 | "BPF_MAXINSNS: Very long jump backwards", |
| 5033 | { }, |
| 5034 | INTERNAL | FLAG_NO_DATA, |
| 5035 | { }, |
| 5036 | { { 0, 0xcbababab } }, |
| 5037 | .fill_helper = bpf_fill_maxinsns9, |
| 5038 | }, |
| 5039 | { /* Mainly checking JIT here. */ |
| 5040 | "BPF_MAXINSNS: Edge hopping nuthouse", |
| 5041 | { }, |
| 5042 | INTERNAL | FLAG_NO_DATA, |
| 5043 | { }, |
| 5044 | { { 0, 0xabababac } }, |
| 5045 | .fill_helper = bpf_fill_maxinsns10, |
| 5046 | }, |
Daniel Borkmann | bde28bc | 2015-05-26 22:35:43 +0200 | [diff] [blame] | 5047 | { |
| 5048 | "BPF_MAXINSNS: Jump, gap, jump, ...", |
| 5049 | { }, |
| 5050 | CLASSIC | FLAG_NO_DATA, |
| 5051 | { }, |
| 5052 | { { 0, 0xababcbac } }, |
| 5053 | .fill_helper = bpf_fill_maxinsns11, |
| 5054 | }, |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 5055 | { |
| 5056 | "BPF_MAXINSNS: ld_abs+get_processor_id", |
| 5057 | { }, |
| 5058 | CLASSIC, |
| 5059 | { }, |
| 5060 | { { 1, 0xbee } }, |
| 5061 | .fill_helper = bpf_fill_ld_abs_get_processor_id, |
| 5062 | }, |
| 5063 | { |
| 5064 | "BPF_MAXINSNS: ld_abs+vlan_push/pop", |
| 5065 | { }, |
| 5066 | INTERNAL, |
| 5067 | { 0x34 }, |
Daniel Borkmann | 0d906b1 | 2016-10-20 17:13:53 +0200 | [diff] [blame] | 5068 | { { ETH_HLEN, 0xbef } }, |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 5069 | .fill_helper = bpf_fill_ld_abs_vlan_push_pop, |
| 5070 | }, |
David Daney | b7127cf | 2017-06-13 16:49:36 -0700 | [diff] [blame] | 5071 | { |
| 5072 | "BPF_MAXINSNS: jump around ld_abs", |
| 5073 | { }, |
| 5074 | INTERNAL, |
| 5075 | { 10, 11 }, |
| 5076 | { { 2, 10 } }, |
| 5077 | .fill_helper = bpf_fill_jump_around_ld_abs, |
| 5078 | }, |
Nicolas Schichan | 2cf1ad7 | 2015-08-04 15:19:09 +0200 | [diff] [blame] | 5079 | /* |
| 5080 | * LD_IND / LD_ABS on fragmented SKBs |
| 5081 | */ |
| 5082 | { |
| 5083 | "LD_IND byte frag", |
| 5084 | .u.insns = { |
| 5085 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 5086 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x0), |
| 5087 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5088 | }, |
| 5089 | CLASSIC | FLAG_SKB_FRAG, |
| 5090 | { }, |
| 5091 | { {0x40, 0x42} }, |
| 5092 | .frag_data = { |
| 5093 | 0x42, 0x00, 0x00, 0x00, |
| 5094 | 0x43, 0x44, 0x00, 0x00, |
| 5095 | 0x21, 0x07, 0x19, 0x83, |
| 5096 | }, |
| 5097 | }, |
| 5098 | { |
| 5099 | "LD_IND halfword frag", |
| 5100 | .u.insns = { |
| 5101 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 5102 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x4), |
| 5103 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5104 | }, |
| 5105 | CLASSIC | FLAG_SKB_FRAG, |
| 5106 | { }, |
| 5107 | { {0x40, 0x4344} }, |
| 5108 | .frag_data = { |
| 5109 | 0x42, 0x00, 0x00, 0x00, |
| 5110 | 0x43, 0x44, 0x00, 0x00, |
| 5111 | 0x21, 0x07, 0x19, 0x83, |
| 5112 | }, |
| 5113 | }, |
| 5114 | { |
| 5115 | "LD_IND word frag", |
| 5116 | .u.insns = { |
| 5117 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 5118 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x8), |
| 5119 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5120 | }, |
| 5121 | CLASSIC | FLAG_SKB_FRAG, |
| 5122 | { }, |
| 5123 | { {0x40, 0x21071983} }, |
| 5124 | .frag_data = { |
| 5125 | 0x42, 0x00, 0x00, 0x00, |
| 5126 | 0x43, 0x44, 0x00, 0x00, |
| 5127 | 0x21, 0x07, 0x19, 0x83, |
| 5128 | }, |
| 5129 | }, |
| 5130 | { |
| 5131 | "LD_IND halfword mixed head/frag", |
| 5132 | .u.insns = { |
| 5133 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 5134 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1), |
| 5135 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5136 | }, |
| 5137 | CLASSIC | FLAG_SKB_FRAG, |
| 5138 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 5139 | { {0x40, 0x0519} }, |
| 5140 | .frag_data = { 0x19, 0x82 }, |
| 5141 | }, |
| 5142 | { |
| 5143 | "LD_IND word mixed head/frag", |
| 5144 | .u.insns = { |
| 5145 | BPF_STMT(BPF_LDX | BPF_IMM, 0x40), |
| 5146 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2), |
| 5147 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5148 | }, |
| 5149 | CLASSIC | FLAG_SKB_FRAG, |
| 5150 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 5151 | { {0x40, 0x25051982} }, |
| 5152 | .frag_data = { 0x19, 0x82 }, |
| 5153 | }, |
| 5154 | { |
| 5155 | "LD_ABS byte frag", |
| 5156 | .u.insns = { |
| 5157 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x40), |
| 5158 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5159 | }, |
| 5160 | CLASSIC | FLAG_SKB_FRAG, |
| 5161 | { }, |
| 5162 | { {0x40, 0x42} }, |
| 5163 | .frag_data = { |
| 5164 | 0x42, 0x00, 0x00, 0x00, |
| 5165 | 0x43, 0x44, 0x00, 0x00, |
| 5166 | 0x21, 0x07, 0x19, 0x83, |
| 5167 | }, |
| 5168 | }, |
| 5169 | { |
| 5170 | "LD_ABS halfword frag", |
| 5171 | .u.insns = { |
| 5172 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x44), |
| 5173 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5174 | }, |
| 5175 | CLASSIC | FLAG_SKB_FRAG, |
| 5176 | { }, |
| 5177 | { {0x40, 0x4344} }, |
| 5178 | .frag_data = { |
| 5179 | 0x42, 0x00, 0x00, 0x00, |
| 5180 | 0x43, 0x44, 0x00, 0x00, |
| 5181 | 0x21, 0x07, 0x19, 0x83, |
| 5182 | }, |
| 5183 | }, |
| 5184 | { |
| 5185 | "LD_ABS word frag", |
| 5186 | .u.insns = { |
| 5187 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x48), |
| 5188 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5189 | }, |
| 5190 | CLASSIC | FLAG_SKB_FRAG, |
| 5191 | { }, |
| 5192 | { {0x40, 0x21071983} }, |
| 5193 | .frag_data = { |
| 5194 | 0x42, 0x00, 0x00, 0x00, |
| 5195 | 0x43, 0x44, 0x00, 0x00, |
| 5196 | 0x21, 0x07, 0x19, 0x83, |
| 5197 | }, |
| 5198 | }, |
| 5199 | { |
| 5200 | "LD_ABS halfword mixed head/frag", |
| 5201 | .u.insns = { |
| 5202 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f), |
| 5203 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5204 | }, |
| 5205 | CLASSIC | FLAG_SKB_FRAG, |
| 5206 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 5207 | { {0x40, 0x0519} }, |
| 5208 | .frag_data = { 0x19, 0x82 }, |
| 5209 | }, |
| 5210 | { |
| 5211 | "LD_ABS word mixed head/frag", |
| 5212 | .u.insns = { |
| 5213 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3e), |
| 5214 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5215 | }, |
| 5216 | CLASSIC | FLAG_SKB_FRAG, |
| 5217 | { [0x3e] = 0x25, [0x3f] = 0x05, }, |
| 5218 | { {0x40, 0x25051982} }, |
| 5219 | .frag_data = { 0x19, 0x82 }, |
| 5220 | }, |
Nicolas Schichan | 08fcb08 | 2015-08-04 15:19:11 +0200 | [diff] [blame] | 5221 | /* |
| 5222 | * LD_IND / LD_ABS on non fragmented SKBs |
| 5223 | */ |
| 5224 | { |
| 5225 | /* |
| 5226 | * this tests that the JIT/interpreter correctly resets X |
| 5227 | * before using it in an LD_IND instruction. |
| 5228 | */ |
| 5229 | "LD_IND byte default X", |
| 5230 | .u.insns = { |
| 5231 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 5232 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5233 | }, |
| 5234 | CLASSIC, |
| 5235 | { [0x1] = 0x42 }, |
| 5236 | { {0x40, 0x42 } }, |
| 5237 | }, |
| 5238 | { |
| 5239 | "LD_IND byte positive offset", |
| 5240 | .u.insns = { |
| 5241 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 5242 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1), |
| 5243 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5244 | }, |
| 5245 | CLASSIC, |
| 5246 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 5247 | { {0x40, 0x82 } }, |
| 5248 | }, |
| 5249 | { |
| 5250 | "LD_IND byte negative offset", |
| 5251 | .u.insns = { |
| 5252 | BPF_STMT(BPF_LDX | BPF_IMM, 0x3e), |
| 5253 | BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x1), |
| 5254 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5255 | }, |
| 5256 | CLASSIC, |
| 5257 | { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 }, |
| 5258 | { {0x40, 0x05 } }, |
| 5259 | }, |
| 5260 | { |
| 5261 | "LD_IND halfword positive offset", |
| 5262 | .u.insns = { |
| 5263 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5264 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x2), |
| 5265 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5266 | }, |
| 5267 | CLASSIC, |
| 5268 | { |
| 5269 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5270 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5271 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5272 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5273 | }, |
| 5274 | { {0x40, 0xdd88 } }, |
| 5275 | }, |
| 5276 | { |
| 5277 | "LD_IND halfword negative offset", |
| 5278 | .u.insns = { |
| 5279 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5280 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x2), |
| 5281 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5282 | }, |
| 5283 | CLASSIC, |
| 5284 | { |
| 5285 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5286 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5287 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5288 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5289 | }, |
| 5290 | { {0x40, 0xbb66 } }, |
| 5291 | }, |
| 5292 | { |
| 5293 | "LD_IND halfword unaligned", |
| 5294 | .u.insns = { |
| 5295 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5296 | BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1), |
| 5297 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5298 | }, |
| 5299 | CLASSIC, |
| 5300 | { |
| 5301 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5302 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5303 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5304 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5305 | }, |
| 5306 | { {0x40, 0x66cc } }, |
| 5307 | }, |
| 5308 | { |
| 5309 | "LD_IND word positive offset", |
| 5310 | .u.insns = { |
| 5311 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5312 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x4), |
| 5313 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5314 | }, |
| 5315 | CLASSIC, |
| 5316 | { |
| 5317 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5318 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5319 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5320 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5321 | [0x24] = 0xee, [0x25] = 0x99, |
| 5322 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5323 | }, |
| 5324 | { {0x40, 0xee99ffaa } }, |
| 5325 | }, |
| 5326 | { |
| 5327 | "LD_IND word negative offset", |
| 5328 | .u.insns = { |
| 5329 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5330 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x4), |
| 5331 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5332 | }, |
| 5333 | CLASSIC, |
| 5334 | { |
| 5335 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5336 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5337 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5338 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5339 | [0x24] = 0xee, [0x25] = 0x99, |
| 5340 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5341 | }, |
| 5342 | { {0x40, 0xaa55bb66 } }, |
| 5343 | }, |
| 5344 | { |
| 5345 | "LD_IND word unaligned (addr & 3 == 2)", |
| 5346 | .u.insns = { |
| 5347 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5348 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2), |
| 5349 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5350 | }, |
| 5351 | CLASSIC, |
| 5352 | { |
| 5353 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5354 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5355 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5356 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5357 | [0x24] = 0xee, [0x25] = 0x99, |
| 5358 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5359 | }, |
| 5360 | { {0x40, 0xbb66cc77 } }, |
| 5361 | }, |
| 5362 | { |
| 5363 | "LD_IND word unaligned (addr & 3 == 1)", |
| 5364 | .u.insns = { |
| 5365 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5366 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3), |
| 5367 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5368 | }, |
| 5369 | CLASSIC, |
| 5370 | { |
| 5371 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5372 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5373 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5374 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5375 | [0x24] = 0xee, [0x25] = 0x99, |
| 5376 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5377 | }, |
| 5378 | { {0x40, 0x55bb66cc } }, |
| 5379 | }, |
| 5380 | { |
| 5381 | "LD_IND word unaligned (addr & 3 == 3)", |
| 5382 | .u.insns = { |
| 5383 | BPF_STMT(BPF_LDX | BPF_IMM, 0x20), |
| 5384 | BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x1), |
| 5385 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5386 | }, |
| 5387 | CLASSIC, |
| 5388 | { |
| 5389 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5390 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5391 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5392 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5393 | [0x24] = 0xee, [0x25] = 0x99, |
| 5394 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5395 | }, |
| 5396 | { {0x40, 0x66cc77dd } }, |
| 5397 | }, |
| 5398 | { |
| 5399 | "LD_ABS byte", |
| 5400 | .u.insns = { |
| 5401 | BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x20), |
| 5402 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5403 | }, |
| 5404 | CLASSIC, |
| 5405 | { |
| 5406 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5407 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5408 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5409 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5410 | [0x24] = 0xee, [0x25] = 0x99, |
| 5411 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5412 | }, |
| 5413 | { {0x40, 0xcc } }, |
| 5414 | }, |
| 5415 | { |
| 5416 | "LD_ABS halfword", |
| 5417 | .u.insns = { |
| 5418 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x22), |
| 5419 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5420 | }, |
| 5421 | CLASSIC, |
| 5422 | { |
| 5423 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5424 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5425 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5426 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5427 | [0x24] = 0xee, [0x25] = 0x99, |
| 5428 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5429 | }, |
| 5430 | { {0x40, 0xdd88 } }, |
| 5431 | }, |
| 5432 | { |
| 5433 | "LD_ABS halfword unaligned", |
| 5434 | .u.insns = { |
| 5435 | BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x25), |
| 5436 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5437 | }, |
| 5438 | CLASSIC, |
| 5439 | { |
| 5440 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5441 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5442 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5443 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5444 | [0x24] = 0xee, [0x25] = 0x99, |
| 5445 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5446 | }, |
| 5447 | { {0x40, 0x99ff } }, |
| 5448 | }, |
| 5449 | { |
| 5450 | "LD_ABS word", |
| 5451 | .u.insns = { |
| 5452 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x1c), |
| 5453 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5454 | }, |
| 5455 | CLASSIC, |
| 5456 | { |
| 5457 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5458 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5459 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5460 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5461 | [0x24] = 0xee, [0x25] = 0x99, |
| 5462 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5463 | }, |
| 5464 | { {0x40, 0xaa55bb66 } }, |
| 5465 | }, |
| 5466 | { |
| 5467 | "LD_ABS word unaligned (addr & 3 == 2)", |
| 5468 | .u.insns = { |
| 5469 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x22), |
| 5470 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5471 | }, |
| 5472 | CLASSIC, |
| 5473 | { |
| 5474 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5475 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5476 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5477 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5478 | [0x24] = 0xee, [0x25] = 0x99, |
| 5479 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5480 | }, |
| 5481 | { {0x40, 0xdd88ee99 } }, |
| 5482 | }, |
| 5483 | { |
| 5484 | "LD_ABS word unaligned (addr & 3 == 1)", |
| 5485 | .u.insns = { |
| 5486 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x21), |
| 5487 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5488 | }, |
| 5489 | CLASSIC, |
| 5490 | { |
| 5491 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5492 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5493 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5494 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5495 | [0x24] = 0xee, [0x25] = 0x99, |
| 5496 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5497 | }, |
| 5498 | { {0x40, 0x77dd88ee } }, |
| 5499 | }, |
| 5500 | { |
| 5501 | "LD_ABS word unaligned (addr & 3 == 3)", |
| 5502 | .u.insns = { |
| 5503 | BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x23), |
| 5504 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5505 | }, |
| 5506 | CLASSIC, |
| 5507 | { |
| 5508 | [0x1c] = 0xaa, [0x1d] = 0x55, |
| 5509 | [0x1e] = 0xbb, [0x1f] = 0x66, |
| 5510 | [0x20] = 0xcc, [0x21] = 0x77, |
| 5511 | [0x22] = 0xdd, [0x23] = 0x88, |
| 5512 | [0x24] = 0xee, [0x25] = 0x99, |
| 5513 | [0x26] = 0xff, [0x27] = 0xaa, |
| 5514 | }, |
| 5515 | { {0x40, 0x88ee99ff } }, |
| 5516 | }, |
Nicolas Schichan | 86bf172 | 2015-08-04 15:19:12 +0200 | [diff] [blame] | 5517 | /* |
| 5518 | * verify that the interpreter or JIT correctly sets A and X |
| 5519 | * to 0. |
| 5520 | */ |
| 5521 | { |
| 5522 | "ADD default X", |
| 5523 | .u.insns = { |
| 5524 | /* |
| 5525 | * A = 0x42 |
| 5526 | * A = A + X |
| 5527 | * ret A |
| 5528 | */ |
| 5529 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 5530 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
| 5531 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5532 | }, |
| 5533 | CLASSIC | FLAG_NO_DATA, |
| 5534 | {}, |
| 5535 | { {0x1, 0x42 } }, |
| 5536 | }, |
| 5537 | { |
| 5538 | "ADD default A", |
| 5539 | .u.insns = { |
| 5540 | /* |
| 5541 | * A = A + 0x42 |
| 5542 | * ret A |
| 5543 | */ |
| 5544 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0x42), |
| 5545 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5546 | }, |
| 5547 | CLASSIC | FLAG_NO_DATA, |
| 5548 | {}, |
| 5549 | { {0x1, 0x42 } }, |
| 5550 | }, |
| 5551 | { |
| 5552 | "SUB default X", |
| 5553 | .u.insns = { |
| 5554 | /* |
| 5555 | * A = 0x66 |
| 5556 | * A = A - X |
| 5557 | * ret A |
| 5558 | */ |
| 5559 | BPF_STMT(BPF_LD | BPF_IMM, 0x66), |
| 5560 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), |
| 5561 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5562 | }, |
| 5563 | CLASSIC | FLAG_NO_DATA, |
| 5564 | {}, |
| 5565 | { {0x1, 0x66 } }, |
| 5566 | }, |
| 5567 | { |
| 5568 | "SUB default A", |
| 5569 | .u.insns = { |
| 5570 | /* |
| 5571 | * A = A - -0x66 |
| 5572 | * ret A |
| 5573 | */ |
| 5574 | BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, -0x66), |
| 5575 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5576 | }, |
| 5577 | CLASSIC | FLAG_NO_DATA, |
| 5578 | {}, |
| 5579 | { {0x1, 0x66 } }, |
| 5580 | }, |
| 5581 | { |
| 5582 | "MUL default X", |
| 5583 | .u.insns = { |
| 5584 | /* |
| 5585 | * A = 0x42 |
| 5586 | * A = A * X |
| 5587 | * ret A |
| 5588 | */ |
| 5589 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 5590 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_X, 0), |
| 5591 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5592 | }, |
| 5593 | CLASSIC | FLAG_NO_DATA, |
| 5594 | {}, |
| 5595 | { {0x1, 0x0 } }, |
| 5596 | }, |
| 5597 | { |
| 5598 | "MUL default A", |
| 5599 | .u.insns = { |
| 5600 | /* |
| 5601 | * A = A * 0x66 |
| 5602 | * ret A |
| 5603 | */ |
| 5604 | BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 0x66), |
| 5605 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5606 | }, |
| 5607 | CLASSIC | FLAG_NO_DATA, |
| 5608 | {}, |
| 5609 | { {0x1, 0x0 } }, |
| 5610 | }, |
| 5611 | { |
| 5612 | "DIV default X", |
| 5613 | .u.insns = { |
| 5614 | /* |
| 5615 | * A = 0x42 |
| 5616 | * A = A / X ; this halt the filter execution if X is 0 |
| 5617 | * ret 0x42 |
| 5618 | */ |
| 5619 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 5620 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0), |
| 5621 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 5622 | }, |
| 5623 | CLASSIC | FLAG_NO_DATA, |
| 5624 | {}, |
| 5625 | { {0x1, 0x0 } }, |
| 5626 | }, |
| 5627 | { |
| 5628 | "DIV default A", |
| 5629 | .u.insns = { |
| 5630 | /* |
| 5631 | * A = A / 1 |
| 5632 | * ret A |
| 5633 | */ |
| 5634 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x1), |
| 5635 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5636 | }, |
| 5637 | CLASSIC | FLAG_NO_DATA, |
| 5638 | {}, |
| 5639 | { {0x1, 0x0 } }, |
| 5640 | }, |
| 5641 | { |
Yang Shi | d4e4bc1 | 2015-11-04 11:36:37 -0800 | [diff] [blame] | 5642 | "MOD default X", |
| 5643 | .u.insns = { |
| 5644 | /* |
| 5645 | * A = 0x42 |
| 5646 | * A = A mod X ; this halt the filter execution if X is 0 |
| 5647 | * ret 0x42 |
| 5648 | */ |
| 5649 | BPF_STMT(BPF_LD | BPF_IMM, 0x42), |
| 5650 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), |
| 5651 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 5652 | }, |
| 5653 | CLASSIC | FLAG_NO_DATA, |
| 5654 | {}, |
| 5655 | { {0x1, 0x0 } }, |
| 5656 | }, |
| 5657 | { |
| 5658 | "MOD default A", |
| 5659 | .u.insns = { |
| 5660 | /* |
| 5661 | * A = A mod 1 |
| 5662 | * ret A |
| 5663 | */ |
| 5664 | BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1), |
| 5665 | BPF_STMT(BPF_RET | BPF_A, 0x0), |
| 5666 | }, |
| 5667 | CLASSIC | FLAG_NO_DATA, |
| 5668 | {}, |
| 5669 | { {0x1, 0x0 } }, |
| 5670 | }, |
| 5671 | { |
Nicolas Schichan | 86bf172 | 2015-08-04 15:19:12 +0200 | [diff] [blame] | 5672 | "JMP EQ default A", |
| 5673 | .u.insns = { |
| 5674 | /* |
| 5675 | * cmp A, 0x0, 0, 1 |
| 5676 | * ret 0x42 |
| 5677 | * ret 0x66 |
| 5678 | */ |
| 5679 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0, 0, 1), |
| 5680 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 5681 | BPF_STMT(BPF_RET | BPF_K, 0x66), |
| 5682 | }, |
| 5683 | CLASSIC | FLAG_NO_DATA, |
| 5684 | {}, |
| 5685 | { {0x1, 0x42 } }, |
| 5686 | }, |
| 5687 | { |
| 5688 | "JMP EQ default X", |
| 5689 | .u.insns = { |
| 5690 | /* |
| 5691 | * A = 0x0 |
| 5692 | * cmp A, X, 0, 1 |
| 5693 | * ret 0x42 |
| 5694 | * ret 0x66 |
| 5695 | */ |
| 5696 | BPF_STMT(BPF_LD | BPF_IMM, 0x0), |
| 5697 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0x0, 0, 1), |
| 5698 | BPF_STMT(BPF_RET | BPF_K, 0x42), |
| 5699 | BPF_STMT(BPF_RET | BPF_K, 0x66), |
| 5700 | }, |
| 5701 | CLASSIC | FLAG_NO_DATA, |
| 5702 | {}, |
| 5703 | { {0x1, 0x42 } }, |
| 5704 | }, |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5705 | }; |
| 5706 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5707 | static struct net_device dev; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5708 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5709 | static struct sk_buff *populate_skb(char *buf, int size) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5710 | { |
| 5711 | struct sk_buff *skb; |
| 5712 | |
| 5713 | if (size >= MAX_DATA) |
| 5714 | return NULL; |
| 5715 | |
| 5716 | skb = alloc_skb(MAX_DATA, GFP_KERNEL); |
| 5717 | if (!skb) |
| 5718 | return NULL; |
| 5719 | |
yuan linyu | de77b96 | 2017-06-18 22:48:17 +0800 | [diff] [blame] | 5720 | __skb_put_data(skb, buf, size); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5721 | |
| 5722 | /* Initialize a fake skb with test pattern. */ |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5723 | skb_reset_mac_header(skb); |
| 5724 | skb->protocol = htons(ETH_P_IP); |
| 5725 | skb->pkt_type = SKB_TYPE; |
| 5726 | skb->mark = SKB_MARK; |
| 5727 | skb->hash = SKB_HASH; |
| 5728 | skb->queue_mapping = SKB_QUEUE_MAP; |
| 5729 | skb->vlan_tci = SKB_VLAN_TCI; |
Jakub Kicinski | 5c0ca3f | 2016-09-12 13:04:57 +0100 | [diff] [blame] | 5730 | skb->vlan_proto = htons(ETH_P_IP); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5731 | skb->dev = &dev; |
| 5732 | skb->dev->ifindex = SKB_DEV_IFINDEX; |
| 5733 | skb->dev->type = SKB_DEV_TYPE; |
| 5734 | skb_set_network_header(skb, min(size, ETH_HLEN)); |
| 5735 | |
| 5736 | return skb; |
| 5737 | } |
| 5738 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5739 | static void *generate_test_data(struct bpf_test *test, int sub) |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5740 | { |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 5741 | struct sk_buff *skb; |
| 5742 | struct page *page; |
| 5743 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5744 | if (test->aux & FLAG_NO_DATA) |
| 5745 | return NULL; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5746 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5747 | /* Test case expects an skb, so populate one. Various |
| 5748 | * subtests generate skbs of different sizes based on |
| 5749 | * the same data. |
| 5750 | */ |
Nicolas Schichan | bac142a | 2015-08-04 15:19:08 +0200 | [diff] [blame] | 5751 | skb = populate_skb(test->data, test->test[sub].data_size); |
| 5752 | if (!skb) |
| 5753 | return NULL; |
| 5754 | |
| 5755 | if (test->aux & FLAG_SKB_FRAG) { |
| 5756 | /* |
| 5757 | * when the test requires a fragmented skb, add a |
| 5758 | * single fragment to the skb, filled with |
| 5759 | * test->frag_data. |
| 5760 | */ |
| 5761 | void *ptr; |
| 5762 | |
| 5763 | page = alloc_page(GFP_KERNEL); |
| 5764 | |
| 5765 | if (!page) |
| 5766 | goto err_kfree_skb; |
| 5767 | |
| 5768 | ptr = kmap(page); |
| 5769 | if (!ptr) |
| 5770 | goto err_free_page; |
| 5771 | memcpy(ptr, test->frag_data, MAX_DATA); |
| 5772 | kunmap(page); |
| 5773 | skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA); |
| 5774 | } |
| 5775 | |
| 5776 | return skb; |
| 5777 | |
| 5778 | err_free_page: |
| 5779 | __free_page(page); |
| 5780 | err_kfree_skb: |
| 5781 | kfree_skb(skb); |
| 5782 | return NULL; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5783 | } |
| 5784 | |
| 5785 | static void release_test_data(const struct bpf_test *test, void *data) |
| 5786 | { |
| 5787 | if (test->aux & FLAG_NO_DATA) |
| 5788 | return; |
| 5789 | |
| 5790 | kfree_skb(data); |
| 5791 | } |
| 5792 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5793 | static int filter_length(int which) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5794 | { |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5795 | struct sock_filter *fp; |
| 5796 | int len; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5797 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5798 | if (tests[which].fill_helper) |
| 5799 | return tests[which].u.ptr.len; |
| 5800 | |
| 5801 | fp = tests[which].u.insns; |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 5802 | for (len = MAX_INSNS - 1; len > 0; --len) |
| 5803 | if (fp[len].code != 0 || fp[len].k != 0) |
| 5804 | break; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5805 | |
Chema Gonzalez | e9d9450 | 2014-05-30 10:15:12 -0700 | [diff] [blame] | 5806 | return len + 1; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5807 | } |
| 5808 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5809 | static void *filter_pointer(int which) |
| 5810 | { |
| 5811 | if (tests[which].fill_helper) |
| 5812 | return tests[which].u.ptr.insns; |
| 5813 | else |
| 5814 | return tests[which].u.insns; |
| 5815 | } |
| 5816 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5817 | static struct bpf_prog *generate_filter(int which, int *err) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5818 | { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5819 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5820 | unsigned int flen = filter_length(which); |
| 5821 | void *fptr = filter_pointer(which); |
| 5822 | struct sock_fprog_kern fprog; |
| 5823 | struct bpf_prog *fp; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5824 | |
| 5825 | switch (test_type) { |
| 5826 | case CLASSIC: |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5827 | fprog.filter = fptr; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5828 | fprog.len = flen; |
| 5829 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5830 | *err = bpf_prog_create(&fp, &fprog); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5831 | if (tests[which].aux & FLAG_EXPECTED_FAIL) { |
| 5832 | if (*err == -EINVAL) { |
| 5833 | pr_cont("PASS\n"); |
| 5834 | /* Verifier rejected filter as expected. */ |
| 5835 | *err = 0; |
| 5836 | return NULL; |
| 5837 | } else { |
| 5838 | pr_cont("UNEXPECTED_PASS\n"); |
| 5839 | /* Verifier didn't reject the test that's |
| 5840 | * bad enough, just return! |
| 5841 | */ |
| 5842 | *err = -EINVAL; |
| 5843 | return NULL; |
| 5844 | } |
| 5845 | } |
| 5846 | /* We don't expect to fail. */ |
| 5847 | if (*err) { |
| 5848 | pr_cont("FAIL to attach err=%d len=%d\n", |
| 5849 | *err, fprog.len); |
| 5850 | return NULL; |
| 5851 | } |
| 5852 | break; |
| 5853 | |
| 5854 | case INTERNAL: |
Daniel Borkmann | 60a3b22 | 2014-09-02 22:53:44 +0200 | [diff] [blame] | 5855 | fp = bpf_prog_alloc(bpf_prog_size(flen), 0); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5856 | if (fp == NULL) { |
| 5857 | pr_cont("UNEXPECTED_FAIL no memory left\n"); |
| 5858 | *err = -ENOMEM; |
| 5859 | return NULL; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5860 | } |
| 5861 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5862 | fp->len = flen; |
Daniel Borkmann | 4962fa1 | 2015-07-30 12:42:46 +0200 | [diff] [blame] | 5863 | /* Type doesn't really matter here as long as it's not unspec. */ |
| 5864 | fp->type = BPF_PROG_TYPE_SOCKET_FILTER; |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5865 | memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn)); |
Alexei Starovoitov | 105c036 | 2017-05-30 13:31:32 -0700 | [diff] [blame] | 5866 | fp->aux->stack_depth = tests[which].stack_depth; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5867 | |
Daniel Borkmann | d1c55ab | 2016-05-13 19:08:31 +0200 | [diff] [blame] | 5868 | /* We cannot error here as we don't need type compatibility |
| 5869 | * checks. |
| 5870 | */ |
| 5871 | fp = bpf_prog_select_runtime(fp, err); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5872 | break; |
| 5873 | } |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5874 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5875 | *err = 0; |
| 5876 | return fp; |
| 5877 | } |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5878 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5879 | static void release_filter(struct bpf_prog *fp, int which) |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5880 | { |
| 5881 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5882 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5883 | switch (test_type) { |
| 5884 | case CLASSIC: |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5885 | bpf_prog_destroy(fp); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5886 | break; |
| 5887 | case INTERNAL: |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5888 | bpf_prog_free(fp); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5889 | break; |
| 5890 | } |
| 5891 | } |
| 5892 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5893 | static int __run_one(const struct bpf_prog *fp, const void *data, |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5894 | int runs, u64 *duration) |
| 5895 | { |
| 5896 | u64 start, finish; |
Alexei Starovoitov | 25ee732 | 2014-09-19 13:53:51 -0700 | [diff] [blame] | 5897 | int ret = 0, i; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5898 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 5899 | start = ktime_get_ns(); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5900 | |
| 5901 | for (i = 0; i < runs; i++) |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5902 | ret = BPF_PROG_RUN(fp, data); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5903 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 5904 | finish = ktime_get_ns(); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5905 | |
Alexei Starovoitov | 4d9c5c5 | 2015-07-20 20:34:19 -0700 | [diff] [blame] | 5906 | *duration = finish - start; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5907 | do_div(*duration, runs); |
| 5908 | |
| 5909 | return ret; |
| 5910 | } |
| 5911 | |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 5912 | 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] | 5913 | { |
| 5914 | int err_cnt = 0, i, runs = MAX_TESTRUNS; |
| 5915 | |
| 5916 | for (i = 0; i < MAX_SUBTESTS; i++) { |
| 5917 | void *data; |
| 5918 | u64 duration; |
| 5919 | u32 ret; |
| 5920 | |
| 5921 | if (test->test[i].data_size == 0 && |
| 5922 | test->test[i].result == 0) |
| 5923 | break; |
| 5924 | |
| 5925 | data = generate_test_data(test, i); |
Nicolas Schichan | e34684f | 2015-08-04 15:19:07 +0200 | [diff] [blame] | 5926 | if (!data && !(test->aux & FLAG_NO_DATA)) { |
| 5927 | pr_cont("data generation failed "); |
| 5928 | err_cnt++; |
| 5929 | break; |
| 5930 | } |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 5931 | ret = __run_one(fp, data, runs, &duration); |
| 5932 | release_test_data(test, data); |
| 5933 | |
| 5934 | if (ret == test->test[i].result) { |
| 5935 | pr_cont("%lld ", duration); |
| 5936 | } else { |
| 5937 | pr_cont("ret %d != %d ", ret, |
| 5938 | test->test[i].result); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 5939 | err_cnt++; |
| 5940 | } |
| 5941 | } |
| 5942 | |
| 5943 | return err_cnt; |
| 5944 | } |
| 5945 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 5946 | static char test_name[64]; |
| 5947 | module_param_string(test_name, test_name, sizeof(test_name), 0); |
| 5948 | |
| 5949 | static int test_id = -1; |
| 5950 | module_param(test_id, int, 0); |
| 5951 | |
| 5952 | static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 }; |
| 5953 | module_param_array(test_range, int, NULL, 0); |
| 5954 | |
| 5955 | static __init int find_test_index(const char *test_name) |
| 5956 | { |
| 5957 | int i; |
| 5958 | |
| 5959 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 5960 | if (!strcmp(tests[i].descr, test_name)) |
| 5961 | return i; |
| 5962 | } |
| 5963 | return -1; |
| 5964 | } |
| 5965 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 5966 | static __init int prepare_bpf_tests(void) |
| 5967 | { |
| 5968 | int i; |
| 5969 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 5970 | if (test_id >= 0) { |
| 5971 | /* |
| 5972 | * if a test_id was specified, use test_range to |
| 5973 | * cover only that test. |
| 5974 | */ |
| 5975 | if (test_id >= ARRAY_SIZE(tests)) { |
| 5976 | pr_err("test_bpf: invalid test_id specified.\n"); |
| 5977 | return -EINVAL; |
| 5978 | } |
| 5979 | |
| 5980 | test_range[0] = test_id; |
| 5981 | test_range[1] = test_id; |
| 5982 | } else if (*test_name) { |
| 5983 | /* |
| 5984 | * if a test_name was specified, find it and setup |
| 5985 | * test_range to cover only that test. |
| 5986 | */ |
| 5987 | int idx = find_test_index(test_name); |
| 5988 | |
| 5989 | if (idx < 0) { |
| 5990 | pr_err("test_bpf: no test named '%s' found.\n", |
| 5991 | test_name); |
| 5992 | return -EINVAL; |
| 5993 | } |
| 5994 | test_range[0] = idx; |
| 5995 | test_range[1] = idx; |
| 5996 | } else { |
| 5997 | /* |
| 5998 | * check that the supplied test_range is valid. |
| 5999 | */ |
| 6000 | if (test_range[0] >= ARRAY_SIZE(tests) || |
| 6001 | test_range[1] >= ARRAY_SIZE(tests) || |
| 6002 | test_range[0] < 0 || test_range[1] < 0) { |
| 6003 | pr_err("test_bpf: test_range is out of bound.\n"); |
| 6004 | return -EINVAL; |
| 6005 | } |
| 6006 | |
| 6007 | if (test_range[1] < test_range[0]) { |
| 6008 | pr_err("test_bpf: test_range is ending before it starts.\n"); |
| 6009 | return -EINVAL; |
| 6010 | } |
| 6011 | } |
| 6012 | |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 6013 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 6014 | if (tests[i].fill_helper && |
| 6015 | tests[i].fill_helper(&tests[i]) < 0) |
| 6016 | return -ENOMEM; |
| 6017 | } |
| 6018 | |
| 6019 | return 0; |
| 6020 | } |
| 6021 | |
| 6022 | static __init void destroy_bpf_tests(void) |
| 6023 | { |
| 6024 | int i; |
| 6025 | |
| 6026 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 6027 | if (tests[i].fill_helper) |
| 6028 | kfree(tests[i].u.ptr.insns); |
| 6029 | } |
| 6030 | } |
| 6031 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 6032 | static bool exclude_test(int test_id) |
| 6033 | { |
| 6034 | return test_id < test_range[0] || test_id > test_range[1]; |
| 6035 | } |
| 6036 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6037 | static __init int test_bpf(void) |
| 6038 | { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6039 | int i, err_cnt = 0, pass_cnt = 0; |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 6040 | int jit_cnt = 0, run_cnt = 0; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6041 | |
| 6042 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
Alexei Starovoitov | 7ae457c | 2014-07-30 20:34:16 -0700 | [diff] [blame] | 6043 | struct bpf_prog *fp; |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6044 | int err; |
| 6045 | |
Nicolas Schichan | d2648d4 | 2015-08-04 15:19:10 +0200 | [diff] [blame] | 6046 | if (exclude_test(i)) |
| 6047 | continue; |
| 6048 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6049 | pr_info("#%d %s ", i, tests[i].descr); |
| 6050 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6051 | fp = generate_filter(i, &err); |
| 6052 | if (fp == NULL) { |
| 6053 | if (err == 0) { |
| 6054 | pass_cnt++; |
| 6055 | continue; |
| 6056 | } |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6057 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6058 | return err; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6059 | } |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 6060 | |
| 6061 | pr_cont("jited:%u ", fp->jited); |
| 6062 | |
| 6063 | run_cnt++; |
| 6064 | if (fp->jited) |
| 6065 | jit_cnt++; |
| 6066 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6067 | err = run_one(fp, &tests[i]); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6068 | release_filter(fp, i); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6069 | |
| 6070 | if (err) { |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6071 | pr_cont("FAIL (%d times)\n", err); |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6072 | err_cnt++; |
| 6073 | } else { |
| 6074 | pr_cont("PASS\n"); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6075 | pass_cnt++; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6076 | } |
| 6077 | } |
| 6078 | |
Daniel Borkmann | 327941f | 2015-04-30 16:17:27 +0200 | [diff] [blame] | 6079 | pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n", |
| 6080 | pass_cnt, err_cnt, jit_cnt, run_cnt); |
| 6081 | |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6082 | return err_cnt ? -EINVAL : 0; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6083 | } |
| 6084 | |
| 6085 | static int __init test_bpf_init(void) |
| 6086 | { |
Daniel Borkmann | a4afd37b | 2015-05-13 13:12:43 +0200 | [diff] [blame] | 6087 | int ret; |
| 6088 | |
| 6089 | ret = prepare_bpf_tests(); |
| 6090 | if (ret < 0) |
| 6091 | return ret; |
| 6092 | |
| 6093 | ret = test_bpf(); |
| 6094 | |
| 6095 | destroy_bpf_tests(); |
| 6096 | return ret; |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6097 | } |
| 6098 | |
| 6099 | static void __exit test_bpf_exit(void) |
| 6100 | { |
| 6101 | } |
| 6102 | |
| 6103 | module_init(test_bpf_init); |
| 6104 | module_exit(test_bpf_exit); |
Daniel Borkmann | 10f18e0 | 2014-05-23 18:44:00 +0200 | [diff] [blame] | 6105 | |
Alexei Starovoitov | 64a8946 | 2014-05-08 14:10:52 -0700 | [diff] [blame] | 6106 | MODULE_LICENSE("GPL"); |