Skip to content

Commit 89e33ea

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: livepatch: convert docs to ReST and rename to *.rst
Convert livepatch documentation to ReST format. The changes are mostly trivial, as the documents are already on a good shape. Just a few markup changes are needed for Sphinx to properly parse the docs. The conversion is actually: - add blank lines and identation in order to identify paragraphs; - fix tables markups; - add some lists markups; - mark literal blocks; - The in-file TOC becomes a comment, in order to skip it from the output, as Sphinx already generates an index there. - adjust title markups. At its new index.rst, let's add a :orphan: while this is not linked to the main index.rst file, in order to avoid build warnings. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Petr Mladek <pmladek@suse.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Joe Lawrence <joe.lawrence@redhat.com> Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 894ee5f commit 89e33ea

8 files changed

Lines changed: 228 additions & 167 deletions

File tree

‎Documentation/ABI/testing/sysfs-kernel-livepatch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Description:
4545
use this feature without a clearance from a patch
4646
distributor. Removal (rmmod) of patch modules is permanently
4747
disabled when the feature is used. See
48-
Documentation/livepatch/livepatch.txt for more information.
48+
Documentation/livepatch/livepatch.rst for more information.
4949

5050
What: /sys/kernel/livepatch/<patch>/<object>
5151
Date: Nov 2014
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ be patched, irrespective of the target klp_object's current state.
3030

3131
Callbacks can be registered for the following livepatch actions:
3232

33-
* Pre-patch - before a klp_object is patched
33+
* Pre-patch
34+
- before a klp_object is patched
3435

35-
* Post-patch - after a klp_object has been patched and is active
36+
* Post-patch
37+
- after a klp_object has been patched and is active
3638
across all tasks
3739

