[PATCH v1 0/2] Fix the failure issue of the module_attach test case

Chenghao Duan posted 2 patches 2 months ago
There is a newer version of this series
arch/loongarch/kernel/mcount_dyn.S          | 14 +++++---
arch/loongarch/kernel/traps.c               |  7 +++-
arch/loongarch/net/bpf_jit.c                | 37 +++++++++++++++------
samples/ftrace/ftrace-direct-modify.c       |  8 ++---
samples/ftrace/ftrace-direct-multi-modify.c |  8 ++---
samples/ftrace/ftrace-direct-multi.c        |  4 +--
samples/ftrace/ftrace-direct-too.c          |  4 +--
samples/ftrace/ftrace-direct.c              |  4 +--
8 files changed, 56 insertions(+), 30 deletions(-)
[PATCH v1 0/2] Fix the failure issue of the module_attach test case
Posted by Chenghao Duan 2 months ago
The following test cases under the tools/testing/selftests/bpf/
directory have passed the test:

./test_progs -t module_attach
./test_progs -t module_fentry_shadow
./test_progs -t subprogs
./test_progs -t subprogs_extable
./test_progs -t tailcalls
./test_progs -t struct_ops -d struct_ops_multi_pages
./test_progs -t fexit_bpf2bpf
./test_progs -t fexit_stress
./test_progs -t module_fentry_shadow
./test_progs -t fentry_test/fentry
./test_progs -t fexit_test/fexit
./test_progs -t fentry_fexit
./test_progs -t modify_return
./test_progs -t fexit_sleep
./test_progs -t test_overhead
./test_progs -t trampoline_count

Chenghao Duan (2):
  LoongArch: Modify the jump logic of the trampoline
  LoongArch: BPF: Enable BPF exception fixup for specific ADE subcode

 arch/loongarch/kernel/mcount_dyn.S          | 14 +++++---
 arch/loongarch/kernel/traps.c               |  7 +++-
 arch/loongarch/net/bpf_jit.c                | 37 +++++++++++++++------
 samples/ftrace/ftrace-direct-modify.c       |  8 ++---
 samples/ftrace/ftrace-direct-multi-modify.c |  8 ++---
 samples/ftrace/ftrace-direct-multi.c        |  4 +--
 samples/ftrace/ftrace-direct-too.c          |  4 +--
 samples/ftrace/ftrace-direct.c              |  4 +--
 8 files changed, 56 insertions(+), 30 deletions(-)

-- 
2.25.1

Re: [PATCH v1 0/2] Fix the failure issue of the module_attach test case
Posted by Hengqi Chen 2 months ago
One minor question, I wonder how you debug these issues ?

On Tue, Dec 9, 2025 at 5:34 PM Chenghao Duan <duanchenghao@kylinos.cn> wrote:
>
> The following test cases under the tools/testing/selftests/bpf/
> directory have passed the test:
>
> ./test_progs -t module_attach
> ./test_progs -t module_fentry_shadow
> ./test_progs -t subprogs
> ./test_progs -t subprogs_extable
> ./test_progs -t tailcalls
> ./test_progs -t struct_ops -d struct_ops_multi_pages
> ./test_progs -t fexit_bpf2bpf
> ./test_progs -t fexit_stress
> ./test_progs -t module_fentry_shadow
> ./test_progs -t fentry_test/fentry
> ./test_progs -t fexit_test/fexit
> ./test_progs -t fentry_fexit
> ./test_progs -t modify_return
> ./test_progs -t fexit_sleep
> ./test_progs -t test_overhead
> ./test_progs -t trampoline_count
>
> Chenghao Duan (2):
>   LoongArch: Modify the jump logic of the trampoline
>   LoongArch: BPF: Enable BPF exception fixup for specific ADE subcode
>
>  arch/loongarch/kernel/mcount_dyn.S          | 14 +++++---
>  arch/loongarch/kernel/traps.c               |  7 +++-
>  arch/loongarch/net/bpf_jit.c                | 37 +++++++++++++++------
>  samples/ftrace/ftrace-direct-modify.c       |  8 ++---
>  samples/ftrace/ftrace-direct-multi-modify.c |  8 ++---
>  samples/ftrace/ftrace-direct-multi.c        |  4 +--
>  samples/ftrace/ftrace-direct-too.c          |  4 +--
>  samples/ftrace/ftrace-direct.c              |  4 +--
>  8 files changed, 56 insertions(+), 30 deletions(-)
>
> --
> 2.25.1
>
Re: [PATCH v1 0/2] Fix the failure issue of the module_attach test case
Posted by Chenghao Duan 2 months ago
On Wed, Dec 10, 2025 at 12:10:46PM +0800, Hengqi Chen wrote:
> One minor question, I wonder how you debug these issues ?
> 

There were initially two issues:
1. When monitoring the function addresses of kernel modules in the
module_attach test case, kernel panic would occur.
2. Illegal address access in the module_attach and subprogs_extable
test cases would lead to kernel panic.

These two issues were debugged by combining different methods for
different scenarios, including gdb, kgdb, embedding break instructions
in assembly code, and printing stack and register data.

