All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] powerpc/fadump: fadump fixes and improvements
@ 2022-04-06  9:38 Hari Bathini
  2022-04-06  9:38 ` [PATCH 1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area Hari Bathini
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hari Bathini @ 2022-04-06  9:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh J Salgaonkar, Sourabh Jain

This series fixes a couple of issues in fadump and improves logging.
The first patch fixes a bug that is observed when memory reserved for
fadump is not adjacent to boot memory area. The second patch ensures
mmap read succeeds for all memory regions in the vmcore. The third
patch improves the data that is printed for fadump.

Hari Bathini (3):
  powerpc/fadump: fix PT_LOAD segment for boot memory area
  powerpc/fadump: align destination address to pagesize
  powerpc/fadump: print start of preserved area

 arch/powerpc/kernel/fadump.c                 | 13 +++++++++++--
 arch/powerpc/platforms/powernv/opal-fadump.c |  6 +++---
 arch/powerpc/platforms/pseries/rtas-fadump.c | 12 +++++++++---
 3 files changed, 23 insertions(+), 8 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area
  2022-04-06  9:38 [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Hari Bathini
@ 2022-04-06  9:38 ` Hari Bathini
  2022-04-06  9:38 ` [PATCH 2/3] powerpc/fadump: align destination address to pagesize Hari Bathini
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2022-04-06  9:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh J Salgaonkar, Sourabh Jain

Boot memory area is setup as separate PT_LOAD segment in the vmcore
as it is moved by f/w, on crash, to a destination address provided by
the kernel. Having separate PT_LOAD segment helps in handling the
different physical address and offset for boot memory area in the
vmcore.

Commit ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to
reduce PT_LOAD segements") inadvertly broke this pre-condition for
cases where some of the first kernel memory is available adjacent to
boot memory area. This scenario is rare but possible when memory for
fadump could not be reserved adjacent to boot memory area owing to
memory hole or such. Reading memory from a vmcore exported in such
scenario provides incorrect data.  Fix it by ensuring no other region
is folded into boot memory area.

Fixes: ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to reduce PT_LOAD segements")
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
 arch/powerpc/kernel/fadump.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 65562c4a0a69..dc2350b288cf 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -867,7 +867,6 @@ static int fadump_alloc_mem_ranges(struct fadump_mrange_info *mrange_info)
 				       sizeof(struct fadump_memory_range));
 	return 0;
 }
-
 static inline int fadump_add_mem_range(struct fadump_mrange_info *mrange_info,
 				       u64 base, u64 end)
 {
@@ -886,7 +885,12 @@ static inline int fadump_add_mem_range(struct fadump_mrange_info *mrange_info,
 		start = mem_ranges[mrange_info->mem_range_cnt - 1].base;
 		size  = mem_ranges[mrange_info->mem_range_cnt - 1].size;
 
-		if ((start + size) == base)
+		/*
+		 * Boot memory area needs separate PT_LOAD segment(s) as it
+		 * is moved to a different location at the time of crash.
+		 * So, fold only if the region is not boot memory area.
+		 */
+		if ((start + size) == base && start >= fw_dump.boot_mem_top)
 			is_adjacent = true;
 	}
 	if (!is_adjacent) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] powerpc/fadump: align destination address to pagesize
  2022-04-06  9:38 [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Hari Bathini
  2022-04-06  9:38 ` [PATCH 1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area Hari Bathini
@ 2022-04-06  9:38 ` Hari Bathini
  2022-04-06  9:38 ` [PATCH 3/3] powerpc/fadump: print start of preserved area Hari Bathini
  2022-05-15 10:12 ` [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2022-04-06  9:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh J Salgaonkar, Sourabh Jain

On crash, boot memory area is copied to a destination address by f/w.
This region is setup as separate PT_LOAD segment with appropriate
offset to handle the different physical address and offset in vmcore.
If this destination address is not page aligned, reading the vmcore
with mmap is likely to fail forcing tools like makedumpfile to fall
back to regular read. Avoid mmap read failure by ensuring that the
destination address is always page aligned.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
 arch/powerpc/kernel/fadump.c                 | 5 +++++
 arch/powerpc/platforms/pseries/rtas-fadump.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index dc2350b288cf..ee564e8226b1 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -365,6 +365,11 @@ static unsigned long __init get_fadump_area_size(void)
 
 	size += fw_dump.cpu_state_data_size;
 	size += fw_dump.hpte_region_size;
+	/*
+	 * Account for pagesize alignment of boot memory area destination address.
+	 * This faciliates in mmap reading of first kernel's memory.
+	 */
+	size = PAGE_ALIGN(size);
 	size += fw_dump.boot_memory_size;
 	size += sizeof(struct fadump_crash_info_header);
 	size += sizeof(struct elfhdr); /* ELF core header.*/
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
index 35f9cb602c30..764df25304bd 100644
--- a/arch/powerpc/platforms/pseries/rtas-fadump.c
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -108,6 +108,12 @@ static u64 rtas_fadump_init_mem_struct(struct fw_dump *fadump_conf)
 	fdm.hpte_region.destination_address = cpu_to_be64(addr);
 	addr += fadump_conf->hpte_region_size;
 
+	/*
+	 * Align boot memory area destination address to page boundary to
+	 * be able to mmap read this area in the vmcore.
+	 */
+	addr = PAGE_ALIGN(addr);
+
 	/* RMA region section */
 	fdm.rmr_region.request_flag = cpu_to_be32(RTAS_FADUMP_REQUEST_FLAG);
 	fdm.rmr_region.source_data_type =
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] powerpc/fadump: print start of preserved area
  2022-04-06  9:38 [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Hari Bathini
  2022-04-06  9:38 ` [PATCH 1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area Hari Bathini
  2022-04-06  9:38 ` [PATCH 2/3] powerpc/fadump: align destination address to pagesize Hari Bathini
@ 2022-04-06  9:38 ` Hari Bathini
  2022-05-15 10:12 ` [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2022-04-06  9:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh J Salgaonkar, Sourabh Jain

Print preserved area start address in fadump_region_show() function.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
 arch/powerpc/platforms/powernv/opal-fadump.c | 6 +++---
 arch/powerpc/platforms/pseries/rtas-fadump.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
index c8ad057c7221..c56fb5a7146a 100644
--- a/arch/powerpc/platforms/powernv/opal-fadump.c
+++ b/arch/powerpc/platforms/powernv/opal-fadump.c
@@ -578,10 +578,10 @@ static void opal_fadump_region_show(struct fw_dump *fadump_conf,
 			   fdm_ptr->rgn[i].size, dumped_bytes);
 	}
 
-	/* Dump is active. Show reserved area start address. */
+	/* Dump is active. Show preserved area start address. */
 	if (fadump_conf->dump_active) {
-		seq_printf(m, "\nMemory above %#016lx is reserved for saving crash dump\n",
-			   fadump_conf->reserve_dump_area_start);
+		seq_printf(m, "\nMemory above %#016llx is reserved for saving crash dump\n",
+			   fadump_conf->boot_mem_top);
 	}
 }
 
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
index 764df25304bd..50b140c7b513 100644
--- a/arch/powerpc/platforms/pseries/rtas-fadump.c
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -468,10 +468,10 @@ static void rtas_fadump_region_show(struct fw_dump *fadump_conf,
 		   be64_to_cpu(fdm_ptr->rmr_region.source_len),
 		   be64_to_cpu(fdm_ptr->rmr_region.bytes_dumped));
 
-	/* Dump is active. Show reserved area start address. */
+	/* Dump is active. Show preserved area start address. */
 	if (fdm_active) {
-		seq_printf(m, "\nMemory above %#016lx is reserved for saving crash dump\n",
-			   fadump_conf->reserve_dump_area_start);
+		seq_printf(m, "\nMemory above %#016llx is reserved for saving crash dump\n",
+			   fadump_conf->boot_mem_top);
 	}
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] powerpc/fadump: fadump fixes and improvements
  2022-04-06  9:38 [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Hari Bathini
                   ` (2 preceding siblings ...)
  2022-04-06  9:38 ` [PATCH 3/3] powerpc/fadump: print start of preserved area Hari Bathini
@ 2022-05-15 10:12 ` Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2022-05-15 10:12 UTC (permalink / raw)
  To: Hari Bathini, linuxppc-dev; +Cc: Mahesh J Salgaonkar, Sourabh Jain

On Wed, 6 Apr 2022 15:08:36 +0530, Hari Bathini wrote:
> This series fixes a couple of issues in fadump and improves logging.
> The first patch fixes a bug that is observed when memory reserved for
> fadump is not adjacent to boot memory area. The second patch ensures
> mmap read succeeds for all memory regions in the vmcore. The third
> patch improves the data that is printed for fadump.
> 
> Hari Bathini (3):
>   powerpc/fadump: fix PT_LOAD segment for boot memory area
>   powerpc/fadump: align destination address to pagesize
>   powerpc/fadump: print start of preserved area
> 
> [...]

Applied to powerpc/next.

[1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area
      https://git.kernel.org/powerpc/c/15eb77f873255cf9f4d703b63cfbd23c46579654
[2/3] powerpc/fadump: align destination address to pagesize
      https://git.kernel.org/powerpc/c/9cf3b3a33a36ef4a988be0a770edd3555297f2a9
[3/3] powerpc/fadump: print start of preserved area
      https://git.kernel.org/powerpc/c/a3ceb5882edf6696ebc6aeb8043ddec548a93052

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-15 10:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  9:38 [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Hari Bathini
2022-04-06  9:38 ` [PATCH 1/3] powerpc/fadump: fix PT_LOAD segment for boot memory area Hari Bathini
2022-04-06  9:38 ` [PATCH 2/3] powerpc/fadump: align destination address to pagesize Hari Bathini
2022-04-06  9:38 ` [PATCH 3/3] powerpc/fadump: print start of preserved area Hari Bathini
2022-05-15 10:12 ` [PATCH 0/3] powerpc/fadump: fadump fixes and improvements Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.