38-
* Pre-unpatch - before a klp_object is unpatched (ie, patched code is
40+
* Pre-unpatch
41+
- before a klp_object is unpatched (ie, patched code is
3942
active), used to clean up post-patch callback
4043
resources
4144

42-
* Post-unpatch - after a klp_object has been patched, all code has
45+
* Post-unpatch
46+
- after a klp_object has been patched, all code has
4347
been restored and no tasks are running patched code,
4448
used to cleanup pre-patch callback resources
4549

Documentation/livepatch/cumulative-patches.txt renamed to Documentation/livepatch/cumulative-patches.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Usage
1818
-----
1919

2020
The atomic replace can be enabled by setting "replace" flag in struct klp_patch,
21-
for example:
21+
for example::
2222

2323
static struct klp_patch patch = {
2424
.mod = THIS_MODULE,
@@ -49,19 +49,19 @@ Features
4949

5050
The atomic replace allows:
5151

52-
+ Atomically revert some functions in a previous patch while
52+
- Atomically revert some functions in a previous patch while
5353
upgrading other functions.
5454

55-
+ Remove eventual performance impact caused by core redirection
55+
- Remove eventual performance impact caused by core redirection
5656
for functions that are no longer patched.
5757

58-
+ Decrease user confusion about dependencies between livepatches.
58+
- Decrease user confusion about dependencies between livepatches.
5959

6060

6161
Limitations:
6262
------------
6363

64-
+ Once the operation finishes, there is no straightforward way
64+
- Once the operation finishes, there is no straightforward way
6565
to reverse it and restore the replaced patches atomically.
6666

6767
A good practice is to set .replace flag in any released livepatch.
@@ -74,7 +74,7 @@ Limitations:
7474
only when the transition was not forced.
7575

7676

77-
+ Only the (un)patching callbacks from the _new_ cumulative livepatch are
77+
- Only the (un)patching callbacks from the _new_ cumulative livepatch are
7878
executed. Any callbacks from the replaced patches are ignored.
7979

8080
In other words, the cumulative patch is responsible for doing any actions
@@ -93,7 +93,7 @@ Limitations:
9393
enabled patches were called.
9494

9595

96-
+ There is no special handling of shadow variables. Livepatch authors
96+
- There is no special handling of shadow variables. Livepatch authors
9797
must create their own rules how to pass them from one cumulative
9898
patch to the other. Especially that they should not blindly remove
9999
them in module_exit() functions.

‎Documentation/livepatch/index.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
:orphan:
2+
3+
===================
4+
Kernel Livepatching
5+
===================
6+
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
livepatch
11+
callbacks
12+
cumulative-patches
13+
module-elf-format
14+
shadow-vars
15+
16+
.. only:: subproject and html
17+
18+
Indices
19+
=======
20+
21+
* :ref:`genindex`
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ Livepatch
44

55
This document outlines basic information about kernel livepatching.
66

7-
Table of Contents:
8-
9-
1. Motivation
10-
2. Kprobes, Ftrace, Livepatching
11-
3. Consistency model
12-
4. Livepatch module
13-
4.1. New functions
14-
4.2. Metadata
15-
5. Livepatch life-cycle
16-
5.1. Loading
17-
5.2. Enabling
18-
5.3. Replacing
19-
5.4. Disabling
20-
5.5. Removing
21-
6. Sysfs
22-
7. Limitations
7+
.. Table of Contents:
8+
9+
1. Motivation
10+
2. Kprobes, Ftrace, Livepatching
11+
3. Consistency model
12+
4. Livepatch module
13+
4.1. New functions
14+
4.2. Metadata
15+
5. Livepatch life-cycle
16+
5.1. Loading
17+
5.2. Enabling
18+
5.3. Replacing
19+
5.4. Disabling
20+
5.5. Removing
21+
6. Sysfs
22+
7. Limitations
2323
2424
2525
1. Motivation
@@ -40,14 +40,14 @@ There are multiple mechanisms in the Linux kernel that are directly related
4040
to redirection of code execution; namely: kernel probes, function tracing,
4141
and livepatching:
4242

43-
+ The kernel probes are the most generic. The code can be redirected by
43+
- The kernel probes are the most generic. The code can be redirected by
4444
putting a breakpoint instruction instead of any instruction.
4545

46-
+ The function tracer calls the code from a predefined location that is
46+
- The function tracer calls the code from a predefined location that is
4747
close to the function entry point. This location is generated by the
4848
compiler using the '-pg' gcc option.
4949

50-
+ Livepatching typically needs to redirect the code at the very beginning
50+
- Livepatching typically needs to redirect the code at the very beginning
5151
of the function entry before the function parameters or the stack
5252
are in any way modified.
5353

@@ -249,7 +249,7 @@ The patch contains only functions that are really modified. But they
249249
might want to access functions or data from the original source file
250250
that may only be locally accessible. This can be solved by a special
251251
relocation section in the generated livepatch module, see
252-
Documentation/livepatch/module-elf-format.txt for more details.
252+
Documentation/livepatch/module-elf-format.rst for more details.
253253

254254

255255
4.2. Metadata
@@ -258,7 +258,7 @@ Documentation/livepatch/module-elf-format.txt for more details.
258258
The patch is described by several structures that split the information
259259
into three levels:
260260

261-
+ struct klp_func is defined for each patched function. It describes
261+
- struct klp_func is defined for each patched function. It describes
262262
the relation between the original and the new implementation of a
263263
particular function.
264264

@@ -275,7 +275,7 @@ into three levels:
275275
only for a particular object ( vmlinux or a kernel module ). Note that
276276
kallsyms allows for searching symbols according to the object name.
277277

278-
+ struct klp_object defines an array of patched functions (struct
278+
- struct klp_object defines an array of patched functions (struct
279279
klp_func) in the same object. Where the object is either vmlinux
280280
(NULL) or a module name.
281281

@@ -285,7 +285,7 @@ into three levels:
285285
only when they are available.
286286

287287

288-
+ struct klp_patch defines an array of patched objects (struct
288+
- struct klp_patch defines an array of patched objects (struct
289289
klp_object).
290290

291291
This structure handles all patched functions consistently and eventually,
@@ -337,14 +337,16 @@ operation fails.
337337
Second, livepatch enters into a transition state where tasks are converging
338338
to the patched state. If an original function is patched for the first
339339
time, a function specific struct klp_ops is created and an universal
340-
ftrace handler is registered[*]. This stage is indicated by a value of '1'
340+
ftrace handler is registered\ [#]_. This stage is indicated by a value of '1'
341341
in /sys/kernel/livepatch/<name>/transition. For more information about
342342
this process, see the "Consistency model" section.
343343

344344
Finally, once all tasks have been patched, the 'transition' value changes
345345
to '0'.
346346

347-
[*] Note that functions might be patched multiple times. The ftrace handler
347+
.. [#]
348+
349+
Note that functions might be patched multiple times. The ftrace handler
348350
is registered only once for a given function. Further patches just add
349351
an entry to the list (see field `func_stack`) of the struct klp_ops.
350352
The right implementation is selected by the ftrace handler, see
@@ -368,7 +370,7 @@ the ftrace handler is unregistered and the struct klp_ops is
368370
freed when the related function is not modified by the new patch
369371
and func_stack list becomes empty.
370372

371-
See Documentation/livepatch/cumulative-patches.txt for more details.
373+
See Documentation/livepatch/cumulative-patches.rst for more details.
372374

373375

374376
5.4. Disabling
@@ -421,7 +423,7 @@ See Documentation/ABI/testing/sysfs-kernel-livepatch for more details.
421423

422424
The current Livepatch implementation has several limitations:
423425

424-
+ Only functions that can be traced could be patched.
426+
- Only functions that can be traced could be patched.
425427

426428
Livepatch is based on the dynamic ftrace. In particular, functions
427429
implementing ftrace or the livepatch ftrace handler could not be
@@ -431,7 +433,7 @@ The current Livepatch implementation has several limitations:
431433

432434

433435

434-
+ Livepatch works reliably only when the dynamic ftrace is located at
436+
- Livepatch works reliably only when the dynamic ftrace is located at
435437
the very beginning of the function.
436438

437439
The function need to be redirected before the stack or the function
@@ -445,15 +447,15 @@ The current Livepatch implementation has several limitations:
445447
this is handled on the ftrace level.
446448

447449

448-
+ Kretprobes using the ftrace framework conflict with the patched
450+
- Kretprobes using the ftrace framework conflict with the patched
449451
functions.
450452

451453
Both kretprobes and livepatches use a ftrace handler that modifies
452454
the return address. The first user wins. Either the probe or the patch
453455
is rejected when the handler is already in use by the other.
454456

455457

456-
+ Kprobes in the original function are ignored when the code is
458+
- Kprobes in the original function are ignored when the code is
457459
redirected to the new implementation.
458460

459461
There is a work in progress to add warnings about this situation.

0 commit comments

Comments
 (0)