Chenghao
> On Tue, Dec 9, 2025 at 5:34 PM Chenghao Duan <duanchenghao@kylinos.cn> wrote:
> >
> > The following test cases under the tools/testing/selftests/bpf/
> > directory have passed the test:
> >
> > ./test_progs -t module_attach
> > ./test_progs -t module_fentry_shadow
> > ./test_progs -t subprogs
> > ./test_progs -t subprogs_extable
> > ./test_progs -t tailcalls
> > ./test_progs -t struct_ops -d struct_ops_multi_pages
> > ./test_progs -t fexit_bpf2bpf
> > ./test_progs -t fexit_stress
> > ./test_progs -t module_fentry_shadow
> > ./test_progs -t fentry_test/fentry
> > ./test_progs -t fexit_test/fexit
> > ./test_progs -t fentry_fexit
> > ./test_progs -t modify_return
> > ./test_progs -t fexit_sleep
> > ./test_progs -t test_overhead
> > ./test_progs -t trampoline_count
> >
> > Chenghao Duan (2):
> >   LoongArch: Modify the jump logic of the trampoline
> >   LoongArch: BPF: Enable BPF exception fixup for specific ADE subcode
> >
> >  arch/loongarch/kernel/mcount_dyn.S          | 14 +++++---
> >  arch/loongarch/kernel/traps.c               |  7 +++-
> >  arch/loongarch/net/bpf_jit.c                | 37 +++++++++++++++------
> >  samples/ftrace/ftrace-direct-modify.c       |  8 ++---
> >  samples/ftrace/ftrace-direct-multi-modify.c |  8 ++---
> >  samples/ftrace/ftrace-direct-multi.c        |  4 +--
> >  samples/ftrace/ftrace-direct-too.c          |  4 +--
> >  samples/ftrace/ftrace-direct.c              |  4 +--
> >  8 files changed, 56 insertions(+), 30 deletions(-)
> >
> > --
> > 2.25.1
> >
Re: [PATCH v1 0/2] Fix the failure issue of the module_attach test case
Posted by Vincent Li 2 months ago
On Tue, Dec 9, 2025 at 1:34 AM Chenghao Duan <duanchenghao@kylinos.cn> wrote:
>
> The following test cases under the tools/testing/selftests/bpf/
> directory have passed the test:
>
> ./test_progs -t module_attach
> ./test_progs -t module_fentry_shadow
> ./test_progs -t subprogs
> ./test_progs -t subprogs_extable
> ./test_progs -t tailcalls
> ./test_progs -t struct_ops -d struct_ops_multi_pages
> ./test_progs -t fexit_bpf2bpf
> ./test_progs -t fexit_stress
> ./test_progs -t module_fentry_shadow
> ./test_progs -t fentry_test/fentry
> ./test_progs -t fexit_test/fexit
> ./test_progs -t fentry_fexit
> ./test_progs -t modify_return
> ./test_progs -t fexit_sleep
> ./test_progs -t test_overhead
> ./test_progs -t trampoline_count
>

Tested-by: Vincent Li <vincent.mc.li@gmail.com>

I tested above  and all passed OK, but I could not complete the full
bpf selftests because test_progs core dumped, don't think it is
related to your patch series.

./test_progs --deny=timer_lockup
...SNIP...
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
test_task_local_data_basic:PASS:pthread_create 0 nsec
test_task_local_data_basic_thread:FAIL:tld_get_data unexpected error: -12
#444/1   task_local_data/task_local_data_basic:FAIL
test_task_local_data_race:PASS:skel_open_and_load 0 nsec
test_task_local_data_race:PASS:calloc tld_keys 0 nsec
test_task_local_data_race:PASS:TLD_DEFINE_KEY 0 nsec
test_task_local_data_race:FAIL:265
#444/2   task_local_data/task_local_data_race:FAIL
#444     task_local_data:FAIL
Caught signal #11!
Stack trace:
./test_progs(crash_handler+0x28)[0x1205b74ac]
linux-vdso.so.1(__vdso_rt_sigreturn+0x0)[0x7ffffffc1084]
./test_progs[0x1204eb064]
./test_progs(test_task_local_data+0x40)[0x1204eb3f8]
./test_progs[0x1205b7bec]
./test_progs(main+0x6c0)[0x1205b9c70]
/lib64/libc.so.6(+0x2882c)[0x7ffff2f6082c]
/lib64/libc.so.6(__libc_start_main+0xa8)[0x7ffff2f60918]
./test_progs(_start+0x48)[0x12013a0c0]
Segmentation fault (core dumped)

> Chenghao Duan (2):
>   LoongArch: Modify the jump logic of the trampoline
>   LoongArch: BPF: Enable BPF exception fixup for specific ADE subcode
>
>  arch/loongarch/kernel/mcount_dyn.S          | 14 +++++---
>  arch/loongarch/kernel/traps.c               |  7 +++-
>  arch/loongarch/net/bpf_jit.c                | 37 +++++++++++++++------
>  samples/ftrace/ftrace-direct-modify.c       |  8 ++---
>  samples/ftrace/ftrace-direct-multi-modify.c |  8 ++---
>  samples/ftrace/ftrace-direct-multi.c        |  4 +--
>  samples/ftrace/ftrace-direct-too.c          |  4 +--
>  samples/ftrace/ftrace-direct.c              |  4 +--
>  8 files changed, 56 insertions(+), 30 deletions(-)
>
> --
> 2.25.1
>