Skip to content

Commit 5ad75fc

Browse files
Jessica YuJiri Kosina
authored andcommitted
Documentation: livepatch: add section about arch-specific code
Document usage of arch-specific elf sections in livepatch as well as implementation of arch-specific code. [[email protected]: fix wording as suggested by Petr Mladek] Signed-off-by: Jessica Yu <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d4c3e6e commit 5ad75fc

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Documentation/livepatch/module-elf-format.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Table of Contents
2525
3.3.2 Required name format
2626
3.3.3 Example livepatch symbol names
2727
3.3.4 Example `readelf --symbols` output
28-
4. Symbol table and Elf section access
28+
4. Architecture-specific sections
29+
5. Symbol table and Elf section access
2930

3031
----------------------------
3132
0. Background and motivation
@@ -46,7 +47,7 @@ architecture.
4647

4748
Since apply_relocate_add() requires access to a module's section header
4849
table, symbol table, and relocation section indices, Elf information is
49-
preserved for livepatch modules (see section 4). Livepatch manages its own
50+
preserved for livepatch modules (see section 5). Livepatch manages its own
5051
relocation sections and symbols, which are described in this document. The
5152
Elf constants used to mark livepatch symbols and relocation sections were
5253
selected from OS-specific ranges according to the definitions from glibc.
@@ -117,7 +118,7 @@ also possible for a livepatch module to have no livepatch relocation
117118
sections, as in the case of the sample livepatch module (see
118119
samples/livepatch).
119120

120-
Since Elf information is preserved for livepatch modules (see Section 4), a
121+
Since Elf information is preserved for livepatch modules (see Section 5), a
121122
livepatch relocation section can be applied simply by passing in the
122123
appropriate section index to apply_relocate_add(), which then uses it to
123124
access the relocation section and apply the relocations.
@@ -292,8 +293,19 @@ Symbol table '.symtab' contains 127 entries:
292293
[*] Note that the 'Ndx' (Section index) for these symbols is SHN_LIVEPATCH (0xff20).
293294
"OS" means OS-specific.
294295

296+
---------------------------------
297+
4. Architecture-specific sections
298+
---------------------------------
299+
Architectures may override arch_klp_init_object_loaded() to perform
300+
additional arch-specific tasks when a target module loads, such as applying
301+
arch-specific sections. On x86 for example, we must apply per-object
302+
.altinstructions and .parainstructions sections when a target module loads.
303+
These sections must be prefixed with ".klp.arch.$objname." so that they can
304+
be easily identified when iterating through a patch module's Elf sections
305+
(See arch/x86/kernel/livepatch.c for a complete example).
306+
295307
--------------------------------------
296-
4. Symbol table and Elf section access
308+
5. Symbol table and Elf section access
297309
--------------------------------------
298310
A livepatch module's symbol table is accessible through module->symtab.
299311

0 commit comments

Comments
 (0)