Skip to content

Commit

Permalink
arm64: Get CPU registers from ELF notes even without crash_notes symbol
Browse files Browse the repository at this point in the history
Currently arm64 crash retrieves the CPU registers from crash_notes symbol
or ELF notes only when the symbol exists, but there are dumpfiles which
have the registers in ELF notes without the symbol.

With the patch, crash can retrieve the registers from ELF notes without
the crash_notes symbol.

Signed-off-by: James Hsu <james.hsu@mediatek.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
  • Loading branch information
JamesHsuTWNO1 authored and k-hagio committed Sep 6, 2021
1 parent 44e5801 commit 4b34197
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions arm64.c
Expand Up @@ -3698,14 +3698,48 @@ arm64_get_crash_notes(void)
{
struct machine_specific *ms = machdep->machspec;
ulong crash_notes;
Elf64_Nhdr *note;
Elf64_Nhdr *note = NULL;
ulong offset;
char *buf, *p;
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);

if (!note) {
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");

Expand Down

0 comments on commit 4b34197

Please sign in to comment.