From: Geliang Tang <geliang@kernel.org>
To: Chenghao Duan <duanchenghao@kylinos.cn>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
yangtiezhu@loongson.cn, hengqi.chen@gmail.com,
chenhuacai@kernel.org
Cc: martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, kernel@xen0n.name,
linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
bpf@vger.kernel.org, guodongtai@kylinos.cn,
youling.tang@linux.dev, jianghaoran@kylinos.cn,
vincent.mc.li@gmail.com
Subject: Re: [PATCH v4 0/5] Support trampoline for LoongArch
Date: Sun, 27 Jul 2025 09:00:43 +0800 [thread overview]
Message-ID: <c4bf63161e13ce1b51a288b1fd0f3fb0b1170f22.camel@kernel.org> (raw)
In-Reply-To: <20250724141929.691853-1-duanchenghao@kylinos.cn>
Hi Chenghao, Huacai, Tuezhu,
I first discovered this Loongarch BPF trampoline issue when debugging
MPTCP BPF selftests on a Loongarch machine last June (see my commit
eef0532e900c "selftests/bpf: Null checks for links in bpf_tcp_ca"), and
reported it to Huachui. Tiezhu and I started implementing BPF
trampoline last June. I also called on more Chinese kernel engineers to
participate in the development of the Loongarch BPF trampoline at the
openEuler Developer Day 2024 and CLSF 2024 conferences. Although this
work was finally handed over to Chenghao, it is also necessary to
mention me as the reporter and our early developers in the commit log.
Thanks,
-Geliang
On Thu, 2025-07-24 at 22:19 +0800, Chenghao Duan wrote:
> v4:
> 1. Delete the #3 patch of version V3.
>
> 2. Add 5 NOP instructions in build_prologue().
> Reserve space for the move_imm + jirl instruction.
>
> 3. Differentiate between direct jumps and ftrace jumps of trampoline:
> direct jumps skip 5 instructions.
> ftrace jumps skip 2 instructions.
>
> 4. Remove the generation of BL jump instructions in
> emit_jump_and_link().
> After the trampoline ends, it will jump to the specified register.
> The BL instruction writes PC+4 to r1 instead of allowing the
> specification of rd.
>
> ---------------------------------------------------------------------
> --
> Historical Version:
> v3:
> 1. Patch 0003 adds EXECMEM_BPF memory type to the execmem subsystem.
>
> 2. Align the size calculated by arch_bpf_trampoline_size to page
> boundaries.
>
> 3. Add the flush icache operation to larch_insn_text_copy.
>
> 4. Unify the implementation of bpf_arch_xxx into the patch
> "0004-LoongArch-BPF-Add-bpf_arch_xxxxx-support-for-Loong.patch".
>
> 5. Change the patch order. Move the patch
> "0002-LoongArch-BPF-Update-the-code-to-rename-validate_.patch" before
> "0005-LoongArch-BPF-Add-bpf-trampoline-support-for-Loon.patch".
>
> URL for version v3:
> https://lore.kernel.org/all/20250709055029.723243-1-duanchenghao@kylinos.cn/
> ---------
> v2:
> 1. Change the fixmap in the instruction copy function to
> set_memory_xxx.
>
> 2. Change the implementation method of the following code.
> - arch_alloc_bpf_trampoline
> - arch_free_bpf_trampoline
> Use the BPF core's allocation and free functions.
>
> - bpf_arch_text_invalidate
> Operate with the function larch_insn_text_copy that carries
> memory attribute modifications.
>
> 3. Correct the incorrect code formatting.
>
> URL for version v2:
> https://lore.kernel.org/all/20250618105048.1510560-1-duanchenghao@kylinos.cn/
> ---------
> v1:
> Support trampoline for LoongArch. The following feature tests have
> been
> completed:
> 1. fentry
> 2. fexit
> 3. fmod_ret
>
> TODO: The support for the struct_ops feature will be provided in
> subsequent patches.
>
> URL for version v1:
> https://lore.kernel.org/all/20250611035952.111182-1-duanchenghao@kylinos.cn/
> ---------------------------------------------------------------------
> --
>
> Chenghao Duan (4):
> LoongArch: Add larch_insn_gen_{beq,bne} helpers
> LoongArch: BPF: Update the code to rename validate_code to
> validate_ctx
> LoongArch: BPF: Add bpf_arch_xxxxx support for Loongarch
> LoongArch: BPF: Add bpf trampoline support for Loongarch
>
> Tiezhu Yang (1):
> LoongArch: BPF: Add struct ops support for trampoline
>
> arch/loongarch/include/asm/inst.h | 3 +
> arch/loongarch/kernel/inst.c | 60 ++++
> arch/loongarch/net/bpf_jit.c | 521
> +++++++++++++++++++++++++++++-
> arch/loongarch/net/bpf_jit.h | 6 +
> 4 files changed, 589 insertions(+), 1 deletion(-)
next prev parent reply other threads:[~2025-07-27 1:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 14:19 Chenghao Duan
2025-07-24 14:19 ` [PATCH v4 1/5] LoongArch: Add larch_insn_gen_{beq,bne} helpers Chenghao Duan
2025-07-24 14:19 ` [PATCH v4 2/5] LoongArch: BPF: Update the code to rename validate_code to validate_ctx Chenghao Duan
2025-07-24 14:19 ` [PATCH v4 3/5] LoongArch: BPF: Add bpf_arch_xxxxx support for Loongarch Chenghao Duan
2025-07-28 2:30 ` Huacai Chen
2025-07-28 10:47 ` Hengqi Chen
2025-07-28 13:21 ` Chenghao Duan
2025-07-29 11:56 ` Chenghao Duan
2025-07-28 10:58 ` Hengqi Chen
2025-07-28 12:59 ` Chenghao Duan
2025-07-24 14:19 ` [PATCH v4 4/5] LoongArch: BPF: Add bpf trampoline " Chenghao Duan
2025-07-28 2:03 ` Geliang Tang
2025-07-28 10:50 ` Hengqi Chen
2025-07-24 14:19 ` [PATCH v4 5/5] LoongArch: BPF: Add struct ops support for trampoline Chenghao Duan
2025-07-28 10:55 ` Hengqi Chen
2025-07-28 13:34 ` Chenghao Duan
2025-07-29 2:32 ` Huacai Chen
2025-07-24 15:30 ` [PATCH v4 0/5] Support trampoline for LoongArch Vincent Li
2025-07-25 10:18 ` Chenghao Duan
2025-07-26 19:14 ` Daniel Borkmann
2025-07-27 1:00 ` Geliang Tang [this message]
2025-07-28 2:42 ` Huacai Chen
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=c4bf63161e13ce1b51a288b1fd0f3fb0b1170f22.camel@kernel.org \
--to=geliang@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=duanchenghao@kylinos.cn \
--cc=eddyz87@gmail.com \
--cc=guodongtai@kylinos.cn \
--cc=haoluo@google.com \
--cc=hengqi.chen@gmail.com \
--cc=jianghaoran@kylinos.cn \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel@xen0n.name \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=vincent.mc.li@gmail.com \
--cc=yangtiezhu@loongson.cn \
--cc=yonghong.song@linux.dev \
--cc=youling.tang@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®