diff options
| author | Matthias Goergens <matthias.goergens@gmail.com> | 2026-09-26 13:21:17 +0800 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2026-09-30 21:59:53 +0200 |
| commit | 29671cabfc09afb1ee2426b21173cdde276a95ac (patch) | |
| tree | 776410d84604891ef956b6f0439a75a86edf0db0 /rust | |
| parent | 9df3e4316c2ee861074b631b8a232ae37ce093ab (diff) | |
x86/hibernate: Ignore page-zero RAM in E820 checksum
The legacy kexec_load path reconstructs the E820 map exported through
sysfs. kexec-tools leaves the first 1 KiB unavailable for the real-mode
transition, so a kernel entered through kexec_load can see conventional
RAM starting at 0x400. A subsequent firmware boot reports the same RAM
range starting at zero.
The hibernation E820 checksum compares those byte representations and
rejects the image, even though the maps agree from page one onwards.
A QEMU guest showed this transition:
firmware: RAM [0-0x9fbff]
kexec_load: gap [0-0x3ff], RAM [0x400-0x9fbff]
firmware: RAM [0-0x9fbff]
The checksum covers e820_table_firmware, which trim_bios_range() leaves
alone. The nosave regions come from e820_table instead, where
trim_bios_range() has already turned conventional RAM in page zero into
reserved memory, so page zero never occurs in the image, whatever the
firmware map says about it.
Canonicalise only the conventional-RAM portion below PAGE_SIZE before
calculating the checksum. Preserve RESERVED, ACPI, NVS, UNUSABLE, PMEM
and all other E820 types so that changes to exceptional mappings remain
detectable.
This is deliberately narrower than Marco Scardovi's June proposal to
checksum only RAM and its opt-in relaxed_memmap successor. Rafael
noted that ignoring non-RAM changes could hide moved ACPI or UEFI
regions still used by the resumed kernel. This patch preserves every
non-RAM entry and ignores only RAM within page zero, which common setup
already reserves and excludes from the image.
Bump RESTORE_MAGIC, since the checksum semantics change, so that an
image written by a kernel without this change is refused by the magic
check instead of being compared under different rules.
In the same guest, with the page-zero difference kept, hibernation and
resume now work after both a direct boot and a kexec_load boot. An
image written by an unpatched kernel is refused at resume with
"Unrecognized hibernate image header format!", and the firmware-booted
kernel carries on.
Fixes: 62a03defeabd ("PM / hibernate: Verify the consistent of e820 memory map by md5 digest")
Reported-by: Roberto Ricci <io@r-ricci.it>
Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
Link: https://lore.kernel.org/all/Z-hYWc9LtBU1Yhtg@desktop0a/
Link: https://lists.openwall.net/linux-kernel/2025/04/04/1372
Link: https://lore.kernel.org/all/CAJZ5v0jmOj0WBtMTvbnaD+2b0bTFowA=JWrqRzaaCYpHpai1Nw@mail.gmail.com/
Link: https://lore.kernel.org/all/20260623165724.10753-1-scardracs@disroot.org/
Link: https://patch.msgid.link/20260926052117.3613637-1-matthias.goergens@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'rust')
0 files changed, 0 insertions, 0 deletions
