|
Michal Suchanek |
2607c5 |
From 15eb77f873255cf9f4d703b63cfbd23c46579654 Mon Sep 17 00:00:00 2001
|
|
Michal Suchanek |
2607c5 |
From: Hari Bathini <hbathini@linux.ibm.com>
|
|
Michal Suchanek |
2607c5 |
Date: Wed, 6 Apr 2022 15:08:37 +0530
|
|
Michal Suchanek |
2607c5 |
Subject: [PATCH] powerpc/fadump: fix PT_LOAD segment for boot memory area
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
References: bsc#1103269 ltc#169948 git-fixes
|
|
Michal Suchanek |
2607c5 |
Patch-mainline: v5.19-rc1
|
|
Michal Suchanek |
2607c5 |
Git-commit: 15eb77f873255cf9f4d703b63cfbd23c46579654
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
Boot memory area is setup as separate PT_LOAD segment in the vmcore
|
|
Michal Suchanek |
2607c5 |
as it is moved by f/w, on crash, to a destination address provided by
|
|
Michal Suchanek |
2607c5 |
the kernel. Having separate PT_LOAD segment helps in handling the
|
|
Michal Suchanek |
2607c5 |
different physical address and offset for boot memory area in the
|
|
Michal Suchanek |
2607c5 |
vmcore.
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
Commit ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to
|
|
Michal Suchanek |
2607c5 |
reduce PT_LOAD segements") inadvertly broke this pre-condition for
|
|
Michal Suchanek |
2607c5 |
cases where some of the first kernel memory is available adjacent to
|
|
Michal Suchanek |
2607c5 |
boot memory area. This scenario is rare but possible when memory for
|
|
Michal Suchanek |
2607c5 |
fadump could not be reserved adjacent to boot memory area owing to
|
|
Michal Suchanek |
2607c5 |
memory hole or such. Reading memory from a vmcore exported in such
|
|
Michal Suchanek |
2607c5 |
scenario provides incorrect data. Fix it by ensuring no other region
|
|
Michal Suchanek |
2607c5 |
is folded into boot memory area.
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
Fixes: ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to reduce PT_LOAD segements")
|
|
Michal Suchanek |
2607c5 |
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
|
|
Michal Suchanek |
2607c5 |
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
|
|
Michal Suchanek |
2607c5 |
Link: https://lore.kernel.org/r/20220406093839.206608-2-hbathini@linux.ibm.com
|
|
Michal Suchanek |
2607c5 |
[ms: we don't have boot_mem_top, use boot_memory_size instead]
|
|
Michal Suchanek |
2607c5 |
Acked-by: Michal Suchanek <msuchanek@suse.de>
|
|
Michal Suchanek |
2607c5 |
---
|
|
Michal Suchanek |
2607c5 |
arch/powerpc/kernel/fadump.c | 8 ++++++--
|
|
Michal Suchanek |
2607c5 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
|
|
Michal Suchanek |
2607c5 |
--- a/arch/powerpc/kernel/fadump.c
|
|
Michal Suchanek |
2607c5 |
+++ b/arch/powerpc/kernel/fadump.c
|
|
Michal Suchanek |
2607c5 |
@@ -867,7 +867,6 @@ static int fadump_alloc_mem_ranges(struct fadump_mrange_info *mrange_info)
|
|
Michal Suchanek |
2607c5 |
sizeof(struct fadump_memory_range));
|
|
Michal Suchanek |
2607c5 |
return 0;
|
|
Michal Suchanek |
2607c5 |
}
|
|
Michal Suchanek |
2607c5 |
-
|
|
Michal Suchanek |
2607c5 |
static inline int fadump_add_mem_range(struct fadump_mrange_info *mrange_info,
|
|
Michal Suchanek |
2607c5 |
u64 base, u64 end)
|
|
Michal Suchanek |
2607c5 |
{
|
|
Michal Suchanek |
2607c5 |
@@ -886,7 +885,12 @@ static inline int fadump_add_mem_range(struct fadump_mrange_info *mrange_info,
|
|
Michal Suchanek |
2607c5 |
start = mem_ranges[mrange_info->mem_range_cnt - 1].base;
|
|
Michal Suchanek |
2607c5 |
size = mem_ranges[mrange_info->mem_range_cnt - 1].size;
|
|
Michal Suchanek |
2607c5 |
|
|
Michal Suchanek |
2607c5 |
- if ((start + size) == base)
|
|
Michal Suchanek |
2607c5 |
+ /*
|
|
Michal Suchanek |
2607c5 |
+ * Boot memory area needs separate PT_LOAD segment(s) as it
|
|
Michal Suchanek |
2607c5 |
+ * is moved to a different location at the time of crash.
|
|
Michal Suchanek |
2607c5 |
+ * So, fold only if the region is not boot memory area.
|
|
Michal Suchanek |
2607c5 |
+ */
|
|
Michal Suchanek |
2607c5 |
+ if ((start + size) == base && start >= fw_dump.boot_memory_size)
|
|
Michal Suchanek |
2607c5 |
is_adjacent = true;
|
|
Michal Suchanek |
2607c5 |
}
|
|
Michal Suchanek |
2607c5 |
if (!is_adjacent) {
|
|
Michal Suchanek |
2607c5 |
--
|
|
Michal Suchanek |
2607c5 |
2.35.3
|
|
Michal Suchanek |
2607c5 |
|