* Re: [PATCH v1] LoongArch: BPF: Implement arch_bpf_stack_walk()
@ 2026-08-25 4:13 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-08-25 4:13 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "linux-review patch is more than 7 days old, verify it wasn't already superseded"
::::::
BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20260813045306.21571-1-yangtiezhu@loongson.cn>
References: <20260813045306.21571-1-yangtiezhu@loongson.cn>
TO: Tiezhu Yang <yangtiezhu@loongson.cn>
TO: Huacai Chen <chenhuacai@kernel.org>
TO: Hengqi Chen <hengqi.chen@gmail.com>
CC: loongarch@lists.linux.dev
CC: bpf@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: George Guo <guodongtai@kylinos.cn>
Hi Tiezhu,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20260821]
[also build test ERROR on linus/master]
[cannot apply to bpf-next/master bpf/master bpf-next/net v7.2 v7.2-rc7 v7.2-rc6 v7.2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/LoongArch-BPF-Implement-arch_bpf_stack_walk/20260813-125306
base: next-20260821
patch link: https://lore.kernel.org/r/20260813045306.21571-1-yangtiezhu%40loongson.cn
patch subject: [PATCH v1] LoongArch: BPF: Implement arch_bpf_stack_walk()
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260825/202608251231.fQmOHVs6-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 935bfc708590c60147a79c7df145bb6e68b1d388)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/202608251231.fQmOHVs6-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202608251231.fQmOHVs6-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/loongarch/net/bpf_jit.c:2446:22: error: redefinition of 'walk_bpf_stackframe'
2446 | static noinline void walk_bpf_stackframe(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp),
| ^
arch/loongarch/net/bpf_jit.c:2372:22: note: previous definition is here
2372 | static noinline void walk_bpf_stackframe(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp),
| ^
>> arch/loongarch/net/bpf_jit.c:2467:6: error: redefinition of 'arch_bpf_stack_walk'
2467 | void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie)
| ^
arch/loongarch/net/bpf_jit.c:2393:6: note: previous definition is here
2393 | void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie)
| ^
2 errors generated.
vim +/walk_bpf_stackframe +2446 arch/loongarch/net/bpf_jit.c
637f7446933b6d George Guo 2026-08-13 2445
637f7446933b6d George Guo 2026-08-13 @2446 static noinline void walk_bpf_stackframe(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp),
637f7446933b6d George Guo 2026-08-13 2447 void *cookie, unsigned long fp)
637f7446933b6d George Guo 2026-08-13 2448 {
637f7446933b6d George Guo 2026-08-13 2449 struct pt_regs dummyregs;
637f7446933b6d George Guo 2026-08-13 2450 struct pt_regs *regs = &dummyregs;
637f7446933b6d George Guo 2026-08-13 2451 struct unwind_state state;
637f7446933b6d George Guo 2026-08-13 2452 unsigned long addr;
637f7446933b6d George Guo 2026-08-13 2453
637f7446933b6d George Guo 2026-08-13 2454 regs->regs[3] = (unsigned long)__builtin_frame_address(0);
637f7446933b6d George Guo 2026-08-13 2455 regs->csr_era = (unsigned long)__builtin_return_address(0);
637f7446933b6d George Guo 2026-08-13 2456 regs->regs[1] = 0;
637f7446933b6d George Guo 2026-08-13 2457 regs->regs[22] = fp;
637f7446933b6d George Guo 2026-08-13 2458
637f7446933b6d George Guo 2026-08-13 2459 for (unwind_start(&state, current, regs);
637f7446933b6d George Guo 2026-08-13 2460 !unwind_done(&state); unwind_next_frame(&state)) {
637f7446933b6d George Guo 2026-08-13 2461 addr = unwind_get_return_address(&state);
637f7446933b6d George Guo 2026-08-13 2462 if (!addr || !consume_fn(cookie, (u64)addr, (u64)state.sp, (u64)state.fp))
637f7446933b6d George Guo 2026-08-13 2463 break;
637f7446933b6d George Guo 2026-08-13 2464 }
637f7446933b6d George Guo 2026-08-13 2465 }
637f7446933b6d George Guo 2026-08-13 2466
637f7446933b6d George Guo 2026-08-13 @2467 void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie)
637f7446933b6d George Guo 2026-08-13 2468 {
637f7446933b6d George Guo 2026-08-13 2469 unsigned long fp;
637f7446933b6d George Guo 2026-08-13 2470
637f7446933b6d George Guo 2026-08-13 2471 /*
637f7446933b6d George Guo 2026-08-13 2472 * Capture the live frame pointer ($r22) at the very front-line before
637f7446933b6d George Guo 2026-08-13 2473 * any kernel C code clobbers it. This must be a thin wrapper with no
637f7446933b6d George Guo 2026-08-13 2474 * large stack locals to prevent the compiler from reusing $r22 early.
637f7446933b6d George Guo 2026-08-13 2475 */
637f7446933b6d George Guo 2026-08-13 2476 asm volatile("move %0, $r22" : "=r"(fp));
637f7446933b6d George Guo 2026-08-13 2477 walk_bpf_stackframe(consume_fn, cookie, fp);
637f7446933b6d George Guo 2026-08-13 2478 }
637f7446933b6d George Guo 2026-08-13 2479 #endif /* CONFIG_UNWINDER_ORC */
637f7446933b6d George Guo 2026-08-13 2480
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH v1] LoongArch: BPF: Implement arch_bpf_stack_walk()
@ 2026-08-13 4:53 Tiezhu Yang
0 siblings, 0 replies; 2+ messages in thread
From: Tiezhu Yang @ 2026-08-13 4:53 UTC (permalink / raw)
To: Huacai Chen, Hengqi Chen; +Cc: loongarch, bpf, linux-kernel, George Guo
From: George Guo <guodongtai@kylinos.cn>
Implement arch_bpf_stack_walk() on top of the ORC unwinder within
the LoongArch BPF JIT backend to provide generic BPF stack walking
capabilities.
This function is required by advanced BPF features, including timed
may_goto timeout tracing and BPF exceptions. It will be invoked in
the BPF core subsystem unwinding paths: bpf_prog_find_from_stack(),
bpf_stream_stage_dump_stack(), and bpf_throw().
Co-developed-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
This is an independent feature, so split it from
https://lore.kernel.org/loongarch/20260702022322.51033-6-dongtai.guo@linux.dev/
Based on the latest loongarch-next, tested on Loongson-3A6000.
arch/loongarch/net/bpf_jit.c | 38 ++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index 7533917c6d47..78c20df2a2f3 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -2402,6 +2402,44 @@ bool bpf_jit_supports_subprog_tailcalls(void)
return true;
}
+#if defined(CONFIG_UNWINDER_ORC)
+#include <asm/unwind.h>
+
+static noinline void walk_bpf_stackframe(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp),
+ void *cookie, unsigned long fp)
+{
+ struct pt_regs dummyregs;
+ struct pt_regs *regs = &dummyregs;
+ struct unwind_state state;
+ unsigned long addr;
+
+ regs->regs[3] = (unsigned long)__builtin_frame_address(0);
+ regs->csr_era = (unsigned long)__builtin_return_address(0);
+ regs->regs[1] = 0;
+ regs->regs[22] = fp;
+
+ for (unwind_start(&state, current, regs);
+ !unwind_done(&state); unwind_next_frame(&state)) {
+ addr = unwind_get_return_address(&state);
+ if (!addr || !consume_fn(cookie, (u64)addr, (u64)state.sp, (u64)state.fp))
+ break;
+ }
+}
+
+void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie)
+{
+ unsigned long fp;
+
+ /*
+ * Capture the live frame pointer ($r22) at the very front-line before
+ * any kernel C code clobbers it. This must be a thin wrapper with no
+ * large stack locals to prevent the compiler from reusing $r22 early.
+ */
+ asm volatile("move %0, $r22" : "=r"(fp));
+ walk_bpf_stackframe(consume_fn, cookie, fp);
+}
+#endif /* CONFIG_UNWINDER_ORC */
+
bool bpf_jit_supports_timed_may_goto(void)
{
return true;
--
2.42.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-25 4:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 4:13 [PATCH v1] LoongArch: BPF: Implement arch_bpf_stack_walk() kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2026-08-13 4:53 Tiezhu Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.