Search code examples
linuxlinux-kerneldriverheader-fileskali-linux

asm vs asm-generic in linux headers -- are they same


In my linux header files folder on my Kali kernal 5.7.0 headers included in include directory /usr/src/linux-headers-5.7.0-kali1-common/include. Inside this folders I have header files contained in sub-folders like asm-generic,linux,uapi,acpi,crypto,etc.. But inside header files, i.e. inside linux/module.h there there is one header file reference included like

    #include <asm/module.h>  // top of linux/module.h

But Actually I don't have asm folder that got included with my header files when I installed them. So one solution that came to mind is. Probably solution: Change the references from asm/* to asm-generic/* as in from asm/module.h to asm-generic/module.h inside linux/module.h and other files which I may use. I like to know is asm and asm-generic are same? meaning they contains same files and structure or is there any difference i can cause problem

If I correct the directory name in include reference than Does it make sense, or I will get into problems when I compile the module if I change headers sub directories names in include list of header files from asm to asm-generic? If I dont do this the header files will be missing


Solution

  • Short answer

    They are not the same.

    kernel developer might include asm-generic headers in a asm header while asm headers are the headers required for kernel modules.

    You may get more info from following post

    Take this question in another way.

    It seems you're trying to make a kernel module.

    To build a kernel module you need kernel-headers or compiled kernel source code. However I don't know kali linux, so I just provide generic suggestions here.

    Where to get them

    • Some of distributions, like Ubuntu, have prebuilt linux-headers.

      • Eg: Ubuntu has it in /usr/src/linux-headers-$(uname -r)/include
    • Download it by sudo apt-get install linux-headers-$(uname -r)

      • It seems kali linux 2.0 might need more operations. Found this post might help.
    • Build it yourself

      1. Checkout linux kernel code of your desired distro.
      2. Set up kernel config with make menuconfig ( You might get stumbled here a while.. many packages might be required )
      3. Compile kernel with make modules_prepare to compile essential Module.symvers for drivers. It take significant less time than compiling a full kernel.

    I presume you already found a kernel module build example. If not, you may consult offical kernel module documentation. It helps a lot if you take a while to read first two chapters.

    Or another example