Skip to content

Commit 686957f

Browse files
authored
Merge pull request #1469 from joe-lawrence/doc-import-ns
patch-author-guide: add a blurb about module namespaces
2 parents 21dad4d + 8a1d847 commit 686957f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

doc/patch-author-guide.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Table of contents
2828
- [Sibling calls](#sibling-calls)
2929
- [Exported symbol versioning](#exported-symbol-versioning)
3030
- [System calls](#system-calls)
31+
- [Symbol Namespaces](#symbol-namespaces)
3132

3233
Patch analysis
3334
--------------
@@ -945,3 +946,21 @@ missing because of the 'inline' annotation, which invokes 'notrace'.
945946
This problem can be worked around by adding `#include "kpatch-syscall.h"` and
946947
replacing the use of the `SYSCALL_DEFINE1` (or similar) macro with the
947948
`KPATCH_` prefixed version.
949+
950+
Symbol Namespaces
951+
-----------------
952+
953+
While kpatch modules automatically inherit namespace imports from
954+
already-patched object files, a manual import may be required when
955+
patching kernel code that is normally built-in.
956+
957+
The original built-in code doesn't need to explicitly import namespaces.
958+
However, when converted into a kpatch module, it must declare any namespace
959+
dependencies. Without this explicit import, the kpatch-build command will fail
960+
with modpost errors for using symbols from a namespace without importing
961+
it, i.e.
962+
```
963+
ERROR: modpost: module livepatch-test uses symbol dma_buf_export from namespace DMA_BUF, but does not import it.
964+
```
965+
To manually import the required namespace, add the MODULE_IMPORT_NS() macro to
966+
the patch source. For example: `MODULE_IMPORT_NS("DMA_BUF")`

0 commit comments

Comments
 (0)