From b6203cb5a34785abc999a9e66101ef50072de9af Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Sun, 30 Jan 2022 15:02:03 +0800 Subject: [PATCH] arm64: Fix segfault by "bt" command with offline cpus Signed-off-by: Chunmei Xu --- ...ault-by-bt-command-with-offline-cpus.patch | 58 +++++++++++++++++++ crash.spec | 9 ++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 1001-crash-anolis-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch diff --git a/1001-crash-anolis-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch b/1001-crash-anolis-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch new file mode 100644 index 0000000..66335c1 --- /dev/null +++ b/1001-crash-anolis-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch @@ -0,0 +1,58 @@ +From dd35cf6fc5463ff31206fbb27238b4c3802c063d Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 26 Jan 2022 06:07:00 +0000 +Subject: [PATCH] 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 +Signed-off-by: Kazuhito Hagio +Tested-by: David Wysochanski +--- + arm64.c | 2 +- + diskdump.c | 3 +-- + 2 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/arm64.c b/arm64.c +index 37aed07..b742621 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -463,7 +463,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 +diff --git a/diskdump.c b/diskdump.c +index 1803ca8..2234455 100644 +--- a/diskdump.c ++++ b/diskdump.c +@@ -112,8 +112,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)) +-- +2.27.0 + diff --git a/crash.spec b/crash.spec index 2c3f833..c6efa6e 100644 --- a/crash.spec +++ b/crash.spec @@ -1,10 +1,11 @@ # # crash core analysis suite # +%define anolis_release .0.1 Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 7.3.0 -Release: 2%{?dist} +Release: 2%{anolis_release}%{?dist} License: GPLv3 Group: Development/Debuggers Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz @@ -20,6 +21,8 @@ Patch0: lzo_snappy.patch Patch1: rhel8_build.patch Patch2: rhel8_arm64_52_bit_fix.patch +Patch1001: 1001-crash-anolis-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch + %description The core analysis suite is a self-contained tool that can be used to investigate either live systems, kernel core dumps created from the @@ -42,6 +45,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %patch0 -p1 -b lzo_snappy.patch %patch1 -p1 -b rhel8_build.patch %patch2 -p1 -b rhel8_arm64_52_bit_fix.patch +%patch1001 -p1 %build cp %{SOURCE1} . @@ -72,6 +76,9 @@ rm -rf %{buildroot} %{_includedir}/* %changelog +* Sun Jan 30 2022 Chunmei Xu - 7.3.0-2.0.1 +- arm64: Fix segfault by "bt" command with offline cpus + * Fri May 14 2021 Lianbo Jiang - 7.3.0-2 - Update the sha512 hash in the sources file to solve the compilation issues -- Gitee