[Dev] External kernel module building and kernel ABI/API check.

Jacek Pielaszkiewicz j.pielaszkie at samsung.com
Tue Dec 10 12:13:12 GMT 2013

Hi everyone,

      I would like to ask all of you for comments and also I would like to
present results of our works related to kernel and external kernel modules

      We have the following plans:
1. Deliver environment to build external kernel modules
2. Provide functionality that detects changes in kernel ABI/API.
3. Provide functionality that allow as early as it is possible check
external modules compatibility with given Linux kernel to avoid potential
problems with loading and running kernel modules.


	The first goal - environment for building external kernel modules
has been already delivered. "platform/kernel/linux-3.10" repository now
provides the following new rpms required in external modules build process:
. linux-kernel-headers - kernel headers
. linux-kernel-sources - complete kernel sources
. linux-kernel-build -pre-build kernel sources
. linux-kernel-uImage - kernel uImage without device tree database


	The second one - detection API/API kernel changes is ongoing. The
solution assumes that kernel sources will be extended by "repository" of
kernel API/ABI fingerprints. The repository will be based on
"Module.symvers" files build during kernel compilation and it will be store
in /boot/abi directory. The repository will contain all historical the
ABI/API fingerprints. The fingerprint for current kernel version will be
marked by symbolic link "/boot/abi/current".
During the kernel building process will be checked if all applied patches
have any influence on the kernel API/ABI. It will be implemented by
comparing actual kernel fingerprint with a new one created during current
compilation (Module.symvers file). If any change has been detected, then
developer will be enforced to update kernel version number and a new ABI/API
fingerprint file into repository. Example result of verification ABI/API

[  342s] + ./build_api_kernel_checker.sh 3.10.19 1
[  343s] 
[  343s]        New symbols in kernel
[  343s]
[  343s]        | Change  |                 Linux kernel symbol name |
CRC | Module name 
[  343s]
[  343s]        | NEW     |                         rndis_borrow_net |
0x6a66e8ca | vmlinux
[  343s]
[  343s]        | CHANGED |                        gether_setup_name |
0x4384f1be | vmlinux
[  343s]        | CHANGED |                 gether_get_host_addr_cdc |
0xf7b01b50 | vmlinux
[  343s]        | CHANGED |                gether_setup_name_default |
0xed9fdd16 | vmlinux
[  343s]
[  343s]        | REMOVED |                     brcmu_pktq_pdeq_tail |
0x411e4ef5 | drivers/net/wireless/brcm80211/brcmutil/brcmutil
[  343s]        | REMOVED |                          brcmu_pktq_penq |
0x63fb81e4 | drivers/net/wireless/brcm80211/brcmutil/brcmutil
[  343s]        | REMOVED |                    brcmu_pktq_pdeq_match |
0x208f2017 | drivers/net/wireless/brcm80211/brcmutil/brcmutil
[  343s]
[  343s] 
[  343s]        Kernel symbols version statistics 
[  343s]        -------------------------------------------------
[  343s]        Symbols in actual kernel/module . 6900
[  343s]        Symbols in new kernel/module .... 6879
[  343s]        New symbols ..................... 1
[  343s]        Removed symbols ................. 22
[  343s]        Changed symbols ................. 18
[  343s]        Unchanged symbols ............... 6860
[  343s] 
[  343s] 
[  343s]        Changes !!!
[  343s] 
[  343s] 
[  343s]
[  343s] 
[  343s] The kernel ABI/API has changed. Please update kernel version and
add a new abi-checker/data/abi_3.10.19_1 file.
[  343s] The kernel sources build will abort.

	New ABI/API fingerprint can be extracted manually from GBS kernel
build directory or by building the repos with a new parameter "abidev" (see
example below how to call)
gbs -v build -A armv7l --include-all -P tizenorg -B ~/GBS-ROOT_TIZENORG/
--define "_with_abidev 1"

	The parameter causes that:
. A new rpm linux-kernel-abi-dev*.rpm will be created. The rpm will contain
API/ABI fingerprint for current kernel
. ABI/API changes checks will not be performed.
. linux-kernel-uImage*.rpm will not contain ABI fingerprints repository


	The third goal - external kernel module compatibility check with
kernel ABI/API version. The solution will be based on ABI/API verification
functionality for Linux kernel. We plan deliver set of simple tools that
allow check the module compatibility. Tools will use kernel ABI/API
fingerprint repository and the module private fingerprint.
	Proposal assumes that output kernel module during build process will
produce fingerprint file. The fingerprint file will be created based on
kernel version present during the module build. The module fingerprint file
will contain only kernel symbols used by the module. The file will be used
during the module installation in %post section of the *spec file. In the
%post section will be compared module fingerprint with the current kernel
fingerprint. The module installation will abort if any change in kernel
symbols will be detected - especially when symbols used by the module
changed or were removed.

	All tools will be provided by linux-kernel repository. The following
tools will be delivered:
- "abi-checker" - compares two kernel fingerprints and creates changes
report (see example above)
- "abi-module-dumper" - creates module fingerprint (for more info see above)
- "abi-module-checker" - compares module fingerprint with kernel fingerprint
and creates changes report

	I'll be grateful for comments.

Best regards

Jacek Pielaszkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Email: j.pielaszkie at samsung.com

More information about the Dev mailing list