Contents
How are the kernel module installed?
Loading a Module
- To load a kernel module, run modprobe module_name as root .
- By default, modprobe attempts to load the module from /lib/modules/kernel_version/kernel/drivers/ .
- Some modules have dependencies, which are other kernel modules that must be loaded before the module in question can be loaded.
Why do we need kernel modules?
Kernel modules can dedicate process registers to specific roles. Kernel code can be optimized for a specific processor. Kernel modules can be dynamically loaded. The collection of subroutines and data that constitute a device driver can be compiled into a single loadable module of object code.
How to find the version of a compiled kernel module?
srcversion is an MD4 hash of the source code used to compile the kernel module. It is calculated automatically at build time from https://github.com/torvalds/linux/blob/v4.9/scripts/mod/modpost.c#L1978 using https://github.com/torvalds/linux/blob/v4.9/scripts/mod/sumversion.c#L400 To enable it, either: set MODULE_VERSION for the module
How are kernel modules used in Linux development?
Most of the device drivers are used in the form of kernel modules. For the development of Linux device drivers, it is recommended to download the kernel sources, configure and compile them and then install the compiled version on the test /development tool machine.
Is it possible to troubleshoot a kernel module?
Troubleshooting a kernel module is much more complicated than debugging a regular program. First, a mistake in a kernel module can lead to blocking the entire system. Troubleshooting is therefore much slowed down. To avoid reboot, it is recommended to use a virtual machine (qemu, virtualbox, vmware).
Where to find the address of a kernel module?
The /proc/modules is used to find the address where a kernel module is loaded. The –adjust-vma option allows you to display instructions relative to 0xc89d4000. The -l option displays the number of each line in the source code interleaved with the assembly language code.