[PATCH 0/2] pstore/ram: refuse zones overlapping the initrd

From: Qianhui Xu

Date: Sun Nov 15 2026 - 23:01:29 EST


On this board the bootloader hands the kernel the initrd buffer at a
physical address it picks itself, and it has no way to know about the
reservations described in the device tree: those only exist in the
kernel. When the buffer lands inside a ramoops zone, the zone is
registered a few milliseconds later, the console zone starts writing to
it, and the initrd is destroyed before it is unpacked:

printk: legacy console [ramoops-1] enabled
...
Initramfs unpacking failed: invalid magic at start of compressed archive

The fix is to refuse to register a zone that overlaps the initrd, and to
say which one was dropped. The zone is skipped for this boot only:
nothing stops the memory from being reused once the initrd is gone, and
the same configuration boots fine if the firmware happens to place the
buffer elsewhere.

Patch 1 adds a helper that reports the physical range of the initrd,
patch 2 uses it in the ramoops driver.

The check can only see an overlap while the initrd still exists. The
built-in driver probes at postcore_initcall(), well before the initramfs
is unpacked, so the normal case is covered; a module loaded later cannot
tell, and gets no protection. This is documented in the code.

Testing: reproduced on an arm64 device and under QEMU, in both cases by
placing a ramoops zone over the initrd buffer:

- QEMU (-M virt, initrd=... pinned by phys address): without the change
the unpack fails with the message above; with it, the console zone is
dropped, the initrd unpacks and the machine boots into init.
- arm64 device (UEFI -> GRUB -> 64 MB initrd landing at
0xc1ab0000-0xc584a5e0, i.e. covering an 8 MB ramoops at 0xc2000000):
without the change the boot dies before unpacking; with it, dmesg
shows the three zones being skipped, the initrd unpacks and userspace
starts.

Kees, Tony, Guilherme: I did not Cc stable, since this needs a bootloader
and a device tree that actually disagree about the memory, which is
unusual outside of Qualcomm boards; happy to add a Cc: stable if you
think it belongs there.

Qianhui Xu (2):
init: initrd: add initrd_phys_range()
pstore/ram: skip zones overlapping the initrd

fs/pstore/ram.c | 114 ++++++++++++++++++++++++++++++++---------
include/linux/initrd.h | 7 +++
init/initramfs.c | 28 ++++++++++
3 files changed, 125 insertions(+), 24 deletions(-)


base-commit: 9d66f26fefacebfeed15de31c1123451a17ff119
--
2.53.0