From eb146eaf8a525cbaaf511a013d0dbb70bb1207b9 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Tue, 7 Nov 2023 21:11:31 +0100 Subject: sys/linux: describe BPF helper bpf_ringbuf_output This helper has the prototype: bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) We need to prepare the second argument (R2) on the stack. We use an 8 bytes data value initialized to some random value on the stack and pointed to by R2. The third argument therefore needs to be 8 (for 8 bytes). Signed-off-by: Paul Chaignon --- sys/linux/bpf.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sys/linux/bpf.txt') diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt index 72e94157e..c66ab24b5 100644 --- a/sys/linux/bpf.txt +++ b/sys/linux/bpf.txt @@ -425,6 +425,7 @@ bpf_insn [ snprintf bpf_insn_snprintf tail_call bpf_insn_tail_call ringbuf_query bpf_insn_ringbuf_query + ringbuf_output bpf_insn_ringbuf_output ] [varlen] bpf_insn_generic { @@ -795,6 +796,25 @@ bpf_insn_ringbuf_query { insn3 bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_query, int32]] } +# (18) r1 = map[id:16] +# (b7) r8 = X +# (7b) *(u64 *)(r10 -8) = r8 +# (bf) r2 = r10 +# (07) r2 += -8 +# (b7) r3 = 8 +# (b7) r4 = 0 +# (85) call bpf_ringbuf_output#322192 +bpf_insn_ringbuf_output { + insn1 bpf_insn_tail_call_map_fd[BPF_REG_1] + insn2 bpf_insn_mov_imm_any[BPF_REG_8] + insn3 bpf_insn_st64_reg[BPF_REG_8, BPF_REG_10, -8] + insn4 bpf_insn_mov_reg[BPF_REG_10, BPF_REG_2] + insn5 bpf_insn_op_imm[BPF_REG_2, BPF_ADD0, -8] + insn6 bpf_insn_mov_imm[BPF_REG_3, 8] + insn7 bpf_insn_mov_imm[BPF_REG_4, 0] + insn8 bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_output, int32]] +} + define MAX_BPF_REG __MAX_BPF_REG bpf_obj_pin_map [ -- cgit mrf-deployment