WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / verifier / ld_imm64.c
blobf9297900cea6d44ecd64cf00f3f60099bb17a70a
2 "test1 ld_imm64",
3 .insns = {
4 BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1),
5 BPF_LD_IMM64(BPF_REG_0, 0),
6 BPF_LD_IMM64(BPF_REG_0, 0),
7 BPF_LD_IMM64(BPF_REG_0, 1),
8 BPF_LD_IMM64(BPF_REG_0, 1),
9 BPF_MOV64_IMM(BPF_REG_0, 2),
10 BPF_EXIT_INSN(),
12 .errstr = "invalid BPF_LD_IMM insn",
13 .errstr_unpriv = "R1 pointer comparison",
14 .result = REJECT,
17 "test2 ld_imm64",
18 .insns = {
19 BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1),
20 BPF_LD_IMM64(BPF_REG_0, 0),
21 BPF_LD_IMM64(BPF_REG_0, 0),
22 BPF_LD_IMM64(BPF_REG_0, 1),
23 BPF_LD_IMM64(BPF_REG_0, 1),
24 BPF_EXIT_INSN(),
26 .errstr = "invalid BPF_LD_IMM insn",
27 .errstr_unpriv = "R1 pointer comparison",
28 .result = REJECT,
31 "test3 ld_imm64",
32 .insns = {
33 BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1),
34 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
35 BPF_LD_IMM64(BPF_REG_0, 0),
36 BPF_LD_IMM64(BPF_REG_0, 0),
37 BPF_LD_IMM64(BPF_REG_0, 1),
38 BPF_LD_IMM64(BPF_REG_0, 1),
39 BPF_EXIT_INSN(),
41 .errstr = "invalid bpf_ld_imm64 insn",
42 .result = REJECT,
45 "test4 ld_imm64",
46 .insns = {
47 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
48 BPF_EXIT_INSN(),
50 .errstr = "invalid bpf_ld_imm64 insn",
51 .result = REJECT,
54 "test6 ld_imm64",
55 .insns = {
56 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
57 BPF_RAW_INSN(0, 0, 0, 0, 0),
58 BPF_EXIT_INSN(),
60 .result = ACCEPT,
63 "test7 ld_imm64",
64 .insns = {
65 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
66 BPF_RAW_INSN(0, 0, 0, 0, 1),
67 BPF_EXIT_INSN(),
69 .result = ACCEPT,
70 .retval = 1,
73 "test8 ld_imm64",
74 .insns = {
75 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 1, 1),
76 BPF_RAW_INSN(0, 0, 0, 0, 1),
77 BPF_EXIT_INSN(),
79 .errstr = "uses reserved fields",
80 .result = REJECT,
83 "test9 ld_imm64",
84 .insns = {
85 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
86 BPF_RAW_INSN(0, 0, 0, 1, 1),
87 BPF_EXIT_INSN(),
89 .errstr = "invalid bpf_ld_imm64 insn",
90 .result = REJECT,
93 "test10 ld_imm64",
94 .insns = {
95 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
96 BPF_RAW_INSN(0, BPF_REG_1, 0, 0, 1),
97 BPF_EXIT_INSN(),
99 .errstr = "invalid bpf_ld_imm64 insn",
100 .result = REJECT,
103 "test11 ld_imm64",
104 .insns = {
105 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
106 BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
107 BPF_EXIT_INSN(),
109 .errstr = "invalid bpf_ld_imm64 insn",
110 .result = REJECT,
113 "test12 ld_imm64",
114 .insns = {
115 BPF_MOV64_IMM(BPF_REG_1, 0),
116 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
117 BPF_RAW_INSN(0, 0, 0, 0, 0),
118 BPF_EXIT_INSN(),
120 .errstr = "not pointing to valid bpf_map",
121 .result = REJECT,
124 "test13 ld_imm64",
125 .insns = {
126 BPF_MOV64_IMM(BPF_REG_1, 0),
127 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
128 BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
129 BPF_EXIT_INSN(),
131 .errstr = "invalid bpf_ld_imm64 insn",
132 .result = REJECT,
135 "test14 ld_imm64: reject 2nd imm != 0",
136 .insns = {
137 BPF_MOV64_IMM(BPF_REG_0, 0),
138 BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
139 BPF_PSEUDO_MAP_FD, 0, 0),
140 BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
141 BPF_EXIT_INSN(),
143 .fixup_map_hash_48b = { 1 },
144 .errstr = "unrecognized bpf_ld_imm64 insn",
145 .result = REJECT,