hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/tools/include/linux/filter.h
....@@ -199,11 +199,31 @@
199199 .off = OFF, \
200200 .imm = 0 })
201201
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
+
202212 /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */
203213
204214 #define BPF_JMP_IMM(OP, DST, IMM, OFF) \
205215 ((struct bpf_insn) { \
206216 .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, \
207227 .dst_reg = DST, \
208228 .src_reg = 0, \
209229 .off = OFF, \
....@@ -258,10 +278,29 @@
258278 .off = 0, \
259279 .imm = ((__u64) (IMM)) >> 32 })
260280
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
+
261295 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
262296
263297 #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)
265304
266305 /* Relative call */
267306