

Mariano1977
Validating-
Posts
1 -
Joined
-
Last visited
-
Very simple module for nothing, Segmentation fault
Mariano1977 replied to Kopia's topic in Allwinner sunxi
Hello, I'm having the same issue. I can load a module but cannot lsmod or rmmod. What I'm going to show here it's a "hello world" test I've made in order to avoid any other kind of error or issue related to our specific code. First of all, we have an Orange PI Zero LTS with the following /proc/cpuinfo: model name : ARMv7 Processor rev 5 (v7l) Hardware : Allwinner sun8i Family Revision : 0000 I download the armbian distribution pointed from the Orange PI site and download the image: Armbian_community_25.5.0-trunk.334_Orangepizero_bookworm_current_6.6.75_minimal.img I have immediately updated thru the repos going from 6.6.75 kernel to 6.12.20: before: Linux orangepizero 6.6.75-current-sunxi #1 SMP Sat Feb 1 17:37:57 UTC 2025 armv7l GNU/Linux after: Linux orangepizero 6.12.20-current-sunxi #1 SMP Sat Mar 22 19:54:28 UTC 2025 armv7l GNU/Linux I installed the current headers: apt install -y linux-headers-current-sunxi and check that everything matches: # ll /lib/modules/6.12.20-current-sunxi/ total 3296 lrwxrwxrwx 1 root root 44 Apr 8 13:30 build -> /usr/src/linux-headers-6.12.20-current-sunxi drwxr-xr-x 11 root root 4096 Apr 11 08:44 kernel -rw-r--r-- 1 root root 821974 Apr 8 13:30 modules.alias -rw-r--r-- 1 root root 854778 Apr 8 13:30 modules.alias.bin -rw-r--r-- 1 root root 12059 Apr 8 13:30 modules.builtin -rw-r--r-- 1 root root 29861 Apr 8 13:30 modules.builtin.alias.bin -rw-r--r-- 1 root root 14691 Apr 8 13:30 modules.builtin.bin -rw-r--r-- 1 root root 90579 Apr 8 13:30 modules.builtin.modinfo -rw-r--r-- 1 root root 265245 Apr 8 13:30 modules.dep -rw-r--r-- 1 root root 399904 Apr 8 13:30 modules.dep.bin -rw-r--r-- 1 root root 251 Apr 8 13:30 modules.devname -rw-r--r-- 1 root root 124510 Apr 8 13:30 modules.order -rw-r--r-- 1 root root 882 Apr 8 13:30 modules.softdep -rw-r--r-- 1 root root 325137 Apr 8 13:30 modules.symbols -rw-r--r-- 1 root root 402929 Apr 8 13:30 modules.symbols.bin The compiler was algo updated: # gcc --version gcc (Debian 12.2.0-14) 12.2.0 Now, the "hello world" code is as simple as: #include <linux/module.h> #include <linux/init.h> static int my_init(void) { printk(KERN_INFO "hello world\n"); printk(KERN_DEBUG "hello world with debug\n"); printk(KERN_ERR "hello world with error\n"); return 0; } static void my_exit(void) { printk(KERN_INFO "Goodbye world!\n"); } module_init(my_init); module_exit(my_exit); MODULE_DESCRIPTION("Hello test"); MODULE_AUTHOR("Mariano <mariano1977@gmail.com>"); MODULE_LICENSE("GPL"); using the following Makefile: obj-m += hello.o PWD := $(CURDIR) all: $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean: $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean then I compile: # make make -C /lib/modules/6.12.20-current-sunxi/build M=/root/kernel_modules/test1 make[1]: Entering directory '/usr/src/linux-headers-6.12.20-current-sunxi' CC [M] /root/kernel_modules/test1/hello.o MODPOST /root/kernel_modules/test1/Module.symvers CC [M] /root/kernel_modules/test1/hello.mod.o CC [M] /root/kernel_modules/test1/.module-common.o LD [M] /root/kernel_modules/test1/hello.ko make[1]: Leaving directory '/usr/src/linux-headers-6.12.20-current-sunxi' # ll total 140 -rw-r--r-- 1 root root 463 Apr 11 09:03 hello.c -rw-r--r-- 1 root root 61208 Apr 11 09:37 hello.ko -rw-r--r-- 1 root root 35 Apr 11 09:37 hello.mod -rw-r--r-- 1 root root 373 Apr 11 09:37 hello.mod.c -rw-r--r-- 1 root root 48640 Apr 11 09:37 hello.mod.o -rw-r--r-- 1 root root 10084 Apr 11 09:37 hello.o -rw-r--r-- 1 root root 173 Apr 11 09:25 Makefile -rw-r--r-- 1 root root 35 Apr 11 09:37 modules.order -rw-r--r-- 1 root root 0 Apr 11 09:37 Module.symvers # modinfo hello.ko filename: /root/kernel_modules/test1/hello.ko license: GPL author: Mariano <mariano1977@gmail.com> description: Hello test depends: name: hello vermagic: 6.12.20-current-sunxi SMP mod_unload ARMv7 thumb2 p2v8 Comparing with a module builded in the distribution: # modinfo /lib/modules/6.12.20-current-sunxi/kernel/net/mac80211/mac80211.ko filename: /lib/modules/6.12.20-current-sunxi/kernel/net/mac80211/mac80211.ko license: GPL description: IEEE 802.11 subsystem depends: cfg80211,libarc4 intree: Y name: mac80211 vermagic: 6.12.20-current-sunxi SMP ll ARMv7 thumb2 p2v8 Now, let's load the module: insmod hello.ko and doing a "dmesg -WT" we get: [Fri Apr 11 09:38:48 2025] hello: loading out-of-tree module taints kernel. [Fri Apr 11 09:38:48 2025] hello world [Fri Apr 11 09:38:48 2025] hello world with debug [Fri Apr 11 09:38:48 2025] hello world with error now when i try to see the loaded modules (via "lsmod"): # lsmod Message from syslogd@orangepizero at Apr 11 09:40:20 ... kernel:[ 388.918263] Internal error: Oops: 5 [#1] SMP THUMB2 Message from syslogd@orangepizero at Apr 11 09:40:20 ... kernel:[ 389.208503] Process lsmod (pid: 1755, stack limit = 0x1cd292f3) Message from syslogd@orangepizero at Apr 11 09:40:20 ... kernel:[ 389.216263] Stack: (0xd17d1e00 to 0xd17d2000) ... Segmentation fault Taking a look at dmesg: [Fri Apr 11 09:40:18 2025] 8<--- cut here --- [Fri Apr 11 09:40:18 2025] Unable to handle kernel paging request at virtual address 7f586345 when read [Fri Apr 11 09:40:18 2025] [7f586345] *pgd=00000000 [Fri Apr 11 09:40:18 2025] Internal error: Oops: 5 [#1] SMP THUMB2 [Fri Apr 11 09:40:18 2025] Modules linked in: hello(O) lima xradio_wlan gpu_sched drm_shmem_helper sun8i_thermal mac80211 libarc4 cfg80211 cpufreq_dt rfkill zram zsmalloc uio_pdrv_genirq uio binfmt_misc usb_f_acm u_serial g_serial libcomposite dm_mod autofs4 ext4 mbcache jbd2 sunxi phy_generic pwrseq_simple ac200_phy [Fri Apr 11 09:40:18 2025] CPU: 1 UID: 0 PID: 1755 Comm: lsmod Tainted: G O 6.12.20-current-sunxi #1 [Fri Apr 11 09:40:18 2025] Tainted: [O]=OOT_MODULE [Fri Apr 11 09:40:19 2025] Hardware name: Allwinner sun8i Family [Fri Apr 11 09:40:19 2025] PC is at m_show+0x74/0x158 [Fri Apr 11 09:40:19 2025] LR is at m_show+0x65/0x158 [Fri Apr 11 09:40:19 2025] pc : [<c0192c1c>] lr : [<c0192c0d>] psr: 90070033 [Fri Apr 11 09:40:19 2025] sp : d17d1e00 ip : c9a9f00d fp : 00400cc0 [Fri Apr 11 09:40:19 2025] r10: 7ffff000 r9 : bfac4304 r8 : c0d8e0bc [Fri Apr 11 09:40:19 2025] r7 : bfac4040 r6 : bfac4044 r5 : c5f385f0 r4 : 7f586335 [Fri Apr 11 09:40:19 2025] r3 : 00000000 r2 : 00000000 r1 : 0000000e r0 : 0000000e [Fri Apr 11 09:40:19 2025] Flags: NzcV IRQs on FIQs on Mode SVC_32 ISA Thumb Segment none [Fri Apr 11 09:40:19 2025] Control: 50c5387d Table: 44e0006a DAC: 00000051 [Fri Apr 11 09:40:19 2025] Register r0 information: non-paged memory [Fri Apr 11 09:40:19 2025] Register r1 information: non-paged memory [Fri Apr 11 09:40:19 2025] Register r2 information: NULL pointer Message from syslogd@orangepizero at Apr 11 09:40:20 ... kernel:[ 388.918263] Internal error: Oops: 5 [#1] SMP THUMB2 [Fri Apr 11 09:40:19 2025] Register r3 information: NULL pointer [Fri Apr 11 09:40:19 2025] Register r4 information: non-paged memory [Fri Apr 11 09:40:19 2025] Register r5 information: slab vm_area_struct start c5f385f0 pointer offset 0 size 80 [Fri Apr 11 09:40:19 2025] Register r6 information: 1-page vmalloc region starting at 0xbfac4000 allocated at load_module+0x4fb/0x16c0 [Fri Apr 11 09:40:19 2025] Register r7 information: 1-page vmalloc region starting at 0xbfac4000 allocated at load_module+0x4fb/0x16c0 [Fri Apr 11 09:40:19 2025] Register r8 information: non-slab/vmalloc memory [Fri Apr 11 09:40:19 2025] Register r9 information: 1-page vmalloc region starting at 0xbfac4000 allocated at load_module+0x4fb/0x16c0 [Fri Apr 11 09:40:19 2025] Register r10 information: non-paged memory [Fri Apr 11 09:40:19 2025] Register r11 information: non-paged memory [Fri Apr 11 09:40:19 2025] Register r12 information: slab kmalloc-cg-4k start c9a9f000 pointer offset 13 size 4096 [Fri Apr 11 09:40:19 2025] Process lsmod (pid: 1755, stack limit = 0x1cd292f3) [Fri Apr 11 09:40:19 2025] Stack: (0xd17d1e00 to 0xd17d2000) [Fri Apr 11 09:40:19 2025] 1e00: c16067b0 00000000 00000000 ffffffff c9a9f000 3a44803b 67f90db3 3a44803b [Fri Apr 11 09:40:19 2025] 1e20: 00000400 c5f385f0 00000000 bfac4044 c5f38608 d17d1eb0 bfac4044 c030982f [Fri Apr 11 09:40:19 2025] 1e40: 00000000 00000000 d17d1e98 c5f38618 00000001 c4954000 0b1e5000 c9a67000 [Fri Apr 11 09:40:19 2025] 1e60: c5f38460 00000000 d17d1f80 c61a46c0 00000000 00000400 00000001 c0b217c4 [Fri Apr 11 09:40:19 2025] 1e80: c0351fcd c0309b7d 00000400 00000001 0133eca0 00000400 00000001 00000000 [Fri Apr 11 09:40:19 2025] 1ea0: d17d1e90 00000400 00000001 00000000 c61a46c0 00000000 00000000 00000000 [Fri Apr 11 09:40:19 2025] 1ec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000400 3a44803b [Fri Apr 11 09:40:19 2025] 1ee0: 00000400 c61a46c0 c49d3c00 0133eca0 d17d1f80 c02e5ef9 00001a55 c4e00048 [Fri Apr 11 09:40:19 2025] 1f00: c4e00048 00000000 00000000 00000000 c23954fc cc190108 00000000 3a44803b [Fri Apr 11 09:40:19 2025] 1f20: b6e94fff d17d1fb0 0133f0a4 00000817 c49d3c00 00000255 c9a67000 c0ac9d73 [Fri Apr 11 09:40:19 2025] 1f40: 00000000 c0ac9d73 00000000 00000000 00000000 3a44803b 00000000 c61a46c0 [Fri Apr 11 09:40:19 2025] 1f60: c61a46c0 00000000 00000000 c01002a0 c49d3c00 00000003 00000000 c02e672d [Fri Apr 11 09:40:19 2025] 1f80: 00000000 00000000 c01002a0 3a44803b bec84020 0133d2e0 000005e8 b6be0888 [Fri Apr 11 09:40:19 2025] 1fa0: 00000003 c0100061 0133d2e0 000005e8 00000003 0133eca0 00000400 00000001 [Fri Apr 11 09:40:19 2025] 1fc0: 0133d2e0 000005e8 b6be0888 00000003 0000000a bec842d4 00000000 00000000 [Fri Apr 11 09:40:19 2025] 1fe0: 00000003 bec84200 b6b7b37b b6af4656 40070030 00000003 00000000 00000000 [Fri Apr 11 09:40:19 2025] Call trace: [Fri Apr 11 09:40:19 2025] m_show from seq_read_iter+0xd3/0x37c [Fri Apr 11 09:40:19 2025] seq_read_iter from seq_read+0xa5/0xcc [Fri Apr 11 09:40:19 2025] seq_read from vfs_read+0x79/0x21c [Fri Apr 11 09:40:19 2025] vfs_read from ksys_read+0x45/0x9c [Fri Apr 11 09:40:19 2025] ksys_read from ret_fast_syscall+0x1/0x5c [Fri Apr 11 09:40:19 2025] Exception stack(0xd17d1fa8 to 0xd17d1ff0) [Fri Apr 11 09:40:19 2025] 1fa0: 0133d2e0 000005e8 00000003 0133eca0 00000400 00000001 [Fri Apr 11 09:40:19 2025] 1fc0: 0133d2e0 000005e8 b6be0888 00000003 0000000a bec842d4 00000000 00000000 [Fri Apr 11 09:40:19 2025] 1fe0: 00000003 bec84200 b6b7b37b b6af4656 [Fri Apr 11 09:40:19 2025] Code: f24e 08bc f2cc 08d8 (6922) 4641 [Fri Apr 11 09:40:19 2025] ---[ end trace 0000000000000000 ]--- I cannot find what's wrong... Does anyone have any idea of what can be happening? regards, Mariano