This repo has a persistent on-disk preset layout. Treat changes in kernel/include/preset.h as ABI changes, not normal refactors. The tools build copies this header into tools/preset.h, so regenerate/keep that generated mirror in sync when building tools.
- Do not change
MAP_SYMBOL_NUMcasually. map_symbol_tsits beforeheader_backupinsidesetup_preset_t, so changingMAP_SYMBOL_NUMmovesheader_backupand every field after it.- This project's versioning diverges from upstream KernelPatch. Do not reuse upstream's
0.13.1/0.13.2header-backup split without mapping it to this repo's own commits and tags. - The relevant offset drift happened after this repo's
0.13.7tag and before0.13.8.
- (
add new method to local kallsyms_lookup & fix 4.14 kallsyms lookup) changesMAP_SYMBOL_NUMfrom5to6, adding oneuint64_tbeforeheader_backup; this movesheader_backupby+8bytes. - (
disable failed fallback) changesMAP_SYMBOL_NUMfrom6to7, replacing the temporarymemblock_start_of_DRAM_reloslot with two type slots; this movesheader_backupby another+8bytes. - then updates the project version to
0.13.8. - (
fix header backup) imports the upstream compatibility reader (preset_header_backup()), but itsVERSION(0, 13, 1)split is upstream-specific and must be adjusted for this project if changing the logic.
- KPatch-Next
0.13.7and older tagged builds:current_header_backup_offset - 16 - KPatch-Next
0.13.8and newer tagged builds/currentmain:current_header_backup_offset current_header_backup_offset - 8corresponds to the non-release intermediate layout afterab26ccbbut beforea7e1734; keep it only as a fallback for local/intermediate images.
tools/patch.c resolves this through preset_header_backup() and validates candidates with the saved primary-entry header.
- Prefer fixed-capacity storage for persistent structs.
- Prefer using reserved space like
__[]for small new metadata. - If a serialized struct must change, add explicit versioned parsing instead of relying on current
offsetof(...).
- Rebuild tools from this repo so
kernel/include/preset.his copied intotools/preset.hbefore compiling. - Re-test upgrade flow with:
- old patched boot -> extract kernel with the external
magiskbootworkflow - repatch extracted kernel
- unpatch or restore the kernel
- repatch again and verify the result
- old patched boot -> extract kernel with the external