* [PATCH net 1/2] s390/bpf: fix stack allocation
@ 2015-06-02 5:48 Alexei Starovoitov
2015-06-02 5:48 ` [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup Alexei Starovoitov
2015-06-04 2:32 ` [PATCH net 1/2] s390/bpf: fix stack allocation David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2015-06-02 5:48 UTC (permalink / raw)
To: David S. Miller
Cc: Michael Holzheu, Martin Schwidefsky, Heiko Carstens,
Daniel Borkmann, netdev
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
On s390x we have to provide 160 bytes stack space before we can call
the next function. From the 160 bytes that we got from the previous
function we only use 11 * 8 bytes and have 160 - 11 * 8 bytes left.
Currently for BPF we allocate additional 160 - 11 * 8 bytes for the
next function. This is wrong because then the next function only gets:
(160 - 11 * 8) + (160 - 11 * 8) = 2 * 72 = 144 bytes
Fix this and allocate enough memory for the next function.
Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
Resubmitting against 'net' with proper 'Fixes' tag.
arch/s390/net/bpf_jit.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/s390/net/bpf_jit.h b/arch/s390/net/bpf_jit.h
index ba8593a515ba..de156ba3bd71 100644
--- a/arch/s390/net/bpf_jit.h
+++ b/arch/s390/net/bpf_jit.h
@@ -48,7 +48,9 @@ extern u8 sk_load_word[], sk_load_half[], sk_load_byte[];
* We get 160 bytes stack space from calling function, but only use
* 11 * 8 byte (old backchain + r15 - r6) for storing registers.
*/
-#define STK_OFF (MAX_BPF_STACK + 8 + 4 + 4 + (160 - 11 * 8))
+#define STK_SPACE (MAX_BPF_STACK + 8 + 4 + 4 + 160)
+#define STK_160_UNUSED (160 - 11 * 8)
+#define STK_OFF (STK_SPACE - STK_160_UNUSED)
#define STK_OFF_TMP 160 /* Offset of tmp buffer on stack */
#define STK_OFF_HLEN 168 /* Offset of SKB header length on stack */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup
2015-06-02 5:48 [PATCH net 1/2] s390/bpf: fix stack allocation Alexei Starovoitov
@ 2015-06-02 5:48 ` Alexei Starovoitov
2015-06-04 2:32 ` David Miller
2015-06-04 2:32 ` [PATCH net 1/2] s390/bpf: fix stack allocation David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2015-06-02 5:48 UTC (permalink / raw)
To: David S. Miller
Cc: Michael Holzheu, Martin Schwidefsky, Heiko Carstens,
Daniel Borkmann, netdev
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Currently the bpf frame pointer is set to the old r15. This is
wrong because of packed stack. Fix this and adjust the frame pointer
to respect packed stack. This now generates a prolog like the following:
3ff8001c3fa: eb67f0480024 stmg %r6,%r7,72(%r15)
3ff8001c400: ebcff0780024 stmg %r12,%r15,120(%r15)
3ff8001c406: b904001f lgr %r1,%r15 <- load backchain
3ff8001c40a: 41d0f048 la %r13,72(%r15) <- load adjusted bfp
3ff8001c40e: a7fbfd98 aghi %r15,-616
3ff8001c412: e310f0980024 stg %r1,152(%r15) <- save backchain
Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
arch/s390/net/bpf_jit_comp.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 20c146d1251a..55423d8be580 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -384,13 +384,16 @@ static void bpf_jit_prologue(struct bpf_jit *jit)
}
/* Setup stack and backchain */
if (jit->seen & SEEN_STACK) {
- /* lgr %bfp,%r15 (BPF frame pointer) */
- EMIT4(0xb9040000, BPF_REG_FP, REG_15);
+ if (jit->seen & SEEN_FUNC)
+ /* lgr %w1,%r15 (backchain) */
+ EMIT4(0xb9040000, REG_W1, REG_15);
+ /* la %bfp,STK_160_UNUSED(%r15) (BPF frame pointer) */
+ EMIT4_DISP(0x41000000, BPF_REG_FP, REG_15, STK_160_UNUSED);
/* aghi %r15,-STK_OFF */
EMIT4_IMM(0xa70b0000, REG_15, -STK_OFF);
if (jit->seen & SEEN_FUNC)
- /* stg %bfp,152(%r15) (backchain) */
- EMIT6_DISP_LH(0xe3000000, 0x0024, BPF_REG_FP, REG_0,
+ /* stg %w1,152(%r15) (backchain) */
+ EMIT6_DISP_LH(0xe3000000, 0x0024, REG_W1, REG_0,
REG_15, 152);
}
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 1/2] s390/bpf: fix stack allocation
2015-06-02 5:48 [PATCH net 1/2] s390/bpf: fix stack allocation Alexei Starovoitov
2015-06-02 5:48 ` [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup Alexei Starovoitov
@ 2015-06-04 2:32 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-06-04 2:32 UTC (permalink / raw)
To: ast; +Cc: holzheu, schwidefsky, heiko.carstens, daniel, netdev
From: Alexei Starovoitov <ast@plumgrid.com>
Date: Mon, 1 Jun 2015 22:48:34 -0700
> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>
> On s390x we have to provide 160 bytes stack space before we can call
> the next function. From the 160 bytes that we got from the previous
> function we only use 11 * 8 bytes and have 160 - 11 * 8 bytes left.
> Currently for BPF we allocate additional 160 - 11 * 8 bytes for the
> next function. This is wrong because then the next function only gets:
>
> (160 - 11 * 8) + (160 - 11 * 8) = 2 * 72 = 144 bytes
>
> Fix this and allocate enough memory for the next function.
>
> Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup
2015-06-02 5:48 ` [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup Alexei Starovoitov
@ 2015-06-04 2:32 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-06-04 2:32 UTC (permalink / raw)
To: ast; +Cc: holzheu, schwidefsky, heiko.carstens, daniel, netdev
From: Alexei Starovoitov <ast@plumgrid.com>
Date: Mon, 1 Jun 2015 22:48:35 -0700
> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
>
> Currently the bpf frame pointer is set to the old r15. This is
> wrong because of packed stack. Fix this and adjust the frame pointer
> to respect packed stack. This now generates a prolog like the following:
>
> 3ff8001c3fa: eb67f0480024 stmg %r6,%r7,72(%r15)
> 3ff8001c400: ebcff0780024 stmg %r12,%r15,120(%r15)
> 3ff8001c406: b904001f lgr %r1,%r15 <- load backchain
> 3ff8001c40a: 41d0f048 la %r13,72(%r15) <- load adjusted bfp
> 3ff8001c40e: a7fbfd98 aghi %r15,-616
> 3ff8001c412: e310f0980024 stg %r1,152(%r15) <- save backchain
>
> Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-04 2:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 5:48 [PATCH net 1/2] s390/bpf: fix stack allocation Alexei Starovoitov
2015-06-02 5:48 ` [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup Alexei Starovoitov
2015-06-04 2:32 ` David Miller
2015-06-04 2:32 ` [PATCH net 1/2] s390/bpf: fix stack allocation David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).