What stands p2v8 in mod_unload modversions ARMv6 p2v8 for? - linux-kernel

After compiling a kernel for qemu, I get a lots of errors like listed below:
ipv6: version magic '3.18.11-hypriotos+ mod_unload modversions ARMv6 '
should be '3.18.11-hypriotos+ mod_unload modversions ARMv6 p2v8 '
Obviously my kernel and the Hypriotos kernel are somehow different. What means p2v8? And how can I enable it in my kernel?

Go and check out yourself in arch/arm/include/asm/module.h. It's added when CONFIG_ARM_PATCH_PHYS_VIRT is set. So you obviously need this config to be enabled. You can read the description of this option in arch/arm/Kconfig
Keep in mind, however, that if you're not using the same kernel sources that were used for the main kernel build, you may encounter strange problems even if your module is successfully loaded.

#define VERMAGIC_STRING \
UTS_RELEASE "4.4.76 SMP mod_unload ARMv7 p2v8 " \
MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
MODULE_ARCH_VERMAGIC
#endif

Related

Unable to load kernel module after compiling it separately

I am trying to "make" and load the "/drivers/md/raid0.ko" module into my linux kernel but I am getting this error.
# modprobe raid0 --force-vermagic
modprobe: ERROR: could not insert 'raid0': Exec format error
dmesg
[Dec 2 15:10] raid0: version magic '5.0.0 SMP mod_unload ' should be '5.0.0-36-generic SMP mod_unload '
My kernel version is
# uname -a
Linux ubuntu1 5.0.0-36-generic #39-Ubuntu SMP Tue Nov 12 09:46:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
and the code from which I am trying to load is taken from the link https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.0.tar.xz
Hence the version in that is 5.0.0, without the EXTRAVERSION -36
I have tried a number of things but failed.
Setting the EXTRAVERSION using command make EXTRAVERSION=-1 modules_prepare, before building the module
Using the --force-vermagic while loading the kernel, but it fails.
Copying the Makefile firectly from /usr/lib/modules/$(uname -r)/build/Makefile before building the kernel.
I have used both make SUBDIRS=drivers/md modules and make M=drivers/md for building, but same result for both.
Need help!
force modprobe to ignore the magic str
use --force-vermagic optin
Every module contains a small string containing important information,
such as the kernel and compiler versions. If a module fails to load
and the kernel complains that the "version magic" doesn't match, you
can use this option to remove it. Naturally, this check is there for
your protection, so this using option is dangerous. This applies to
any modules inserted: both the module (or alias) on the command line
and any modules on which it
in this case modprob ignore magic str

YOCTO : can't insert linux module to the kernel : versions are different

I'm using YOCTO PROJECT to build a linux os for my embedded board.
I have a module named uleds which i want insert to my kernel so i taped this insmod command:
insmod
/lib/modules/4.14.73-linux4sam-6.0-dirty/kernel/drivers/leds/uleds.ko
But an errors comes out :
uleds: version magic '4.14.88-01445-g234c56a01768-dirty mod_unload
ARMv7 p2v8 ' should be '4.14.73-linux4sam-6.0-dirty mod_unload ARMv7
p2v8 '
uleds: version magic '4.14.88-01445-g234c56a01768-dirty mod_unload
ARMv7 p2v8 ' should be '4.14.73-linux4sam-6.0-dirty mod_unload ARMv7
p2v8 '
insmod: can't insert
'/lib/modules/4.14.73-linux4sam-6.0-dirty/kernel/drivers/leds/uleds.ko':
invalid module
What i see that my linux kernel version and the module version are not the same. My question is How can I fix this problem so I can insert the module to the kernel ?
The module is not compiled with the same version as your kernel (on the embedded device).
You need to simply compile the module with the right kernel.
You will need to find your kernel recipe in the meta of Yocto, download it (reset the repository of the downloaded kernel to the SRCREV of the recipe), then build your module.

How to add SMP and Preempt in Kernel module version magic?

I am trying to build my custom kernel module. it is compling successfully but while inserting module it is giving me error
insmod: init_module 'helloworld.ko' failed (Exec format error)
And dmesg Log shows:
version magic '3.10.0+ mod_unload ARMv7 p2v8 ' should be '3.10.0 SMP preempt mod_unload ARMv7 p2v8 '
How can I add "SMP" & "preempt" in version magic ?
Check whether CONFIG_PREEMPT and CONFIG_SMP is enabled in the kernel config of the kernel which you are using to compile your kernel module. Enable it in your kernel and then recompile your module using this config.

How to build kernel and kernel modules for specific kernel version magic?

I need to build kernel to have vermagic
3.10.28-gbc1b510-33899-g9fa745e SMP preempt mod_unload modversions ARMv7
but after building and verification some module via modinfo it displays
3.10.28 preempt mod_unload modversions ARMv6
Looks like I can't load module because different vermagic. How to build kernel and modules for vermagic to be axactly the same ?. I'm using buildroot.
I created this shell script in order to prepare for build
#!/bin/sh
export PATH=$PATH:/buildroot-2018.02.3/output/host/arm-buildroot-linux-gnueabi/bin:/buildroot-2018.02.3/output/host/bin:/buildroot-2018.02.3/output/host/sbin:/buildroot-2018.02.3/output/host/bin
export LD_LIBRARY_PATH=/buildroot-2018.02.3/output/host/lib
export LIBRARY_PATH=/buildroot-2018.02.3/output/host/lib
export PKG_CONFIG_PATH=/buildroot-2018.02.3/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/lib/pkgconfig
exec /bin/bash
then I enter folder
/buildroot-2018.02.3/output/build/linux-3.10.28/
and
make distclean
make clean
then copy .config and
make ARCH=arm menuconfig
and
make -j9 ARCH=arm
I'm using original kernel konfig with additionaly selected a few options to build as modules without modifications of any other.
There is linux-3.10.28/arch/arm/Makefile file. In this file there are those defines
arch-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
I found suggestion somewhere which lead me to replace
arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
with
arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
I olso uncommented these two:
tune-$(CONFIG_CPU_V6) :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
tune-$(CONFIG_CPU_V6K) :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
I added
-gbc1b510-33899-g9fa745e SMP
as local_version in kernel .config
and now version string print by modinfo is the same.

Cross compiling a kernel module: invalid module format

I'm trying to cross compile a helloworld kernel module with specifications:
host: intel x86 32 bit, linux-3.0.0
target: ARM machine (Parrot AR.Drone), linux-2.6.27.47
I'm using the makefile:
PWD := $(shell pwd)
obj-m := test.o
all:
$(MAKE) -C /path/to/kernel M=$(PWD) CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm modules
Where arm-none-linux-gnueabi- is the prefix of the arm toolchain.
As kernel, I tried using a clone from git://github.com/CyanogenMod/cm-kernel.git as kernel. This is a 2.6 kernel fork. Using this kernel, compilation was successfull. When trying to insert the module, it gives the error:
invalid module format
Which, sadly, says very little.
Thanks to the hint of Eugene to use dmesg, I found the error:
version magic '2.6.37.6 mod_unload modversions ARMv5 ' should be '2.6.27.47-parrot preempt mod_unload ARMv5 '
Conclusion: when compiling a kernel module, not only versions need to match, but also some config-parameters. My problem was solved by using the right version and editing the configuration.
If you don't want to reconfigure everything, a quick (ugly) fix is to edit include/generated/autoconf.h
my ugly fix is modifing script file
"scripts/setlocalversion"
170 if test "${LOCALVERSION+set}" != "set"; then
171 scm=$(scm_version --short)
172 # res="$res${scm:++}"
173 res="${res}"
174 fi
Hi, everyone.. I did found simple soulution.
just modify envirionment vairable
export LOCALVERSION=
that's all

Resources