1 {
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(),
11 	},
12 	.errstr = "invalid BPF_LD_IMM insn",
13 	.errstr_unpriv = "R1 pointer comparison",
14 	.result = REJECT,
15 },
16 {
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(),
25 	},
26 	.errstr = "invalid BPF_LD_IMM insn",
27 	.errstr_unpriv = "R1 pointer comparison",
28 	.result = REJECT,
29 },
30 {
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(),
40 	},
41 	.errstr = "invalid bpf_ld_imm64 insn",
42 	.result = REJECT,
43 },
44 {
45 	"test4 ld_imm64",
46 	.insns = {
47 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
48 	BPF_EXIT_INSN(),
49 	},
50 	.errstr = "invalid bpf_ld_imm64 insn",
51 	.result = REJECT,
52 },
53 {
54 	"test5 ld_imm64",
55 	.insns = {
56 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
57 	},
58 	.errstr = "invalid bpf_ld_imm64 insn",
59 	.result = REJECT,
60 },
61 {
62 	"test6 ld_imm64",
63 	.insns = {
64 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
65 	BPF_RAW_INSN(0, 0, 0, 0, 0),
66 	BPF_EXIT_INSN(),
67 	},
68 	.result = ACCEPT,
69 },
70 {
71 	"test7 ld_imm64",
72 	.insns = {
73 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
74 	BPF_RAW_INSN(0, 0, 0, 0, 1),
75 	BPF_EXIT_INSN(),
76 	},
77 	.result = ACCEPT,
78 	.retval = 1,
79 },
80 {
81 	"test8 ld_imm64",
82 	.insns = {
83 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 1, 1),
84 	BPF_RAW_INSN(0, 0, 0, 0, 1),
85 	BPF_EXIT_INSN(),
86 	},
87 	.errstr = "uses reserved fields",
88 	.result = REJECT,
89 },
90 {
91 	"test9 ld_imm64",
92 	.insns = {
93 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
94 	BPF_RAW_INSN(0, 0, 0, 1, 1),
95 	BPF_EXIT_INSN(),
96 	},
97 	.errstr = "invalid bpf_ld_imm64 insn",
98 	.result = REJECT,
99 },
100 {
101 	"test10 ld_imm64",
102 	.insns = {
103 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
104 	BPF_RAW_INSN(0, BPF_REG_1, 0, 0, 1),
105 	BPF_EXIT_INSN(),
106 	},
107 	.errstr = "invalid bpf_ld_imm64 insn",
108 	.result = REJECT,
109 },
110 {
111 	"test11 ld_imm64",
112 	.insns = {
113 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
114 	BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
115 	BPF_EXIT_INSN(),
116 	},
117 	.errstr = "invalid bpf_ld_imm64 insn",
118 	.result = REJECT,
119 },
120 {
121 	"test12 ld_imm64",
122 	.insns = {
123 	BPF_MOV64_IMM(BPF_REG_1, 0),
124 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
125 	BPF_RAW_INSN(0, 0, 0, 0, 0),
126 	BPF_EXIT_INSN(),
127 	},
128 	.errstr = "not pointing to valid bpf_map",
129 	.result = REJECT,
130 },
131 {
132 	"test13 ld_imm64",
133 	.insns = {
134 	BPF_MOV64_IMM(BPF_REG_1, 0),
135 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
136 	BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
137 	BPF_EXIT_INSN(),
138 	},
139 	.errstr = "invalid bpf_ld_imm64 insn",
140 	.result = REJECT,
141 },
142 {
143 	"test14 ld_imm64: reject 2nd imm != 0",
144 	.insns = {
145 	BPF_MOV64_IMM(BPF_REG_0, 0),
146 	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
147 		     BPF_PSEUDO_MAP_FD, 0, 0),
148 	BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
149 	BPF_EXIT_INSN(),
150 	},
151 	.fixup_map_hash_48b = { 1 },
152 	.errstr = "unrecognized bpf_ld_imm64 insn",
153 	.result = REJECT,
154 },
155