bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] s390/bpf: fix lcgr instruction encoding
@ 2019-08-12 15:03 Ilya Leoshkevich
  2019-08-12 15:46 ` Vasily Gorbik
  2019-08-12 16:06 ` Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2019-08-12 15:03 UTC (permalink / raw)
  To: bpf, netdev; +Cc: gor, heiko.carstens, Ilya Leoshkevich

"masking, test in bounds 3" fails on s390, because
BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0) ignores the top 32 bits of
BPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr.
The associated comment indicates that the code was intended to emit lcgr
in the first place, it's just that the wrong opcode was used.

Fix by using the correct opcode.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 arch/s390/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index e636728ab452..6299156f9738 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -863,7 +863,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i
 		break;
 	case BPF_ALU64 | BPF_NEG: /* dst = -dst */
 		/* lcgr %dst,%dst */
-		EMIT4(0xb9130000, dst_reg, dst_reg);
+		EMIT4(0xb9030000, dst_reg, dst_reg);
 		break;
 	/*
 	 * BPF_FROM_BE/LE
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] s390/bpf: fix lcgr instruction encoding
  2019-08-12 15:03 [PATCH bpf] s390/bpf: fix lcgr instruction encoding Ilya Leoshkevich
@ 2019-08-12 15:46 ` Vasily Gorbik
  2019-08-12 16:06 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Vasily Gorbik @ 2019-08-12 15:46 UTC (permalink / raw)
  To: Ilya Leoshkevich; +Cc: bpf, netdev, heiko.carstens

On Mon, Aug 12, 2019 at 05:03:32PM +0200, Ilya Leoshkevich wrote:
> "masking, test in bounds 3" fails on s390, because
> BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0) ignores the top 32 bits of
> BPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr.
> The associated comment indicates that the code was intended to emit lcgr
> in the first place, it's just that the wrong opcode was used.
> 
> Fix by using the correct opcode.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>  arch/s390/net/bpf_jit_comp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index e636728ab452..6299156f9738 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -863,7 +863,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i
>  		break;
>  	case BPF_ALU64 | BPF_NEG: /* dst = -dst */
>  		/* lcgr %dst,%dst */
> -		EMIT4(0xb9130000, dst_reg, dst_reg);
> +		EMIT4(0xb9030000, dst_reg, dst_reg);
>  		break;
>  	/*
>  	 * BPF_FROM_BE/LE
> -- 
> 2.21.0
> 
Please add
Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
or whatever it should be. With that:
Acked-by: Vasily Gorbik <gor@linux.ibm.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] s390/bpf: fix lcgr instruction encoding
  2019-08-12 15:03 [PATCH bpf] s390/bpf: fix lcgr instruction encoding Ilya Leoshkevich
  2019-08-12 15:46 ` Vasily Gorbik
@ 2019-08-12 16:06 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-08-12 16:06 UTC (permalink / raw)
  To: Ilya Leoshkevich, bpf, netdev; +Cc: gor, heiko.carstens

On 8/12/19 5:03 PM, Ilya Leoshkevich wrote:
> "masking, test in bounds 3" fails on s390, because
> BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0) ignores the top 32 bits of
> BPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr.
> The associated comment indicates that the code was intended to emit lcgr
> in the first place, it's just that the wrong opcode was used.
> 
> Fix by using the correct opcode.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-12 16:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 15:03 [PATCH bpf] s390/bpf: fix lcgr instruction encoding Ilya Leoshkevich
2019-08-12 15:46 ` Vasily Gorbik
2019-08-12 16:06 ` Daniel Borkmann

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).