Commit 7fc8c362 authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik
Browse files

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: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Reviewed-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Tested-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 484a8ed8
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -624,16 +624,8 @@ static int get_probe_mem_regno(const u8 *insn)

bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)
{
	int regno;
	u8 *insn;

	regs->psw.addr = extable_fixup(x);
	insn = (u8 *)__rewind_psw(regs->psw, regs->int_code >> 16);
	regno = get_probe_mem_regno(insn);
	if (WARN_ON_ONCE(regno < 0))
		/* JIT bug - unexpected instruction. */
		return false;
	regs->gprs[regno] = 0;
	regs->gprs[x->data] = 0;
	return true;
}

@@ -641,16 +633,17 @@ static int bpf_jit_probe_mem(struct bpf_jit *jit, struct bpf_prog *fp,
			     int probe_prg, int nop_prg)
{
	struct exception_table_entry *ex;
	int reg, prg;
	s64 delta;
	u8 *insn;
	int prg;
	int i;

	if (!fp->aux->extable)
		/* Do nothing during early JIT passes. */
		return 0;
	insn = jit->prg_buf + probe_prg;
	if (WARN_ON_ONCE(get_probe_mem_regno(insn) < 0))
	reg = get_probe_mem_regno(insn);
	if (WARN_ON_ONCE(reg < 0))
		/* JIT bug - unexpected probe instruction. */
		return -1;
	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,
			return -1;
		ex->fixup = delta;
		ex->type = EX_TYPE_BPF;
		ex->data = reg;
		jit->excnt++;
	}
	return 0;