[Crash-utility] arm64: Get CPU registers without crash_notes symbol

James Hsu (徐慶薰) James.Hsu at mediatek.com
Thu Aug 5 11:18:34 UTC 2021


An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20210805/a773aee1/attachment.htm>
-------------- next part --------------
Dear Crash maintainers,

We want to improve the crash_tool for the case that need offline cpu  register info even Kdump without crash_notes.

For one thing,  we will prepare a Kdump with all CPU register info in ELF note.
For another thing, we need to modify crash_tool and make it support adding offline cpu register info even Kdump without crash_notes.

We prepare a patch for the case with ARCH=arm64. 
It is verified with our kdump without crash_note and can get all cpu register.
Please take your time to review our patch and look forward to receiving your comments.

Patch detail as below

--- crash-7.3.0/arm64.c	2021-04-27 16:01:07.000000000 +0800
+++ crash-7.3.0.mod/arm64.c	2021-06-15 17:13:54.037273227 +0800
@@ -3667,8 +3667,41 @@ arm64_get_crash_notes(void)
 	ulong *notes_ptrs;
 	ulong i, found;
 
-	if (!symbol_exists("crash_notes"))
+	if (!symbol_exists("crash_notes")) {
+		if (DISKDUMP_DUMPFILE() || KDUMP_DUMPFILE()) {
+			if (!(ms->panic_task_regs = calloc((size_t)kt->cpus, sizeof(struct arm64_pt_regs))))
+				error(FATAL, "cannot calloc panic_task_regs space\n");
+
+			for  (i = found = 0; i < kt->cpus; i++) {
+				if (DISKDUMP_DUMPFILE())
+					note = diskdump_get_prstatus_percpu(i);
+				else if (KDUMP_DUMPFILE())
+					note = netdump_get_prstatus_percpu(i);
+				else {
+					error(WARNING, "cpu %d: cannot find NT_PRSTATUS note\n", i);
+					continue;
+				}
+		
+				/*
+				 * Find correct location of note data. This contains elf_prstatus
+				 * structure which has registers etc. for the crashed task.
+				 */
+				offset = sizeof(Elf64_Nhdr);
+				offset = roundup(offset + note->n_namesz, 4);
+				p = (char *)note + offset; /* start of elf_prstatus */
+				
+				BCOPY(p + OFFSET(elf_prstatus_pr_reg), &ms->panic_task_regs[i],
+				      sizeof(struct arm64_pt_regs));
+				
+				found++;
+			}
+		}
+		if (!found) {
+			free(ms->panic_task_regs);
+			ms->panic_task_regs = NULL;
+		}
 		return;
+	}
 
 	crash_notes = symbol_value("crash_notes");


Thanks,
James Hsu




-------------- next part --------------
A non-text attachment was scrubbed...
Name: crash-arm64-support_cpu_register_without_crash_note.zip
Type: application/x-zip-compressed
Size: 864 bytes
Desc: crash-arm64-support_cpu_register_without_crash_note.zip
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20210805/a773aee1/attachment.bin>


More information about the Crash-utility mailing list