bpf/samples: Fix PT_REGS_IP on s390x and use it
PATCH 1/1 bpf/samples: Fix PT_REGS_IP on s390x and use it
The files "sampleip_kern.c" and "trace_event_kern.c" directly access "ctx->regs.ip" which is not available on s390x. Fix this and use the PT_REGS_IP() macro instead.
Besides of that also fix the macro for s390x and use psw.addr from pt_regs.
Reported-by Zvonko Kosic <[email protected]>
Signed-off-by Michael Holzheu <[email protected]>
--- samples/bpf/bpf_helpers.h | 2 +- samples/bpf/sampleip_kern.c | 2 +- samples/bpf/trace_event_kern.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
samples/bpf/bpf_helpers.h +1 -1
@@ -113,7 +113,7 @@ static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) =#define PT_REGS_FP (x) ((x)->gprs[11])/* Works only with CONFIG_FRAME_POINTER */ #define PT_REGS_RC (x) ((x)->gprs[2])#define PT_REGS_SP (x) ((x)->gprs[15]) -#define PT_REGS_IP (x) ((x)->ip) +#define PT_REGS_IP (x) ((x)->psw.addr)#elif defined(__aarch64__)
samples/bpf/sampleip_kern.c +1 -1
@@ -25,7 +25,7 @@ int do_sample(struct bpf_perf_event_data *ctx)u64 ip;u32 *value, init_val =1 ; - ip = ctx->regs.ip; + ip =PT_REGS_IP (&ctx->regs); value =bpf_map_lookup_elem (&ip_map, &ip);if (value) *value +=1 ;
samples/bpf/trace_event_kern.c +1 -1
@@ -50,7 +50,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx) key.userstack =bpf_get_stackid (ctx, &stackmap,USER_STACKID_FLAGS );if ((int )key.kernstack <0 && (int )key.userstack <0 ) {bpf_trace_printk (fmt,sizeof (fmt), cpu, ctx->sample_period, - ctx->regs.ip); +PT_REGS_IP (&ctx->regs));return 0 ; }
Signature · 1 line
2.8.4
Quoted 8 lines · Michael Holzheu
The files "
sampleip_kern.c" and "trace_event_kern.c" directly access "ctx->regs.ip" which is not available on s390x. Fix this and use thePT_REGS_IP()macro instead.Besides of that also fix the macro for s390x and use psw.addr from
pt_regs.Reported-by Zvonko Kosic <[email protected]>Signed-off-by Michael Holzheu <[email protected]>
Looks good.
Please resubmit it to net-next and cc Dave.
note that my @plumgrid email no longer vaid.