From 990ae4e7d18d352895ca3f86f3c82cd259b336c5 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Wed, 29 Dec 2021 15:21:46 +0800 Subject: [PATCH] Release: crash-8.0.0-4 Resolves: rhbz#2034779 Signed-off-by: Lianbo Jiang --- ...-pvops-Xen-detection-for-arm-machine.patch | 69 ++++++++++++ ...x-member-changes-for-kernels-5.16-rc.patch | 101 ++++++++++++++++++ crash.spec | 9 +- 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 0001-Fix-pvops-Xen-detection-for-arm-machine.patch create mode 100644 0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch diff --git a/0001-Fix-pvops-Xen-detection-for-arm-machine.patch b/0001-Fix-pvops-Xen-detection-for-arm-machine.patch new file mode 100644 index 0000000..c085a34 --- /dev/null +++ b/0001-Fix-pvops-Xen-detection-for-arm-machine.patch @@ -0,0 +1,69 @@ +From 7eba220e1a7d443cad6716dd83d4953ffd62d566 Mon Sep 17 00:00:00 2001 +From: Qi Zheng +Date: Tue, 21 Dec 2021 15:40:31 +0800 +Subject: [PATCH 1/2] Fix pvops Xen detection for arm machine + +Since the xen_start_info on the arm/arm64 platform points to a static +variable '_xen_start_info'(see its definition as below), which makes +that the address of xen_start_info will never be null. + +arch/arm/xen/enlighten.c:40:static struct start_info _xen_start_info; +arch/arm/xen/enlighten.c:41:struct start_info *xen_start_info = &_xen_start_info; +arch/arm/xen/enlighten.c:42:EXPORT_SYMBOL(xen_start_info); + +As a result, the is_pvops_xen() in commit 4badc6229c69 ("Fix pvops +Xen detection for kernels >= v4.20") always returns TRUE because it +can always read out the non-null address of xen_start_info, finally +the following error will be reported on arm/arm64 platform(non-Xen +environment) because p2m_mid_missing and xen_p2m_addr are not defined: + + crash: cannot resolve "p2m_top" + +For the arm/arm64 platform, fix it by using xen_vcpu_info instead of +xen_start_info to detect Xen dumps. + +In addition, also explicitly narrow the scope of the xen_start_info +check to x86 with the machine_type(), there is no need to check it on +other architectures. + +Fixes: 4badc6229c69 ("Fix pvops Xen detection for kernels >= v4.20") +Signed-off-by: Qi Zheng +Acked-by: Kazuhito Hagio +--- + kernel.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/kernel.c b/kernel.c +index f4598ea217a3..37b7af74ed2e 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -10757,11 +10757,21 @@ is_pvops_xen(void) + STREQ(sym, "paravirt_patch_default"))) + return TRUE; + +- if (symbol_exists("xen_start_info") && +- readmem(symbol_value("xen_start_info"), KVADDR, &addr, +- sizeof(void *), "xen_start_info", RETURN_ON_ERROR) && +- addr != 0) +- return TRUE; ++ if (machine_type("X86") || machine_type("X86_64")) { ++ if (symbol_exists("xen_start_info") && ++ readmem(symbol_value("xen_start_info"), KVADDR, &addr, ++ sizeof(void *), "xen_start_info", RETURN_ON_ERROR) && ++ addr != 0) ++ return TRUE; ++ } ++ ++ if (machine_type("ARM") || machine_type("ARM64")) { ++ if (symbol_exists("xen_vcpu_info") && ++ readmem(symbol_value("xen_vcpu_info"), KVADDR, &addr, ++ sizeof(void *), "xen_vcpu_info", RETURN_ON_ERROR) && ++ addr != 0) ++ return TRUE; ++ } + + return FALSE; + } +-- +2.20.1 + diff --git a/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch b/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch new file mode 100644 index 0000000..fb8a27b --- /dev/null +++ b/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch @@ -0,0 +1,101 @@ +From 98b417fc63467339b919ef6d322c1893d6d55f86 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Fri, 24 Dec 2021 18:56:35 +0800 +Subject: [PATCH 2/2] Handle blk_mq_ctx member changes for kernels 5.16-rc1 and + later + +Kernel commit 9a14d6ce4135 ("block: remove debugfs blk_mq_ctx +dispatched/merged/completed attributes") removed the member +rq_dispatched and rq_completed from struct blk_mq_ctx. Without +the patch, "dev -d|-D" options will fail with the following error: + +crash> dev -d +MAJOR GENDISK NAME REQUEST_QUEUE TOTAL ASYNC SYNC + +dev: invalid structure member offset: blk_mq_ctx_rq_dispatched + FILE: dev.c LINE: 4229 FUNCTION: get_one_mctx_diskio() + +Signed-off-by: Lianbo Jiang +Signed-off-by: Kazuhito Hagio +--- + dev.c | 57 +++++++++++++++++++++++++++++++++++++++------------------ + 1 file changed, 39 insertions(+), 18 deletions(-) + +diff --git a/dev.c b/dev.c +index effe789f38d8..a493e51ac95c 100644 +--- a/dev.c ++++ b/dev.c +@@ -4246,6 +4246,10 @@ get_mq_diskio(unsigned long q, unsigned long *mq_count) + unsigned long mctx_addr; + struct diskio tmp; + ++ if (INVALID_MEMBER(blk_mq_ctx_rq_dispatched) || ++ INVALID_MEMBER(blk_mq_ctx_rq_completed)) ++ return; ++ + memset(&tmp, 0x00, sizeof(struct diskio)); + + readmem(q + OFFSET(request_queue_queue_ctx), KVADDR, &queue_ctx, +@@ -4475,24 +4479,41 @@ display_one_diskio(struct iter *i, unsigned long gendisk, ulong flags) + && (io.read + io.write == 0)) + return; + +- fprintf(fp, "%s%s%s %s%s%s%s %s%5d%s%s%s%s%s", +- mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major), +- space(MINSPACE), +- mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk), +- space(MINSPACE), +- mkstring(buf2, 10, LJUST, disk_name), +- space(MINSPACE), +- mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN, +- LJUST|LONG_HEX, (char *)queue_addr), +- space(MINSPACE), +- io.read + io.write, +- space(MINSPACE), +- mkstring(buf4, 5, RJUST|INT_DEC, +- (char *)(unsigned long)io.read), +- space(MINSPACE), +- mkstring(buf5, 5, RJUST|INT_DEC, +- (char *)(unsigned long)io.write), +- space(MINSPACE)); ++ if (use_mq_interface(queue_addr) && ++ (INVALID_MEMBER(blk_mq_ctx_rq_dispatched) || ++ INVALID_MEMBER(blk_mq_ctx_rq_completed))) ++ fprintf(fp, "%s%s%s %s%s%s%s %s%s%s", ++ mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major), ++ space(MINSPACE), ++ mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk), ++ space(MINSPACE), ++ mkstring(buf2, 10, LJUST, disk_name), ++ space(MINSPACE), ++ mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN, ++ LJUST|LONG_HEX, (char *)queue_addr), ++ space(MINSPACE), ++ mkstring(buf4, 17, RJUST, "(not supported)"), ++ space(MINSPACE)); ++ ++ else ++ fprintf(fp, "%s%s%s %s%s%s%s %s%5d%s%s%s%s%s", ++ mkstring(buf0, 5, RJUST|INT_DEC, (char *)(unsigned long)major), ++ space(MINSPACE), ++ mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, (char *)gendisk), ++ space(MINSPACE), ++ mkstring(buf2, 10, LJUST, disk_name), ++ space(MINSPACE), ++ mkstring(buf3, VADDR_PRLEN <= 11 ? 11 : VADDR_PRLEN, ++ LJUST|LONG_HEX, (char *)queue_addr), ++ space(MINSPACE), ++ io.read + io.write, ++ space(MINSPACE), ++ mkstring(buf4, 5, RJUST|INT_DEC, ++ (char *)(unsigned long)io.read), ++ space(MINSPACE), ++ mkstring(buf5, 5, RJUST|INT_DEC, ++ (char *)(unsigned long)io.write), ++ space(MINSPACE)); + + if (VALID_MEMBER(request_queue_in_flight)) { + if (!use_mq_interface(queue_addr)) { +-- +2.20.1 + diff --git a/crash.spec b/crash.spec index df8c84e..73967c0 100644 --- a/crash.spec +++ b/crash.spec @@ -4,7 +4,7 @@ Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 8.0.0 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz @@ -22,6 +22,8 @@ Patch1: crash-8.0.0_build.patch Patch2: 0001-arm64-Support-overflow-stack-panic.patch Patch3: 0002-defs.h-fix-breakage-of-compatibility-of-struct-machd.patch Patch4: 0003-defs.h-fix-breakage-of-compatibility-of-struct-symbo.patch +Patch5: 0001-Fix-pvops-Xen-detection-for-arm-machine.patch +Patch6: 0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch %description The core analysis suite is a self-contained tool that can be used to @@ -46,6 +48,8 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build @@ -71,6 +75,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Wed Dec 29 2021 Lianbo Jiang - 8.0.0-4 +- Handle blk_mq_ctx member changes for kernels 5.16-rc1 and later + * Mon Dec 13 2021 Lianbo Jiang - 8.0.0-3 - Fix segmentation fault caused by crash extension modules - Support the overflow stack exception handling on aarch64