Module load (insmod) Unknown symbol

Hi,

I am trying to to insert a driver (successuffly compiled) on to the Poplar Board but I’m getting the “unknown symbol” error when I try to load it with insmod.

 Unknown symbol __check_object_size (err 0)
 Unknown symbol __check_object_size (err 0)
 Unknown symbol kmem_cache_alloc_trace (err 0)
 Unknown symbol kmem_cache_alloc_trace (err 0)
 Unknown symbol _mcount (err 0)
 Unknown symbol _mcount (err 0)

I know this error is related to some missing module, but I don’t know how to ensure what module is missing.

uname output is:

Linux poplar 4.9.51-g6f2c493-dirty #1 SMP PREEMPT Thu Feb 21 16:44:02 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

modinfo output is:

license: GPL
depends:
vermagic: 4.9.51-g6f2c493-dirty SMP preempt mod_unload aarch64
parm: rx_pool_size:receive pool size (default 5MB) (int)
parm: tx_pool_size:transmit pool size (default 5MB) (int)
parm: aspm_enable:enable ASPM (int)

I compiled the module like this:
-build this kernel https://github.com/96boards-poplar/linux/commits/poplar-4.9 on to a fedora machine with the .config taken from Poplar board (/proc/config.gz).
-build the module with that kernel
-cross_compile both of them (kernel and module) with https://releases.linaro.org/components/toolchain/binaries/7.1-2017.08/aarch64-linux-gnu/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu.tar.xz
-simple copy the module.ko file to poplar board and get that error when I try to load it with insmod.

What exactly is causing this error and what is the best way to solve it ?
Thank you in advance.
Best regards,
Emi

This looks like a config mismatch to me.

I know you said you copied the config from /proc/config.gz but I think
something has gone wrong. It looks like the module has been compiled
with symbols (including but perhaps not limited to
CONFIG_HARDENED_USERCOPY and CONFIG_TRACING) that were not enabled in
the main kernel.

Daniel.

Thanks for the reply.

I enable the CONFIG_HARDENED_USERCOPY and CONFIG_TRACING_SUPPORT ( I could not found the CONFIG_TRACING)

When I compile the kernel with the make ARCH=arm64 CROSS_COMPILE=/opt/gcc-linaro-7.1.1-2017.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- I get the error:

drivers/built-in.o: In function hisi_ion_parse_cmdline': :(.text+0x2cb978): undefined reference tohisi_get_cma_device’
drivers/built-in.o: In function hisi_get_cma_heap': :(.text+0x2cba4c): undefined reference tohisi_get_cma_zone’
make: *** [Makefile:1063: vmlinux] Error 1

I know this is causing by a linking error when it tries to form the executable files, the code looks right.
The compiler or the way I compile is the problem?

Thank you.
Best regards,
Emi

I’m not sure how this happens, and I can not reproduce the problem on my side. Both hisi_get_cma_device() and hisi_get_cma_zone() are in drivers/hisilicon/cma/hi_cma.c which should be built, since we have CONFIG_CMA=y in poplar_defconfig.

I have modify the .config file and now I can compile the kernel. Now, I don’t get that error from first comment instead I get this one:

Unknown symbol pci_read_config_dword (err 0)
Unknown symbol pci_read_config_dword (err 0)
Unknown symbol pci_read_config_word (err 0)
Unknown symbol pci_read_config_word (err 0)
Unknown symbol pci_alloc_irq_vectors_affinity (err 0)
Unknown symbol pci_alloc_irq_vectors_affinity (err 0)
Unknown symbol pci_write_config_word (err 0)
Unknown symbol pci_write_config_word (err 0)
Unknown symbol pci_write_config_dword (err 0)
Unknown symbol pci_write_config_dword (err 0)
insmod: ERROR: could not insert module xxx.ko: Unknown symbol in module

May I have a .config file with which you built this kernel https://github.com/96boards-poplar/linux/commits/poplar-4.9 and works fine to insert a module on linaro built from here https://github.com/96boards-poplar/Documentation/blob/master/debian/debian_build_instructions.md#build-everything ?

Thank you.
Best regards,
Emi

insmod is a very low level tool. Try using modprobe instead (it gives
you intra-module dependency tracking).

I get the same output when I try to insert it with modprobe.

Using the documented command below, you will get the .config file you are asking for.

make ARCH=arm64 CROSS_COMPILE="${CROSS_64}" poplar_defconfig

I’ve solved the error, you were right, the problem was in .config file.
I disabled the CONFIG_ANDROID and then I was able to insert the module without a error.

Thanks,
Best regards,
Emi