* [PATCH] bpf/samples: Fix PT_REGS_IP on s390x and use it
@ 2016-11-23 15:28 Michael Holzheu
2016-11-24 2:24 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Michael Holzheu @ 2016-11-23 15:28 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Heiko Carstens, Martin Schwidefsky, Zvonko Kosic, linux-kernel
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 <zvonko.kosic@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
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(-)
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index 90f44bd..dadd516 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -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__)
diff --git a/samples/bpf/sampleip_kern.c b/samples/bpf/sampleip_kern.c
index 774a681..ceabf31 100644
--- a/samples/bpf/sampleip_kern.c
+++ b/samples/bpf/sampleip_kern.c
@@ -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;
diff --git a/samples/bpf/trace_event_kern.c b/samples/bpf/trace_event_kern.c
index 71a8ed3..41b6115 100644
--- a/samples/bpf/trace_event_kern.c
+++ b/samples/bpf/trace_event_kern.c
@@ -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;
}
--
2.8.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] bpf/samples: Fix PT_REGS_IP on s390x and use it
2016-11-23 15:28 [PATCH] bpf/samples: Fix PT_REGS_IP on s390x and use it Michael Holzheu
@ 2016-11-24 2:24 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2016-11-24 2:24 UTC (permalink / raw)
To: Michael Holzheu
Cc: Heiko Carstens, Martin Schwidefsky, Zvonko Kosic, linux-kernel,
Daniel Borkmann
On Wed, Nov 23, 2016 at 04:28:39PM +0100, Michael Holzheu wrote:
> 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 <zvonko.kosic@de.ibm.com>
> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Looks good.
Acked-by: Alexei Starovoitov <ast@kernel.org>
Please resubmit it to net-next and cc Dave.
note that my @plumgrid email no longer vaid.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-24 2:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 15:28 [PATCH] bpf/samples: Fix PT_REGS_IP on s390x and use it Michael Holzheu
2016-11-24 2:24 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome