Books : The Linux Kernel Module Programming Guide (LKMPG)
The link you shared points to the modern, actively maintained edition of The Linux Kernel Module Programming Guide (LKMPG) hosted by the sysprog21 project on GitHub.
While the book stems from Ori Pomerantz's original text for Linux v2.2, this specific edition is tracked and updated by a team led by Jim Huang (jserv) to stay fully compatible with modern Linux long-term support (LTS) kernels (v5.10 and later).
📘 Book Structure & Core Modules
The guide is uniquely divided into five key technical logical zones, taking you from zero kernel exposure to complex hardware routing:
Part 1: Getting Started
The Baseline: Sets up a safe environment for development, utilizing a custom QEMU virtual machine workflow bundled directly in the guide’s repository. This allows you to compile and test code safely without threatening your main host system or running into continuous reboots.
Hello World: Breaks down basic loading syntax, kernel headers, macros (
__initand__exit), and passing module command-line arguments.
Part 2: Core Kernel Interfaces
Space Distinctions: Solidifies the operational boundaries between User Space and Kernel Space, namespacing, and system code layout.
The Communication Channels: Deep dives into writing classic Character Device Drivers using
file_operationsstructures.Virtual File Systems: Explains interacting with userspace via standard diagnostic nodes like
/proc(usingseq_file),/sys(sysfs), and/sys/kernel/debug(debugfs).
Part 3: Execution Context and Control Flow
Intercepts & Traps: Investigates safe interactions with standard system calls.
Concurrency Management: Discusses how to properly block processes, use completions, and deploy internal synchronization tools like Mutexes, Spinlocks, Read/Write locks, and Atomic operations to prevent data corruption.
Part 4: Memory, Time, and Data Movement
Boundary Hopping: Handles safe memory allocation inside the kernel and data transportation across the strict user-kernel boundary.
Hardware Mapping: Demystifies Memory-Mapped I/O (MMIO), register access, Direct Memory Access (DMA) rules, and scatter-gather lists.
Part 5: Hardware Integration & Advanced Topics
Real-World Infrastructure: Moves beyond virtual interfaces into writing production-style code for physical architecture, including GPIO pins, Interrupt Handlers, tasklets, work queues, PCI drivers, USB sub-systems, Block storage devices, and modern Network interfaces (
net_device).The Linux Device Model: Explains how modern kernels abstract architecture using Device Trees.
⚠️ Common Pitfalls Highlighted
One of the most practical sections of this specific guide outlines exactly what not to do when working inside kernel space, acting as an essential safeguard for systems engineers:
Never attempt to link standard C libraries (there is no
<stdio.h>).Understanding the structural hazards of disabling hardware interrupts carelessly.
Managing the tiny, fixed-size Kernel Stack (and why allocating large buffers on it triggers immediate stack overflows).
The absolute restriction on Floating Point math operations within standard kernel code paths.
👥 Target Audience
This book is highly technical but assumes a practical mindset. It is best suited for developers who know C programming well and are comfortable navigating a command line interface, looking to transition directly into embedded systems, operating system design, or low-level driver development.

Comments
Post a Comment