Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf: Add helpers to access traced function arguments #2234

Closed
wants to merge 4 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf: Add helpers to access traced function arguments
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285

@kernel-patches-bot
Copy link
Author

Master branch: da54ab1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 866de40
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 942df4d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: db52f57
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 222c98c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

Nobody and others added 4 commits December 6, 2021 14:26
As suggested by Andrii, adding variables for registers and ip
address offsets, which makes the code more clear, rather than
abusing single stack_size variable for everything.

Also describing the stack layout in the comment.

There is no function change.

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Adding following helpers for tracing programs:

Get n-th argument of the traced function:
  long bpf_get_func_arg(void *ctx, u32 n, u64 *value)

Get return value of the traced function:
  long bpf_get_func_ret(void *ctx, u64 *value)

Get arguments count of the traced funtion:
  long bpf_get_func_arg_cnt(void *ctx)

The trampoline now stores number of arguments on ctx-8
address, so it's easy to verify argument index and find
return value argument's position.

Moving function ip address on the trampoline stack behind
the number of functions arguments, so it's now stored on
ctx-16 address if it's needed.

All helpers above are inlined by verifier.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding tests for get_func_[arg|ret|arg_cnt] helpers.
Using these helpers in fentry/fexit/fmod_ret programs.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@kernel-patches-bot
Copy link
Author

Master branch: d5284de
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=590285
version: 1

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=590285 expired. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant