github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/bpf_prog.txt (about)

     1  # Copyright 2023 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  include <uapi/linux/bpf.h>
     5  include <uapi/linux/bpf_common.h>
     6  
     7  define BPF_LINE_INFO_SIZE	sizeof(struct bpf_line_info)
     8  define BPF_FUNC_INFO_SIZE	sizeof(struct bpf_func_info)
     9  define BPF_CORE_RELO_SIZE	sizeof(struct bpf_core_relo)
    10  
    11  type bpf_prog_t[TYPE, ATTACH_TYPE, BTF_ID, PROG_FD] {
    12  	type			TYPE
    13  	ninsn			bytesize8[insns, int32]
    14  	insns			ptr64[in, bpf_instructions]
    15  	license			ptr64[in, string[bpf_licenses]]
    16  	loglev			int32
    17  	logsize			len[log, int32]
    18  	log			ptr64[out, array[int8], opt]
    19  	kern_version		flags[bpf_kern_version, int32]
    20  	flags			flags[bpf_prog_load_flags, int32]
    21  	prog_name		array[const[0, int8], BPF_OBJ_NAME_LEN]
    22  	prog_ifindex		ifindex[opt]
    23  	expected_attach_type	ATTACH_TYPE
    24  	btf_fd			fd_btf[opt]
    25  	func_info_rec_size	const[BPF_FUNC_INFO_SIZE, int32]
    26  	func_info		ptr64[in, bpf_func_info, opt]
    27  	func_info_cnt		len[func_info, int32]
    28  	line_info_rec_size	const[BPF_LINE_INFO_SIZE, int32]
    29  	line_info		ptr64[in, bpf_line_info, opt]
    30  	line_info_cnt		len[line_info, int32]
    31  	attach_btf_id		BTF_ID
    32  	attach_prog_fd		PROG_FD
    33  	core_relo_cnt		len[core_relos, int32]
    34  	fd_array		ptr64[in, array[fd_bpf_map], opt]
    35  	core_relos		ptr64[in, array[bpf_core_relo], opt]
    36  	core_relo_rec_size	const[BPF_CORE_RELO_SIZE, int32]
    37  	log_true_size		int32
    38  }
    39  
    40  type bpf_prog bpf_prog_t[flags[bpf_prog_type, int32], flags[bpf_attach_type, int32], bpf_btf_id[opt], fd_bpf_prog[opt]]
    41  
    42  bpf_licenses = "GPL", "syzkaller"
    43  bpf_kern_version = 0x40f00, 0x41000, 0x41100
    44  
    45  bpf_func_info {
    46  # This is instruction index, so should not be too large.
    47  	insn_off	int32[0:10]
    48  	type_id		btf_type_id
    49  }
    50  
    51  bpf_line_info {
    52  # This is instruction index, so should not be too large.
    53  	insn_off	int32[0:5]
    54  	file_name_off	btf_opt_name_off
    55  	line_off	int32
    56  	line_col	int32
    57  }
    58  
    59  bpf_core_relo {
    60  # This is instruction index, so should not be too large.
    61  	insn_off	int32[0:5]
    62  	type_id		btf_type_id
    63  	access_str_off	btf_opt_name_off
    64  	kind		flags[bpf_core_relo_kind, int32]
    65  }
    66  
    67  bpf_instructions [
    68  	raw	array[bpf_insn]
    69  	framed	bpf_framed_program
    70  	ringbuf	bpf_program_ringbuf
    71  ] [varlen]
    72  
    73  bpf_framed_program {
    74  	initr0	bpf_insn_init_r0
    75  	body	array[bpf_insn]
    76  	exit	bpf_insn_exit
    77  } [packed]
    78  
    79  bpf_program_ringbuf {
    80  	initr0		bpf_insn_init_r0
    81  	reserve		bpf_insn_ringbuf_reserve
    82  	null_check	bpf_insn_null_check[BPF_REG_9]
    83  	body		array[bpf_insn]
    84  	free		bpf_insn_ringbuf_free
    85  	exit		bpf_insn_exit
    86  } [packed]
    87  
    88  bpf_insn [
    89  	generic		bpf_insn_generic
    90  	ldst		bpf_insn_ldst
    91  	alu		bpf_insn_alu
    92  	jmp		bpf_insn_jmp
    93  	call		bpf_insn_call_helper
    94  	func		bpf_insn_call_func
    95  	kfunc		bpf_insn_call_kfunc
    96  	exit		bpf_insn_exit
    97  	initr0		bpf_insn_init_r0
    98  	map_fd		bpf_insn_map_fd
    99  	map_idx		bpf_insn_map_idx
   100  	map_val		bpf_insn_map_value
   101  	map_idx_val	bpf_insn_map_idx_value
   102  	btf_id		bpf_insn_btf_id
   103  	cb_func		bpf_insn_cb_func
   104  	printk		bpf_insn_trace_printk
   105  	snprintf	bpf_insn_snprintf
   106  	tail_call	bpf_insn_tail_call
   107  	ringbuf_query	bpf_insn_ringbuf_query
   108  	ringbuf_output	bpf_insn_ringbuf_output
   109  ] [varlen]
   110  
   111  bpf_insn_generic {
   112  	code	int8
   113  	dst	int8:4
   114  	src	int8:4
   115  	off	int16
   116  	imm	int32
   117  }
   118  
   119  type bpf_insn_ldst_t[CLASS, SZ, MODE, DST, SRC, OFF, IMM] {
   120  	code_class	int8:3[CLASS]
   121  	code_size	int8:2[SZ]
   122  	code_mode	int8:3[MODE]
   123  	dst		DST
   124  	src		SRC
   125  	off		OFF
   126  	imm		IMM
   127  }
   128  
   129  type bpf_insn_ldst bpf_insn_ldst_t[bpf_ldst_insn, bpf_ldst_size, bpf_ldst_mode, flags[bpf_reg, int8:4], flags[bpf_reg, int8:4], flags[bpf_insn_offsets, int16], flags[bpf_insn_immediates, int32]]
   130  type bpf_insn_st64_reg[SRC, DST, OFF] bpf_insn_ldst_t[BPF_STX, BPF_DW0, BPF_MEM0, const[DST, int8:4], const[SRC, int8:4], const[OFF, int16], const[0, int32]]
   131  
   132  bpf_ldst_insn = BPF_LD, BPF_LDX, BPF_ST, BPF_STX
   133  bpf_ldst_size = BPF_W0, BPF_H0, BPF_B0, BPF_DW0
   134  bpf_ldst_mode = BPF_IMM0, BPF_ABS0, BPF_IND0, BPF_MEM0, BPF_XADD0, BPF_MEMSX0
   135  
   136  define BPF_W0	BPF_W >> 3
   137  define BPF_H0	BPF_H >> 3
   138  define BPF_B0	BPF_B >> 3
   139  define BPF_DW0	BPF_DW >> 3
   140  
   141  define BPF_IMM0	BPF_IMM >> 5
   142  define BPF_ABS0	BPF_ABS >> 5
   143  define BPF_IND0	BPF_IND >> 5
   144  define BPF_MEM0	BPF_MEM >> 5
   145  define BPF_XADD0	BPF_XADD >> 5
   146  define BPF_MEMSX0	BPF_MEMSX >> 5
   147  
   148  type bpf_insn_alu_t[CLASS, SOURCE, OP, DST, SRC, OFF, IMM] {
   149  	code_class	int8:3[CLASS]
   150  	code_s		int8:1[SOURCE]
   151  	code_op		int8:4[OP]
   152  	dst		DST
   153  	src		SRC
   154  	off		OFF
   155  	imm		IMM
   156  }
   157  
   158  type bpf_insn_alu bpf_insn_alu_t[bpf_alu_insn, bpf_alu_source, bpf_alu_op, flags[bpf_reg, int8:4], flags[bpf_reg, int8:4], flags[bpf_insn_offsets, int16], flags[bpf_insn_immediates, int32]]
   159  type bpf_insn_mov_imm[DST, IMM] bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, const[DST, int8:4], const[0, int8:4], const[0, int16], const[IMM, int32]]
   160  type bpf_insn_mov_imm_any[DST] bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, const[DST, int8:4], const[0, int8:4], const[0, int16], int32]
   161  type bpf_insn_mov_imm_flag[DST, FLAG] bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, const[DST, int8:4], const[0, int8:4], const[0, int16], flags[FLAG, int32]]
   162  type bpf_insn_mov_reg[SRC, DST] bpf_insn_alu_t[BPF_ALU64, BPF_X0, BPF_MOV0, const[DST, int8:4], const[SRC, int8:4], const[0, int16], const[0, int32]]
   163  type bpf_insn_op_imm[DST, OP, IMM] bpf_insn_alu_t[BPF_ALU64, BPF_K0, OP, const[DST, int8:4], const[0, int8:4], const[0, int16], const[IMM, int32]]
   164  
   165  bpf_alu_source = BPF_K0, BPF_X0
   166  bpf_alu_insn = BPF_ALU, BPF_ALU64
   167  bpf_alu_op = BPF_ADD0, BPF_SUB0, BPF_MUL0, BPF_DIV0, BPF_OR0, BPF_AND0, BPF_LSH0, BPF_RSH0, BPF_NEG0, BPF_MOD0, BPF_XOR0, BPF_MOV0, BPF_ARSH0, BPF_END0
   168  
   169  define BPF_ADD0	BPF_ADD >> 4
   170  define BPF_SUB0	BPF_SUB >> 4
   171  define BPF_MUL0	BPF_MUL >> 4
   172  define BPF_DIV0	BPF_DIV >> 4
   173  define BPF_OR0	BPF_OR >> 4
   174  define BPF_AND0	BPF_AND >> 4
   175  define BPF_LSH0	BPF_LSH >> 4
   176  define BPF_RSH0	BPF_RSH >> 4
   177  define BPF_NEG0	BPF_NEG >> 4
   178  define BPF_MOD0	BPF_MOD >> 4
   179  define BPF_XOR0	BPF_XOR >> 4
   180  define BPF_MOV0	BPF_MOV >> 4
   181  define BPF_ARSH0	BPF_ARSH >> 4
   182  define BPF_END0	BPF_END >> 4
   183  
   184  define BPF_K0	BPF_K >> 3
   185  define BPF_X0	BPF_X >> 3
   186  
   187  bpf_insn_jmp {
   188  	code_class	const[BPF_JMP, int8:3]
   189  	code_s		int8:1
   190  	code_op		flags[bpf_jmp_op, int8:4]
   191  	dst		flags[bpf_reg, int8:4]
   192  	src		flags[bpf_reg, int8:4]
   193  	off		flags[bpf_insn_offsets, int16]
   194  	imm		flags[bpf_insn_immediates, int32]
   195  }
   196  
   197  # Equivalent to: if reg != 0 goto +1;
   198  type bpf_insn_not_null_jmp[REG] {
   199  	code_class	const[BPF_JMP, int8:3]
   200  	code_s		const[BPF_K0, int8:1]
   201  	code_op		const[BPF_JNE0, int8:4]
   202  	dst		const[REG, int8:4]
   203  	src		const[0, int8:4]
   204  	off		const[1, int16]
   205  	imm		const[0, int32]
   206  }
   207  
   208  bpf_jmp_op = BPF_JA0, BPF_JEQ0, BPF_JGT0, BPF_JGE0, BPF_JSET0, BPF_JNE0, BPF_JSGT0, BPF_JSGE0, BPF_CALL0, BPF_EXIT0, BPF_JLT0, BPF_JLE0, BPF_JSLT0, BPF_JSLE0
   209  
   210  define BPF_JA0	BPF_JA >> 4
   211  define BPF_JEQ0	BPF_JEQ >> 4
   212  define BPF_JGT0	BPF_JGT >> 4
   213  define BPF_JGE0	BPF_JGE >> 4
   214  define BPF_JSET0	BPF_JSET >> 4
   215  define BPF_JNE0	BPF_JNE >> 4
   216  define BPF_JSGT0	BPF_JSGT >> 4
   217  define BPF_JSGE0	BPF_JSGE >> 4
   218  define BPF_CALL0	BPF_CALL >> 4
   219  define BPF_EXIT0	BPF_EXIT >> 4
   220  define BPF_JLT0	BPF_JLT >> 4
   221  define BPF_JLE0	BPF_JLE >> 4
   222  define BPF_JSLT0	BPF_JSLT >> 4
   223  define BPF_JSLE0	BPF_JSLE >> 4
   224  
   225  type bpf_insn_call_helper_t[FUNC] {
   226  	code	const[bpf_call_code, int8]
   227  	regs	const[0, int8]
   228  	off	const[0, int16]
   229  	func	FUNC
   230  }
   231  
   232  type bpf_insn_call_helper bpf_insn_call_helper_t[int32[0:__BPF_FUNC_MAX_ID]]
   233  
   234  bpf_insn_call_func {
   235  	code	const[bpf_call_code, int8]
   236  	dst	const[0, int8:4]
   237  	src	const[BPF_PSEUDO_CALL, int8:4]
   238  	off	const[0, int16]
   239  # NEED: to limit the call offset to the program size, we'd need support for path expressions inside ranges of values.
   240  	func	int32[-8:8]
   241  }
   242  
   243  bpf_insn_call_kfunc {
   244  	code	const[bpf_call_code, int8]
   245  	dst	const[0, int8:4]
   246  	src	const[BPF_PSEUDO_KFUNC_CALL, int8:4]
   247  	off	const[0, int16]
   248  	kfunc	btf_type_id
   249  }
   250  
   251  define bpf_call_code	BPF_JMP | BPF_CALL
   252  
   253  bpf_insn_exit {
   254  	code	const[bpf_exit_code, int8]
   255  	regs	const[0, int8]
   256  	off	const[0, int16]
   257  	imm	const[0, int32]
   258  }
   259  
   260  define bpf_exit_code	BPF_JMP | BPF_EXIT
   261  
   262  bpf_insn_init_r0 {
   263  	code	const[bpf_insn_load_imm_dw, int8]
   264  	dst	const[BPF_REG_0, int8:4]
   265  	src	const[0, int8:4]
   266  	off	const[0, int16]
   267  	imm	int32
   268  	code2	const[0, int8]
   269  	regs2	const[0, int8]
   270  	off2	const[0, int16]
   271  	imm2	int32
   272  }
   273  
   274  type bpf_insn_mov_imm64[DST, IMM1, IMM2] {
   275  	code	const[bpf_insn_load_imm_dw, int8]
   276  	dst	const[DST, int8:4]
   277  	src	const[0, int8:4]
   278  	off	const[0, int16]
   279  	imm	const[IMM1, int32]
   280  	code2	const[0, int8]
   281  	regs2	const[0, int8]
   282  	off2	const[0, int16]
   283  	imm2	const[IMM2, int32]
   284  }
   285  
   286  type bpf_insn_map_fd_t[DST, MAP_FD] {
   287  	code	const[bpf_insn_load_imm_dw, int8]
   288  	dst	DST
   289  	src	const[BPF_PSEUDO_MAP_FD, int8:4]
   290  	off	const[0, int16]
   291  	imm	MAP_FD
   292  	code2	const[0, int8]
   293  	regs2	const[0, int8]
   294  	off2	const[0, int16]
   295  	imm2	const[0, int32]
   296  }
   297  
   298  type bpf_insn_map_fd bpf_insn_map_fd_t[flags[bpf_reg, int8:4], fd_bpf_map]
   299  type bpf_insn_tail_call_map_fd[DST] bpf_insn_map_fd_t[const[DST, int8:4], tail_call_map]
   300  type bpf_insn_ringbuf_fd[DST] bpf_insn_map_fd_t[const[DST, int8:4], ringbuf_map_fd]
   301  
   302  bpf_insn_map_idx {
   303  	code	const[bpf_insn_load_imm_dw, int8]
   304  	dst	flags[bpf_reg, int8:4]
   305  	src	const[BPF_PSEUDO_MAP_IDX, int8:4]
   306  	off	const[0, int16]
   307  	imm	map_fd_id
   308  	code2	const[0, int8]
   309  	regs2	const[0, int8]
   310  	off2	const[0, int16]
   311  	imm2	const[0, int32]
   312  }
   313  
   314  type bpf_insn_map_value_t[DST, MAP_FD, VALUE_OFFSET] {
   315  	code	const[bpf_insn_load_imm_dw, int8]
   316  	dst	DST
   317  	src	const[BPF_PSEUDO_MAP_VALUE, int8:4]
   318  	off	const[0, int16]
   319  	imm	MAP_FD
   320  	code2	const[0, int8]
   321  	regs2	const[0, int8]
   322  	off2	const[0, int16]
   323  	imm2	VALUE_OFFSET
   324  }
   325  
   326  type bpf_insn_map_value bpf_insn_map_value_t[flags[bpf_reg, int8:4], fd_bpf_map, int32]
   327  type bpf_insn_const_str[DST] bpf_insn_map_value_t[const[DST, int8:4], bpf_frozen_const_str, const[0, int32]]
   328  
   329  bpf_insn_map_idx_value {
   330  	code	const[bpf_insn_load_imm_dw, int8]
   331  	dst	flags[bpf_reg, int8:4]
   332  	src	const[BPF_PSEUDO_MAP_IDX_VALUE, int8:4]
   333  	off	const[0, int16]
   334  	imm	map_fd_id
   335  	code2	const[0, int8]
   336  	regs2	const[0, int8]
   337  	off2	const[0, int16]
   338  	imm2	int32
   339  }
   340  
   341  bpf_insn_cb_func {
   342  	code	const[bpf_insn_load_imm_dw, int8]
   343  	dst	flags[bpf_reg, int8:4]
   344  	src	const[BPF_PSEUDO_FUNC, int8:4]
   345  	off	const[0, int16]
   346  # NEED: to limit the call offset to the program size, we'd need support for path expressions inside ranges of values.
   347  	imm	int32[-8:8]
   348  	code2	const[0, int8]
   349  	regs2	const[0, int8]
   350  	off2	const[0, int16]
   351  	imm2	const[0, int32]
   352  }
   353  
   354  bpf_insn_btf_id {
   355  	code	const[bpf_insn_load_imm_dw, int8]
   356  	dst	flags[bpf_reg, int8:4]
   357  	src	const[BPF_PSEUDO_BTF_ID, int8:4]
   358  	off	const[0, int16]
   359  	imm	btf_type_id
   360  	code2	const[0, int8]
   361  	regs2	const[0, int8]
   362  	off2	const[0, int16]
   363  	imm2	const[0, int32]
   364  }
   365  
   366  define bpf_insn_load_imm_dw	BPF_LD | BPF_DW | BPF_IMM
   367  
   368  # Slightly prune state space, these values frequently must be 0.
   369  bpf_insn_offsets = 0, 1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 80, 128, 256, -1, -2, -4, -8, -12, -16, -32, -64
   370  bpf_insn_immediates = 0, 1, 4, 8, 16, -1, -4, -16
   371  bpf_reg = BPF_REG_0, BPF_REG_1, BPF_REG_2, BPF_REG_3, BPF_REG_4, BPF_REG_5, BPF_REG_6, BPF_REG_7, BPF_REG_8, BPF_REG_9, BPF_REG_10, __MAX_BPF_REG
   372  
   373  # Equivalent to:
   374  # if reg != 0 goto +1;
   375  # exit;
   376  # This is useful to check null pointers. We exit if the pointer is null and
   377  # continue the normal flow otherwise.
   378  type bpf_insn_null_check[REG] {
   379  	cond_jump	bpf_insn_not_null_jmp[REG]
   380  	exit		bpf_insn_exit
   381  }
   382  
   383  # Format specifiers for bpf_trace_printk, encoded as a zero-terminated string
   384  # of 7 characters. For example, field 'p' corresponds to "%p     ".
   385  type bpf_insn_mov_printk_str_hex[DST] [
   386  	p	bpf_insn_mov_imm64[DST, 0x25702020, 0x20202000]
   387  	d	bpf_insn_mov_imm64[DST, 0x25642020, 0x20202000]
   388  	i	bpf_insn_mov_imm64[DST, 0x25692020, 0x20202000]
   389  	u	bpf_insn_mov_imm64[DST, 0x25752020, 0x20202000]
   390  	x	bpf_insn_mov_imm64[DST, 0x25782020, 0x20202000]
   391  	ld	bpf_insn_mov_imm64[DST, 0x256c6420, 0x20202000]
   392  	li	bpf_insn_mov_imm64[DST, 0x256c6920, 0x20202000]
   393  	lu	bpf_insn_mov_imm64[DST, 0x256c7520, 0x20202000]
   394  	lx	bpf_insn_mov_imm64[DST, 0x256c7820, 0x20202000]
   395  	lld	bpf_insn_mov_imm64[DST, 0x256c6c64, 0x20202000]
   396  	lli	bpf_insn_mov_imm64[DST, 0x256c6c69, 0x20202000]
   397  	llu	bpf_insn_mov_imm64[DST, 0x256c6c75, 0x20202000]
   398  	llx	bpf_insn_mov_imm64[DST, 0x256c6c78, 0x20202000]
   399  	s	bpf_insn_mov_imm64[DST, 0x25732020, 0x20202000]
   400  ]
   401  
   402  # (18) r1 = "%d     "
   403  # (7b) *(u64 *)(r10 -8) = r1
   404  # (bf) r1 = r10
   405  # (07) r1 += -8
   406  # (b7) r2 = 8
   407  # (b7) r3 = X
   408  # (85) call bpf_trace_printk#-108352
   409  bpf_insn_trace_printk {
   410  	insn1	bpf_insn_mov_printk_str_hex[BPF_REG_1]
   411  	insn2	bpf_insn_st64_reg[BPF_REG_1, BPF_REG_10, -8]
   412  	insn3	bpf_insn_mov_reg[BPF_REG_10, BPF_REG_1]
   413  	insn4	bpf_insn_op_imm[BPF_REG_1, BPF_ADD0, -8]
   414  	insn5	bpf_insn_mov_imm[BPF_REG_2, 8]
   415  	insn6	bpf_insn_mov_imm_any[BPF_REG_3]
   416  	insn7	bpf_insn_call_helper_t[const[BPF_FUNC_trace_printk, int32]]
   417  }
   418  
   419  # (b7) r8 = 0
   420  # (7b) *(u64 *)(r10 -8) = r8
   421  # (b7) r8 = X
   422  # (7b) *(u64 *)(r10 -16) = r8
   423  # (bf) r1 = r10
   424  # (07) r1 += -8
   425  # (bf) r4 = r10
   426  # (07) r4 += -16
   427  # (b7) r2 = 8
   428  # (18) r3 = map[id:31][0]+0
   429  # (b7) r5 = 8
   430  # (85) call bpf_snprintf#168880
   431  bpf_insn_snprintf {
   432  	insn1	bpf_insn_mov_imm[BPF_REG_8, 0]
   433  	insn2	bpf_insn_st64_reg[BPF_REG_8, BPF_REG_10, -8]
   434  	insn3	bpf_insn_mov_imm_any[BPF_REG_8]
   435  	insn4	bpf_insn_st64_reg[BPF_REG_8, BPF_REG_10, -16]
   436  	insn5	bpf_insn_mov_reg[BPF_REG_10, BPF_REG_1]
   437  	insn6	bpf_insn_op_imm[BPF_REG_1, BPF_ADD0, -8]
   438  	insn7	bpf_insn_mov_reg[BPF_REG_10, BPF_REG_4]
   439  	insn8	bpf_insn_op_imm[BPF_REG_4, BPF_ADD0, -16]
   440  	insn9	bpf_insn_mov_imm[BPF_REG_2, 8]
   441  	insn10	bpf_insn_const_str[BPF_REG_3]
   442  	insn11	bpf_insn_mov_imm[BPF_REG_5, 8]
   443  	insn12	bpf_insn_call_helper_t[const[BPF_FUNC_snprintf, int32]]
   444  }
   445  
   446  # (18) r2 = map[id:10]
   447  # (b7) r3 = 2
   448  # (85) call bpf_tail_call#12
   449  # (b7) r0 = 0
   450  bpf_insn_tail_call {
   451  	insn1	bpf_insn_tail_call_map_fd[BPF_REG_2]
   452  	insn2	bpf_insn_mov_imm[BPF_REG_3, 0]
   453  	insn3	bpf_insn_call_helper_t[const[BPF_FUNC_tail_call, int32]]
   454  	insn4	bpf_insn_mov_imm[BPF_REG_0, 0]
   455  }
   456  
   457  # (18) r1 = map[id:16]
   458  # (b7) r2 = 8
   459  # (b7) r3 = 0
   460  # (85) call bpf_ringbuf_reserve#320112
   461  # (bf) r9 = r0
   462  bpf_insn_ringbuf_reserve {
   463  	insn1	bpf_insn_ringbuf_fd[BPF_REG_1]
   464  	insn2	bpf_insn_mov_imm[BPF_REG_2, 20]
   465  	insn3	bpf_insn_mov_imm[BPF_REG_3, 0]
   466  	insn4	bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_reserve, int32]]
   467  	insn5	bpf_insn_mov_reg[BPF_REG_0, BPF_REG_9]
   468  }
   469  
   470  # (bf) r1 = r9
   471  # (b7) r2 = BPF_RB_X
   472  # (85) call bpf_ringbuf_{submit,discard}#322192
   473  # (bf) r0 = 0
   474  bpf_insn_ringbuf_free {
   475  	insn1	bpf_insn_mov_reg[BPF_REG_9, BPF_REG_1]
   476  	insn2	bpf_insn_mov_imm_flag[BPF_REG_2, bpf_ringbuf_wakeup_flags]
   477  	insn3	bpf_insn_call_helper_t[flags[bpf_helpers_ringbuf_free, int32]]
   478  	insn4	bpf_insn_mov_imm[BPF_REG_0, 0]
   479  }
   480  
   481  bpf_helpers_ringbuf_free = BPF_FUNC_ringbuf_submit, BPF_FUNC_ringbuf_discard
   482  
   483  # (18) r1 = map[id:16]
   484  # (b7) r2 = 0
   485  # (85) call bpf_ringbuf_query#322192
   486  bpf_insn_ringbuf_query {
   487  	insn1	bpf_insn_tail_call_map_fd[BPF_REG_1]
   488  	insn2	bpf_insn_mov_imm[BPF_REG_2, 0]
   489  	insn3	bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_query, int32]]
   490  }
   491  
   492  # (18) r1 = map[id:16]
   493  # (b7) r8 = X
   494  # (7b) *(u64 *)(r10 -8) = r8
   495  # (bf) r2 = r10
   496  # (07) r2 += -8
   497  # (b7) r3 = 8
   498  # (b7) r4 = BPF_RB_X
   499  # (85) call bpf_ringbuf_output#322192
   500  bpf_insn_ringbuf_output {
   501  	insn1	bpf_insn_tail_call_map_fd[BPF_REG_1]
   502  	insn2	bpf_insn_mov_imm_any[BPF_REG_8]
   503  	insn3	bpf_insn_st64_reg[BPF_REG_8, BPF_REG_10, -8]
   504  	insn4	bpf_insn_mov_reg[BPF_REG_10, BPF_REG_2]
   505  	insn5	bpf_insn_op_imm[BPF_REG_2, BPF_ADD0, -8]
   506  	insn6	bpf_insn_mov_imm[BPF_REG_3, 8]
   507  	insn7	bpf_insn_mov_imm_flag[BPF_REG_4, bpf_ringbuf_wakeup_flags]
   508  	insn8	bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_output, int32]]
   509  }
   510  
   511  define MAX_BPF_REG	__MAX_BPF_REG
   512  
   513  bpf_ringbuf_wakeup_flags = 0, BPF_RB_NO_WAKEUP, BPF_RB_FORCE_WAKEUP