Skip to content
Snippets Groups Projects
Commit 4da40ae7 authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Greg Kroah-Hartman
Browse files

s390/bpf: Fix 64-bit subtraction of the -0x80000000 constant


commit 6e61dc9d upstream.

The JIT uses agfi for subtracting constants, but -(-0x80000000) cannot
be represented as a 32-bit signed binary integer. Fix by using algfi in
this particular case.

Reported-by: default avatarJohan Almbladh <johan.almbladh@anyfinetworks.com>
Fixes: 05462310 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a5a5d371
No related branches found
No related tags found
No related merge requests found
...@@ -626,8 +626,13 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i ...@@ -626,8 +626,13 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i
case BPF_ALU64 | BPF_SUB | BPF_K: /* dst = dst - imm */ case BPF_ALU64 | BPF_SUB | BPF_K: /* dst = dst - imm */
if (!imm) if (!imm)
break; break;
/* agfi %dst,-imm */ if (imm == -0x80000000) {
EMIT6_IMM(0xc2080000, dst_reg, -imm); /* algfi %dst,0x80000000 */
EMIT6_IMM(0xc20a0000, dst_reg, 0x80000000);
} else {
/* agfi %dst,-imm */
EMIT6_IMM(0xc2080000, dst_reg, -imm);
}
break; break;
/* /*
* BPF_MUL * BPF_MUL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment