Skip to content

Commit 7fc8c36

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/bpf: encode register within extable entry
Instead of decoding the instruction that faulted to get the register which needs to be zeroed, simply encode its number into the extable entries during code generation. This allows to get rid of a bit of code, and is also what other architectures are doing. Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 484a8ed commit 7fc8c36

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

arch/s390/net/bpf_jit_comp.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -624,33 +624,26 @@ static int get_probe_mem_regno(const u8 *insn)
624624

625625
bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)
626626
{
627-
int regno;
628-
u8 *insn;
629-
630627
regs->psw.addr = extable_fixup(x);
631-
insn = (u8 *)__rewind_psw(regs->psw, regs->int_code >> 16);
632-
regno = get_probe_mem_regno(insn);
633-
if (WARN_ON_ONCE(regno < 0))
634-
/* JIT bug - unexpected instruction. */
635-
return false;
636-
regs->gprs[regno] = 0;
628+
regs->gprs[x->data] = 0;
637629
return true;
638630
}
639631

640632
static int bpf_jit_probe_mem(struct bpf_jit *jit, struct bpf_prog *fp,
641633
int probe_prg, int nop_prg)
642634
{
643635
struct exception_table_entry *ex;
636+
int reg, prg;
644637
s64 delta;
645638
u8 *insn;
646-
int prg;
647639
int i;
648640

649641
if (!fp->aux->extable)
650642
/* Do nothing during early JIT passes. */
651643
return 0;
652644
insn = jit->prg_buf + probe_prg;
653-
if (WARN_ON_ONCE(get_probe_mem_regno(insn) < 0))
645+
reg = get_probe_mem_regno(insn);
646+
if (WARN_ON_ONCE(reg < 0))
654647
/* JIT bug - unexpected probe instruction. */
655648
return -1;
656649
if (WARN_ON_ONCE(probe_prg + insn_length(*insn) != nop_prg))
@@ -678,6 +671,7 @@ static int bpf_jit_probe_mem(struct bpf_jit *jit, struct bpf_prog *fp,
678671
return -1;
679672
ex->fixup = delta;
680673
ex->type = EX_TYPE_BPF;
674+
ex->data = reg;
681675
jit->excnt++;
682676
}
683677
return 0;

0 commit comments

Comments
 (0)