From: Pu Lehui <pulehui@huaweicloud.com>
To: "Björn Töpel" <bjorn@kernel.org>,
bpf@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Puranjay Mohan <puranjay@kernel.org>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>, Pu Lehui <pulehui@huawei.com>,
Pu Lehui <pulehui@huaweicloud.com>
Subject: [PATCH bpf-next 4/4] riscv, bpf: Remove arch_bpf_trampoline_skip
Date: Tue, 1 Dec 2026 13:34:04 +0000 [thread overview]
Message-ID: <20261201133404.2227100-5-pulehui@huaweicloud.com> (raw)
In-Reply-To: <20261201133404.2227100-1-pulehui@huaweicloud.com>
From: Pu Lehui <pulehui@huawei.com>
Now that the preceding commit extends bpf_arch_text_poke() to cover the
functionality of arch_bpf_trampoline_skip(), the RV64-specific
implementation is redundant. Remove it in favor of the generic weak
implementation which calls bpf_arch_text_poke().
Also align the skip nop in invoke_bpf_prog() to 4 bytes with c.nop when
RVC is enabled, as bpf_arch_text_poke() requires 4-byte alignment for
atomic single-instruction patching.
Signed-off-by: Pu Lehui <pulehui@huawei.com>
---
arch/riscv/net/bpf_jit_comp64.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 3a533e26a0f1..89634c3bfa86 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -10,7 +10,6 @@
#include <linux/filter.h>
#include <linux/memory.h>
#include <linux/smp.h>
-#include <linux/stop_machine.h>
#include <asm/text-patching.h>
#include <asm/cfi.h>
#include <asm/percpu.h>
@@ -918,24 +917,6 @@ static int gen_poke_insn(void *target, void *ip, void *plt_slot, u32 *insn,
return 0;
}
-int arch_bpf_trampoline_skip(void *nop, void *target)
-{
- u32 old_insn = rv_nop();
- u32 new_insn = rv_jal(RV_REG_ZERO, (target - nop) >> 1);
- int ret;
-
- if (memcmp(nop, &old_insn, sizeof(old_insn)))
- return -EFAULT;
-
- cpus_read_lock();
- mutex_lock(&text_mutex);
- ret = patch_text(nop, &new_insn, sizeof(new_insn));
- mutex_unlock(&text_mutex);
- cpus_read_unlock();
-
- return ret;
-}
-
int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
enum bpf_text_poke_type new_t, void *old_addr,
void *new_addr)
@@ -1083,8 +1064,12 @@ static int invoke_bpf_prog(struct bpf_tramp_image *im, struct bpf_tramp_node *no
int ret, branch_off;
struct bpf_prog *p = node->link->prog;
int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie);
- void *skip = ctx->ro_insns + ctx->ninsns;
+ void *skip;
+ /* make sure skip address is 4-byte aligned */
+ if (rvc_enabled() && (ninsns_rvoff(ctx->ninsns) & 2))
+ emitc(rvc_nop(), ctx);
+ skip = ctx->ro_insns + ctx->ninsns;
/* nop, patched to a jal over this prog when it is detached */
emit(rv_nop(), ctx);
--
2.34.1
prev parent reply other threads:[~2026-12-01 13:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:34 [PATCH bpf-next 0/4] riscv, bpf: Miscellaneous JIT optimizations Pu Lehui
2026-12-01 13:34 ` [PATCH bpf-next 1/4] riscv, bpf: Fix forward jump offset calculation during JIT passes Pu Lehui
2026-12-01 13:34 ` [PATCH bpf-next 2/4] riscv, bpf: Reuse tailcall epilogue across tailcall sites Pu Lehui
2026-12-01 13:34 ` [PATCH bpf-next 3/4] riscv, bpf: Eliminate stop_machine in bpf_arch_text_poke with per-image PLT Pu Lehui
2026-12-01 14:19 ` bot+bpf-ci
2026-12-01 13:34 ` Pu Lehui [this message]
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=20261201133404.2227100-5-pulehui@huaweicloud.com \
--to=pulehui@huaweicloud.com \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®