|
@@ -613,6 +613,32 @@ static const struct bpf_func_proto bpf_get_stackid_proto_tp = {
|
|
|
.arg3_type = ARG_ANYTHING,
|
|
|
};
|
|
|
|
|
|
+BPF_CALL_3(bpf_perf_prog_read_value_tp, struct bpf_perf_event_data_kern *, ctx,
|
|
|
+ struct bpf_perf_event_value *, buf, u32, size)
|
|
|
+{
|
|
|
+ int err = -EINVAL;
|
|
|
+
|
|
|
+ if (unlikely(size != sizeof(struct bpf_perf_event_value)))
|
|
|
+ goto clear;
|
|
|
+ err = perf_event_read_local(ctx->event, &buf->counter, &buf->enabled,
|
|
|
+ &buf->running);
|
|
|
+ if (unlikely(err))
|
|
|
+ goto clear;
|
|
|
+ return 0;
|
|
|
+clear:
|
|
|
+ memset(buf, 0, size);
|
|
|
+ return err;
|
|
|
+}
|
|
|
+
|
|
|
+static const struct bpf_func_proto bpf_perf_prog_read_value_proto_tp = {
|
|
|
+ .func = bpf_perf_prog_read_value_tp,
|
|
|
+ .gpl_only = true,
|
|
|
+ .ret_type = RET_INTEGER,
|
|
|
+ .arg1_type = ARG_PTR_TO_CTX,
|
|
|
+ .arg2_type = ARG_PTR_TO_UNINIT_MEM,
|
|
|
+ .arg3_type = ARG_CONST_SIZE,
|
|
|
+};
|
|
|
+
|
|
|
static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)
|
|
|
{
|
|
|
switch (func_id) {
|
|
@@ -620,6 +646,8 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)
|
|
|
return &bpf_perf_event_output_proto_tp;
|
|
|
case BPF_FUNC_get_stackid:
|
|
|
return &bpf_get_stackid_proto_tp;
|
|
|
+ case BPF_FUNC_perf_prog_read_value:
|
|
|
+ return &bpf_perf_prog_read_value_proto_tp;
|
|
|
default:
|
|
|
return tracing_func_proto(func_id);
|
|
|
}
|