| .. | .. |
|---|
| 199 | 199 | .off = OFF, \ |
|---|
| 200 | 200 | .imm = 0 }) |
|---|
| 201 | 201 | |
|---|
| 202 | +/* Like BPF_JMP_REG, but with 32-bit wide operands for comparison. */ |
|---|
| 203 | + |
|---|
| 204 | +#define BPF_JMP32_REG(OP, DST, SRC, OFF) \ |
|---|
| 205 | + ((struct bpf_insn) { \ |
|---|
| 206 | + .code = BPF_JMP32 | BPF_OP(OP) | BPF_X, \ |
|---|
| 207 | + .dst_reg = DST, \ |
|---|
| 208 | + .src_reg = SRC, \ |
|---|
| 209 | + .off = OFF, \ |
|---|
| 210 | + .imm = 0 }) |
|---|
| 211 | + |
|---|
| 202 | 212 | /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ |
|---|
| 203 | 213 | |
|---|
| 204 | 214 | #define BPF_JMP_IMM(OP, DST, IMM, OFF) \ |
|---|
| 205 | 215 | ((struct bpf_insn) { \ |
|---|
| 206 | 216 | .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ |
|---|
| 217 | + .dst_reg = DST, \ |
|---|
| 218 | + .src_reg = 0, \ |
|---|
| 219 | + .off = OFF, \ |
|---|
| 220 | + .imm = IMM }) |
|---|
| 221 | + |
|---|
| 222 | +/* Like BPF_JMP_IMM, but with 32-bit wide operands for comparison. */ |
|---|
| 223 | + |
|---|
| 224 | +#define BPF_JMP32_IMM(OP, DST, IMM, OFF) \ |
|---|
| 225 | + ((struct bpf_insn) { \ |
|---|
| 226 | + .code = BPF_JMP32 | BPF_OP(OP) | BPF_K, \ |
|---|
| 207 | 227 | .dst_reg = DST, \ |
|---|
| 208 | 228 | .src_reg = 0, \ |
|---|
| 209 | 229 | .off = OFF, \ |
|---|
| .. | .. |
|---|
| 258 | 278 | .off = 0, \ |
|---|
| 259 | 279 | .imm = ((__u64) (IMM)) >> 32 }) |
|---|
| 260 | 280 | |
|---|
| 281 | +#define BPF_LD_IMM64_RAW_FULL(DST, SRC, OFF1, OFF2, IMM1, IMM2) \ |
|---|
| 282 | + ((struct bpf_insn) { \ |
|---|
| 283 | + .code = BPF_LD | BPF_DW | BPF_IMM, \ |
|---|
| 284 | + .dst_reg = DST, \ |
|---|
| 285 | + .src_reg = SRC, \ |
|---|
| 286 | + .off = OFF1, \ |
|---|
| 287 | + .imm = IMM1 }), \ |
|---|
| 288 | + ((struct bpf_insn) { \ |
|---|
| 289 | + .code = 0, /* zero is reserved opcode */ \ |
|---|
| 290 | + .dst_reg = 0, \ |
|---|
| 291 | + .src_reg = 0, \ |
|---|
| 292 | + .off = OFF2, \ |
|---|
| 293 | + .imm = IMM2 }) |
|---|
| 294 | + |
|---|
| 261 | 295 | /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ |
|---|
| 262 | 296 | |
|---|
| 263 | 297 | #define BPF_LD_MAP_FD(DST, MAP_FD) \ |
|---|
| 264 | | - BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD) |
|---|
| 298 | + BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_FD, 0, 0, \ |
|---|
| 299 | + MAP_FD, 0) |
|---|
| 300 | + |
|---|
| 301 | +#define BPF_LD_MAP_VALUE(DST, MAP_FD, VALUE_OFF) \ |
|---|
| 302 | + BPF_LD_IMM64_RAW_FULL(DST, BPF_PSEUDO_MAP_VALUE, 0, 0, \ |
|---|
| 303 | + MAP_FD, VALUE_OFF) |
|---|
| 265 | 304 | |
|---|
| 266 | 305 | /* Relative call */ |
|---|
| 267 | 306 | |
|---|