Skip to content

Commit c690191

Browse files
iii-iAlexei Starovoitov
authored andcommitted
s390/bpf: Implement unconditional jump with 32-bit offset
Implement the cpuv4 unconditional jump with 32-bit offset, which is encoded as BPF_JMP32 | BPF_JA and stores the offset in the imm field. Reuse the existing BPF_JMP | BPF_JA logic. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Link: https://lore.kernel.org/r/20230919101336.2223655-8-iii@linux.ibm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 90f426d commit c690191

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

arch/s390/net/bpf_jit_comp.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
779779
int i, bool extra_pass, u32 stack_depth)
780780
{
781781
struct bpf_insn *insn = &fp->insnsi[i];
782+
s16 branch_oc_off = insn->off;
782783
u32 dst_reg = insn->dst_reg;
783784
u32 src_reg = insn->src_reg;
784785
int last, insn_count = 1;
@@ -1625,6 +1626,9 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
16251626
* instruction itself (loop) and for BPF with offset 0 we
16261627
* branch to the instruction behind the branch.
16271628
*/
1629+
case BPF_JMP32 | BPF_JA: /* if (true) */
1630+
branch_oc_off = imm;
1631+
fallthrough;
16281632
case BPF_JMP | BPF_JA: /* if (true) */
16291633
mask = 0xf000; /* j */
16301634
goto branch_oc;
@@ -1793,14 +1797,16 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
17931797
break;
17941798
branch_oc:
17951799
if (!is_first_pass(jit) &&
1796-
can_use_rel(jit, addrs[i + off + 1])) {
1800+
can_use_rel(jit, addrs[i + branch_oc_off + 1])) {
17971801
/* brc mask,off */
17981802
EMIT4_PCREL_RIC(0xa7040000,
1799-
mask >> 12, addrs[i + off + 1]);
1803+
mask >> 12,
1804+
addrs[i + branch_oc_off + 1]);
18001805
} else {
18011806
/* brcl mask,off */
18021807
EMIT6_PCREL_RILC(0xc0040000,
1803-
mask >> 12, addrs[i + off + 1]);
1808+
mask >> 12,
1809+
addrs[i + branch_oc_off + 1]);
18041810
}
18051811
break;
18061812
}

0 commit comments

Comments
 (0)