diff --git a/0001-Add-blk_mq-shared-tags-support-for-dev-d-D.patch b/0001-Add-blk_mq-shared-tags-support-for-dev-d-D.patch new file mode 100644 index 0000000000000000000000000000000000000000..c9bbf6e6886e21e5214b7182bd6d724a081ab281 --- /dev/null +++ b/0001-Add-blk_mq-shared-tags-support-for-dev-d-D.patch @@ -0,0 +1,219 @@ +From 62486400d35b258e4e3c40c4bf0daedc231f835a Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Fri, 27 Jun 2025 23:30:59 +1200 +Subject: [PATCH] Add blk_mq shared tags support for dev -d/-D + +When blk_mq shared tags enabled for devices like scsi, the IO status is +incorrect, e.g: + + crash> dev -d + MAJOR GENDISK NAME REQUEST_QUEUE TOTAL ASYNC SYNC + 8 ffff90528df86000 sda ffff9052a3d61800 144 144 0 + 8 ffff905280718c00 sdb ffff9052a3d63c00 48 48 0 + + crash> epython rqlist + ffff90528e94a5c0 sda is unknown, deadline: 89.992 (90) rq_alloc: 0.196 + ffff90528e92f700 sda is unknown, deadline: 89.998 (90) rq_alloc: 0.202 + ffff90528e95ccc0 sda is unknown, deadline: 89.999 (90) rq_alloc: 0.203 + ffff90528e968bc0 sdb is unknown, deadline: 89.997 (90) rq_alloc: 0.201 + +The root cause is: for shared tags case, only the shared tags are put +into count. Without this patch, tags of all the hw_ctx are counted, +which is incorrect. + +After apply the patch: + + crash> dev -d + MAJOR GENDISK NAME REQUEST_QUEUE TOTAL READ WRITE + 8 ffff90528df86000 sda ffff9052a3d61800 3 3 0 + 8 ffff905280718c00 sdb ffff9052a3d63c00 1 1 0 + +This patch makes the following modification: +1) blk_mq shared tag support. +2) Function renaming: queue_for_each_hw_ctx -> blk_mq_queue_tag_busy_iter, + because the latter is more close to the corresponding kernel function. +3) Extract a new queue_for_each_hw_ctx() function to be called for both + shared-tags case and the hw_ctx case. + +Note: +The patch is safe for earlier kernels which have no blk_mq shared tags +implemented, because the blk_mq_is_shared_tags() check will exit safely. + +Signed-off-by: Tao Liu +--- + defs.h | 3 ++ + dev.c | 96 ++++++++++++++++++++++++++++++++++++++----------------- + symbols.c | 6 ++++ + 3 files changed, 76 insertions(+), 29 deletions(-) + +diff --git a/defs.h b/defs.h +index bbd6d4b..4fecb83 100644 +--- a/defs.h ++++ b/defs.h +@@ -2271,6 +2271,9 @@ struct offset_table { /* stash of commonly-used offsets */ + long task_struct_thread_context_x28; + long neigh_table_hash_heads; + long neighbour_hash; ++ long request_queue_tag_set; ++ long blk_mq_tag_set_flags; ++ long blk_mq_tag_set_shared_tags; + }; + + struct size_table { /* stash of commonly-used sizes */ +diff --git a/dev.c b/dev.c +index 9d38aef..8391d71 100644 +--- a/dev.c ++++ b/dev.c +@@ -4326,6 +4326,12 @@ struct bt_iter_data { + #define MQ_RQ_IN_FLIGHT 1 + #define REQ_OP_BITS 8 + #define REQ_OP_MASK ((1 << REQ_OP_BITS) - 1) ++#define BLK_MQ_F_TAG_HCTX_SHARED (1 << 3) ++ ++static bool blk_mq_is_shared_tags(unsigned int flags) ++{ ++ return flags & BLK_MQ_F_TAG_HCTX_SHARED; ++} + + static uint op_is_write(uint op) + { +@@ -4403,43 +4409,72 @@ static void bt_for_each(ulong q, ulong tags, ulong sbq, uint reserved, uint nr_r + sbitmap_for_each_set(&sc, bt_iter, &iter_data); + } + +-static void queue_for_each_hw_ctx(ulong q, ulong *hctx, uint cnt, struct diskio *dio) ++static bool queue_for_each_hw_ctx(ulong q, ulong blk_mq_tags_ptr, ++ bool bitmap_tags_is_ptr, struct diskio *dio) + { +- uint i; ++ uint nr_reserved_tags = 0; ++ ulong tags = 0, addr = 0; ++ bool ret = FALSE; ++ ++ if (!readmem(blk_mq_tags_ptr, KVADDR, &tags, sizeof(ulong), ++ "blk_mq_hw_ctx.tags", RETURN_ON_ERROR)) ++ goto out; ++ ++ addr = tags + OFFSET(blk_mq_tags_nr_reserved_tags); ++ if (!readmem(addr, KVADDR, &nr_reserved_tags, sizeof(uint), ++ "blk_mq_tags_nr_reserved_tags", RETURN_ON_ERROR)) ++ goto out; ++ ++ if (nr_reserved_tags) { ++ addr = tags + OFFSET(blk_mq_tags_breserved_tags); ++ if (bitmap_tags_is_ptr && ++ !readmem(addr, KVADDR, &addr, sizeof(ulong), ++ "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR)) ++ goto out; ++ bt_for_each(q, tags, addr, 1, nr_reserved_tags, dio); ++ } ++ addr = tags + OFFSET(blk_mq_tags_bitmap_tags); ++ if (bitmap_tags_is_ptr && ++ !readmem(addr, KVADDR, &addr, sizeof(ulong), ++ "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR)) ++ goto out; ++ bt_for_each(q, tags, addr, 0, nr_reserved_tags, dio); ++ ++ ret = TRUE; ++out: ++ return ret; ++} ++ ++/* ++ * Replica of kernel block/blk-mq-tag.c:blk_mq_queue_tag_busy_iter() ++*/ ++static void blk_mq_queue_tag_busy_iter(ulong q, ulong *hctx, uint cnt, ++ struct diskio *dio) ++{ ++ uint i, flags; + int bitmap_tags_is_ptr = 0; ++ ulong addr = 0; + + if (MEMBER_TYPE("blk_mq_tags", "bitmap_tags") == TYPE_CODE_PTR) + bitmap_tags_is_ptr = 1; + +- for (i = 0; i < cnt; i++) { +- ulong addr = 0, tags = 0; +- uint nr_reserved_tags = 0; ++ readmem(q + OFFSET(request_queue_tag_set), KVADDR, &addr, ++ sizeof(ulong), "request_queue.tag_set", RETURN_ON_ERROR); + +- /* Tags owned by the block driver */ +- addr = hctx[i] + OFFSET(blk_mq_hw_ctx_tags); +- if (!readmem(addr, KVADDR, &tags, sizeof(ulong), +- "blk_mq_hw_ctx.tags", RETURN_ON_ERROR)) +- break; ++ readmem(addr + OFFSET(blk_mq_tag_set_flags), KVADDR, ++ &flags, sizeof(uint), "blk_mq_tag_set.flags", RETURN_ON_ERROR); + +- addr = tags + OFFSET(blk_mq_tags_nr_reserved_tags); +- if (!readmem(addr, KVADDR, &nr_reserved_tags, sizeof(uint), +- "blk_mq_tags_nr_reserved_tags", RETURN_ON_ERROR)) +- break; ++ if (blk_mq_is_shared_tags(flags)) { ++ addr = addr + OFFSET(blk_mq_tag_set_shared_tags); ++ queue_for_each_hw_ctx(q, addr, bitmap_tags_is_ptr, dio); ++ return; ++ } + +- if (nr_reserved_tags) { +- addr = tags + OFFSET(blk_mq_tags_breserved_tags); +- if (bitmap_tags_is_ptr && +- !readmem(addr, KVADDR, &addr, sizeof(ulong), +- "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR)) +- break; +- bt_for_each(q, tags, addr, 1, nr_reserved_tags, dio); +- } +- addr = tags + OFFSET(blk_mq_tags_bitmap_tags); +- if (bitmap_tags_is_ptr && +- !readmem(addr, KVADDR, &addr, sizeof(ulong), +- "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR)) +- break; +- bt_for_each(q, tags, addr, 0, nr_reserved_tags, dio); ++ for (i = 0; i < cnt; i++) { ++ /* Tags owned by the block driver */ ++ addr = hctx[i] + OFFSET(blk_mq_hw_ctx_tags); ++ if (queue_for_each_hw_ctx(q, addr, bitmap_tags_is_ptr, dio) == FALSE) ++ return; + } + } + +@@ -4489,7 +4524,7 @@ static void get_mq_diskio_from_hw_queues(ulong q, struct diskio *dio) + return; + } + +- queue_for_each_hw_ctx(q, hctx_array, cnt, dio); ++ blk_mq_queue_tag_busy_iter(q, hctx_array, cnt, dio); + + FREEBUF(hctx_array); + } +@@ -4914,6 +4949,9 @@ void diskio_init(void) + MEMBER_SIZE_INIT(class_private_devices, "class_private", + "class_devices"); + MEMBER_OFFSET_INIT(disk_stats_in_flight, "disk_stats", "in_flight"); ++ MEMBER_OFFSET_INIT(request_queue_tag_set, "request_queue", "tag_set"); ++ MEMBER_OFFSET_INIT(blk_mq_tag_set_flags, "blk_mq_tag_set", "flags"); ++ MEMBER_OFFSET_INIT(blk_mq_tag_set_shared_tags, "blk_mq_tag_set", "shared_tags"); + + dt->flags |= DISKIO_INIT; + } +diff --git a/symbols.c b/symbols.c +index e30fafe..794519a 100644 +--- a/symbols.c ++++ b/symbols.c +@@ -11487,6 +11487,12 @@ dump_offset_table(char *spec, ulong makestruct) + OFFSET(blk_mq_tags_nr_reserved_tags)); + fprintf(fp, " blk_mq_tags_rqs: %ld\n", + OFFSET(blk_mq_tags_rqs)); ++ fprintf(fp, " request_queue_tag_set: %ld\n", ++ OFFSET(request_queue_tag_set)); ++ fprintf(fp, " blk_mq_tag_set_flags: %ld\n", ++ OFFSET(blk_mq_tag_set_flags)); ++ fprintf(fp, " blk_mq_tag_set_shared_tags: %ld\n", ++ OFFSET(blk_mq_tag_set_shared_tags)); + + fprintf(fp, " subsys_private_subsys: %ld\n", OFFSET(subsys_private_subsys)); + fprintf(fp, " subsys_private_klist_devices: %ld\n", +-- +2.47.0 + diff --git a/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch b/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch new file mode 100644 index 0000000000000000000000000000000000000000..adaa340817ffa13dd64ead6c327e4b91f21d6b25 --- /dev/null +++ b/0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch @@ -0,0 +1,53 @@ +From 145cc6a75f24dfce2e644b620b3afb6de04cadfd Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Wed, 9 Jul 2025 17:41:12 +1200 +Subject: [PATCH 1/5] x86_64: filter unwanted warning message for "bt -T" cmd + +After patch "x86_64: Add gdb multi-stack unwind support" applied, a +warning message is observed for "bt -T" cmd: + + crash> bt -T + bt: seek error: kernel virtual address: fffffffffffffffb type: "gdb_readmem_callback" + [ffffbaebc60d6fa8] srso_return_thunk at ffffffff82246fa5 + ... + +The root cause is, "bt -T" will set BT_TEXT_SYMBOLS_ALL for bt->flags, +and eip is set to be 0 in kernel.c:back_trace(). Later in +x86_64_low_budget_back_trace_cmd(), eip - 5, or 0xfffffffffffffffb is +used for address disassembly by gdb "x/1i 0x%lx". This address is invalid so +the warning message is output. + +In fact, multi-stack unwind isn't designed for "bt -T" and eip = 0 case. +To avoid the warning message, let's simply bypass the "bt -T" case for +x86_64. Other archs(arm64/ppc64) aren't affected by the issue because +the gdb "x/1i 0x%lx" are not applied on those archs. + +After apply the patch: + + crash> bt -T + [ffffbaebc60d6fa8] srso_return_thunk at ffffffff82246fa5 + ... + +Signed-off-by: Tao Liu +Signed-off-by: Lianbo Jiang +--- + x86_64.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/x86_64.c b/x86_64.c +index cfefe3f80c4f..d7da536d20d8 100644 +--- a/x86_64.c ++++ b/x86_64.c +@@ -3636,7 +3636,8 @@ x86_64_low_budget_back_trace_cmd(struct bt_info *bt_in) + level++; + } + +- if (is_task_active(bt->task) && bt->flags & BT_DUMPFILE_SEARCH) { ++ if (is_task_active(bt->task) && bt->flags & BT_DUMPFILE_SEARCH && ++ !(bt->flags & BT_TEXT_SYMBOLS_ALL)) { + if (!extra_stacks_regs[extra_stacks_idx]) { + extra_stacks_regs[extra_stacks_idx] = + (struct user_regs_bitmap_struct *) +-- +2.50.0 + diff --git a/0002-Fix-incorrect-task-state-during-exit.patch b/0002-Fix-incorrect-task-state-during-exit.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3c214cb611c308db65159f3ad3e5d8190014f6f --- /dev/null +++ b/0002-Fix-incorrect-task-state-during-exit.patch @@ -0,0 +1,84 @@ +From 6eb51d8284aaca9cc882ddb1b9e135c708abbaa4 Mon Sep 17 00:00:00 2001 +From: Stephen Brennan +Date: Fri, 2 May 2025 13:18:17 -0700 +Subject: [PATCH 2/9] Fix incorrect task state during exit + +task_state() assumes that exit_state is a unsigned long, when in +reality, it has been declared as an int since 97dc32cdb1b53 ("reduce +size of task_struct on 64-bit machines"), in Linux 2.6.22. So on 64-bit +machines, task_state() reads 8 bytes rather than 4, and gets the wrong +exit_state value by including the next field. + +This has gone unnoticed because directly after exit_state comes +exit_code, which is generally zero while the task is alive. When the +exit_code is set, exit_state is usually set not long after. Since +task_state_string() only checks whether exit_state bits are set, it +never notices the presence of the exit code inside of the state. + +But this leaves open a window during the process exit, when the +exit_code has been set (in do_exit()), but the exit_state has not (in +exit_notify()). In this case, crash reports a state of "??", but in +reality, the task is still running -- it's just running the exit() +system call. This race window can be long enough to be observed in core +dumps, for example if the mmput() takes a long time. + +This should be considered a bug. A task state of "??" or "(unknown)" is +frequently of concern when debugging, as it could indicate that the +state fields had some sort of corruption, and draw the attention of the +debugger. To handle it properly, record the size of exit_state, and read +it conditionally as a UINT or ULONG, just like the state. This ensures +we retain compatibility with kernel before v2.6.22. Whether that is +actually desirable is anybody's guess. + +Reported-by: Jeffery Yoder +Signed-off-by: Stephen Brennan +Signed-off-by: Lianbo Jiang +--- + defs.h | 1 + + task.c | 11 +++++++++-- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/defs.h b/defs.h +index 4cf169c85144..2fdb4db56a05 100644 +--- a/defs.h ++++ b/defs.h +@@ -2448,6 +2448,7 @@ struct size_table { /* stash of commonly-used sizes */ + long fred_frame; + long vmap_node; + long cpumask_t; ++ long task_struct_exit_state; + }; + + struct array_table { +diff --git a/task.c b/task.c +index 3bafe796381f..e07b479a3bec 100644 +--- a/task.c ++++ b/task.c +@@ -306,6 +306,7 @@ task_init(void) + MEMBER_SIZE_INIT(task_struct_state, "task_struct", "__state"); + } + MEMBER_OFFSET_INIT(task_struct_exit_state, "task_struct", "exit_state"); ++ MEMBER_SIZE_INIT(task_struct_exit_state, "task_struct", "exit_state"); + MEMBER_OFFSET_INIT(task_struct_pid, "task_struct", "pid"); + MEMBER_OFFSET_INIT(task_struct_comm, "task_struct", "comm"); + MEMBER_OFFSET_INIT(task_struct_next_task, "task_struct", "next_task"); +@@ -5965,8 +5966,14 @@ task_state(ulong task) + state = ULONG(tt->task_struct + OFFSET(task_struct_state)); + else + state = UINT(tt->task_struct + OFFSET(task_struct_state)); +- exit_state = VALID_MEMBER(task_struct_exit_state) ? +- ULONG(tt->task_struct + OFFSET(task_struct_exit_state)) : 0; ++ ++ if (VALID_MEMBER(task_struct_exit_state) ++ && SIZE(task_struct_exit_state) == sizeof(ulong)) ++ exit_state = ULONG(tt->task_struct + OFFSET(task_struct_exit_state)); ++ else if (VALID_MEMBER(task_struct_exit_state)) ++ exit_state = UINT(tt->task_struct + OFFSET(task_struct_exit_state)); ++ else ++ exit_state = 0; + + return (state | exit_state); + } +-- +2.47.1 + diff --git a/0002-doc-Update-requirements-for-building-on-Fedora.patch b/0002-doc-Update-requirements-for-building-on-Fedora.patch new file mode 100644 index 0000000000000000000000000000000000000000..462343e70f003da48bdbd1f5fb7a93c36aeaa799 --- /dev/null +++ b/0002-doc-Update-requirements-for-building-on-Fedora.patch @@ -0,0 +1,51 @@ +From 6167a55b227db61eb52c2a4f96f44fc559a8b1d0 Mon Sep 17 00:00:00 2001 +From: Charles Haithcock +Date: Fri, 18 Jul 2025 16:14:25 -0600 +Subject: [PATCH 2/5] doc: Update requirements for building on Fedora + +Attempting to build on Fedora fails with the following error; + +$ make +TARGET: RISCV64 + CRASH: 9.0.0++ + GDB: 16.2 + +Saving 'gdb-16.2.tar.gz' +[...] +checking for the correct version of gmp.h... no +configure: error: Building GDB requires GMP 4.2+, and MPFR 3.1.0+. +Try the --with-gmp and/or --with-mpfr options to specify +their locations. If you obtained GMP and/or MPFR from a vendor +distribution package, make sure that you have installed both the libraries +and the header files. They may be located in separate packages. +make[2]: *** No targets specified and no makefile found. Stop. + +crash build failed + +make[1]: *** [Makefile:316: gdb_merge] Error 1 +make: *** [Makefile:307: all] Error 2 + +Installing gmp-devel and mpfr-devel fixed this, so this patch updates the +requirements for building on Fedora. + +Signed-off-by: Lianbo Jiang +--- + README | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/README b/README +index 2e34fbb15f1a..f9824c7240bf 100644 +--- a/README ++++ b/README +@@ -73,7 +73,7 @@ + that is created in the top-level kernel build directory must be saved. + + o Requirements for building: +- Fedora: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel ++ Fedora: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel gmp-devel mpfr-devel + Ubuntu/Debian: make gcc g++ libncurses-dev zlib1g-dev liblzo2-dev libsnappy-dev bison wget patch texinfo libzstd-dev + Arch Linux: make gcc ncurses zlib lzo snappy bison wget patch texinfo zstd + openSUSE: make gcc gcc-c++ ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel +-- +2.50.0 + diff --git a/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch b/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch new file mode 100644 index 0000000000000000000000000000000000000000..2fb513bbc7dec87df8145cc79cf620f3cc1969d0 --- /dev/null +++ b/0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch @@ -0,0 +1,98 @@ +From 6642b2729067399696f8f24f29267b3483d895c6 Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Tue, 8 Jul 2025 13:26:38 +1200 +Subject: [PATCH 3/5] gdb: Fix a regression for eppic extension on gdb-16.2 + +There is a regression found when testing eppic extension on gdb-16.2 +crash: + + crash> cgroup + /root/.eppic/cgroup.c : line 99 : Error: undefined variable 'cgroup_roots' + +The root cause is when doing gdb upgrading, the replacement of +gdb_get_datatype() is incorrect: + +The original gdb-10.2 version: + + long value = SYMBOL_VALUE(expr->elts[2].symbol); + +The incorrect gdb-16.2 replacement: + + long value = value_as_long(expr->evaluate()); + +According to gdb/tracepoint.c, the correct gdb-16.2 replacement should be: + + symbol *sym; + expr::var_value_operation *vvop + = (gdb::checked_static_cast + (exp->op.get ())); + sym = vvop->get_symbol (); + long value = sym->value_longest (); + +Otherwise, the value_as_long() will throw an exception when trying to +convert a struct into long, such as "cgroup_roots". The reason why this +issue only observed on crash extensions, is the faulty code block +triggered with "req->tcb", which is a callback for gdb_interface(), and +the callback is used by eppic extension, but the normal crash internal calls +hardly use it. + +After: + crash> cgroup + 0:/user.slice/user-1000.slice/session-2.scope + +Signed-off-by: Tao Liu +Signed-off-by: Lianbo Jiang +--- + gdb-16.2.patch | 32 +++++++++++++++++++++++++++++++- + 1 file changed, 31 insertions(+), 1 deletion(-) + +diff --git a/gdb-16.2.patch b/gdb-16.2.patch +index 151e4e2039d9..9d056580b2f7 100644 +--- a/gdb-16.2.patch ++++ b/gdb-16.2.patch +@@ -9,7 +9,8 @@ + # to all subsequent patch applications. + + tar xvzmf gdb-16.2.tar.gz \ +- gdb-16.2/gdb/symfile.c ++ gdb-16.2/gdb/symfile.c \ ++ gdb-16.2/gdb/symtab.c + + exit 0 + +@@ -1952,3 +1953,32 @@ exit 0 + } + + /* Remember the bfd indexes for the .text, .data, .bss and ++--- gdb-16.2/gdb/symtab.c.orig +++++ gdb-16.2/gdb/symtab.c ++@@ -7690,7 +7690,11 @@ ++ console("expr->first_opcode(): OP_VAR_VALUE\n"); ++ type = expr->evaluate_type()->type(); ++ if (req->tcb) { ++- long value = value_as_long(expr->evaluate()); +++ expr::var_value_operation *vvop +++ = (gdb::checked_static_cast +++ (expr->op.get ())); +++ sym = vvop->get_symbol (); +++ long value = sym->value_longest (); ++ /* callback with symbol value */ ++ req->typecode = TYPE_CODE(type); ++ req->tcb(EOP_VALUE, req, &value, 0, 0, 0); ++@@ -7701,8 +7705,12 @@ ++ req->length = type->length(); ++ } ++ if (TYPE_CODE(type) == TYPE_CODE_ENUM) { +++ expr::var_value_operation *vvop +++ = (gdb::checked_static_cast +++ (expr->op.get ())); +++ sym = vvop->get_symbol (); ++ req->typecode = TYPE_CODE(type); ++- req->value = value_as_long(expr->evaluate()); +++ req->value = sym->value_longest (); ++ req->tagname = (char *)TYPE_TAG_NAME(type); ++ if (!req->tagname) { ++ val = expr->evaluate_type(); +-- +2.50.0 + diff --git a/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch b/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d8da1a0169e2b20523bfd53026e5a8ec375df48 --- /dev/null +++ b/0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch @@ -0,0 +1,42 @@ +From 31a69d378efb4319a5b9ef8cf3d7a93030f5c863 Mon Sep 17 00:00:00 2001 +From: Ming Wang +Date: Mon, 9 Jun 2025 11:03:02 +0800 +Subject: [PATCH 4/5] Fix crash initialization failure on LoongArch with recent + GDB versions + +The crash tool failed to initialize on LoongArch64 when using +GDB 16.2 (and likely other recent GDB versions that have enhanced +LoongArch support) due to the error: +"fatal error: buffer size is not enough to fit register value". + +This occurs in supply_registers() because GDB now correctly +reports the size of LoongArch LASX (256-bit) vector registers +(xr0-xr31) as 32 bytes. The `regval` buffer in `crash_target.c` +was previously fixed at 16 bytes. + +This patch increases the `regval` buffer size to 32 bytes to +accommodate the largest LoongArch registers reported by GDB. +This allows crash to initialize successfully. + +Signed-off-by: Ming Wang +Signed-off-by: Lianbo Jiang +--- + crash_target.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/crash_target.c b/crash_target.c +index ad1480c9188f..49c6e88c5140 100644 +--- a/crash_target.c ++++ b/crash_target.c +@@ -80,7 +80,7 @@ public: + + static void supply_registers(struct regcache *regcache, int regno) + { +- gdb_byte regval[16]; ++ gdb_byte regval[32]; + struct gdbarch *arch = regcache->arch (); + const char *regname = gdbarch_register_name(arch, regno); + int regsize = register_size(arch, regno); +-- +2.50.0 + diff --git a/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch b/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch new file mode 100644 index 0000000000000000000000000000000000000000..c8c3cc01d8d3f04466f7fb47f9a47e240da3eed5 --- /dev/null +++ b/0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch @@ -0,0 +1,93 @@ +From 2c69f93e59c6b2efac5bae9f7891dbe1e0094fdd Mon Sep 17 00:00:00 2001 +From: Shivang Upadhyay +Date: Mon, 21 Jul 2025 13:47:33 +0530 +Subject: [PATCH 5/5] gdb: Disable DT_DEBUG lookup by GDB inside the vmcore + +Crash with GDB 16.2, the following warnings are printed: + +crash> +crash: page excluded: kernel virtual address: c0000000022d6098 type: "gdb_readmem_callback" +crash: page excluded: kernel virtual address: c0000000022d6098 type: "gdb_readmem_callback" + +This occurs because the elf_locate_base function in GDB 16.2 +attempts to read the address of the dynamic linker runtime +structure, which is present in the .dynamic section of the +executable. However, this section may be excluded from the +dump by makedumpfile. + +The repeated calls to elf_locate_base were introduced by gdb +commit [1] aebb370 ("gdb, solib-svr4: support namespaces in +DSO iteration") via svr4_iterate_over_objfiles_in_search_order. + +To check whether the kernel includes DT_DEBUG information, +prints were added inside crash::xfer_partial, which is +called through elf_locate_base when reading from vmcore. +Even when running crash on /proc/kcore, all output data was +zero. This confirms that DT_DEBUG information is never +present in the kernel image. + +`mod -S` continues to function correctly after the following +patch: + +... +crash> mod -S +Enable debuginfod for this session? (y or [n]) + MODULE NAME TEXT_BASE SIZE OBJECT FILE +c0080000004a0300 dm_log c008000000480000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-log.ko +c0080000006d1100 sd_mod c008000000580000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/scsi/sd_mod.ko +c0080000005c0080 dm_region_hash c0080000005a0000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-region-hash.ko +c008000000770700 sg c008000000620000 262144 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/scsi/sg.ko +c008000000660500 dm_mirror c008000000640000 196608 XXX/lib/modules/5.14.0-592.el9.ppc64le/kernel/drivers/md/dm-mirror.ko +... + +Commit e906eaca2b1a ("Fix the issue of "page excluded" +messages flooding") attempted fix this by suppressing these +warnings for regular users, but the warnings still appear +when crash is started in debug mode. + +To fix this, remove the DT_DEBUG read call, from the +elf_locate_base function in GDB that tries to read the +.dynamic section, as this information is not useful for +debugging kernel images in either dump or live kernel +scenarios. + +[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aebb370 + +Cc: Tao liu +Cc: Lianbo Jiang +Cc: Sourabh Jain +Signed-off-by: shivang.upadhyay +Signed-off-by: Lianbo Jiang +--- + gdb-16.2.patch | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/gdb-16.2.patch b/gdb-16.2.patch +index 9d056580b2f7..6767bf7d7bf0 100644 +--- a/gdb-16.2.patch ++++ b/gdb-16.2.patch +@@ -1982,3 +1982,21 @@ exit 0 + req->tagname = (char *)TYPE_TAG_NAME(type); + if (!req->tagname) { + val = expr->evaluate_type(); ++--- gdb-16.2/gdb/solib-svr4.c.orig +++++ gdb-16.2/gdb/solib-svr4.c ++@@ -741,13 +741,13 @@ ++ return 0; ++ return extract_typed_address (pbuf, ptr_type); ++ } ++- +++#ifndef CRASH_MERGE ++ /* Find DT_DEBUG. */ ++ if (gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), ++ &dyn_ptr, NULL) ++ || scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL)) ++ return dyn_ptr; ++- +++#endif ++ /* This may be a static executable. Look for the symbol ++ conventionally named _r_debug, as a last resort. */ ++ bound_minimal_symbol msymbol +-- +2.50.0 + diff --git a/0009-Fix-kmem-p-option-on-Linux-6.16-rc1-and-later-kernel.patch b/0009-Fix-kmem-p-option-on-Linux-6.16-rc1-and-later-kernel.patch new file mode 100644 index 0000000000000000000000000000000000000000..8219731e78582585caf748462b1f5136cd9a43fa --- /dev/null +++ b/0009-Fix-kmem-p-option-on-Linux-6.16-rc1-and-later-kernel.patch @@ -0,0 +1,35 @@ +From 7e8a2796580d992ed19b2e49b5d555e432303e96 Mon Sep 17 00:00:00 2001 +From: "k-hagio-ab@nec.com" +Date: Tue, 17 Jun 2025 06:08:52 +0000 +Subject: [PATCH 9/9] Fix "kmem -p" option on Linux 6.16-rc1 and later kernels + +Kernel commit acc53a0b4c156 ("mm: rename page->index to +page->__folio_index"), which is contained in Linux 6.16-rc1 and later +kernels, renamed the member. Without the patch, the "kmem -p" option +fails with the following error: + + kmem: invalid structure member offset: page_index + FILE: memory.c LINE: 6016 FUNCTION: dump_mem_map_SPARSEMEM() + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + memory.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/memory.c b/memory.c +index 58624bb5f44c..400d31a04cd4 100644 +--- a/memory.c ++++ b/memory.c +@@ -531,6 +531,8 @@ vm_init(void) + ASSIGN_OFFSET(page_mapping) = MEMBER_OFFSET("page", "_mapcount") + + STRUCT_SIZE("atomic_t") + sizeof(ulong); + MEMBER_OFFSET_INIT(page_index, "page", "index"); ++ if (INVALID_MEMBER(page_index)) /* 6.16 and later */ ++ MEMBER_OFFSET_INIT(page_index, "page", "__folio_index"); + if (INVALID_MEMBER(page_index)) + ANON_MEMBER_OFFSET_INIT(page_index, "page", "index"); + MEMBER_OFFSET_INIT(page_buffers, "page", "buffers"); +-- +2.47.1 + diff --git a/crash-8.0.6.tar.gz b/crash-8.0.6.tar.gz deleted file mode 100644 index 75e49b260b650e233fedaacf8f8516a5ef942ad2..0000000000000000000000000000000000000000 Binary files a/crash-8.0.6.tar.gz and /dev/null differ diff --git a/crash-9.0.0.tar.gz b/crash-9.0.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2e6c6094cb9a19b8c1d7998bd015196616a4f766 Binary files /dev/null and b/crash-9.0.0.tar.gz differ diff --git a/crash-9.0.0_build.patch b/crash-9.0.0_build.patch new file mode 100644 index 0000000000000000000000000000000000000000..37b08cfdd8cac35c3ebd60a3f8c27868718c58e0 --- /dev/null +++ b/crash-9.0.0_build.patch @@ -0,0 +1,33 @@ +--- crash-9.0.0/Makefile.orig ++++ crash-9.0.0/Makefile +@@ -204,7 +204,7 @@ GDB_FLAGS= + # TARGET_CFLAGS will be configured automatically by configure + TARGET_CFLAGS= + +-CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ++CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${GDB_FLAGS} ${CFLAGS} ${CPPFLAGS} -fPIE + + GPL_FILES= + TAR_FILES=${SOURCE_FILES} Makefile ${GPL_FILES} README .rh_rpm_package crash.8 \ +@@ -256,7 +256,7 @@ all: make_configure + gdb_merge: force + @if [ ! -f ${GDB}/README ]; then \ + $(MAKE) gdb_unzip; fi +- @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic" > ${GDB}/gdb/mergelibs ++ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic -Wl,-z,now -fPIE" > ${GDB}/gdb/mergelibs + @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj + @rm -f ${PROGRAM} + @if [ ! -f ${GDB}/config.status ]; then \ +--- crash-9.0.0/configure.c.orig ++++ crash-9.0.0/configure.c +@@ -810,7 +810,8 @@ build_configure(struct supported_gdb_version *sp) + fprintf(fp2, "%s\n", sp->GDB); + sprintf(target_data.gdb_version, "%s", &sp->GDB[4]); + } else if (strncmp(buf, "LDFLAGS=", strlen("LDFLAGS=")) == 0) { +- fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); ++ if (ldflags) ++ fprintf(fp2, "LDFLAGS=%s\n", ldflags ? ldflags : ""); + } else + fprintf(fp2, "%s", buf); + + diff --git a/crash.spec b/crash.spec index 757ec259f5d788d87b6bcee6147169cec360165c..9611ed00cb00530cd1be57138e55cc6d119996a3 100644 --- a/crash.spec +++ b/crash.spec @@ -1,20 +1,31 @@ -%define anolis_release 3 +%define anolis_release 1 Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash -Version: 8.0.6 +Version: 9.0.0 Release: %{anolis_release}%{?dist} License: GPL-3.0-only -Source0: https://github.com/crash-utility/crash/archive/%{version}/crash-%{version}.tar.gz -Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz Patch0: lzo_snappy_zstd.patch Patch1: crash-8.0.6_build.patch Patch2: LoongArch-set-NR_CPUS-to-2048-for-loongarch64.patch +Patch3: 0001-Add-blk_mq-shared-tags-support-for-dev-d-D.patch +Patch4: crash-9.0.0_build.patch +Patch5: 0001-x86_64-filter-unwanted-warning-message-for-bt-T-cmd.patch +Patch6: 0003-gdb-Fix-a-regression-for-eppic-extension-on-gdb-16.2.patch +Patch7: 0002-doc-Update-requirements-for-building-on-Fedora.patch +Patch8: 0009-Fix-kmem-p-option-on-Linux-6.16-rc1-and-later-kernel.patch +Patch9: 0002-Fix-incorrect-task-state-during-exit.patch +Patch10: 0005-gdb-Disable-DT_DEBUG-lookup-by-GDB-inside-the-vmcore.patch +Patch11: 0004-Fix-crash-initialization-failure-on-LoongArch-with-r.patch URL: https://crash-utility.github.io +Source0: https://github.com/crash-utility/crash/archive/crash-9.0.0.tar.gz +Source1: http://ftp.gnu.org/gnu/gdb/gdb-16.2.tar.gz ExclusiveOS: Linux ExclusiveArch: x86_64 aarch64 loongarch64 riscv64 BuildRequires: ncurses-devel zlib-devel lzo-devel snappy-devel bison wget patch texinfo libzstd-devel BuildRequires: gcc gcc-c++ BuildRequires: make +BuildRequires: gmp-devel +BuildRequires: mpfr-devel Requires: binutils Provides: bundled(libiberty) Provides: bundled(gdb) = 10.2 @@ -76,6 +87,17 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Thu Sep 18 2025 wenyuzifang - 9.0.0-1 +- Updated to version 9.0.0 to fix xxxxxx +- Fix inaccurate I/O request counting in blk-mq shared tags environments for reliable crash analysis. +- Suppress misleading seek error warnings during bt -T to improve clarity and usability. +- Fix symbol evaluation in GDB 16.2 to restore eppic extension functionality and prevent crashes. +- Update the README with missing dependencies to ensure successful builds on Fedora. +- Ensure kmem -p works correctly on Linux 5.16 and later kernels by fixing page index access. +- Fix incorrect task state reporting to prevent debugging confusion and ensure accurate crash analysis. +- Eliminate spurious 'page excluded' warnings in crash output when using GDB 16.2 on vmcore. +- Fix initialization failure on LoongArch64 by accommodating larger register sizes from recent GDB versions. + * Thu May 16 2025 Yihao Yan - 8.0.6-3 - add support for riscv64 @@ -107,4 +129,3 @@ cp -p defs.h %{buildroot}%{_includedir}/crash * Thu May 05 2022 mgb01105731 - 8.0.1-1 - Init from upstream version 8.0.1 - diff --git a/gdb-10.2.tar.gz b/gdb-16.2.tar.gz similarity index 76% rename from gdb-10.2.tar.gz rename to gdb-16.2.tar.gz index dfe4b7d83e0f7f0894de0e961490ff600d84e2b5..d24199fdea89b73f4d4dcc4f8ed051d3ca7451b6 100644 Binary files a/gdb-10.2.tar.gz and b/gdb-16.2.tar.gz differ