mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2025-12-10 07:34:40 +01:00
Enable xdp-loader to attach multiple XDP programs to a single interface by backporting the BPF trampoline implementation from Linux kernel 6.17 to 6.12 for LoongArch64. The xdp-loader utility relies on libxdp, which in turn requires kernel support for BPF trampoline. While x86_64 and other architectures have this feature, LoongArch64 only gained it in kernel 6.17. Without this backport, xdp-loader fails on LoongArch64 systems running kernel 6.12. Changes backported include: - BPF trampoline infrastructure for LoongArch64 - Necessary JIT compiler updates - Related BPF subsystem changes This allows full compatibility with the xdp-tools ecosystem on LoongArch64 systems running older kernel versions. Reference: https://github.com/xdp-project/xdp-tools/tree/main/lib/libxdp Signed-off-by: Vincent Li <vincent.mc.li@gmail.com> Link: https://github.com/openwrt/openwrt/pull/21077 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
52 lines
1.5 KiB
Diff
52 lines
1.5 KiB
Diff
From ed1a1fe6ec5e73b23b310b434ace07d1e5060657 Mon Sep 17 00:00:00 2001
|
|
From: Chenghao Duan <duanchenghao@kylinos.cn>
|
|
Date: Tue, 5 Aug 2025 19:00:18 +0800
|
|
Subject: [PATCH 02/12] LoongArch: BPF: Rename and refactor validate_code()
|
|
|
|
1. Rename the existing validate_code() to validate_ctx()
|
|
2. Factor out the code validation handling into a new helper
|
|
validate_code()
|
|
|
|
Then:
|
|
|
|
* validate_code() is used to check the validity of code.
|
|
* validate_ctx() is used to check both code validity and table entry
|
|
correctness.
|
|
|
|
The new validate_code() will be used in subsequent changes.
|
|
|
|
Reviewed-by: Hengqi Chen <hengqi.chen@gmail.com>
|
|
Co-developed-by: George Guo <guodongtai@kylinos.cn>
|
|
Signed-off-by: George Guo <guodongtai@kylinos.cn>
|
|
Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
|
|
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
|
|
---
|
|
arch/loongarch/net/bpf_jit.c | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
--- a/arch/loongarch/net/bpf_jit.c
|
|
+++ b/arch/loongarch/net/bpf_jit.c
|
|
@@ -1170,6 +1170,14 @@ static int validate_code(struct jit_ctx
|
|
return -1;
|
|
}
|
|
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int validate_ctx(struct jit_ctx *ctx)
|
|
+{
|
|
+ if (validate_code(ctx))
|
|
+ return -1;
|
|
+
|
|
if (WARN_ON_ONCE(ctx->num_exentries != ctx->prog->aux->num_exentries))
|
|
return -1;
|
|
|
|
@@ -1278,7 +1286,7 @@ skip_init_ctx:
|
|
build_epilogue(&ctx);
|
|
|
|
/* 3. Extra pass to validate JITed code */
|
|
- if (validate_code(&ctx)) {
|
|
+ if (validate_ctx(&ctx)) {
|
|
bpf_jit_binary_free(header);
|
|
prog = orig_prog;
|
|
goto out_offset;
|