Currently, the fadump crash memory reservation base is derived from
the crashkernel reservation size. For example, with crashkernel=768M,
the crash memory area is preferably placed at 768M physical address.
If a suitable reservation area is not available due to memory holes or
reserved ranges, the base address is adjusted accordingly.

When a kernel crashes with fadump enabled, the system performs a reboot
and the next kernel boots with special device tree properties added by
firmware to indicate an active dump. During this reboot flow, GRUB is
invoked again before the capture kernel boots.

To preserve the crashed kernel memory, GRUB operation must stay below
the fadump crash memory reservation area. Currently this works because
fadump requires a minimum crashkernel reservation of 768M, which ensures
that the fadump memory reservation base address is at least 768M.

However, if GRUB increases its memory access range in future, it may
overwrite the preserved crash memory before the capture kernel boots,
resulting in dump corruption.

Avoid this dependency by moving the fadump crash memory reservation
base to the middle of system RAM instead of deriving it from the
crashkernel reservation size.

Signed-off-by: Sourabh Jain <[email protected]>
---
 arch/powerpc/kernel/fadump.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 501d43bf18f3..1b4a330b7de0 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -586,7 +586,11 @@ int __init fadump_reserve_mem(void)
        else
                mem_boundary = memblock_end_of_DRAM();
 
-       base = fw_dump.boot_mem_top;
+       if (fw_dump.dump_active)
+               base = fw_dump.boot_mem_top;
+       else
+               base = mem_boundary / 2;
+
        size = get_fadump_area_size();
        fw_dump.reserve_dump_area_size = size;
        if (fw_dump.dump_active) {
-- 
2.52.0


Reply via email to