* [PATCH bpf-next] bpf: fix build on architectures with special bpf_user_pt_regs_t
@ 2020-07-24 20:05 Song Liu
2020-07-25 8:40 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Song Liu @ 2020-07-24 20:05 UTC (permalink / raw)
To: linux-kernel, bpf, netdev
Cc: ast, daniel, kernel-team, john.fastabend, kpsingh, brouer,
Song Liu, kernel test robot
Architectures like s390, powerpc, arm64, riscv have speical definition of
bpf_user_pt_regs_t. So we need to cast the pointer before passing it to
bpf_get_stack(). This is similar to bpf_get_stack_tp().
Fixes: 03d42fd2d83f ("bpf: Separate bpf_get_[stack|stackid] for perf events BPF")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
kernel/bpf/stackmap.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 5beb2f8c23da1..4fd830a62be2d 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -678,6 +678,7 @@ const struct bpf_func_proto bpf_get_task_stack_proto = {
BPF_CALL_4(bpf_get_stack_pe, struct bpf_perf_event_data_kern *, ctx,
void *, buf, u32, size, u64, flags)
{
+ struct pt_regs *regs = (struct pt_regs *)(ctx->regs);
struct perf_event *event = ctx->event;
struct perf_callchain_entry *trace;
bool kernel, user;
@@ -685,7 +686,7 @@ BPF_CALL_4(bpf_get_stack_pe, struct bpf_perf_event_data_kern *, ctx,
__u64 nr_kernel;
if (!(event->attr.sample_type & __PERF_SAMPLE_CALLCHAIN_EARLY))
- return __bpf_get_stack(ctx->regs, NULL, NULL, buf, size, flags);
+ return __bpf_get_stack(regs, NULL, NULL, buf, size, flags);
if (unlikely(flags & ~(BPF_F_SKIP_FIELD_MASK | BPF_F_USER_STACK |
BPF_F_USER_BUILD_ID)))
@@ -705,8 +706,7 @@ BPF_CALL_4(bpf_get_stack_pe, struct bpf_perf_event_data_kern *, ctx,
__u64 nr = trace->nr;
trace->nr = nr_kernel;
- err = __bpf_get_stack(ctx->regs, NULL, trace, buf,
- size, flags);
+ err = __bpf_get_stack(regs, NULL, trace, buf, size, flags);
/* restore nr */
trace->nr = nr;
@@ -718,8 +718,7 @@ BPF_CALL_4(bpf_get_stack_pe, struct bpf_perf_event_data_kern *, ctx,
goto clear;
flags = (flags & ~BPF_F_SKIP_FIELD_MASK) | skip;
- err = __bpf_get_stack(ctx->regs, NULL, trace, buf,
- size, flags);
+ err = __bpf_get_stack(regs, NULL, trace, buf, size, flags);
}
return err;
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: fix build on architectures with special bpf_user_pt_regs_t
2020-07-24 20:05 [PATCH bpf-next] bpf: fix build on architectures with special bpf_user_pt_regs_t Song Liu
@ 2020-07-25 8:40 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2020-07-25 8:40 UTC (permalink / raw)
To: Song Liu
Cc: LKML, bpf, Network Development, Alexei Starovoitov,
Daniel Borkmann, Kernel Team, John Fastabend, KP Singh,
Jesper Dangaard Brouer, kernel test robot
On Fri, Jul 24, 2020 at 1:08 PM Song Liu <songliubraving@fb.com> wrote:
>
> Architectures like s390, powerpc, arm64, riscv have speical definition of
> bpf_user_pt_regs_t. So we need to cast the pointer before passing it to
> bpf_get_stack(). This is similar to bpf_get_stack_tp().
>
> Fixes: 03d42fd2d83f ("bpf: Separate bpf_get_[stack|stackid] for perf events BPF")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Song Liu <songliubraving@fb.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-25 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 20:05 [PATCH bpf-next] bpf: fix build on architectures with special bpf_user_pt_regs_t Song Liu
2020-07-25 8:40 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.