Lines Matching refs:pos

29 	struct bpf_insn *pos;  member
33 pos_get_cnt(struct bpf_insn_pos *pos) in pos_get_cnt() argument
35 return pos->pos - pos->begin; in pos_get_cnt()
39 append_insn(struct bpf_insn new_insn, struct bpf_insn_pos *pos) in append_insn() argument
41 if (!pos->pos) in append_insn()
44 if (pos->pos + 1 >= pos->end) { in append_insn()
46 pos->pos = NULL; in append_insn()
50 *(pos->pos)++ = new_insn; in append_insn()
55 check_pos(struct bpf_insn_pos *pos) in check_pos() argument
57 if (!pos->pos || pos->pos >= pos->end) in check_pos()
112 gen_ldx_reg_from_ctx(struct bpf_insn_pos *pos, int ctx_reg, in gen_ldx_reg_from_ctx() argument
122 ins(BPF_LDX_MEM(BPF_DW, target_reg, ctx_reg, offset), pos); in gen_ldx_reg_from_ctx()
124 return check_pos(pos); in gen_ldx_reg_from_ctx()
142 gen_read_mem(struct bpf_insn_pos *pos, in gen_read_mem() argument
150 ins(BPF_MOV64_REG(BPF_REG_ARG3, src_base_addr_reg), pos); in gen_read_mem()
153 ins(BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG3, offset), pos); in gen_read_mem()
156 ins(BPF_ALU64_IMM(BPF_MOV, BPF_REG_ARG2, BPF_REG_SIZE), pos); in gen_read_mem()
160 ins(BPF_MOV64_REG(BPF_REG_ARG1, dst_addr_reg), pos); in gen_read_mem()
163 ins(BPF_EMIT_CALL(probeid), pos); in gen_read_mem()
170 pos); in gen_read_mem()
172 return check_pos(pos); in gen_read_mem()
183 gen_prologue_fastpath(struct bpf_insn_pos *pos, in gen_prologue_fastpath() argument
189 err = gen_ldx_reg_from_ctx(pos, BPF_REG_1, args[i].value, in gen_prologue_fastpath()
195 return check_pos(pos); in gen_prologue_fastpath()
242 gen_prologue_slowpath(struct bpf_insn_pos *pos, in gen_prologue_slowpath() argument
257 err = gen_ldx_reg_from_ctx(pos, BPF_REG_CTX, reg, in gen_prologue_slowpath()
266 ins(BPF_MOV64_REG(BPF_REG_7, BPF_REG_FP), pos); in gen_prologue_slowpath()
268 ins(BPF_ALU64_IMM(BPF_ADD, BPF_REG_7, stack_offset), pos); in gen_prologue_slowpath()
277 stack_offset), pos); in gen_prologue_slowpath()
288 err = gen_read_mem(pos, BPF_REG_3, BPF_REG_7, in gen_prologue_slowpath()
303 BPF_REG_FP, stack_offset), pos); in gen_prologue_slowpath()
314 BPF_REG_FP, -BPF_REG_SIZE * (i + 1)), pos); in gen_prologue_slowpath()
317 ins(BPF_JMP_IMM(BPF_JA, BPF_REG_0, 0, JMP_TO_SUCCESS_CODE), pos); in gen_prologue_slowpath()
319 return check_pos(pos); in gen_prologue_slowpath()
325 prologue_relocate(struct bpf_insn_pos *pos, struct bpf_insn *error_code, in prologue_relocate() argument
330 if (check_pos(pos)) in prologue_relocate()
333 for (insn = pos->begin; insn < pos->pos; insn++) { in prologue_relocate()
371 struct bpf_insn_pos pos; in bpf__gen_prologue() local
381 pos.begin = new_prog; in bpf__gen_prologue()
382 pos.end = new_prog + cnt_space; in bpf__gen_prologue()
383 pos.pos = new_prog; in bpf__gen_prologue()
387 &pos); in bpf__gen_prologue()
389 if (check_pos(&pos)) in bpf__gen_prologue()
392 *new_cnt = pos_get_cnt(&pos); in bpf__gen_prologue()
441 err = gen_prologue_fastpath(&pos, args, nargs); in bpf__gen_prologue()
448 ins(BPF_MOV64_REG(BPF_REG_CTX, BPF_REG_ARG1), &pos); in bpf__gen_prologue()
450 err = gen_prologue_slowpath(&pos, args, nargs); in bpf__gen_prologue()
462 error_code = pos.pos; in bpf__gen_prologue()
464 &pos); in bpf__gen_prologue()
470 &pos); in bpf__gen_prologue()
472 &pos); in bpf__gen_prologue()
480 success_code = pos.pos; in bpf__gen_prologue()
481 ins(BPF_ALU64_IMM(BPF_MOV, BPF_PROLOGUE_FETCH_RESULT_REG, 0), &pos); in bpf__gen_prologue()
487 user_code = pos.pos; in bpf__gen_prologue()
493 ins(BPF_MOV64_REG(BPF_REG_ARG1, BPF_REG_CTX), &pos); in bpf__gen_prologue()
494 err = prologue_relocate(&pos, error_code, success_code, in bpf__gen_prologue()
500 err = check_pos(&pos); in bpf__gen_prologue()
504 *new_cnt = pos_get_cnt(&pos); in bpf__gen_prologue()