XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Trying to build kernel module : modprobe Exec format error

    Scheduled Pinned Locked Moved Development
    5 Posts 3 Posters 14.3k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      benze
      last edited by benze

      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

      1 Reply Last reply Reply Quote 0
      • olivierlambertO Offline
        olivierlambert Vates 🪐 Co-Founder CEO
        last edited by

        Ping @r1 and @stormi

        1 Reply Last reply Reply Quote 0
        • R Offline
          r1 XCP-ng Team
          last edited by r1

          @benze what does # modinfo drivers/usb/class/cdc-acm.ko says?

          Are you able to # insmod cdc-acm.ko manually? Share # dmesg | tail after it.

          AFAIK Exec format error is most likely due to loading a module which was not built for the kernel.

          1 Reply Last reply Reply Quote 0
          • B Offline
            benze
            last edited by benze

            @r1 modinfo displays a huge number of aliases (abrieviated, but can include the entire list if helpful at all):

            root@xenserver class]# modinfo cdc-acm.ko
            filename:       /lib/modules/4.4.0+10/extra/class/cdc-acm.ko
            alias:          char-major-166-*
            license:        GPL
            description:    USB Abstract Control Model driver for USB modems and ISDN adapters
            author:         Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek, Johan Hovold
            srcversion:     4DA17ECECFACCD02EC1D87C
            alias:          usb:v1519p0452d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip06in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip05in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip04in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip03in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip02in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip01in*
            alias:          usb:v*p*d*dc*dsc*dp*ic02isc02ip00in*
            alias:          usb:v058Bp0041d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v04E8p685Dd*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v04D8p000Bd*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v03EBp0030d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v04E7p6651d*dc*dsc*dp*ic02isc02ipFFin*
            ...
            ...
            ...
            alias:          usb:v22B8p7000d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0ACEp1611d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0ACEp1608d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0ACEp1602d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v079Bp000Fd*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0482p0203d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0E8Dp3329d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0E8Dp0003d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v0870p0001d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v17EFp7000d*dc*dsc*dp*ic*isc*ip*in*
            alias:          usb:v076Dp0006d*dc*dsc*dp*ic*isc*ip*in*
            depends:
            vermagic:       4.4.0+10 SMP mod_unload modversions
            [root@xenserver class]#
            

            insmod fails with similar error messages.

            insmod: ERROR: could not insert module cdc-acm.ko: Invalid module format 
            [root@xenserver class]# dmesg | tail -n 5                                
            [529766.051521] cdc_acm: no symbol version for module_layout             
            [529886.114801] cdc_acm: no symbol version for module_layout             
            [530436.174773] cdc_acm: no symbol version for module_layout             
            [593078.042958] cdc_acm: no symbol version for module_layout             
            [593101.361321] cdc_acm: no symbol version for module_layout             
            

            What I don't understand is why this module built using the docker container for XCP 7.5 would fail, unless the kernel was different.

            [root@xenserver class]# uname -a
            Linux xenserver 4.4.0+10 #1 SMP Thu Aug 9 14:42:20 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
            [root@xenserver class]# md5sum /boot/initrd-4.4.0+10.img
            def1ea3930f11bb46abfec42c3b9d6ec  /boot/initrd-4.4.0+10.img
            [root@xenserver class]# file /boot/vmlinuz-4.4.0+10                                                                                                                               
            /boot/vmlinuz-4.4.0+10: Linux kernel x86 boot executable bzImage, version 4.4.0+10 (mockbuild@6fb104f99393) #1 SMP Thu Aug 9 14:42:20 UTC, RO-rootFS, swap_dev 0x4, Normal VGA    
            [root@xenserver class]# md5sum /boot/vmlinuz-4.4.0+10                                                                                                                             
            d5de46e85a4047faf427932ecc41969f  /boot/vmlinuz-4.4.0+10                                                                                                                          
            

            Any ideas? Is my kernel not actually 4.4.0+10? What I don't understand is why it is v4.4.0+10, but the rpm source package lists it as 4.4.52-4.0.7. Can there be 2 different versions of the same build somehow?

            Thanks,

            Eric

            1 Reply Last reply Reply Quote 0
            • R Offline
              r1 XCP-ng Team
              last edited by r1

              Short answer is that the module is referring to wrong symbol table. Its a lookup table for function interaction between module and kernel.

              Easy answer is to use this .config file and build full kernel.

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post