Skip to content

Commit 30342fe

Browse files
Michael HolzheuMartin Schwidefsky
authored andcommitted
s390/bpf: clear correct BPF accumulator register
Currently we assumed the following BPF to eBPF register mapping: - BPF_REG_A -> BPF_REG_7 - BPF_REG_X -> BPF_REG_8 Unfortunately this mapping is wrong. The correct mapping is: - BPF_REG_A -> BPF_REG_0 - BPF_REG_X -> BPF_REG_7 So clear the correct registers and use the BPF_REG_A and BPF_REG_X macros instead of BPF_REG_0/7. Fixes: 0546231 ("s390/bpf: Add s390x eBPF JIT compiler backend") Cc: stable@vger.kernel.org # 4.0+ Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent cbfe8fa commit 30342fe

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎arch/s390/net/bpf_jit_comp.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ static void bpf_jit_prologue(struct bpf_jit *jit)
448448
EMIT6_DISP_LH(0xe3000000, 0x0004, REG_SKB_DATA, REG_0,
449449
BPF_REG_1, offsetof(struct sk_buff, data));
450450
}
451-
/* BPF compatibility: clear A (%b7) and X (%b8) registers */
452-
if (REG_SEEN(BPF_REG_7))
453-
/* lghi %b7,0 */
454-
EMIT4_IMM(0xa7090000, BPF_REG_7, 0);
455-
if (REG_SEEN(BPF_REG_8))
456-
/* lghi %b8,0 */
457-
EMIT4_IMM(0xa7090000, BPF_REG_8, 0);
451+
/* BPF compatibility: clear A (%b0) and X (%b7) registers */
452+
if (REG_SEEN(BPF_REG_A))
453+
/* lghi %ba,0 */
454+
EMIT4_IMM(0xa7090000, BPF_REG_A, 0);
455+
if (REG_SEEN(BPF_REG_X))
456+
/* lghi %bx,0 */
457+
EMIT4_IMM(0xa7090000, BPF_REG_X, 0);
458458
}
459459

460460
/*

0 commit comments

Comments
 (0)