Blame SOURCES/0010-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch

412566
From 1a1fd21c625cb2ca335e626eb50426f13c4160f7 Mon Sep 17 00:00:00 2001
412566
From: Kazuhito Hagio <k-hagio-ab@nec.com>
412566
Date: Wed, 26 Jan 2022 06:07:00 +0000
412566
Subject: [PATCH 10/11] arm64: Fix segfault by "bt" command with offline cpus
412566
412566
Currently on arm64, NT_PRSTATUS notes in dumpfile are not mapped to
412566
online cpus and machine_specific->panic_task_regs correctly.  As a
412566
result, the "bt" command can cause a segmentation fault.
412566
412566
  crash> bt -c 0
412566
  PID: 0      TASK: ffff8000117fa240  CPU: 0   COMMAND: "swapper/0"
412566
  Segmentation fault (core dumped)
412566
412566
To fix this,
412566
1) make map_cpus_to_prstatus_kdump_cmprs() map the notes to
412566
   dd->nt_prstatus_percpu also on arm64, and
412566
2) move arm64_get_crash_notes() to machdep_init(POST_INIT) in order
412566
   to apply the mapping to machine_specific->panic_task_regs.
412566
412566
Resolves: https://github.com/crash-utility/crash/issues/105
412566
Reported-by: xuchunmei000 <xuchunmei@linux.alibaba.com>
412566
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
412566
Tested-by: David Wysochanski <dwysocha@redhat.com>
412566
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
412566
---
412566
 arm64.c    | 2 +-
412566
 diskdump.c | 3 +--
412566
 2 files changed, 2 insertions(+), 3 deletions(-)
412566
412566
diff --git a/arm64.c b/arm64.c
412566
index 23c3d75d85aa..4f2c2b5104a1 100644
412566
--- a/arm64.c
412566
+++ b/arm64.c
412566
@@ -472,7 +472,7 @@ arm64_init(int when)
412566
 		arm64_stackframe_init();
412566
 		break;
412566
 
412566
-	case POST_VM:
412566
+	case POST_INIT:
412566
 		/*
412566
 		 * crash_notes contains machine specific information about the
412566
 		 * crash. In particular, it contains CPU registers at the time
412566
diff --git a/diskdump.c b/diskdump.c
412566
index 112f769f8949..690b42443ed2 100644
412566
--- a/diskdump.c
412566
+++ b/diskdump.c
412566
@@ -111,8 +111,7 @@ map_cpus_to_prstatus_kdump_cmprs(void)
412566
 	if (pc->flags2 & QEMU_MEM_DUMP_COMPRESSED)  /* notes exist for all cpus */
412566
 		goto resize_note_pointers;
412566
 
412566
-	if (!(online = get_cpus_online()) || (online == kt->cpus) || 
412566
-	    machine_type("ARM64"))
412566
+	if (!(online = get_cpus_online()) || (online == kt->cpus))
412566
 		goto resize_note_pointers;
412566
 
412566
 	if (CRASHDEBUG(1))
412566
-- 
412566
2.20.1
412566