arm64: Fix segfault by "bt" command with offline cpus

Currently on arm64, NT_PRSTATUS notes in dumpfile are not mapped to
online cpus and machine_specific->panic_task_regs correctly.  As a
result, the "bt" command can cause a segmentation fault.

  crash> bt -c 0
  PID: 0      TASK: ffff8000117fa240  CPU: 0   COMMAND: "swapper/0"
  Segmentation fault (core dumped)

To fix this,
1) make map_cpus_to_prstatus_kdump_cmprs() map the notes to
   dd->nt_prstatus_percpu also on arm64, and
2) move arm64_get_crash_notes() to machdep_init(POST_INIT) in order
   to apply the mapping to machine_specific->panic_task_regs.

Resolves: https://github.com/crash-utility/crash/issues/105
Reported-by: xuchunmei000 <xuchunmei@linux.alibaba.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Tested-by: David Wysochanski <dwysocha@redhat.com>
This commit is contained in:
Kazuhito Hagio 2022-01-26 06:07:00 +00:00 committed by Lianbo Jiang
parent e389667cf6
commit dd35cf6fc5
2 changed files with 2 additions and 3 deletions

View File

@ -472,7 +472,7 @@ arm64_init(int when)
arm64_stackframe_init();
break;
case POST_VM:
case POST_INIT:
/*
* crash_notes contains machine specific information about the
* crash. In particular, it contains CPU registers at the time

View File

@ -111,8 +111,7 @@ map_cpus_to_prstatus_kdump_cmprs(void)
if (pc->flags2 & QEMU_MEM_DUMP_COMPRESSED) /* notes exist for all cpus */
goto resize_note_pointers;
if (!(online = get_cpus_online()) || (online == kt->cpus) ||
machine_type("ARM64"))
if (!(online = get_cpus_online()) || (online == kt->cpus))
goto resize_note_pointers;
if (CRASHDEBUG(1))