32-bits offset issue preventing module to load,
Hello,
I have a Fedora RISC-V running fine in QEMU, using packaged kernel "5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64". Some modules won't load, such as openvswitch:
#####
$ sudo modprobe openvswitch ; dmesg | tail -1 modprobe: ERROR: could not insert 'openvswitch': Invalid argument [ 227.833317] openvswitch: target ffffffe0000d1fd8 can not be addressed by the 32-bit offset from PC = 00000000bcd11221 #####
The message is explicit, a 32-bits offset is not enough to access the data @ 0xffffffe0000d1fd8 from 0x00000000bcd11221. The relevant (I think) part of the System.map is:
#####
/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 D __init_end /usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 D __per_cpu_end /usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 T _stext /usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 T _text /usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 t trace_initcall_finish_cb
#####
As far as I can tell, the issue lies with the fact that the offending modules are using per-cpu data, an uncommon occurrence in modules (according to 'grep' ;-) ). I have a small reproducer that fails in the same way on my QEMU machine. It's small enough I can put it inline at the end of this mail (sometimes attachment gets stripped...). I get the same error in dmesg when trying to load it:
[ 585.528200] toto: target ffffffe0000d1fd8 can not be addressed by the 32-bit offset from PC = 00000000465adc9c
The test code works just fine on x86-64, I couldn't try another architecture.
Cordially,
Romain Dolbeau
##### toto.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kmod.h>
MODULE_LICENSE("GPL");MODULE_AUTHOR("None will accept the blame");MODULE_DESCRIPTION("Bug reproducer");MODULE_VERSION("0.01");
static DEFINE_PER_CPU(uint64_t[2], test_data);
static int __init toto_init(void) {
int i;
printk(KERN_INFO "Hello, World!\n");
for_each_possible_cpu(i) {
uint64_t *data = per_cpu(test_data, i);
printk(KERN_INFO "data for %d is %p\n", i, data);
}
return 0;
}static void __exit toto_exit(void) {
printk(KERN_INFO "Goodbye, World!\n");
}module_init(toto_init);module_exit(toto_exit);
##### Makefile
obj-m += toto.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
test:
sudo insmod toto.ko && sudo rmmod toto || true sudo dmesg | tail -5
#####
Signature · 10 lines
Romain Dolbeau _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi,
Quoted 10 lines · Romain Dolbeau
Hello,
I have a Fedora RISC-V running fine in QEMU, using packaged kernel "5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64". Some modules won't load, such as openvswitch:
#####
$ sudo modprobe openvswitch ; dmesg | tail -1 modprobe: ERROR: could not insert 'openvswitch': Invalid argument [ 227.833317] openvswitch: target ffffffe0000d1fd8 can not be addressed by the 32-bit offset from PC = 00000000bcd11221 #####
The same problem also happens on a 5.2.17 kernel (from the Debian package) with the scsi_mod loading (dependency of virtio_scsi):
[ 330.737763] scsi_mod: target ffffffe00007fa20 can not be addressed by the 32-bit offset from PC = 00000000e0712647
Quoted 9 lines
The message is explicit, a 32-bits offset is not enough to access the data @
0xffffffe0000d1fd8from0x00000000bcd11221. The relevant (I think) part of the System.map is:#####
/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 D__init_end/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 D__per_cpu_end/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 T_stext/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 T_text/usr/src/kernels/5.4.0-0.rc4.git0.300.1.riscv64.fc32.riscv64/System.map:ffffffe0000d1fd8 ttrace_initcall_finish_cb
#####
In my case, it points to the same symbols:
ffffffe00007fa18 D __init_endffffffe00007fa18 D __per_cpu_endffffffe00007fa18 T _stextffffffe00007fa18 T _textffffffe00007fa18 t trace_initcall_finish_cb
Aurelien
Signature · 7 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://www.aurel32.net _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv