From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH bpf-next 02/10] s390/bpf: Get rid of get_probe_mem_regno()
Date: Thu, 27 Jun 2024 11:07:05 +0200 [thread overview]
Message-ID: <20240627090900.20017-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20240627090900.20017-1-iii@linux.ibm.com>
Commit 7fc8c362e782 ("s390/bpf: encode register within extable entry")
introduced explicit passing of the number of the register to be cleared
to ex_handler_bpf(), which replaced deducing it from the respective
native load instruction using get_probe_mem_regno().
Replace the second and last usage in the same manner, and remove this
function.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
arch/s390/net/bpf_jit_comp.c | 33 +++++++--------------------------
1 file changed, 7 insertions(+), 26 deletions(-)
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 260e7009784b..d9d79aa2be1b 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -667,25 +667,6 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
jit->prg += sizeof(struct bpf_plt);
}
-static int get_probe_mem_regno(const u8 *insn)
-{
- /*
- * insn must point to llgc, llgh, llgf, lg, lgb, lgh or lgf, which have
- * destination register at the same position.
- */
- if (insn[0] != 0xe3) /* common prefix */
- return -1;
- if (insn[5] != 0x90 && /* llgc */
- insn[5] != 0x91 && /* llgh */
- insn[5] != 0x16 && /* llgf */
- insn[5] != 0x04 && /* lg */
- insn[5] != 0x77 && /* lgb */
- insn[5] != 0x15 && /* lgh */
- insn[5] != 0x14) /* lgf */
- return -1;
- return insn[1] >> 4;
-}
-
bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)
{
regs->psw.addr = extable_fixup(x);
@@ -699,12 +680,14 @@ bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)
struct bpf_jit_probe {
int prg; /* JITed instruction offset */
int nop_prg; /* JITed nop offset */
+ int reg; /* Register to clear on exception */
};
static void bpf_jit_probe_init(struct bpf_jit_probe *probe)
{
probe->prg = -1;
probe->nop_prg = -1;
+ probe->reg = -1;
}
/*
@@ -725,7 +708,7 @@ static int bpf_jit_probe_mem(struct bpf_jit *jit, struct bpf_prog *fp,
struct bpf_jit_probe *probe)
{
struct exception_table_entry *ex;
- int i, prg, reg;
+ int i, prg;
s64 delta;
u8 *insn;
@@ -734,10 +717,6 @@ static int bpf_jit_probe_mem(struct bpf_jit *jit, struct bpf_prog *fp,
/* Do nothing during early JIT passes. */
return 0;
insn = jit->prg_buf + probe->prg;
- 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) != probe->nop_prg))
/* JIT bug - gap between probe and nop instructions. */
return -1;
@@ -763,7 +742,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;
+ ex->data = probe->reg;
jit->excnt++;
}
return 0;
@@ -821,8 +800,10 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
bpf_jit_probe_init(&probe);
if (BPF_CLASS(insn->code) == BPF_LDX &&
(BPF_MODE(insn->code) == BPF_PROBE_MEM ||
- BPF_MODE(insn->code) == BPF_PROBE_MEMSX))
+ BPF_MODE(insn->code) == BPF_PROBE_MEMSX)) {
probe.prg = jit->prg;
+ probe.reg = reg2hex[dst_reg];
+ }
switch (insn->code) {
/*
--
2.45.2
next prev parent reply other threads:[~2024-06-27 9:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 9:07 [PATCH bpf-next 00/10] s390/bpf: Implement arena Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 01/10] s390/bpf: Factor out emitting probe nops Ilya Leoshkevich
2024-06-27 9:07 ` Ilya Leoshkevich [this message]
2024-06-27 9:07 ` [PATCH bpf-next 03/10] s390/bpf: Introduce pre- and post- probe functions Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 04/10] s390/bpf: Land on the next JITed instruction after exception Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 05/10] s390/bpf: Support BPF_PROBE_MEM32 Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 06/10] s390/bpf: Support address space cast instruction Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 07/10] s390/bpf: Enable arena Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 08/10] s390/bpf: Support arena atomics Ilya Leoshkevich
2024-06-28 0:43 ` Alexei Starovoitov
2024-06-28 9:09 ` Ilya Leoshkevich
2024-06-27 9:07 ` [PATCH bpf-next 09/10] selftests/bpf: Add UAF tests for " Ilya Leoshkevich
2024-06-28 0:45 ` Alexei Starovoitov
2024-06-28 9:13 ` Ilya Leoshkevich
2024-07-03 2:10 ` kernel test robot
2024-06-27 9:07 ` [PATCH bpf-next 10/10] selftests/bpf: Remove arena tests from DENYLIST.s390x Ilya Leoshkevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240627090900.20017-3-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox