With the metere kernel, an Android simulator has been run and another compiled kernel is being added dynamically.
I initially found a hello.c file from the Web and wrote the Makefile the way he did, but when I ran the command insmod, it reported an error:
insmod: init_module ‘hello.ko’ failed (Exec format error)
Period, check a lot of information is still not solved, and then to test it according to this blog, succeeded, the connection address: http://blog.csdn.net/yf210yf/article/details/9901375
Next I post his Makefie file. There is no problem with the hello.c file, but the problem is with the Makefile. Write the Makefile the way he writes it and you can dynamically insert your own compiled kernel. The following code is posted:
Obj – m: = hello – yf. O
hello – yf – objs: = hello. O
KID: = ~/android – kernel/goldfish
the PWD: = $(shell PWD)
the ARCH = arm
CROSS_COMPILE = arm eabi –
CC = $(CROSS_COMPILE) GCC
LD = $(CROSS_COMPILE) LD
all:
the make – C $(KID) ARCH = $(ARCH) CROSS_COMPILE = $(CROSS_COMPILE) M = ${PWD} modules
the clean:
rm-rf *. O. CMD *. Ko *. Mod. C. tmp_versions
however, I do not know why he writes this way right now, I am looking into it. I’ve been updating this blog since I figured it out, but this problem has been solved.
I think I understand why, but look at this code:
All:
mak-c $(KID) ARCH=$(CROSS_COMPILE) M=${PWD} modules
I think this piece of code is the key to solve this problem. First, with mak-c $(KID), the local path of the current source code is given into the compile environment. Then assign the ARCH and cross-compiled environment variables separately, so that the above problems will not occur. You should have no problem writing makefiles this way if you want to compile your own kernel.
——————————————————————————————————————————————————————————————————– ———————–
To update this, the ‘M=’ option is used to add ‘M=dir’ to the make modules command when the user needs to compile an external module based on a kernel. The program will automatically look for the module’s source code in the dir directory you specify, compile it, and generate the KO file. This allows the generated KO files to be dynamically inserted into the kernel.
Read More:
I’m trying to update the driver for our Intel C62x Chipset QuickAssist Technology add-on card, but getting the mentioned errors when I try to load the modules. I haven’t done this in a while, but I thought the process was pretty straightforward:
- Stop the QAT services [ ok ]
uninstall
the QAT driver [ ok ]modprobe -r
any remaining QAT modules [ ok ]- download, extract,
configure
,make
the new QAT driver [ ok ] install
the new driver [ FAIL ]
For example:
# make -j16 install
[...]
make -C /lib/modules/4.19.0-5-amd64/build M=/usr/local/src/QAT.L.4.20.0-00001/quickassist/qat INSTALL_MOD_DIR=updates modules_install
make[3]: Entering directory '/usr/src/linux-headers-4.19.0-5-amd64'
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_200xx/qat_200xx.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_200xxvf/qat_200xxvf.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c3xxx/qat_c3xxx.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c3xxxvf/qat_c3xxxvf.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c4xxx/qat_c4xxx.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c4xxxvf/qat_c4xxxvf.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c62x/qat_c62x.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_c62xvf/qat_c62xvf.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_common/intel_qat.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_d15xx/qat_d15xx.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_d15xxvf/qat_d15xxvf.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_dh895xcc/qat_dh895xcc.ko
INSTALL /usr/local/src/QAT.L.4.20.0-00001/quickassist/qat/drivers/crypto/qat/qat_dh895xccvf/qat_dh895xccvf.ko
DEPMOD 4.19.0-5-amd64
Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[3]: Leaving directory '/usr/src/linux-headers-4.19.0-5-amd64'
make[2]: Leaving directory '/usr/local/src/QAT.L.4.20.0-00001/quickassist/qat'
Creating startup and kill scripts
Copying libqat_s.so to /usr/local/lib
Copying libusdm_drv_s.so to /usr/local/lib
Copying usdm module to system drivers
Group qat already exists.
Creating udev rules
Creating module.dep file for QAT released kernel object
This will take a few moments
Created symlink /etc/systemd/system/multi-user.target.wants/qat.service → /lib/systemd/system/qat.service.
Starting QAT service
modprobe: ERROR: could not insert 'qat_c62x': Exec format error
modprobe: ERROR: could not insert 'usdm_drv': Exec format error
modprobe: ERROR: could not insert 'qat_api': Exec format error
Restarting all devices.
Can not open /dev/qat_adf_ctl
Checking status of all devices.
Can not open /dev/qat_adf_ctl
*** Error:usdm_drv module not installed ***
*** Error:qat_api module not installed ***
*** Error:qat_c62x module not installed ***
Can not open /dev/qat_adf_ctl
make[1]: Nothing to be done for 'install-data-am'.
make[1]: Leaving directory '/usr/local/src/QAT.L.4.20.0-00001'
# modprobe -v qat_c62x
insmod /lib/modules/4.19.0-5-amd64/updates/drivers/crypto/qat/qat_common/intel_qat.ko
modprobe: ERROR: could not insert 'qat_c62x': Exec format error
# modprobe -v intel_qat
insmod /lib/modules/4.19.0-5-amd64/updates/drivers/crypto/qat/qat_common/intel_qat.ko
modprobe: ERROR: could not insert 'intel_qat': Exec format error
#
Meanwhile, the system log shows:
<date> <host> kernel: [<uptime>] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 000000005c09d38d, val ffffffffc09ba2fe
<date> <host> kernel: [<uptime>] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 00000000690eef73, val ffffffffc0b572fe
<date> <host> kernel: [<uptime>] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 000000007d30ad16, val ffffffffc0c862fe
<date> <host> kernel: [<uptime>] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 00000000671d2da7, val ffffffffc0cd82fe
<date> <host> kernel: [<uptime>] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 0000000072877855, val ffffffffc0d2a2fe
What are these errors even talking about and what is the cause and possible solutions?
Thanks so much!
I’m trying to build a kernel module that I cannot seem to find anywhere for XCP-ng 7.5.0. It is the USB Modem module, I believe, controlled via the kernel option:
CONFIG_USB_ACM=m
To start, I followed the steps on xcp-ng / xcp-ng-build-env to create a docker container and spun it up:
$ ./build.sh 7.5
$ ./run.py -b 7.5 -n --name xcp
I downloaded all the kernel* dependencies, and ran make menuconfig
to find the right kernel module.
[root@543abc754417 4.4.0+10-x86_64]# rpm -qa | grep kernel
kernel-devel-4.4.52-4.0.7.1.x86_64
kernel-tools-libs-devel-3.10.0-327.36.3.el7.x86_64
kernel-headers-4.4.52-4.0.7.1.x86_64
kernel-tools-3.10.0-327.36.3.el7.x86_64
kernel-debug-devel-3.10.0-327.36.3.el7.x86_64
kernel-tools-libs-3.10.0-327.36.3.el7.x86_64
kernel-4.4.52-4.0.7.1.x86_64
But when I try to prepare the module, I get an error:
[root@543abc754417 4.4.0+10-x86_64]# pwd
/usr/src/kernels/4.4.0+10-x86_64
[root@543abc754417 4.4.0+10-x86_64]# make modules_prepare
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC scripts/selinux/genheaders/genheaders
scripts/selinux/genheaders/genheaders.c:13:22: fatal error: classmap.h: No such file or directory
#include "classmap.h"
^
compilation terminated.
make[3]: *** [scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/selinux] Error 2
make: *** [scripts] Error 2
[root@543abc754417 4.4.0+10-x86_64]#
So I downloaded the kernel sources from https://updates.xcp-ng.org/7/7.5/base/Source/SPackages/kernel-4.4.52-4.0.7.src.rpm:
[root@543abc754417 kernel-4.4.52]# rpm -i kernel-4.4.52-4.0.7.src.rpm
[root@543abc754417 kernel-4.4.52]# cd ~/rpmbuild/SPECS
[root@543abc754417 kernel-4.4.52]# rpmbuild -bp --target=$(uname -m) kernel.spec
[root@543abc754417 kernel-4.4.52]# cd ~/rpmbuild/BUILD//kernel-4.4.52/
[root@543abc754417 kernel-4.4.52]# make menuconfig
[root@543abc754417 kernel-4.4.52]# make modules_prepare
[root@543abc754417 kernel-4.4.52]# make M=drivers/usb modules
[root@543abc754417 kernel-4.4.52]# find drivers/usb/ -name cd*.ko
drivers/usb/class/cdc-acm.ko
drivers/usb/class/cdc-wdm.ko
Success!
So I copied the cdc-acm.ko
from the container to my DOM0 in the modules/extra folder:
[root@xenserver class]# pwd
/lib/modules/4.4.0+10/extra/class
[root@xenserver class]# ls -l
total 416
-rwxr--r-- 1 root root 421069 May 16 00:29 cdc-acm.ko
Next run depmod
to update module info and dependencies, and try to load the module, and modprobe
fails.
[root@xenserver class]# depmod
[root@xenserver class]# modprobe cdc-acm
modprobe: ERROR: could not insert 'cdc_acm': Exec format error
At this point I am seriously stuck. I would have thought/expected that having built the module in the 7.5 container would produce the exact module that I needed for the DOM0.
What am I doing wrong? Am I missing something? Did I use the incorrect sources?
Thanks,
Eric