From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=124.71.94.104 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796131770; b=FOTGRc/Xz2xuA3YzHwl8x3hdO34ZZ48EDaUblHc2pdQs82taAtzRCWU6IMFTgB3fIT9G oONP+L+CcZ0tCsvX3WLjP0oB1zVF15kGsHnkbcBwoKWCW0HfxkeXL9JFBfrR2o/j/ORME scqj2F4cd7ZnBriqgZelhwlNKo6AxnDTU5iD2irh31qznyn+OMimba+gcXuo3DOU0wi90 i2eZlLsHxdvKPQU5oeJbsFzBFa1JTdPVYhd9Tc7UuL41xTFzORW/fFoN403F+h1aOLvhP u0+QM30cSE5ZqNpRDbru3hEEDOmVKhi0C7lD69Ia7ZRe75A42TUJh0dN7Xqbv+Bm0Bw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131770; h=DMARC-Filter:Received:Received:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=XPWLsfuobrCJgAgQuzpla+av5Kv4ho43mBL+ECCx+GI=; b=a+GPR2ZHUaZrdWX7u12jPMH02+5Gf7oaEV9bdCGzgzLSpqIutAzzG1jmQUGgvGQZrege Ei+7ooEQs3F2bN1eJFvMG4gxpTarKZbwcA1BtEICYe2xO5n5M0ZSI2ygQY853KBG563UX sHeODC2B1WIzh+qo/mziQaPOWWCapISIE1ko1g/rhxjSvhDrvEF9wH1rcZTk0qHZc7OOV RUMDf7yhEDwLefLrzs/Co2HrK6xney4qxqEbFtm80/f+y2glIaSKwTBijqUg5kpt308iq Gi0DfF2p5CAvL5fsTBtTN91IAP+p2SntuW6uqtK0zKceSG7Go7YNU+CX6YnZ+Jy7LGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.remote-ip=124.71.94.104 Received: from dggmsgout13.his.huawei.com (dggmsgout13.his.huawei.com [124.71.94.104]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BF37606A329; Tue, 1 Dec 2026 13:29:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6BF37606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.170]) by dggmsgout13.his.huawei.com (SkyGuard) with ESMTP id 4jf1v65FNjz1rrH0; Tue, 1 Dec 2026 21:29:06 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id DED0A4056B; Tue, 1 Dec 2026 21:29:20 +0800 (CST) Received: from ultra.huawei.com (unknown [10.90.53.71]) by APP4 (Coremail) with UTF8SMTPA id gCh0CgCHveyvyw5roXYmGg--.32601S6; Tue, 01 Dec 2026 21:29:20 +0800 (CST) From: Pu Lehui To: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Puranjay Mohan , Paul Walmsley , Palmer Dabbelt , Alexandre Ghiti , Pu Lehui , Pu Lehui Subject: [PATCH bpf-next 4/4] riscv, bpf: Remove arch_bpf_trampoline_skip Date: Tue, 1 Dec 2026 13:34:04 +0000 Message-Id: <20261201133404.2227100-5-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261201133404.2227100-1-pulehui@huaweicloud.com> References: <20261201133404.2227100-1-pulehui@huaweicloud.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:gCh0CgCHveyvyw5roXYmGg--.32601S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw4Uur48GFy8Jr1fZrWkJFb_yoW8KrWkpF sxCrsxArWDXr48XFn2qa18Xr15t3yvgF17WrWvkay0yay2vr9xtFWvkw1Yvr9YkFW8Cr1a vFZ09asxZw1DZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ From: Pu Lehui 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 --- 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 #include #include -#include #include #include #include @@ -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