s390/bpf: Fix optimizing out zero-extensions
authorIlya Leoshkevich <iii@linux.ibm.com>
Mon, 6 Sep 2021 13:04:14 +0000 (15:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:28:02 +0000 (12:28 +0200)
commitd92d3a9c2b6541f29f800fc2bd44620578b8f8a6
treebe7c7ac51590400303094e0057aaf2f70760b2ab
parent4a933932033854fc7be495ed966e47a42132a8c4
s390/bpf: Fix optimizing out zero-extensions

commit db7bee653859ef7179be933e7d1384644f795f26 upstream.

Currently the JIT completely removes things like `reg32 += 0`,
however, the BPF_ALU semantics requires the target register to be
zero-extended in such cases.

Fix by optimizing out only the arithmetic operation, but not the
subsequent zero-extension.

Reported-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/net/bpf_jit_comp.c