Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 Or Later and SUSE Linux Enterprise 15
Total Page:16
File Type:pdf, Size:1020Kb
SUSE Best Practices Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux Enterprise 15 SUSE Linux Enterprise 12 SP2+, 15 Document Owner: Ann Davis, Senior Software Engineer, SUSE Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 1 Enterprise 15 SUSE-based distributions use the RPM Package Manager for software management. As such, any external kernel modules (these are kernel modules not included in SUSE kernel packages) should be packaged in RPM packages. These RPMs should be built in accordance with specic guidelines to ensure that the resulting Kernel Module Packages (KMPs) can be installed and updated appropriately, in synchronization with kernel updates. This document species the requirements for RPM packages that contain kernel modules, and describes the processes surrounding those packages including building, signing, installing and upgrading. A complete example is given and explained. This version of the Kernel Module Packages Manual applies to SUSE Linux Enterprise Server 12 (Service Pack 2 and later), and SUSE Linux Enterprise Server 15, and all products based on these versions. Publication Date: July 31, 2019 Contents 1 Scope 4 2 Background 4 3 Kernel Packages 6 4 Kernel Modules 7 5 Kernel Module Packages 8 6 RPM Provides and Requires 12 7 Building Kernel Module Packages 12 8 Signing 14 9 Deploying Kernel Module Packages 18 10 System Installation and Kernel Module Packages 18 Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 2 Enterprise 15 11 Kernel Updates and Kernel Module Packages 19 12 Appendix A: Sample Source for suse-hello Kernel Module Package 20 13 Appendix B: Changes and References 22 14 Legal Notice 23 15 GNU Free Documentation License 24 Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 3 Enterprise 15 1 Scope This version of the Kernel Module Packages Manual applies to: SUSE Linux Enterprise Server 12 Service Pack 2 and later or SUSE Linux Enterprise Desktop 12 Service Pack 2 and later, and all products based on these versions SUSE Linux Enterprise Server 15 and SUSE Linux Enterprise Desktop 15 (along with service packs) All products and extensions based on SUSE Linux Enterprise Server 12 SP2 or later and SUSE Linux Enterprise Server 15 Developers who want to build for SUSE Linux Enterprise Server versions before SUSE Linux Enterprise Server 12 SP2 should use previous versions of this document SUSE SolidDriver Documentation: Kernel Module Packages Manual for Code 11 (https://documentation.suse.com/ sbp/all/html/SBP-KMP-Manual/index.html) . Appendix B provides a list of changes that have been made to this document to accommodate new features. 2 Background The Linux kernel supports adding functionality at runtime through kernel-loadable modules. It includes more than 1500 modules, about 75 percent of which are hardware drivers. These modules are shipped as part of the kernel packages. In some cases it is desirable to add additional modules or replace existing ones. For example, a driver for a particular storage controller that was not available at the time of product release might be added later to support new hardware. Kernel modules interact with the kernel by the means of exported symbols, in a way similar to how user space binaries use shared libraries. The /proc/kallsyms le lists all symbols currently known to the kernel. To ensure that the kernel and modules refer to the same symbols, a version checksum ( modversion ) is added to each symbol. The checksum is computed from the symbol's type: in the case of function symbols, the checksum is determined by the function's parameters and return type. Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 4 Enterprise 15 When any of a function's parameters or the return type changes, the checksum changes as well. This includes all the data types involved recursively: If a function takes a struct task_struct as parameter and struct task_struct includes a eld of type struct dentry, then a change to struct dentry will cause the symbol's version checksum to change as well. Symbol version checksums for dierent kernel avors (for example kernel- default versus kernel-xen) will not match, and symbol versions of the same kernel package on dierent architectures will not match either. This mechanism ensures that the kernel and kernel modules agree on the types of data structures that they use to communicate. Unless symbol version checking is disabled, modules will load only if the checksums of the symbols they use match the checksums of the symbols that the kernel exports. The exported symbols and their version checksums comprise the kernel Application Binary Interface (kABI). When an updated kernel includes kABI changes, kernel modules that use any modied symbols must be updated as well. During their multi-year lifecycle, products like SUSE Linux Enterprise Server undergo continuous changes. Dierent kinds of updates like service packs (SPs), maintenance/security updates, and customer-specic updates (Program Temporary Fixes) are released. The Application Binary Interface (ABI) between the kernel and kernel modules is volatile. Some kernel updates will change the kernel ABI (kABI) by adding or removing exported symbols, or existing symbol checksums can change in a kernel update because of changes in data structures they reference. SUSE strives to keep the kernel ABI stable in maintenance and security and customer-specic updates, but sometimes changes cannot be avoided. In service packs, SUSE reserves the right to introduce more intrusive changes, which increases the likelihood of ABI changes. SUSE believes that the added exibility outweighs the disadvantages of breaking older modules. For full discussion of this topic, see the documentation SUSE SolidDriver Documentation: SUSE Kernel ABI Stability (https://drivers.suse.com/doc/SolidDriver/SUSE_Kernel_ABI_Stability.html) and The Linux Kernel Driver Interface (http://www.kroah.com/log/linux/stable_api_nonsense.html) from Greg Kroah-Hartman (also provided as stable_api_nonsense.txt in the upstream kernel source tree). SUSE Linux Enterprise-based operating systems include technology to ensure that kernel modules can be reused or updated in synchronization with kernel updates. To use this technology, kernel modules must be packaged into Kernel Module Packages (KMPs) as dened in this document. Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 5 Enterprise 15 3 Kernel Packages Each product based on SUSE Linux Enterprise 12 SP2 or SUSE Linux Enterprise 15 contains a set of kernel packages that share the same version and release number; they are built from the same kernel sources. These packages are: kernel-FLAVOR , kernel-FLAVOR-base The binary kernel packages. Each architecture has its own set of kernel avors (for example kernel-default , kernel-debug , etc.). These are the packages that the kernel modules will be used with. The kernel-FLAVOR-base packages are subsets of the kernel-FLAVOR packages, intended for use with minimal installs. They are not installed by default. kernel-source The kernel source tree, generated by unpacking the vanilla kernel sources and applying all necessary patches. Although the kernel-FLAVOR packages technically are not built from the kernel-source package, they are built from the same source tree. This tree should be used for module building. kernel-devel , kernel-macros Kernel-level headers, makeles, and RPM macros and templates required for development of external kernel modules. kernel-syms , kernel-FLAVOR-devel Kernel symbol version information for compiling external modules. The kernel-FLAVOR-devel package is required for building external modules. If this package is not used, the resulting modules will be missing symbol version information, which will cause them to break during kernel updates. The kernel-syms package is a placeholder package which depends on the kernel-FLAVOR-devel packages for all kernel avors. Kernel Module Packages Manual for SUSE Linux Enterprise 12 SP2 or later and SUSE Linux 6 Enterprise 15 For more information, refer to the document “Working With The SUSE 2.6.x and 3.x Kernel Sources” from Andreas Gruenbacher and Michal Marek. This document is provided as README.SUSE in the SUSE kernel-source package. 4 Kernel Modules Documentation on general kernel module building can be found in abundance on the Internet. Two good lectures are: Peter Jay Salzman, Michael Burian, Ori Pomerantz: The Linux Kernel Module Programming Guide, http://www.tldp.org/LDP/lkmpg/2.6/html/index.html Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman: Linux Device Drivers, Third Edition, February 2005, http://www.oreilly.com/catalog/linuxdrive3/ (also available online at http://lwn.net/Kernel/LDD3/ ) SUSE-specic information is found in the above-mentioned README.SUSE in the kernel- source package. When built, kernel module binaries are installed below /lib/modules/VERSION-RELEASE- FLAVOR on the le system (example: /lib/modules/4.4.73-5-default for the SUSE Linux Enterprise Server 12 SP3 kernel-default-4.4.73-5 package). Dierent kernels have dierent module directories, and will usually not see each other's modules. Update modules are modules intended to replace or augment the modules that are provided in the kernel packages. Update modules must be stored below the /lib/modules/VERSION- RELEASE-FLAVOR/updates/ directory. Modules in the updates/ directory have precedence over other modules with the same name. Never replace modules from the kernel package by overwriting les: this would lead to inconsistencies between the le system and the RPM database. Note: Where to Store Modules Modules intended to take precedence over in-kernel modules of the same name should be stored below /lib/modules/VERSION-RELEASE-FLAVOR/updates/ . Other add-on modules can be stored below /lib/modules/VERSION-RELEASE-FLAVOR/extra/ .