You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lkmpg.tex
+24-20Lines changed: 24 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -105,11 +105,12 @@ \subsection{What Is A Kernel Module?}
105
105
could potentially cause the complete erasure of an entire file system,
106
106
leading to an event that prompts a complete system reboot.
107
107
108
-
Precisely defined, a kernel module refers to a segment of code that possesses the ability to be dynamically loaded and unloaded within the kernel according to necessity.
109
-
Such modules elevate kernel capabilities without the imposition of a system reboot requirement.
110
-
A notable instance is observed in the device driver module, which serves to facilitate the interaction of the kernel with the hardware components attached to the system.
111
-
In the absence of modules, the prevailing approach leans toward monolithic kernels, necessitating the direct integration of novel functionalities into the kernel image.
112
-
This approach not only contributes to the generation of larger kernels but also mandates the undertaking of kernel rebuilding and subsequent system rebooting whenever a desired addition of functionality arises.
108
+
A kernel module is precisely defined as a code segment capable of dynamic loading and unloading within the kernel as needed.
109
+
These modules enhance kernel capabilities without necessitating a system reboot.
110
+
A notable example is seen in the device driver module, which facilitates kernel interaction with hardware components linked to the system.
111
+
In the absence of modules, the prevailing approach leans toward monolithic kernels,
112
+
requiring direct integration of new functionalities into the kernel image.
113
+
This approach leads to larger kernels and necessitates kernel rebuilding and subsequent system rebooting when new functionalities are desired.
113
114
114
115
\subsection{Kernel module package}
115
116
\label{sec:packages}
@@ -161,27 +162,30 @@ \subsection{Before We Begin}
161
162
162
163
\begin{enumerate}
163
164
\item Modversioning.
164
-
A module compiled for one kernel will not load if you boot a different kernel unless you enable \cpp|CONFIG_MODVERSIONS| in the kernel.
165
-
We will not go into module versioning until later in this guide.
166
-
Until we cover modversions, the examples in the guide may not work if you are running a kernel with modversioning turned on.
167
-
However, most stock Linux distribution kernels come with it turned on.
168
-
If you are having trouble loading the modules because of versioning errors, compile a kernel with modversioning turned off.
165
+
A module compiled for one kernel will not load if a different kernel is booted,
166
+
unless \cpp|CONFIG_MODVERSIONS| is enabled in the kernel.
167
+
Module versioning will be discussed later in this guide.
168
+
Until module versioning is covered, the examples in this guide may not work correctly if running a kernel with modversioning turned on.
169
+
However, most stock Linux distribution kernels come with modversioning enabled.
170
+
If difficulties arise when loading the modules due to versioning errors, consider compiling a kernel with modversioning turned off.
169
171
170
172
\item Using X Window System.
171
173
\label{sec:using_x}
172
-
It is highly recommended that you extract, compile and load all the examples this guide discusses from a console.
173
-
You should not be working on this stuff in X Window System.
174
-
175
-
Modules can not print to the screen like \cpp|printf()| can, but they can log information and warnings, which ends up being printed on your screen, but only on a console.
176
-
If you \sh|insmod| a module from an xterm, the information and warnings will be logged, but only to your systemd journal.
177
-
You will not see it unless you look through your \sh|journalctl| .
178
-
See \ref{sec:helloworld} for details.
179
-
To have immediate access to this information, do all your work from the console.
174
+
It is highly recommended to extract, compile, and load all the examples discussed in this guide from a console.
175
+
Working on these tasks within the X Window System is discouraged.
176
+
177
+
Modules cannot directly print to the screen like \cpp|printf()| can,
178
+
but they can log information and warnings that are eventually displayed on the screen,
179
+
specifically within a console.
180
+
If a module is loaded from an \sh|xterm|, the information and warnings will be logged,
181
+
but solely within the systemd journal. These logs will not be visible unless consulting the \sh|journalctl|.
182
+
Refer to \ref{sec:helloworld} for more information.
183
+
For instant access to this information, it is advisable to perform all tasks from the console.
180
184
\item SecureBoot.
181
185
Many contemporary computers are pre-configured with UEFI SecureBoot enabled.
182
186
It is a security standard that can make sure the device boots using only software that is trusted by original equipment manufacturer.
183
187
The default Linux kernel from some distributions have also enabled the SecureBoot.
184
-
For such distributions, the kernel module has to be signed with the security key or you would get the "\emph{ERROR: could not insert module}" when you insert your first hello world module:
188
+
For such distributions, the kernel module has to be signed with the security key or you would get the ``\emph{ERROR: could not insert module}'' when you insert your first hello world module:
185
189
186
190
\begin{codebash}
187
191
insmod ./hello-1.ko
@@ -191,7 +195,7 @@ \subsection{Before We Begin}
191
195
\emph{Lockdown: insmod: unsigned module loading is restricted;
192
196
see man kernel lockdown.7}
193
197
194
-
If you got this message, the simplest way is to disable the UEFI SecureBoot from the PC/laptop boot menu to have your "hello-1" to be inserted.
198
+
If you got this message, the simplest way is to disable the UEFI SecureBoot from the PC/laptop boot menu to have your ``hello-1'' to be inserted.
195
199
Of course you can go through complicated steps to generate keys, install keys to your system, and finally sign your module to make it work.
196
200
However, this is not suitable for beginners.
197
201
You could read and follow the steps in \href{https://wiki.debian.org/SecureBoot}{SecureBoot} if you are interested.
0 commit comments