Skip to content

Commit 17864b9

Browse files
committed
ply: Use new read_kernel variants
In order to eliminate possible compatibility issues, we should update probe_read[_str] to the probe_read_kernel[_str] variants. Note that this requires linux kernel version 5.5 and above. Signed-off-by: Mingzheng Xing [email protected]
1 parent 54d3bbf commit 17864b9

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/libply/built-in/memory.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int str_ir_post(const struct func *func, struct node *n,
140140
ir_emit_ldbp(pb->ir, BPF_REG_1, n->sym->irs.stack);
141141
ir_emit_insn(ir, MOV_IMM((int32_t)type_sizeof(n->sym->type)), BPF_REG_2, 0);
142142
ir_emit_sym_to_reg(ir, BPF_REG_3, ptr->sym);
143-
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read_str), 0, 0);
143+
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read_kernel_str), 0, 0);
144144
return 0;
145145
}
146146

@@ -305,7 +305,7 @@ static int struct_dot_ir_pre(const struct func *func, struct node *n,
305305
sou->sym->irs.hint.dot = 1;
306306

307307
/* this also means we need to put ourselves on the
308-
* stack since data will be loaded via probe_read */
308+
* stack since data will be loaded via probe_read_kernel */
309309
n->sym->irs.hint.stack = 1;
310310
}
311311
return 0;
@@ -334,7 +334,7 @@ static int struct_dot_ir_post(const struct func *func, struct node *n,
334334

335335
ir_emit_sym_to_reg(pb->ir, BPF_REG_3, ptr->sym);
336336
ir_emit_insn(pb->ir, ALU64_IMM(BPF_ADD, offset), BPF_REG_3, 0);
337-
goto probe_read;
337+
goto probe_read_kernel;
338338
}
339339

340340
offset += sou->sym->irs.stack;
@@ -346,10 +346,10 @@ static int struct_dot_ir_post(const struct func *func, struct node *n,
346346
}
347347

348348
ir_emit_insn(pb->ir, ALU_IMM(BPF_ADD, offset), BPF_REG_3, 0);
349-
probe_read:
349+
probe_read_kernel:
350350
ir_emit_insn(pb->ir, MOV_IMM((int32_t)dst->size), BPF_REG_2, 0);
351351
ir_emit_ldbp(pb->ir, BPF_REG_1, dst->stack);
352-
ir_emit_insn(pb->ir, CALL(BPF_FUNC_probe_read), 0, 0);
352+
ir_emit_insn(pb->ir, CALL(BPF_FUNC_probe_read_kernel), 0, 0);
353353
/* TODO if (r0) exit(r0); */
354354
return 0;
355355
}

src/libply/ir.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ static const char *bpf_func_name(enum bpf_func_id id)
3838
return "map_update_elem";
3939
case BPF_FUNC_perf_event_output:
4040
return "perf_event_output";
41-
case BPF_FUNC_probe_read:
42-
return "probe_read";
43-
case BPF_FUNC_probe_read_str:
44-
return "probe_read_str";
41+
case BPF_FUNC_probe_read_kernel:
42+
return "probe_read_kernel";
43+
case BPF_FUNC_probe_read_kernel_str:
44+
return "probe_read_kernel_str";
4545
case BPF_FUNC_trace_printk:
4646
return "trace_printk";
4747
default:
@@ -416,7 +416,7 @@ void ir_emit_read_to_sym(struct ir *ir, struct sym *dst, uint16_t src)
416416
if (src != BPF_REG_3)
417417
ir_emit_insn(ir, MOV, BPF_REG_3, src);
418418

419-
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read), 0, 0);
419+
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read_kernel), 0, 0);
420420
/* TODO if (r0) exit(r0); */
421421
}
422422

src/libply/provider/tracepoint.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static int tracepoint_dyn_ir_post(const struct func *func, struct node *n,
6868
ir_emit_insn(ir, ALU_IMM(BPF_AND, 0xffff), BPF_REG_4, 0);
6969
ir_emit_insn(ir, ALU64(BPF_ADD), BPF_REG_3, BPF_REG_4);
7070

71-
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read), 0, 0);
71+
ir_emit_insn(ir, CALL(BPF_FUNC_probe_read_kernel), 0, 0);
7272
return 0;
7373
}
7474

0 commit comments

Comments
 (0)