Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\verifier.c Create Date:2022-07-28 13:04:58
Last Modify:2022-05-19 20:02:10 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:jit_subprogs

Proto:static int jit_subprogs(struct bpf_verifier_env *env)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
8928  prog = BPF program being verified
8929  subprog_end = 0
8934  If subprog_cnt <= 1 Then Return 0
8937  When i < Number of filter blocks cycle
8938  If opcode != (BPF_JMP | unction call ) || source register != when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative* offset to another bpf function Then Continue
8945  subprog = find_subprog(env, i + signed immediate constant + 1)
8946  If subprog < 0 Then
8947  WARN_ONCE(1, "verifier bug. No program starts at insn %d\n", i + signed immediate constant + 1)
8949  Return -EFAULT
8954  signed offset = subprog
8958  saved imm field of call insn = signed immediate constant
8960  signed immediate constant = 1
8963  err = bpf_prog_alloc_jited_linfo(prog)
8964  If err Then Go to out_undo_insn
8967  err = -ENOMEM
8968  func = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
8969  If Not func Then Go to out_undo_insn
8972  When i < subprog_cnt cycle
8973  subprog_start = subprog_end
8974  subprog_end = insn idx of function entry point
8976  len = subprog_end - subprog_start
8982  func[i] = bpf_prog_alloc_no_stats(bpf_prog_size(len), GFP_USER)
8983  If Not func[i] Then Go to out_free
8985  No 3D Now!(insnsi, & insnsi[subprog_start], len * sizeof(structbpf_insn))
8987  Type of BPF program = Type of BPF program
8988  Number of filter blocks = len
8989  If bpf_prog_calc_tag(func[i]) Then Go to out_free
8991  program is a bpf function = 1
8992  0 for non-func prog, the index in func array for func prog = i
8994  btf = btf
8995  func_info = func_info
9000  name[0] = 'F'
9001  stack_depth = max. stack depth used by this function
9002  archs need to JIT the prog = 1
9003  bpf_line_info loaded from userspace. linfo->insn_off * has the xlated insn offset. * Both the main and sub prog share the same linfo. * The subprog can access its first linfo by * using the linfo_idx. = bpf_line_info loaded from userspace. linfo->insn_off * has the xlated insn offset. * Both the main and sub prog share the same linfo. * The subprog can access its first linfo by * using the linfo_idx.
9004  nr_linfo = nr_linfo
9005  jited_linfo is the jited addr of the linfo. It has a * one to one mapping to linfo: * jited_linfo[i] is the jited addr for the linfo[i]->insn_off. * Both the main and sub prog share the same jited_linfo. * The subprog can access its first jited_linfo by * = jited_linfo is the jited addr of the linfo. It has a * one to one mapping to linfo: * jited_linfo[i] is the jited addr for the linfo[i]->insn_off. * Both the main and sub prog share the same jited_linfo. * The subprog can access its first jited_linfo by *
9006  subprog can use linfo_idx to access its first linfo and * jited_linfo. * main prog always has linfo_idx == 0 = The idx to the main_prog->aux->linfo
9007  func[i] = Stub for JITs that only support cBPF. eBPF programs are interpreted.* It is encouraged to implement bpf_int_jit_compile() instead, so that* eBPF and implicitly also cBPF can get JITed!
9008  If Not Is our filter JIT'ed? Then
9010  Go to out_free
9012  cond_resched()
9018  When i < subprog_cnt cycle
9019  insn = insnsi
9040  func = func
9041  used by non-func prog as the number of func progs = subprog_cnt
9043  When i < subprog_cnt cycle
9044  old_bpf_func = bpf_func
9045  tmp = Stub for JITs that only support cBPF. eBPF programs are interpreted.* It is encouraged to implement bpf_int_jit_compile() instead, so that* eBPF and implicitly also cBPF can get JITed!
9046  If tmp != func[i] || bpf_func != old_bpf_func Then
9047  verbose(env, "JIT doesn't support bpf-to-bpf calls\n")
9049  Go to out_free
9051  cond_resched()
9057  When i < subprog_cnt cycle
9058  bpf_prog_lock_ro(func[i])
9059  bpf_prog_kallsyms_add(func[i])
9066  When i < Number of filter blocks cycle
9067  If opcode != (BPF_JMP | unction call ) || source register != when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative* offset to another bpf function Then Continue
9070  signed offset = saved imm field of call insn
9071  subprog = find_subprog(env, i + signed offset + 1)
9072  signed immediate constant = subprog
9075  Is our filter JIT'ed? = 1
9076  bpf_func = bpf_func
9077  func = func
9078  used by non-func prog as the number of func progs = subprog_cnt
9079  bpf_prog_free_unused_jited_linfo(prog)
9080  Return 0
9081  out_free :
9082  When i < subprog_cnt cycle If func[i] Then
9084  bpf_jit_free(func[i])
9085  kfree(func)
9086  out_undo_insn :
9088  archs need to JIT the prog = 0
9089  When i < Number of filter blocks cycle
9090  If opcode != (BPF_JMP | unction call ) || source register != when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative* offset to another bpf function Then Continue
9093  signed offset = 0
9094  signed immediate constant = saved imm field of call insn
9096  bpf_prog_free_jited_linfo(prog)
9097  Return err
Caller
NameDescribe
fixup_call_args