Skip to contentSkip to conversation

ppc/fadump: collect dump when CPU_STATE_DATA is less than reserved

PATCH Applied Shivang Upadhyay 2 participants 2 messages Sep 28 – Oct 14 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 ppc/fadump: collect dump when CPU_STATE_DATA is less than reserved

During Fadump in Qemu VM, when maxcpus value is set to more than current cpus, following failure is observed.

    [    0.045806] [      T1] rtas fadump: Dump taken by platform is
        incomplete (0)

This is because the CPU_STATE_DATA is allocated for maxcpus, while the data is only filled for current cpus. As per current implementation of Fadump, dumped_bytes and source_len for a region have to match, Which is failing for qemu's case, Even tough the dumped bytes are reported correctly for only the current cpus. After this /proc/vmcore generatition also fails.

Allowing dumped_bytes to be lesser than or equal to allocated length, for CPU_STATE_DATA Fadump region.

---

Changelog:
v5:
- rebase to master
- fixed error message to incomplete/corrupted based on dumped size.

v4: https://lore.kernel.org/all/[email protected]/
removed extra blank line.

v3: https://lore.kernel.org/all/[email protected]/
removed extra variable.

v2: https://lore.kernel.org/all/[email protected]/
Only allowing lesser size for CPU_STATE_DATE Fadump region.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

---
 arch/powerpc/platforms/pseries/rtas-fadump.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/rtas-fadump.c +15 -3
index 3bb4ac2ab6cc..9b9e09f3d900 100644
@@ -459,6 +459,8 @@ static int __init rtas_fadump_process(struct fw_dump *fadump_conf)
 	/* Check if the dump data is valid. */
 	for (int i = 0; i < be16_to_cpu(fdm_active->header.dump_num_sections); i++) {
 		int type = be16_to_cpu(fdm_active->rgn[i].source_data_type);
+		uint64_t bytes_dumped = be64_to_cpu(fdm_active->rgn[i].bytes_dumped);
+		uint64_t source_len = be64_to_cpu(fdm_active->rgn[i].source_len);
 		int rc = 0;
 
 		switch (type) {
@@ -469,10 +471,20 @@ static int __init rtas_fadump_process(struct fw_dump *fadump_conf)
 				pr_err("Dump taken by platform is not valid (%d)\n", i);
 				rc = -EINVAL;
 			}
-			if (fdm_active->rgn[i].bytes_dumped != fdm_active->rgn[i].source_len) {
-				pr_err("Dump taken by platform is incomplete (%d)\n", i);
+
+			/*
+			 * Make sure that dump is collected for entire region.
+			 * CPU_STATE_DATA region is allowed to dump less than allocated space.
+			 */
+			if (!(bytes_dumped == source_len ||
+			(type == RTAS_FADUMP_CPU_STATE_DATA && bytes_dumped <= source_len))) {
+				pr_err("Dump taken by platform is %s (%d)\n",
+					(bytes_dumped < source_len ? "incomplete" : "corrupted"), i);
+				pr_debug("type -> %d, bytes_dumped -> %llx, source_len -> %llx\n",
+					 type, bytes_dumped, source_len);
 				rc = -EINVAL;
 			}
+
 			if (rc) {
 				pr_warn("Region type: %u src addr: 0x%llx dest addr: 0x%llx\n",
 					be16_to_cpu(fdm_active->rgn[i].source_data_type),
@@ -482,7 +494,7 @@ static int __init rtas_fadump_process(struct fw_dump *fadump_conf)
 			}
 			break;
 		case RTAS_FADUMP_PARAM_AREA:
-			if (fdm_active->rgn[i].bytes_dumped != fdm_active->rgn[i].source_len ||
+			if (bytes_dumped != source_len ||
 			    fdm_active->rgn[i].error_flags != 0) {
 				pr_warn("Failed to process additional parameters! Proceeding anyway..\n");
 				fadump_conf->param_area = 0;
Signature · 1 line
2.54.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Shivang Upadhyay

During Fadump in Qemu VM, when maxcpus value is set to more than current cpus, following failure is observed.

    [    0.045806] [      T1] rtas fadump: Dump taken by platform is
        incomplete (0)
Quoted 8 lines

This is because the CPU_STATE_DATA is allocated for maxcpus, while the data is only filled for current cpus. As per current implementation of Fadump, dumped_bytes and source_len for a region have to match, Which is failing for qemu's case, Even tough the dumped bytes are reported correctly for only the current cpus. After this /proc/vmcore generatition also fails.

[...]

Applied to powerpc/next.

[1/1] ppc/fadump: collect dump when CPU_STATE_DATA is less than reserved

      https://git.kernel.org/powerpc/c/b3d75e2bc299a759de2fd11649c7ed275b1b2067

cheers