diff --git a/.crash.metadata b/.crash.metadata new file mode 100644 index 0000000..5276fe8 --- /dev/null +++ b/.crash.metadata @@ -0,0 +1,2 @@ +692a903aa3cae47cf2c5dbb7fe79ae6e774e3641 SOURCES/crash-8.0.0.tar.gz +6bf5ee7877a4740835745ed97ce525a00bb2232c SOURCES/gdb-10.2.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a9c68b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/crash-8.0.0.tar.gz +SOURCES/gdb-10.2.tar.gz diff --git a/SOURCES/0001-Fix-for-timer-r-option-to-display-all-the-per-CPU-cl.patch b/SOURCES/0001-Fix-for-timer-r-option-to-display-all-the-per-CPU-cl.patch new file mode 100644 index 0000000..eebe17f --- /dev/null +++ b/SOURCES/0001-Fix-for-timer-r-option-to-display-all-the-per-CPU-cl.patch @@ -0,0 +1,59 @@ +From 70a27ae9f2b45d6dba56ee4240b6adf79c544ee1 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Thu, 6 Jan 2022 22:34:26 +0800 +Subject: [PATCH 01/10] Fix for "timer -r" option to display all the per-CPU + clocks + +Currently, the hrtimer_max_clock_bases is hard-coded to 3, which +makes that crash only prints three clocks, and the rest of clocks +are not displayed. + +Without the patch: +crash> timer -r -C 11 +CPU: 11 HRTIMER_CPU_BASE: ffff9a775f95ee00 + CLOCK: 0 HRTIMER_CLOCK_BASE: ffff9a775f95ee80 [ktime_get] + (empty) + + CLOCK: 1 HRTIMER_CLOCK_BASE: ffff9a775f95ef00 [ktime_get_real] + (empty) + + CLOCK: 2 HRTIMER_CLOCK_BASE: ffff9a775f95ef80 [ktime_get_boottime] + (empty) + +With the patch: +crash> timer -r -C 11 +CPU: 11 HRTIMER_CPU_BASE: ffff9a775f95ee00 + CLOCK: 0 HRTIMER_CLOCK_BASE: ffff9a775f95ee80 [ktime_get] + (empty) + + CLOCK: 1 HRTIMER_CLOCK_BASE: ffff9a775f95ef00 [ktime_get_real] + (empty) + + CLOCK: 2 HRTIMER_CLOCK_BASE: ffff9a775f95ef80 [ktime_get_boottime] + (empty) +... + CLOCK: 7 HRTIMER_CLOCK_BASE: ffff9a775f95f200 [ktime_get_clocktai] + (empty) + +Signed-off-by: Lianbo Jiang +--- + kernel.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kernel.c b/kernel.c +index 37b7af74ed2e..36c57ed501ad 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -7675,7 +7675,8 @@ dump_hrtimer_data(const ulong *cpus) + if (VALID_STRUCT(hrtimer_clock_base)) { + hrtimer_max_clock_bases = 2; + if (symbol_exists("ktime_get_boottime")) +- hrtimer_max_clock_bases = 3; ++ hrtimer_max_clock_bases = MEMBER_SIZE("hrtimer_cpu_base", "clock_base") / ++ SIZE(hrtimer_clock_base); + } else if (VALID_STRUCT(hrtimer_base)) { + max_hrtimer_bases = 2; + } else +-- +2.20.1 + diff --git a/SOURCES/0001-Fix-pvops-Xen-detection-for-arm-machine.patch b/SOURCES/0001-Fix-pvops-Xen-detection-for-arm-machine.patch new file mode 100644 index 0000000..c085a34 --- /dev/null +++ b/SOURCES/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/SOURCES/0001-arm64-Support-overflow-stack-panic.patch b/SOURCES/0001-arm64-Support-overflow-stack-panic.patch new file mode 100644 index 0000000..310c55e --- /dev/null +++ b/SOURCES/0001-arm64-Support-overflow-stack-panic.patch @@ -0,0 +1,379 @@ +From 995db8ab88916b6397676b67be98c0a4f82cca49 Mon Sep 17 00:00:00 2001 +From: Hong YANG +Date: Mon, 15 Nov 2021 15:41:01 +0800 +Subject: [PATCH 1/3] arm64: Support overflow stack panic + +Kernel commit <872d8327ce89> ("arm64: add VMAP_STACK overflow detection") +has supported the overflow stack exception handling. Without the patch, the +"bt" command will make crash generate a core dump because of segmentation +fault. With the patch, the "bt" command can display the overflow stack. + +Before: +crash> bt +PID: 3607 TASK: ffffffcbf9a4da00 CPU: 2 COMMAND: "sh" +Segmentation fault (core dumped) + +After: +crash> bt +PID: 3607 TASK: ffffffcbf9a4da00 CPU: 2 COMMAND: "sh" + #0 [ffffffccbfd85f50] __delay at ffffff8008ceded8 +... + #5 [ffffffccbfd85fd0] emergency_restart at ffffff80080d49fc + #6 [ffffffccbfd86140] panic at ffffff80080af4c0 + #7 [ffffffccbfd86150] nmi_panic at ffffff80080af150 + #8 [ffffffccbfd86190] handle_bad_stack at ffffff800808b0b8 + #9 [ffffffccbfd862d0] __bad_stack at ffffff800808285c + PC: ffffff8008082e80 [el1_sync] + LR: ffffff8000d6c214 [stack_overflow_demo+84] + SP: ffffff1a79930070 PSTATE: 204003c5 + X29: ffffff8011b03d00 X28: ffffffcbf9a4da00 X27: ffffff8008e02000 + X26: 0000000000000040 X25: 0000000000000124 X24: ffffffcbf9a4da00 + X23: 0000007daec2e288 X22: ffffffcbfe03b800 X21: 0000007daec2e288 + X20: 0000000000000002 X19: 0000000000000002 X18: 0000000000000002 + X17: 00000000000003e7 X16: 0000000000000000 X15: 0000000000000000 + X14: ffffffcc17facb00 X13: ffffffccb4c25c00 X12: 0000000000000000 + X11: ffffffcc17fad660 X10: 0000000000000af0 X9: 0000000000000000 + X8: ffffff1a799334f0 X7: 0000000000000000 X6: 000000000000003f + X5: 0000000000000040 X4: 0000000000000010 X3: 00000065981d07f0 + X2: 00000065981d07f0 X1: 0000000000000000 X0: ffffff1a799334f0 + +Signed-off-by: Hong YANG +--- + arm64.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++------ + defs.h | 6 ++ + 2 files changed, 159 insertions(+), 16 deletions(-) + +diff --git a/arm64.c b/arm64.c +index 94681d1a37db..23c3d75d85aa 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -45,6 +45,7 @@ static int arm64_vtop_3level_4k(ulong, ulong, physaddr_t *, int); + static int arm64_vtop_4level_4k(ulong, ulong, physaddr_t *, int); + static ulong arm64_get_task_pgd(ulong); + static void arm64_irq_stack_init(void); ++static void arm64_overflow_stack_init(void); + static void arm64_stackframe_init(void); + static int arm64_eframe_search(struct bt_info *); + static int arm64_is_kernel_exception_frame(struct bt_info *, ulong); +@@ -63,6 +64,7 @@ static int arm64_get_dumpfile_stackframe(struct bt_info *, struct arm64_stackfra + static int arm64_in_kdump_text(struct bt_info *, struct arm64_stackframe *); + static int arm64_in_kdump_text_on_irq_stack(struct bt_info *); + static int arm64_switch_stack(struct bt_info *, struct arm64_stackframe *, FILE *); ++static int arm64_switch_stack_from_overflow(struct bt_info *, struct arm64_stackframe *, FILE *); + static int arm64_get_stackframe(struct bt_info *, struct arm64_stackframe *); + static void arm64_get_stack_frame(struct bt_info *, ulong *, ulong *); + static void arm64_gen_hidden_frame(struct bt_info *bt, ulong, struct arm64_stackframe *); +@@ -78,8 +80,11 @@ static int arm64_get_smp_cpus(void); + static void arm64_clear_machdep_cache(void); + static int arm64_on_process_stack(struct bt_info *, ulong); + static int arm64_in_alternate_stack(int, ulong); ++static int arm64_in_alternate_stackv(int cpu, ulong stkptr, ulong *stacks, ulong stack_size); + static int arm64_on_irq_stack(int, ulong); ++static int arm64_on_overflow_stack(int, ulong); + static void arm64_set_irq_stack(struct bt_info *); ++static void arm64_set_overflow_stack(struct bt_info *); + static void arm64_set_process_stack(struct bt_info *); + static int arm64_get_kvaddr_ranges(struct vaddr_range *); + static void arm64_get_crash_notes(void); +@@ -463,6 +468,7 @@ arm64_init(int when) + machdep->hz = 100; + + arm64_irq_stack_init(); ++ arm64_overflow_stack_init(); + arm64_stackframe_init(); + break; + +@@ -1715,6 +1721,49 @@ arm64_irq_stack_init(void) + } + } + ++/* ++ * Gather Overflow stack values. ++ * ++ * Overflow stack supported since 4.14, in commit 872d8327c ++ */ ++static void ++arm64_overflow_stack_init(void) ++{ ++ int i; ++ struct syment *sp; ++ struct gnu_request request, *req; ++ struct machine_specific *ms = machdep->machspec; ++ req = &request; ++ ++ if (symbol_exists("overflow_stack") && ++ (sp = per_cpu_symbol_search("overflow_stack")) && ++ get_symbol_type("overflow_stack", NULL, req)) { ++ if (CRASHDEBUG(1)) { ++ fprintf(fp, "overflow_stack: \n"); ++ fprintf(fp, " type: %x, %s\n", ++ (int)req->typecode, ++ (req->typecode == TYPE_CODE_ARRAY) ? ++ "TYPE_CODE_ARRAY" : "other"); ++ fprintf(fp, " target_typecode: %x, %s\n", ++ (int)req->target_typecode, ++ req->target_typecode == TYPE_CODE_INT ? ++ "TYPE_CODE_INT" : "other"); ++ fprintf(fp, " target_length: %ld\n", ++ req->target_length); ++ fprintf(fp, " length: %ld\n", req->length); ++ } ++ ++ if (!(ms->overflow_stacks = (ulong *)malloc((size_t)(kt->cpus * sizeof(ulong))))) ++ error(FATAL, "cannot malloc overflow_stack addresses\n"); ++ ++ ms->overflow_stack_size = ARM64_OVERFLOW_STACK_SIZE; ++ machdep->flags |= OVERFLOW_STACKS; ++ ++ for (i = 0; i < kt->cpus; i++) ++ ms->overflow_stacks[i] = kt->__per_cpu_offset[i] + sp->value; ++ } ++} ++ + /* + * Gather and verify all of the backtrace requirements. + */ +@@ -1960,6 +2009,7 @@ static char *arm64_exception_functions[] = { + "do_mem_abort", + "do_el0_irq_bp_hardening", + "do_sp_pc_abort", ++ "handle_bad_stack", + NULL + }; + +@@ -1978,7 +2028,10 @@ arm64_in_exception_text(ulong ptr) + if ((ptr >= ms->__exception_text_start) && + (ptr < ms->__exception_text_end)) + return TRUE; +- } else if ((name = closest_symbol(ptr))) { /* Linux 5.5 and later */ ++ } ++ ++ name = closest_symbol(ptr); ++ if (name != NULL) { /* Linux 5.5 and later */ + for (func = &arm64_exception_functions[0]; *func; func++) { + if (STREQ(name, *func)) + return TRUE; +@@ -2252,15 +2305,14 @@ arm64_unwind_frame(struct bt_info *bt, struct arm64_stackframe *frame) + if ((frame->fp == 0) && (frame->pc == 0)) + return FALSE; + +- if (!(machdep->flags & IRQ_STACKS)) +- return TRUE; +- +- if (!(machdep->flags & IRQ_STACKS)) ++ if (!(machdep->flags & (IRQ_STACKS | OVERFLOW_STACKS))) + return TRUE; + + if (machdep->flags & UNW_4_14) { +- if ((bt->flags & BT_IRQSTACK) && +- !arm64_on_irq_stack(bt->tc->processor, frame->fp)) { ++ if (((bt->flags & BT_IRQSTACK) && ++ !arm64_on_irq_stack(bt->tc->processor, frame->fp)) || ++ ((bt->flags & BT_OVERFLOW_STACK) && ++ !arm64_on_overflow_stack(bt->tc->processor, frame->fp))) { + if (arm64_on_process_stack(bt, frame->fp)) { + arm64_set_process_stack(bt); + +@@ -2677,6 +2729,9 @@ arm64_back_trace_cmd(struct bt_info *bt) + if (arm64_on_irq_stack(bt->tc->processor, bt->frameptr)) { + arm64_set_irq_stack(bt); + bt->flags |= BT_IRQSTACK; ++ } else if (arm64_on_overflow_stack(bt->tc->processor, bt->frameptr)) { ++ arm64_set_overflow_stack(bt); ++ bt->flags |= BT_OVERFLOW_STACK; + } + stackframe.sp = bt->stkptr; + stackframe.pc = bt->instptr; +@@ -2731,7 +2786,9 @@ arm64_back_trace_cmd(struct bt_info *bt) + break; + + if (arm64_in_exception_text(bt->instptr) && INSTACK(stackframe.fp, bt)) { +- if (!(bt->flags & BT_IRQSTACK) || ++ if (bt->flags & BT_OVERFLOW_STACK) { ++ exception_frame = stackframe.fp - KERN_EFRAME_OFFSET; ++ } else if (!(bt->flags & BT_IRQSTACK) || + ((stackframe.sp + SIZE(pt_regs)) < bt->stacktop)) { + if (arm64_is_kernel_exception_frame(bt, stackframe.fp - KERN_EFRAME_OFFSET)) + exception_frame = stackframe.fp - KERN_EFRAME_OFFSET; +@@ -2745,6 +2802,12 @@ arm64_back_trace_cmd(struct bt_info *bt) + break; + } + ++ if ((bt->flags & BT_OVERFLOW_STACK) && ++ !arm64_on_overflow_stack(bt->tc->processor, stackframe.fp)) { ++ bt->flags &= ~BT_OVERFLOW_STACK; ++ if (arm64_switch_stack_from_overflow(bt, &stackframe, ofp) == USER_MODE) ++ break; ++ } + + level++; + } +@@ -3131,6 +3194,43 @@ arm64_switch_stack(struct bt_info *bt, struct arm64_stackframe *frame, FILE *ofp + return KERNEL_MODE; + } + ++static int ++arm64_switch_stack_from_overflow(struct bt_info *bt, struct arm64_stackframe *frame, FILE *ofp) ++{ ++ int i; ++ ulong stacktop, words, addr; ++ ulong *stackbuf; ++ char buf[BUFSIZE]; ++ struct machine_specific *ms = machdep->machspec; ++ ++ if (bt->flags & BT_FULL) { ++ stacktop = ms->overflow_stacks[bt->tc->processor] + ms->overflow_stack_size; ++ words = (stacktop - bt->bptr) / sizeof(ulong); ++ stackbuf = (ulong *)GETBUF(words * sizeof(ulong)); ++ readmem(bt->bptr, KVADDR, stackbuf, words * sizeof(long), ++ "top of overflow stack", FAULT_ON_ERROR); ++ ++ addr = bt->bptr; ++ for (i = 0; i < words; i++) { ++ if (!(i & 1)) ++ fprintf(ofp, "%s %lx: ", i ? "\n" : "", addr); ++ fprintf(ofp, "%s ", format_stack_entry(bt, buf, stackbuf[i], 0)); ++ addr += sizeof(ulong); ++ } ++ fprintf(ofp, "\n"); ++ FREEBUF(stackbuf); ++ } ++ fprintf(ofp, "--- ---\n"); ++ ++ if (frame->fp == 0) ++ return USER_MODE; ++ ++ if (!(machdep->flags & UNW_4_14)) ++ arm64_print_exception_frame(bt, frame->sp, KERNEL_MODE, ofp); ++ ++ return KERNEL_MODE; ++} ++ + static int + arm64_get_dumpfile_stackframe(struct bt_info *bt, struct arm64_stackframe *frame) + { +@@ -3682,6 +3782,16 @@ arm64_display_machine_stats(void) + machdep->machspec->irq_stacks[i]); + } + } ++ if (machdep->machspec->overflow_stack_size) { ++ fprintf(fp, "OVERFLOW STACK SIZE: %ld\n", ++ machdep->machspec->overflow_stack_size); ++ fprintf(fp, " OVERFLOW STACKS:\n"); ++ for (i = 0; i < kt->cpus; i++) { ++ pad = (i < 10) ? 3 : (i < 100) ? 2 : (i < 1000) ? 1 : 0; ++ fprintf(fp, "%s CPU %d: %lx\n", space(pad), i, ++ machdep->machspec->overflow_stacks[i]); ++ } ++ } + } + + static int +@@ -3875,24 +3985,41 @@ arm64_on_process_stack(struct bt_info *bt, ulong stkptr) + } + + static int +-arm64_on_irq_stack(int cpu, ulong stkptr) ++arm64_in_alternate_stackv(int cpu, ulong stkptr, ulong *stacks, ulong stack_size) + { +- return arm64_in_alternate_stack(cpu, stkptr); ++ if ((cpu >= kt->cpus) || (stacks == NULL) || !stack_size) ++ return FALSE; ++ ++ if ((stkptr >= stacks[cpu]) && ++ (stkptr < (stacks[cpu] + stack_size))) ++ return TRUE; ++ ++ return FALSE; + } + + static int + arm64_in_alternate_stack(int cpu, ulong stkptr) ++{ ++ return (arm64_on_irq_stack(cpu, stkptr) || ++ arm64_on_overflow_stack(cpu, stkptr)); ++} ++ ++static int ++arm64_on_irq_stack(int cpu, ulong stkptr) + { + struct machine_specific *ms = machdep->machspec; + +- if (!ms->irq_stack_size || (cpu >= kt->cpus)) +- return FALSE; ++ return arm64_in_alternate_stackv(cpu, stkptr, ++ ms->irq_stacks, ms->irq_stack_size); ++} + +- if ((stkptr >= ms->irq_stacks[cpu]) && +- (stkptr < (ms->irq_stacks[cpu] + ms->irq_stack_size))) +- return TRUE; ++static int ++arm64_on_overflow_stack(int cpu, ulong stkptr) ++{ ++ struct machine_specific *ms = machdep->machspec; + +- return FALSE; ++ return arm64_in_alternate_stackv(cpu, stkptr, ++ ms->overflow_stacks, ms->overflow_stack_size); + } + + static void +@@ -3905,6 +4032,16 @@ arm64_set_irq_stack(struct bt_info *bt) + alter_stackbuf(bt); + } + ++static void ++arm64_set_overflow_stack(struct bt_info *bt) ++{ ++ struct machine_specific *ms = machdep->machspec; ++ ++ bt->stackbase = ms->overflow_stacks[bt->tc->processor]; ++ bt->stacktop = bt->stackbase + ms->overflow_stack_size; ++ alter_stackbuf(bt); ++} ++ + static void + arm64_set_process_stack(struct bt_info *bt) + { +diff --git a/defs.h b/defs.h +index a2f30853a4b1..7e2a16e34a59 100644 +--- a/defs.h ++++ b/defs.h +@@ -3218,6 +3218,7 @@ typedef signed int s32; + #define UNW_4_14 (0x200) + #define FLIPPED_VM (0x400) + #define HAS_PHYSVIRT_OFFSET (0x800) ++#define OVERFLOW_STACKS (0x1000) + + /* + * Get kimage_voffset from /dev/crash +@@ -3260,6 +3261,7 @@ typedef signed int s32; + + #define ARM64_STACK_SIZE (16384) + #define ARM64_IRQ_STACK_SIZE ARM64_STACK_SIZE ++#define ARM64_OVERFLOW_STACK_SIZE (4096) + + #define _SECTION_SIZE_BITS 30 + #define _SECTION_SIZE_BITS_5_12 27 +@@ -3332,6 +3334,9 @@ struct machine_specific { + char *irq_stackbuf; + ulong __irqentry_text_start; + ulong __irqentry_text_end; ++ ulong overflow_stack_size; ++ ulong *overflow_stacks; ++ char *overflow_stackbuf; + /* for exception vector code */ + ulong exp_entry1_start; + ulong exp_entry1_end; +@@ -5770,6 +5775,7 @@ ulong cpu_map_addr(const char *type); + #define BT_CPUMASK (0x1000000000000ULL) + #define BT_SHOW_ALL_REGS (0x2000000000000ULL) + #define BT_REGS_NOT_FOUND (0x4000000000000ULL) ++#define BT_OVERFLOW_STACK (0x8000000000000ULL) + #define BT_SYMBOL_OFFSET (BT_SYMBOLIC_ARGS) + + #define BT_REF_HEXVAL (0x1) +-- +2.30.2 + diff --git a/SOURCES/0001-arm64-Use-CONFIG_ARM64_VA_BITS-to-initialize-VA_BITS.patch b/SOURCES/0001-arm64-Use-CONFIG_ARM64_VA_BITS-to-initialize-VA_BITS.patch new file mode 100644 index 0000000..ffc3f85 --- /dev/null +++ b/SOURCES/0001-arm64-Use-CONFIG_ARM64_VA_BITS-to-initialize-VA_BITS.patch @@ -0,0 +1,34 @@ +From 6ecb8a23ca294de5ef92726c782f4c92fcb39d92 Mon Sep 17 00:00:00 2001 +From: Huang Shijie +Date: Fri, 11 Feb 2022 09:46:42 +0000 +Subject: [PATCH] arm64: Use CONFIG_ARM64_VA_BITS to initialize VA_BITS_ACTUAL + +We can get VA_BITS_ACTUAL from CONFIG_ARM64_VA_BITS by guess. + +Without this patch, we may need to use "--machdep vabits_actual=48" to +set the VA_BITS_ACTUAL. + +Signed-off-by: Huang Shijie +--- + arm64.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/arm64.c b/arm64.c +index 4f2c2b5..de1038a 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -4170,6 +4170,11 @@ arm64_calc_VA_BITS(void) + } else if (machdep->machspec->VA_BITS_ACTUAL) { + machdep->machspec->VA_BITS = machdep->machspec->VA_BITS_ACTUAL; + machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL); ++ } else if (machdep->machspec->CONFIG_ARM64_VA_BITS) { ++ /* guess */ ++ machdep->machspec->VA_BITS_ACTUAL = machdep->machspec->CONFIG_ARM64_VA_BITS; ++ machdep->machspec->VA_BITS = machdep->machspec->CONFIG_ARM64_VA_BITS; ++ machdep->machspec->VA_START = _VA_START(machdep->machspec->VA_BITS_ACTUAL); + } else + error(FATAL, "cannot determine VA_BITS_ACTUAL\n"); + } +-- +2.31.1 + diff --git a/SOURCES/0001-arm64-deduce-the-start-address-of-kernel-code-based-.patch b/SOURCES/0001-arm64-deduce-the-start-address-of-kernel-code-based-.patch new file mode 100644 index 0000000..0454be6 --- /dev/null +++ b/SOURCES/0001-arm64-deduce-the-start-address-of-kernel-code-based-.patch @@ -0,0 +1,69 @@ +From e3bdc32aab5d8fe09b679cf394da8ba8826e207f Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 24 Feb 2022 11:52:12 +0800 +Subject: [PATCH] arm64: deduce the start address of kernel code, based on + kernel version + +After kernel commit e2a073dde921 ("arm64: omit [_text, _stext) from +permanent kernel mapping"), the range [_text, _stext] is reclaimed. But +the current crash code still assumes kernel starting from "_text". + +This change only affects the vmalloced area on arm64 and may result a +false in arm64_IS_VMALLOC_ADDR(). + +Since vmcore has no extra information about this trival change, it can +only be deduced from kernel version, which means ms->kimage_text can not +be correctly initialized until kernel_init() finishes. Here on arm64, it +can be done at the point machdep_init(POST_GDB). This is fine +since there is no access to vmalloced area at this stage. + +Signed-off-by: Pingfan Liu +--- + arm64.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/arm64.c b/arm64.c +index de1038a..3ab8489 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -92,6 +92,20 @@ static void arm64_calc_VA_BITS(void); + static int arm64_is_uvaddr(ulong, struct task_context *); + static void arm64_calc_KERNELPACMASK(void); + ++static void arm64_calc_kernel_start(void) ++{ ++ struct machine_specific *ms = machdep->machspec; ++ struct syment *sp; ++ ++ if (THIS_KERNEL_VERSION >= LINUX(5,11,0)) ++ sp = kernel_symbol_search("_stext"); ++ else ++ sp = kernel_symbol_search("_text"); ++ ++ ms->kimage_text = (sp ? sp->value : 0); ++ sp = kernel_symbol_search("_end"); ++ ms->kimage_end = (sp ? sp->value : 0); ++} + + /* + * Do all necessary machine-specific setup here. This is called several times +@@ -241,6 +255,7 @@ arm64_init(int when) + if (machdep->flags & NEW_VMEMMAP) { + struct syment *sp; + ++ /* It is finally decided in arm64_calc_kernel_start() */ + sp = kernel_symbol_search("_text"); + ms->kimage_text = (sp ? sp->value : 0); + sp = kernel_symbol_search("_end"); +@@ -387,6 +402,8 @@ arm64_init(int when) + break; + + case POST_GDB: ++ /* Rely on kernel version to decide the kernel start address */ ++ arm64_calc_kernel_start(); + arm64_calc_virtual_memory_ranges(); + arm64_get_section_size_bits(); + +-- +2.31.1 + diff --git a/SOURCES/0002-Fix-for-bt-v-option-to-display-the-stack-end-address.patch b/SOURCES/0002-Fix-for-bt-v-option-to-display-the-stack-end-address.patch new file mode 100644 index 0000000..0cc8b35 --- /dev/null +++ b/SOURCES/0002-Fix-for-bt-v-option-to-display-the-stack-end-address.patch @@ -0,0 +1,69 @@ +From 0d3d80b47d69c5d303b48c0463a026e60633cae2 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Thu, 6 Jan 2022 12:01:17 +0800 +Subject: [PATCH 02/10] Fix for "bt -v" option to display the stack-end address + correctly + +The "bt -v" command prints incorrect stack-end address when the +"CONFIG_THREAD_INFO_IN_TASK=y" is enabled in kernel, the "bt -v" +command output shows that the value stored at 0xffff8dee0312c198 +is 0xffffffffc076400a, however, the value stored actually at +0xffff8dee0312c198 is NULL(0x0000000000000000), the stack-end +address is incorrect. + +Without the patch: +crash> bt -v +PID: 28642 TASK: ffff8dee0312c180 CPU: 0 COMMAND: "insmod" + possible stack overflow: ffff8dee0312c198: ffffffffc076400a != STACK_END_MAGIC + ^^^^^^^^^^^^^^^^ + +crash> rd 0xffff8dee0312c198 +ffff8dee0312c198: 0000000000000000 ........ + ^^^^^^^^^^^^^^^^ + +With the patch: +crash> bt -v +PID: 28642 TASK: ffff8dee0312c180 CPU: 0 COMMAND: "insmod" + possible stack overflow: ffff991340bc0000: ffffffffc076400a != STACK_END_MAGIC + +crash> rd 0xffff991340bc0000 +ffff991340bc0000: ffffffffc076400a .@v..... + +Signed-off-by: Lianbo Jiang +--- + task.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/task.c b/task.c +index bb6a5da8ad33..b5ddc88e0acb 100644 +--- a/task.c ++++ b/task.c +@@ -11202,7 +11202,7 @@ check_stack_overflow(void) + { + int i, overflow, cpu_size, cpu, total; + char buf[BUFSIZE]; +- ulong magic, task, stackbase; ++ ulong magic, task, stackbase, location; + struct task_context *tc; + + if (!tt->stack_end_magic && +@@ -11286,9 +11286,15 @@ check_stack_end_magic: + if (magic != STACK_END_MAGIC) { + if (!overflow) + print_task_header(fp, tc, 0); ++ ++ if (tt->flags & THREAD_INFO_IN_TASK) ++ location = task_to_stackbase(tc->task); ++ else ++ location = tc->thread_info + SIZE(thread_info); ++ + fprintf(fp, + " possible stack overflow: %lx: %lx != STACK_END_MAGIC\n", +- tc->thread_info + SIZE(thread_info), magic); ++ location, magic); + overflow++, total++; + } + +-- +2.20.1 + diff --git a/SOURCES/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch b/SOURCES/0002-Handle-blk_mq_ctx-member-changes-for-kernels-5.16-rc.patch new file mode 100644 index 0000000..fb8a27b --- /dev/null +++ b/SOURCES/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/SOURCES/0002-defs.h-fix-breakage-of-compatibility-of-struct-machd.patch b/SOURCES/0002-defs.h-fix-breakage-of-compatibility-of-struct-machd.patch new file mode 100644 index 0000000..fdb0cc3 --- /dev/null +++ b/SOURCES/0002-defs.h-fix-breakage-of-compatibility-of-struct-machd.patch @@ -0,0 +1,41 @@ +From c477b04aee34d4f4784c326ed715e91b2c43eb3e Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Thu, 9 Dec 2021 01:05:07 +0000 +Subject: [PATCH 2/3] defs.h: fix breakage of compatibility of struct + machdep_table for extension modules + +Commit <2f967fb5ebd7> ("crash_taget: fetch_registers support") added new +member get_cpu_reg in the middle of struct machdep_table, which breaks +compatibility of struct machdep_table for extension modules. As the result, +crash gcore command results in unexpected behavior, furthermore may cause +segmentation fault. + +Fixes: 2f967fb5ebd7 ("crash_taget: fetch_registers support") +Signed-off-by: HATAYAMA Daisuke +--- + defs.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/defs.h b/defs.h +index 7e2a16e34a59..7d3ed78fcd23 100644 +--- a/defs.h ++++ b/defs.h +@@ -1013,7 +1013,6 @@ struct machdep_table { + ulong (*processor_speed)(void); + int (*uvtop)(struct task_context *, ulong, physaddr_t *, int); + int (*kvtop)(struct task_context *, ulong, physaddr_t *, int); +- int (*get_cpu_reg)(int, int, const char *, int, void *); + ulong (*get_task_pgd)(ulong); + void (*dump_irq)(int); + void (*get_stack_frame)(struct bt_info *, ulong *, ulong *); +@@ -1063,6 +1062,7 @@ struct machdep_table { + void (*get_irq_affinity)(int); + void (*show_interrupts)(int, ulong *); + int (*is_page_ptr)(ulong, physaddr_t *); ++ int (*get_cpu_reg)(int, int, const char *, int, void *); + }; + + /* +-- +2.30.2 + diff --git a/SOURCES/0003-Fix-for-HZ-calculation-on-Linux-5.14-and-later.patch b/SOURCES/0003-Fix-for-HZ-calculation-on-Linux-5.14-and-later.patch new file mode 100644 index 0000000..303ba3b --- /dev/null +++ b/SOURCES/0003-Fix-for-HZ-calculation-on-Linux-5.14-and-later.patch @@ -0,0 +1,35 @@ +From b9dc76e232e0226a14ae3089e3be5c915f2bb981 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Mon, 10 Jan 2022 17:25:06 +0800 +Subject: [PATCH 03/10] Fix for HZ calculation on Linux 5.14 and later + +Kernel commit 3e9a99eba058 ("block/mq-deadline: Rename dd_init_queue() +and dd_exit_queue()") renamed dd_init_queue to dd_init_sched. Without +the patch, the 'help -m' may print incorrect hz value as follows: + +crash> help -m | grep hz + hz: 1000 <---The correct hz value on ppc64le machine is 100. + ^^^^ + +Fixes: b93027ce5c75 ("Add alternate HZ calculation using write_expire") +Signed-off-by: Lianbo Jiang +--- + task.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/task.c b/task.c +index b5ddc88e0acb..76e184ae70b1 100644 +--- a/task.c ++++ b/task.c +@@ -440,6 +440,8 @@ task_init(void) + } + } else if ((symbol_exists("dd_init_queue") && + gdb_set_crash_scope(symbol_value("dd_init_queue"), "dd_init_queue")) || ++ (symbol_exists("dd_init_sched") && ++ gdb_set_crash_scope(symbol_value("dd_init_sched"), "dd_init_sched")) || + (symbol_exists("deadline_init_queue") && + gdb_set_crash_scope(symbol_value("deadline_init_queue"), "deadline_init_queue"))) { + char buf[BUFSIZE]; +-- +2.20.1 + diff --git a/SOURCES/0003-defs.h-fix-breakage-of-compatibility-of-struct-symbo.patch b/SOURCES/0003-defs.h-fix-breakage-of-compatibility-of-struct-symbo.patch new file mode 100644 index 0000000..91fe99b --- /dev/null +++ b/SOURCES/0003-defs.h-fix-breakage-of-compatibility-of-struct-symbo.patch @@ -0,0 +1,41 @@ +From 6968345893178d2750b8872055498d2a6010a861 Mon Sep 17 00:00:00 2001 +From: HATAYAMA Daisuke +Date: Wed, 8 Dec 2021 12:07:34 +0000 +Subject: [PATCH 3/3] defs.h: fix breakage of compatibility of struct + symbol_table_data for extension modules + +Commit <2fab8fbc0c4f> ("symbols: Implement install and remove operations +for mod_symname_hash") added new member variable mod_symname_hash in the +middle of struct symbol_table_date, which breaks compatibility of struct +symbol_table_data for extension modules. As the result, crash trace command +results in segmentation fault. + +Fixes: 2fab8fbc0c4f ("symbols: Implement install and remove operations for mod_symname_hash") +Signed-off-by: HATAYAMA Daisuke +--- + defs.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/defs.h b/defs.h +index 7d3ed78fcd23..b63741c7d78b 100644 +--- a/defs.h ++++ b/defs.h +@@ -2753,7 +2753,6 @@ struct symbol_table_data { + double val_hash_searches; + double val_hash_iterations; + struct syment *symname_hash[SYMNAME_HASH]; +- struct syment *mod_symname_hash[SYMNAME_HASH]; + struct symbol_namespace kernel_namespace; + struct syment *ext_module_symtable; + struct syment *ext_module_symend; +@@ -2780,6 +2779,7 @@ struct symbol_table_data { + ulong kaiser_init_vmlinux; + int kernel_symbol_type; + ulong linux_banner_vmlinux; ++ struct syment *mod_symname_hash[SYMNAME_HASH]; + }; + + /* flags for st */ +-- +2.30.2 + diff --git a/SOURCES/0004-memory-Handle-struct-slab-changes-on-Linux-5.17-rc1-.patch b/SOURCES/0004-memory-Handle-struct-slab-changes-on-Linux-5.17-rc1-.patch new file mode 100644 index 0000000..dfb2728 --- /dev/null +++ b/SOURCES/0004-memory-Handle-struct-slab-changes-on-Linux-5.17-rc1-.patch @@ -0,0 +1,39 @@ +From 14f8c460473c8613553b5defd174ca2af812ddcb Mon Sep 17 00:00:00 2001 +From: Alexander Egorenkov +Date: Mon, 6 Dec 2021 16:04:19 +0100 +Subject: [PATCH 04/10] memory: Handle struct slab changes on Linux 5.17-rc1 + and later + +Since kernel commit d122019bf061 ("mm: Split slab into its own type"), +the struct slab is used for both SLAB and SLUB. Therefore, don't depend +on the non-presence of the struct slab to decide whether SLAB implementation +should be chosen and use the member variable "cpu_slab" of the struct +kmem_cache instead, it should be present only in SLUB. + +Without the patch, crash fails to start with the error message: + + crash: invalid structure member offset: kmem_cache_s_num + FILE: memory.c LINE: 9619 FUNCTION: kmem_cache_init() + +Signed-off-by: Alexander Egorenkov +--- + memory.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/memory.c b/memory.c +index 86c02c132890..5af45fd7d834 100644 +--- a/memory.c ++++ b/memory.c +@@ -576,7 +576,8 @@ vm_init(void) + STRUCT_SIZE_INIT(cpucache_s, "cpucache_s"); + + } else if (!VALID_STRUCT(kmem_slab_s) && +- !VALID_STRUCT(slab_s) && ++ !VALID_STRUCT(slab_s) && ++ !MEMBER_EXISTS("kmem_cache", "cpu_slab") && + (VALID_STRUCT(slab) || (vt->flags & SLAB_OVERLOAD_PAGE))) { + vt->flags |= PERCPU_KMALLOC_V2; + +-- +2.20.1 + diff --git a/SOURCES/0005-Move-the-initialization-of-boot_date-to-task_init.patch b/SOURCES/0005-Move-the-initialization-of-boot_date-to-task_init.patch new file mode 100644 index 0000000..e7b41c9 --- /dev/null +++ b/SOURCES/0005-Move-the-initialization-of-boot_date-to-task_init.patch @@ -0,0 +1,75 @@ +From d16dc6fff0260ec26002046fae4aeb546d6b9a0e Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Mon, 17 Jan 2022 15:14:00 +0800 +Subject: [PATCH 05/10] Move the initialization of "boot_date" to task_init() + +The "boot_date" is initialized conditionally in the cmd_log(), which may +display incorrect "boot_date" value with the following command before +running the "log -T" command: + +crash> help -k | grep date + date: Wed Dec 22 13:39:29 IST 2021 + boot_date: Thu Jan 1 05:30:00 IST 1970 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The calculation of "boot_date" depends on the HZ value, and the HZ will +be calculated in task_init() at the latest, so let's move it here. + +Signed-off-by: Lianbo Jiang +--- + kernel.c | 18 +++--------------- + task.c | 10 ++++++++++ + 2 files changed, 13 insertions(+), 15 deletions(-) + +diff --git a/kernel.c b/kernel.c +index 36c57ed501ad..094fe9b2efad 100644 +--- a/kernel.c ++++ b/kernel.c +@@ -5025,21 +5025,9 @@ cmd_log(void) + if (argerrs) + cmd_usage(pc->curcmd, SYNOPSIS); + +- if (msg_flags & SHOW_LOG_CTIME) { +- if (pc->flags & MINIMAL_MODE) { +- error(WARNING, "the option '-T' is not available in minimal mode\n"); +- return; +- } +- +- if (kt->boot_date.tv_sec == 0) { +- ulonglong uptime_jiffies; +- ulong uptime_sec; +- +- get_uptime(NULL, &uptime_jiffies); +- uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz; +- kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec; +- kt->boot_date.tv_nsec = 0; +- } ++ if (msg_flags & SHOW_LOG_CTIME && pc->flags & MINIMAL_MODE) { ++ error(WARNING, "the option '-T' is not available in minimal mode\n"); ++ return; + } + + if (msg_flags & SHOW_LOG_AUDIT) { +diff --git a/task.c b/task.c +index 76e184ae70b1..263a8344dd94 100644 +--- a/task.c ++++ b/task.c +@@ -692,6 +692,16 @@ task_init(void) + + stack_overflow_check_init(); + ++ if (machdep->hz) { ++ ulonglong uptime_jiffies; ++ ulong uptime_sec; ++ ++ get_uptime(NULL, &uptime_jiffies); ++ uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz; ++ kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec; ++ kt->boot_date.tv_nsec = 0; ++ } ++ + tt->flags |= TASK_INIT_DONE; + } + +-- +2.20.1 + diff --git a/SOURCES/0006-Remove-ptype-command-from-ps-t-option-to-reduce-memo.patch b/SOURCES/0006-Remove-ptype-command-from-ps-t-option-to-reduce-memo.patch new file mode 100644 index 0000000..f2e59b1 --- /dev/null +++ b/SOURCES/0006-Remove-ptype-command-from-ps-t-option-to-reduce-memo.patch @@ -0,0 +1,78 @@ +From 2ebd8c5ecf1f077975b82325a38dd777b594d0a9 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 19 Jan 2022 16:24:49 +0900 +Subject: [PATCH 06/10] Remove ptype command from "ps -t" option to reduce + memory and time + +With some vmlinux e.g. RHEL9 ones, the first execution of the gdb ptype +command heavily consumes memory and time. The "ps -t" option uses it in +start_time_timespec(), and it can be replaced with the crash macros. + +This can reduce about 1.4 GB memory and 6 seconds time comsumption in +the following test: + + $ echo "ps -t" | time crash vmlinux vmcore + + Without the patch: + 11.60user 0.43system 0:11.94elapsed 100%CPU (0avgtext+0avgdata 1837964maxresident)k + 0inputs+400outputs (0major+413636minor)pagefaults 0swaps + + With the patch: + 5.40user 0.16system 0:05.46elapsed 101%CPU (0avgtext+0avgdata 417896maxresident)k + 0inputs+384outputs (0major+41528minor)pagefaults 0swaps + +Although the ptype command and similar ones cannot be fully removed, +but removing some of them will make the use of crash safer, especially +for an automatic crash reporter. + +Signed-off-by: Kazuhito Hagio +--- + task.c | 25 +++++-------------------- + 1 file changed, 5 insertions(+), 20 deletions(-) + +diff --git a/task.c b/task.c +index 263a8344dd94..a79ed0d96fb5 100644 +--- a/task.c ++++ b/task.c +@@ -4662,8 +4662,6 @@ show_task_times(struct task_context *tcp, ulong flags) + static int + start_time_timespec(void) + { +- char buf[BUFSIZE]; +- + switch(tt->flags & (TIMESPEC | NO_TIMESPEC | START_TIME_NSECS)) + { + case TIMESPEC: +@@ -4677,24 +4675,11 @@ start_time_timespec(void) + + tt->flags |= NO_TIMESPEC; + +- open_tmpfile(); +- sprintf(buf, "ptype struct task_struct"); +- if (!gdb_pass_through(buf, NULL, GNU_RETURN_ON_ERROR)) { +- close_tmpfile(); +- return FALSE; +- } +- +- rewind(pc->tmpfile); +- while (fgets(buf, BUFSIZE, pc->tmpfile)) { +- if (strstr(buf, "start_time;")) { +- if (strstr(buf, "struct timespec")) { +- tt->flags &= ~NO_TIMESPEC; +- tt->flags |= TIMESPEC; +- } +- } +- } +- +- close_tmpfile(); ++ if (VALID_MEMBER(task_struct_start_time) && ++ STREQ(MEMBER_TYPE_NAME("task_struct", "start_time"), "timespec")) { ++ tt->flags &= ~NO_TIMESPEC; ++ tt->flags |= TIMESPEC; ++ } + + if ((tt->flags & NO_TIMESPEC) && (SIZE(task_struct_start_time) == 8)) { + tt->flags &= ~NO_TIMESPEC; +-- +2.20.1 + diff --git a/SOURCES/0007-GDB-fix-completion-related-libstdc-assert.patch b/SOURCES/0007-GDB-fix-completion-related-libstdc-assert.patch new file mode 100644 index 0000000..fb78bc9 --- /dev/null +++ b/SOURCES/0007-GDB-fix-completion-related-libstdc-assert.patch @@ -0,0 +1,73 @@ +From ce92e458506aec5bc5516a771e26b0f907ce0db4 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Wed, 26 Jan 2022 20:32:35 +0800 +Subject: [PATCH 07/10] GDB: fix completion related libstdc++ assert + +Currently crash built with some specific flags (-D_GLIBCXX_ASSERTIONS +and etc.) may abort and print the following error when running the gdb +list command or tab-completion of symbols. For example: + + crash> l panic + /usr/include/c++/11/string_view:234: ... + Aborted (core dumped) + + crash> p "TAB completion" + crash> p /usr/include/c++/11/string_view:234: ... + Aborted (core dumped) + +When the name string is null (the length of name is zero), there are +multiple places where array access is out of bounds in the gdb/ada-lang.c +(see ada_fold_name() and ada_lookup_name_info()). + +The patch backports these gdb patches: +6a780b676637 ("Fix completion related libstdc++ assert when using -D_GLIBCXX_DEBUG") +2ccee230f830 ("Fix off-by-one error in ada_fold_name") + +Signed-off-by: Lianbo Jiang +Signed-off-by: Kazuhito Hagio +--- + gdb-10.2.patch | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/gdb-10.2.patch b/gdb-10.2.patch +index 1332b6638028..f5e4c06e6f97 100644 +--- a/gdb-10.2.patch ++++ b/gdb-10.2.patch +@@ -1591,3 +1591,34 @@ + max += 2; + limit = cols / max; + if (limit != 1 && (limit * max == cols)) ++--- gdb-10.2/gdb/ada-lang.c.orig +++++ gdb-10.2/gdb/ada-lang.c ++@@ -997,7 +997,7 @@ ada_fold_name (gdb::string_view name) ++ int len = name.size (); ++ GROW_VECT (fold_buffer, fold_buffer_size, len + 1); ++ ++- if (name[0] == '\'') +++ if (!name.empty () && name[0] == '\'') ++ { ++ strncpy (fold_buffer, name.data () + 1, len - 2); ++ fold_buffer[len - 2] = '\000'; ++@@ -1006,8 +1006,9 @@ ada_fold_name (gdb::string_view name) ++ { ++ int i; ++ ++- for (i = 0; i <= len; i += 1) +++ for (i = 0; i < len; i += 1) ++ fold_buffer[i] = tolower (name[i]); +++ fold_buffer[i] = '\0'; ++ } ++ ++ return fold_buffer; ++@@ -13596,7 +13597,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name) ++ { ++ gdb::string_view user_name = lookup_name.name (); ++ ++- if (user_name[0] == '<') +++ if (!user_name.empty () && user_name[0] == '<') ++ { ++ if (user_name.back () == '>') ++ m_encoded_name +-- +2.20.1 + diff --git a/SOURCES/0008-Improve-the-ps-performance-for-vmcores-with-large-nu.patch b/SOURCES/0008-Improve-the-ps-performance-for-vmcores-with-large-nu.patch new file mode 100644 index 0000000..6d2fa91 --- /dev/null +++ b/SOURCES/0008-Improve-the-ps-performance-for-vmcores-with-large-nu.patch @@ -0,0 +1,149 @@ +From e389667cf62ef5db82f9796cdbc0134ec38612dc Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Fri, 21 Jan 2022 13:43:09 +0800 +Subject: [PATCH 08/10] Improve the ps performance for vmcores with large + number of threads + +Previously, the ps command will iterate over all threads which +have the same tgid, to accumulate their rss value, in order to +get a thread/process's final rss value as part of the final output. + +For non-live systems, the rss accumulation values are identical for +threads which have the same tgid, so there is no need to do the +iteration and accumulation repeatly, thus a lot of readmem calls are +skipped. Otherwise it will be the performance bottleneck if the +vmcores have a large number of threads. + +In this patch, the rss accumulation value will be stored in a cache, +next time a thread with the same tgid will take it directly without +the iteration. + +For example, we can monitor the performance issue when a vmcore has +~65k processes, most of which are threads for several specific +processes. Without the patch, it will take ~7h for ps command +to finish. With the patch, ps command will finish in 1min. + +Signed-off-by: Tao Liu +--- + defs.h | 1 + + memory.c | 70 +++++++++++++++++++++++++++++++------------------------- + task.c | 1 + + 3 files changed, 41 insertions(+), 31 deletions(-) + +diff --git a/defs.h b/defs.h +index b63741c7d78b..55600d56ef1c 100644 +--- a/defs.h ++++ b/defs.h +@@ -829,6 +829,7 @@ struct task_context { /* context stored for each task */ + struct tgid_context { /* tgid and task stored for each task */ + ulong tgid; + ulong task; ++ long rss_cache; + }; + + struct task_table { /* kernel/local task table data */ +diff --git a/memory.c b/memory.c +index 5af45fd7d834..e80c59ea4534 100644 +--- a/memory.c ++++ b/memory.c +@@ -4665,7 +4665,7 @@ void + get_task_mem_usage(ulong task, struct task_mem_usage *tm) + { + struct task_context *tc; +- long rss = 0; ++ long rss = 0, rss_cache = 0; + + BZERO(tm, sizeof(struct task_mem_usage)); + +@@ -4730,38 +4730,46 @@ get_task_mem_usage(ulong task, struct task_mem_usage *tm) + (last->tgid == (last + 1)->tgid)) + last++; + +- while (first <= last) +- { +- /* count 0 -> filepages */ +- if (!readmem(first->task + +- OFFSET(task_struct_rss_stat) + +- OFFSET(task_rss_stat_count), KVADDR, +- &sync_rss, +- sizeof(int), +- "task_struct rss_stat MM_FILEPAGES", +- RETURN_ON_ERROR)) +- continue; +- +- rss += sync_rss; +- +- /* count 1 -> anonpages */ +- if (!readmem(first->task + +- OFFSET(task_struct_rss_stat) + +- OFFSET(task_rss_stat_count) + +- sizeof(int), +- KVADDR, &sync_rss, +- sizeof(int), +- "task_struct rss_stat MM_ANONPAGES", +- RETURN_ON_ERROR)) +- continue; +- +- rss += sync_rss; +- +- if (first == last) +- break; +- first++; ++ /* ++ * Using rss cache for dumpfile is more beneficial than live debug ++ * because its value never changes in dumpfile. ++ */ ++ if (ACTIVE() || last->rss_cache == UNINITIALIZED) { ++ while (first <= last) ++ { ++ /* count 0 -> filepages */ ++ if (!readmem(first->task + ++ OFFSET(task_struct_rss_stat) + ++ OFFSET(task_rss_stat_count), KVADDR, ++ &sync_rss, ++ sizeof(int), ++ "task_struct rss_stat MM_FILEPAGES", ++ RETURN_ON_ERROR)) ++ continue; ++ ++ rss_cache += sync_rss; ++ ++ /* count 1 -> anonpages */ ++ if (!readmem(first->task + ++ OFFSET(task_struct_rss_stat) + ++ OFFSET(task_rss_stat_count) + ++ sizeof(int), ++ KVADDR, &sync_rss, ++ sizeof(int), ++ "task_struct rss_stat MM_ANONPAGES", ++ RETURN_ON_ERROR)) ++ continue; ++ ++ rss_cache += sync_rss; ++ ++ if (first == last) ++ break; ++ first++; ++ } ++ last->rss_cache = rss_cache; + } + ++ rss += last->rss_cache; + tt->last_tgid = last; + } + } +diff --git a/task.c b/task.c +index a79ed0d96fb5..864c838637ee 100644 +--- a/task.c ++++ b/task.c +@@ -2947,6 +2947,7 @@ add_context(ulong task, char *tp) + tg = tt->tgid_array + tt->running_tasks; + tg->tgid = *tgid_addr; + tg->task = task; ++ tg->rss_cache = UNINITIALIZED; + + if (do_verify && !verify_task(tc, do_verify)) { + error(INFO, "invalid task address: %lx\n", tc->task); +-- +2.20.1 + diff --git a/SOURCES/0009-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch b/SOURCES/0009-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch new file mode 100644 index 0000000..20f6a86 --- /dev/null +++ b/SOURCES/0009-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 09/10] 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 23c3d75d85aa..4f2c2b5104a1 100644 +--- a/arm64.c ++++ b/arm64.c +@@ -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 +diff --git a/diskdump.c b/diskdump.c +index 3e1cfd548c96..d5674276e1fd 100644 +--- a/diskdump.c ++++ b/diskdump.c +@@ -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)) +-- +2.20.1 + diff --git a/SOURCES/0010-Fix-for-kmem-s-S-and-bt-F-F-on-Linux-5.17-rc1.patch b/SOURCES/0010-Fix-for-kmem-s-S-and-bt-F-F-on-Linux-5.17-rc1.patch new file mode 100644 index 0000000..df06083 --- /dev/null +++ b/SOURCES/0010-Fix-for-kmem-s-S-and-bt-F-F-on-Linux-5.17-rc1.patch @@ -0,0 +1,88 @@ +From 5f390ed811b00753ce7d5ceec5717280df16fd28 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 2 Feb 2022 02:14:56 +0000 +Subject: [PATCH 10/10] Fix for "kmem -s|-S" and "bt -F[F]" on Linux 5.17-rc1 + +Since the following kernel commits split slab info from struct page +into struct slab, crash cannot get several slab related offsets from +struct page. + + d122019bf061 ("mm: Split slab into its own type") + 07f910f9b729 ("mm: Remove slab from struct page") + +Without the patch, "kmem -s|-S" and "bt -F[F]" options cannot work +correctly with the following errors: + + crash> kmem -s kmem_cache + CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME + kmem: page_to_nid: invalid page: ffff9454afc35020 + kmem: kmem_cache: cannot gather relevant slab data + ffff945140042000 216 ? ? ? 8k kmem_cache + + crash> bt -F + ... + bt: invalid structure member offset: page_slab + FILE: memory.c LINE: 9477 FUNCTION: vaddr_to_kmem_cache() + +Signed-by: Kazuhito Hagio +--- + memory.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/memory.c b/memory.c +index e80c59ea4534..8448ddc3a16c 100644 +--- a/memory.c ++++ b/memory.c +@@ -421,6 +421,8 @@ vm_init(void) + MEMBER_OFFSET_INIT(page_prev, "page", "prev"); + if (INVALID_MEMBER(page_next)) + ANON_MEMBER_OFFSET_INIT(page_next, "page", "next"); ++ if (INVALID_MEMBER(page_next)) ++ MEMBER_OFFSET_INIT(page_next, "slab", "next"); + + MEMBER_OFFSET_INIT(page_list, "page", "list"); + if (VALID_MEMBER(page_list)) { +@@ -747,11 +749,15 @@ vm_init(void) + MEMBER_OFFSET_INIT(kmem_cache_random, "kmem_cache", "random"); + MEMBER_OFFSET_INIT(kmem_cache_cpu_freelist, "kmem_cache_cpu", "freelist"); + MEMBER_OFFSET_INIT(kmem_cache_cpu_page, "kmem_cache_cpu", "page"); ++ if (INVALID_MEMBER(kmem_cache_cpu_page)) ++ MEMBER_OFFSET_INIT(kmem_cache_cpu_page, "kmem_cache_cpu", "slab"); + MEMBER_OFFSET_INIT(kmem_cache_cpu_node, "kmem_cache_cpu", "node"); + MEMBER_OFFSET_INIT(kmem_cache_cpu_partial, "kmem_cache_cpu", "partial"); + MEMBER_OFFSET_INIT(page_inuse, "page", "inuse"); + if (INVALID_MEMBER(page_inuse)) + ANON_MEMBER_OFFSET_INIT(page_inuse, "page", "inuse"); ++ if (INVALID_MEMBER(page_inuse)) ++ MEMBER_OFFSET_INIT(page_inuse, "slab", "inuse"); + MEMBER_OFFSET_INIT(page_offset, "page", "offset"); + if (INVALID_MEMBER(page_offset)) + ANON_MEMBER_OFFSET_INIT(page_offset, "page", "offset"); +@@ -763,6 +769,9 @@ vm_init(void) + if (INVALID_MEMBER(page_slab)) + ANON_MEMBER_OFFSET_INIT(page_slab, "page", "slab_cache"); + } ++ if (INVALID_MEMBER(page_slab)) ++ MEMBER_OFFSET_INIT(page_slab, "slab", "slab_cache"); ++ + MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page"); + if (INVALID_MEMBER(page_slab_page)) + ANON_MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page"); +@@ -772,10 +781,14 @@ vm_init(void) + MEMBER_OFFSET_INIT(page_freelist, "page", "freelist"); + if (INVALID_MEMBER(page_freelist)) + ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist"); ++ if (INVALID_MEMBER(page_freelist)) ++ MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist"); + if (INVALID_MEMBER(kmem_cache_objects)) { + MEMBER_OFFSET_INIT(kmem_cache_oo, "kmem_cache", "oo"); + /* NOTE: returns offset of containing bitfield */ + ANON_MEMBER_OFFSET_INIT(page_objects, "page", "objects"); ++ if (INVALID_MEMBER(page_objects)) ++ ANON_MEMBER_OFFSET_INIT(page_objects, "slab", "objects"); + } + if (VALID_MEMBER(kmem_cache_node)) { + ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.node", NULL, 0); +-- +2.20.1 + diff --git a/SOURCES/crash-8.0.0_build.patch b/SOURCES/crash-8.0.0_build.patch new file mode 100644 index 0000000..d857d7f --- /dev/null +++ b/SOURCES/crash-8.0.0_build.patch @@ -0,0 +1,33 @@ +--- crash-8.0.0/Makefile.orig ++++ crash-8.0.0/Makefile +@@ -203,7 +203,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 \ +@@ -233,7 +233,7 @@ all: make_configure + gdb_merge: force + @if [ ! -f ${GDB}/README ]; then \ + make --no-print-directory 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-8.0.0/configure.c.orig ++++ crash-8.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/SOURCES/lzo_snappy_zstd.patch b/SOURCES/lzo_snappy_zstd.patch new file mode 100644 index 0000000..87b51fe --- /dev/null +++ b/SOURCES/lzo_snappy_zstd.patch @@ -0,0 +1,23 @@ +--- crash-8.0.0/Makefile.orig ++++ crash-8.0.0/Makefile +@@ -233,7 +233,7 @@ all: make_configure + gdb_merge: force + @if [ ! -f ${GDB}/README ]; then \ + make --no-print-directory gdb_unzip; fi +- @echo "${LDFLAGS} -lz -ldl -rdynamic" > ${GDB}/gdb/mergelibs ++ @echo "${LDFLAGS} -lz -llzo2 -lsnappy -lzstd -ldl -rdynamic" > ${GDB}/gdb/mergelibs + @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj + @rm -f ${PROGRAM} + @if [ ! -f ${GDB}/config.status ]; then \ +--- crash-8.0.0/diskdump.c.orig ++++ crash-8.0.0/diskdump.c +@@ -23,6 +23,9 @@ + * GNU General Public License for more details. + */ + ++#define LZO ++#define SNAPPY ++#define ZSTD + #include "defs.h" + #include "diskdump.h" + #include "xen_dom0.h" diff --git a/SPECS/crash.spec b/SPECS/crash.spec new file mode 100644 index 0000000..d6de6a9 --- /dev/null +++ b/SPECS/crash.spec @@ -0,0 +1,570 @@ +# +# crash core analysis suite +# +Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles +Name: crash +Version: 8.0.0 +Release: 6%{?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 +URL: https://crash-utility.github.io +ExclusiveOS: Linux +ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x %{arm} aarch64 ppc64le +BuildRequires: ncurses-devel zlib-devel lzo-devel snappy-devel bison texinfo libzstd-devel +BuildRequires: gcc gcc-c++ +BuildRequires: make +Requires: binutils +Provides: bundled(libiberty) +Provides: bundled(gdb) = 10.2 +Patch0: lzo_snappy_zstd.patch +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 +Patch7: 0001-Fix-for-timer-r-option-to-display-all-the-per-CPU-cl.patch +Patch8: 0002-Fix-for-bt-v-option-to-display-the-stack-end-address.patch +Patch9: 0003-Fix-for-HZ-calculation-on-Linux-5.14-and-later.patch +Patch10: 0004-memory-Handle-struct-slab-changes-on-Linux-5.17-rc1-.patch +Patch11: 0005-Move-the-initialization-of-boot_date-to-task_init.patch +Patch12: 0006-Remove-ptype-command-from-ps-t-option-to-reduce-memo.patch +Patch13: 0007-GDB-fix-completion-related-libstdc-assert.patch +Patch14: 0008-Improve-the-ps-performance-for-vmcores-with-large-nu.patch +Patch15: 0009-arm64-Fix-segfault-by-bt-command-with-offline-cpus.patch +Patch16: 0010-Fix-for-kmem-s-S-and-bt-F-F-on-Linux-5.17-rc1.patch +Patch17: 0001-arm64-Use-CONFIG_ARM64_VA_BITS-to-initialize-VA_BITS.patch +Patch18: 0001-arm64-deduce-the-start-address-of-kernel-code-based-.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 +netdump, diskdump and kdump packages from Red Hat Linux, the mcore kernel patch +offered by Mission Critical Linux, or the LKCD kernel patch. + +%package devel +Requires: %{name} = %{version}, zlib-devel +Summary: kernel crash analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles + +%description devel +The core analysis suite is a self-contained tool that can be used to +investigate either live systems, kernel core dumps created from the +netdump, diskdump and kdump packages from Red Hat Linux, the mcore kernel patch +offered by Mission Critical Linux, or the LKCD kernel patch. + +%prep +%setup -n %{name}-%{version} -q +%patch0 -p1 -b lzo_snappy_zstd.patch +%patch1 -p1 -b crash-8.0.0_build.patch +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 +%patch17 -p1 +%patch18 -p1 + +%build + +cp %{SOURCE1} . +make RPMPKG="%{version}-%{release}" CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}%{_bindir} +%make_install +mkdir -p %{buildroot}%{_mandir}/man8 +cp -p crash.8 %{buildroot}%{_mandir}/man8/crash.8 +mkdir -p %{buildroot}%{_includedir}/crash +chmod 0644 defs.h +cp -p defs.h %{buildroot}%{_includedir}/crash + +%files +%{_bindir}/crash +%{_mandir}/man8/crash.8* +%doc README COPYING3 + +%files devel +%{_includedir}/* + +%changelog +* Fri Mar 04 2022 Lianbo Jiang - 8.0.0-6 +- Fix for "bt: read of IRQ stack failed" issue on aarch64 + +* Mon Feb 07 2022 Lianbo Jiang - 8.0.0-5 +- Fix segfault on aarch64 for "bt -a|-c" command +- Fix segfault for the "l" command of gdb +- Fix HZ calculation on Linux 5.14 and later +- Fix for other issues + +* 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 + +* Mon Dec 06 2021 Lianbo Jiang - 8.0.0-2 +- Enable ZSTD feature support + +* Thu Nov 25 2021 Lianbo Jiang - 8.0.0-1 +- Rebase to upstream 8.0.0 + +* Mon Aug 09 2021 Mohan Boddu - 7.3.0-6 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Thu Jul 22 2021 Lianbo Jiang - 7.3.0-5 +- Fix for handling task_struct state member changes(kernels >= 5.14-rc1) + +* Wed Jul 07 2021 Lianbo Jiang - 7.3.0-4 +- Fix memory layout for aarch64 + +* Mon Jul 05 2021 Lianbo Jiang - 7.3.0-3 +- Fix "kmem -n|-p" options display wrong values. + +* Fri Jun 11 2021 Lianbo Jiang - 7.3.0-2 +- Fix for "kmem -s|-S" option on Linux 5.7 and later kernels + +* Mon May 10 2021 Lianbo Jiang - 7.3.0-1 +- Rebase to upstream 7.3.0 + +* Thu Apr 15 2021 Mohan Boddu - 7.2.9-7 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Tue Apr 13 2021 Lianbo Jiang - 7.2.9-6 +- Update to the latest upstream: commit <8dfc228b29ae> + +* Mon Mar 08 2021 Lianbo Jiang - 7.2.9-5 +- Fix Segmentation fault +- Update to the latest upstream: commit <9c0c6c1b3750> + +* Fri Feb 05 2021 Lianbo Jiang - 7.2.9-4 +- Update to the latest upstream: commit + +* Tue Jan 26 2021 Fedora Release Engineering - 7.2.9-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Fri Dec 11 2020 Lianbo Jiang - 7.2.9-2 +- Add support for lockless ringbuffer + +* Wed Nov 25 2020 Lianbo Jiang - 7.2.9-1 +- Update to latest upstream release + +* Mon Jul 27 2020 Fedora Release Engineering - 7.2.8-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jul 13 2020 Tom Stellard - 7.2.8-4 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + +* Tue Jun 30 2020 Jeff Law - 7.2.8-3 +- Disable LTO + +* Fri Jan 31 2020 Dave Anderson - 7.2.8-2 +- Update to latest upstream release +- Fix aarch64 build for gcc-10 -fno-common + +* Tue Jan 28 2020 Fedora Release Engineering - 7.2.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Mon Sep 23 2019 Dave Anderson - 7.2.7-1 +- Update to latest upstream release + +* Wed Jul 24 2019 Fedora Release Engineering - 7.2.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Mon May 6 2019 Dave Anderson - 7.2.6-1 +- Update to latest upstream release + +* Sun Feb 17 2019 Igor Gnatenko - 7.2.5-3 +- Rebuild for readline 8.0 + +* Thu Jan 31 2019 Fedora Release Engineering - 7.2.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jan 11 2019 Dave Anderson - 7.2.5-1 +- Update to latest upstream release + +* Mon Sep 24 2018 Dave Anderson - 7.2.4-1 +- Update to latest upstream release + +* Thu Jul 12 2018 Fedora Release Engineering - 7.2.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri May 18 2018 Dave Anderson - 7.2.3-1 +- Update to latest upstream release + +* Fri Feb 23 2018 Dave Anderson - 7.2.1-2 +- Use RPM build flags for LDFLAGS + +* Fri Feb 16 2018 Dave Anderson - 7.2.1-1 +- Update to latest upstream release + +* Wed Feb 07 2018 Fedora Release Engineering - 7.2.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Oct 2 2017 Dave Anderson - 7.2.0-1 +- Update to latest upstream release + +* Wed Aug 02 2017 Fedora Release Engineering - 7.1.9-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 7.1.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon Apr 24 2017 Dave Anderson - 7.1.9-1 +- Update to latest upstream release + +* Thu Feb 23 2017 Dave Anderson - 7.1.8-1 +- Update to latest upstream release + +* Fri Feb 10 2017 Fedora Release Engineering - 7.1.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Jan 12 2017 Igor Gnatenko - 7.1.7-2 +- Rebuild for readline 7.x + +* Tue Dec 6 2016 Dave Anderson - 7.1.7-1 +- Update to latest upstream release + +* Fri Oct 14 2016 Dave Anderson - 7.1.6-1 +- Update to latest upstream release +- Fix for RHBZ#1044119 - crash bundles gdb + +* Thu May 5 2016 Dave Anderson - 7.1.5-2 +- BZ #1333295 - FTBFS due compiler warnings in elf64-s390.c + +* Thu Apr 28 2016 Dave Anderson - 7.1.5-1 +- Update to latest upstream release + +* Wed Feb 03 2016 Fedora Release Engineering - 7.1.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Thu Dec 17 2015 Dave Anderson - 7.1.4-1 +- Update to latest upstream release + +* Thu Sep 3 2015 Dave Anderson - 7.1.3-1 +- Update to latest upstream release + +* Mon Jul 13 2015 Dave Anderson - 7.1.2-1 +- Update to latest upstream release + +* Wed Jun 17 2015 Fedora Release Engineering - 7.1.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Thu May 28 2015 Dave Anderson - 7.1.1-1 +- Update to latest upstream release + +* Mon Mar 2 2015 Dave Anderson - 7.1.0-3 +- Support increment of Linux version from 3 to 4 + +* Sat Feb 21 2015 Till Maas - 7.1.0-2 +- Rebuilt for Fedora 23 Change + https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code + +* Tue Feb 10 2015 Dave Anderson - 7.1.0-1 +- Update to latest upstream release + +* Fri Nov 15 2014 Dave Anderson - 7.0.9-1 +- Update to latest upstream release + +* Mon Sep 15 2014 Dave Anderson - 7.0.8-1 +- Update to latest upstream release +- Add ppc64le as supported architecture for crash package (BZ #1136050) + +* Sat Aug 16 2014 Fedora Release Engineering - 7.0.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Wed Jul 02 2014 Dave Anderson - 7.0.7-2 +- Fix FTBS for aarch64 (BZ #1114588) + +* Wed Jun 11 2014 Dave Anderson - 7.0.7-1 +- Update to latest upstream release +- Fix Fedora_21_Mass_Rebuild FTBFS (BZ #1106090) + +* Sat Jun 07 2014 Fedora Release Engineering - 7.0.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Fri Feb 28 2014 Dave Anderson - 7.0.5-1 +- Update to latest upstream release +- Use system readline library +- Fix "crash --log vmcore" command for 3.11 and later kernels. + +* Tue Dec 17 2013 Toshio Kuratomi - 7.0.4-2 +- crash bundles gdb which bundles libiberty. Add virtual Provides for + libiberty tracking. Open a bug for unbundling gdb RHBZ#1044119 + +* Mon Dec 16 2013 Dave Anderson - 7.0.4-1 +- Update to latest upstream release + +* Tue Oct 29 2013 Dave Anderson - 7.0.3-1 +- Update to latest upstream release + +* Wed Sep 04 2013 Dave Anderson - 7.0.2-1 +- Update to latest upstream release +- Build with lzo and snappy compression capability + +* Sat Aug 03 2013 Fedora Release Engineering - 7.0.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Mon Jun 17 2013 Dave Anderson - 7.0.1-1 +- Update to latest upstream release +- Add aarch64 as an exclusive arch + +* Tue Apr 9 2013 Dave Anderson - 6.1.6-1 +- Update to latest upstream release + +* Tue Feb 19 2013 Dave Anderson - 6.1.4-1 +- Update to latest upstream release + +* Wed Feb 13 2013 Fedora Release Engineering - 6.1.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Jan 9 2013 Dave Anderson - 6.1.2-1 +- Update to latest upstream release + +* Tue Nov 27 2012 Dave Anderson - 6.1.1-1 +- Update to latest upstream release + +* Mon Sep 1 2012 Dave Anderson - 6.1.0-1 +- Add ppc to ExclusiveArch list +- Update to latest upstream release + +* Tue Aug 21 2012 Dave Anderson - 6.0.9-1 +- Update to latest upstream release + +* Wed Jul 18 2012 Fedora Release Engineering - 6.0.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Jul 1 2012 Dave Anderson - 6.0.8-1 +- Update to latest upstream release. +- Replace usage of "struct siginfo" with "siginfo_t". + +* Mon Apr 30 2012 Dave Anderson - 6.0.6-1 +- Update to latest upstream release + +* Mon Mar 26 2012 Dave Anderson - 6.0.5-1 +- Update to latest upstream release + +* Wed Jan 4 2012 Dave Anderson - 6.0.2-1 +- Update to latest upstream release + +* Wed Oct 26 2011 Dave Anderson - 6.0.0-1 +- Update to latest upstream release + +* Tue Sep 20 2011 Dave Anderson - 5.1.8-1 +- Update to latest upstream release +- Additional fixes for gcc-4.6 -Werror compile failures for ARM architecture. + +* Thu Sep 1 2011 Dave Anderson - 5.1.7-2 +- Fixes for gcc-4.6 -Werror compile failures for ARM architecture. + +* Wed Aug 17 2011 Dave Anderson - 5.1.7-1 +- Update to latest upstream release +- Fixes for gcc-4.6 -Werror compile failures for ppc64/ppc. + +* Tue May 31 2011 Peter Robinson - 5.1.5-1 +- Update to latest upstream release +- Add ARM to the Exclusive arch + +* Wed Feb 25 2011 Dave Anderson - 5.1.2-2 +- Fixes for gcc-4.6 -Werror compile failures in gdb module. + +* Wed Feb 23 2011 Dave Anderson - 5.1.2-1 +- Upstream version. + +* Tue Feb 08 2011 Fedora Release Engineering - 5.0.6-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Jul 20 2010 Dave Anderson - 5.0.6-2 +- Bump version. + +* Tue Jul 20 2010 Dave Anderson - 5.0.6-1 +- Update to upstream version. + +* Fri Sep 11 2009 Dave Anderson - 4.0.9-2 + Bump version. + +* Fri Sep 11 2009 Dave Anderson - 4.0.9-1 +- Update to upstream release, which allows the removal of the + Revision tag workaround, the crash-4.0-8.11-dwarf3.patch and + the crash-4.0-8.11-optflags.patch + +* Sun Aug 05 2009 Lubomir Rintel - 4.0.8.11-2 +- Fix reading of dwarf 3 DW_AT_data_member_location +- Use proper compiler flags + +* Wed Aug 05 2009 Lubomir Rintel - 4.0.8.11-1 +- Update to later upstream release +- Fix abuse of Revision tag + +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild +* Fri Jul 24 2009 Fedora Release Engineering - 4.0-9.7.2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Tue Feb 24 2009 Fedora Release Engineering - 4.0-8.7.2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Feb 19 2009 Dave Anderson - 4.0-7.7.2 +- Replace exclusive arch i386 with ix86. + +* Thu Feb 19 2009 Dave Anderson - 4.0-7.7.1 +- Updates to this file per crash merge review +- Update to upstream version 4.0-7.7. Full changelog viewable in: + http://people.redhat.com/anderson/crash.changelog.html + +* Tue Jul 15 2008 Tom "spot" Callaway 4.0-7 +- fix license tag + +* Tue Apr 29 2008 Dave Anderson - 4.0-6.3 +- Added crash-devel subpackage +- Updated crash.patch to match upstream version 4.0-6.3 + +* Wed Feb 20 2008 Dave Anderson - 4.0-6.0.5 +- Second attempt at addressing the GCC 4.3 build, which failed due + to additional ptrace.h includes in the lkcd vmdump header files. + +* Wed Feb 20 2008 Dave Anderson - 4.0-6.0.4 +- First attempt at addressing the GCC 4.3 build, which failed on x86_64 + because ptrace-abi.h (included by ptrace.h) uses the "u32" typedef, + which relies on , and include/asm-x86_64/types.h + does not not typedef u32 as done in include/asm-x86/types.h. + +* Mon Feb 18 2008 Fedora Release Engineering - 4.0-6.0.3 +- Autorebuild for GCC 4.3 + +* Wed Jan 23 2008 Dave Anderson - 4.0-5.0.3 +- Updated crash.patch to match upstream version 4.0-5.0. + +* Wed Aug 29 2007 Dave Anderson - 4.0-4.6.2 +- Updated crash.patch to match upstream version 4.0-4.6. + +* Wed Sep 13 2006 Dave Anderson - 4.0-3.3 +- Updated crash.patch to match upstream version 4.0-3.3. +- Support for x86_64 relocatable kernels. BZ #204557 + +* Mon Aug 7 2006 Dave Anderson - 4.0-3.1 +- Updated crash.patch to match upstream version 4.0-3.1. +- Added kdump reference to description. +- Added s390 and s390x to ExclusiveArch list. BZ #199125 +- Removed LKCD v1 pt_regs references for s390/s390x build. +- Removed LKCD v2_v3 pt_regs references for for s390/s390x build. + +* Fri Jul 14 2006 Jesse Keating - 4.0-3 +- rebuild + +* Mon May 15 2006 Dave Anderson - 4.0-2.26.4 +- Updated crash.patch such that is not #include'd + by s390_dump.c; IBM did not make the file s390[s] only; BZ #192719 + +* Mon May 15 2006 Dave Anderson - 4.0-2.26.3 +- Updated crash.patch such that is not #include'd + by vas_crash.h; only ia64 build complained; BZ #191719 + +* Mon May 15 2006 Dave Anderson - 4.0-2.26.2 +- Updated crash.patch such that is not #include'd + by lkcd_x86_trace.c; also for BZ #191719 + +* Mon May 15 2006 Dave Anderson - 4.0-2.26.1 +- Updated crash.patch to bring it up to 4.0-2.26, which should + address BZ #191719 - "crash fails to build in mock" + +* Tue Feb 07 2006 Jesse Keating - 4.0-2.18.1 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Wed Jan 04 2006 Dave Anderson 4.0-2.18 +- Updated source package to crash-4.0.tar.gz, and crash.patch + to bring it up to 4.0-2.18. + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Thu Mar 03 2005 Dave Anderson 3.10-13 +- Compiler error- and warning-related fixes for gcc 4 build. +- Update to enhance x86 and x86_64 gdb disassembly output so as to + symbolically display call targets from kernel module text without + requiring module debuginfo data. +- Fix hole where an ia64 vmcore could be mistakenly accepted as a + usable dumpfile on an x86_64 machine, leading eventually to a + non-related error message. +* Wed Mar 02 2005 Dave Anderson 3.10-12 +- rebuild (gcc 4) +* Thu Feb 10 2005 Dave Anderson 3.10-9 +- Updated source package to crash-3.10.tar.gz, containing + IBM's final ppc64 processor support for RHEL4 +- Fixes potential "bt -a" hang on dumpfile where netdump IPI interrupted + an x86 process while executing the instructions just after it had entered + the kernel for a syscall, but before calling the handler. BZ #139437 +- Update to handle backtraces in dumpfiles generated on IA64 with the + INIT switch (functionality intro'd in RHEL3-U5 kernel). BZ #139429 +- Fix for handling ia64 and x86_64 machines booted with maxcpus=1 on + an SMP kernel. BZ #139435 +- Update to handle backtraces in dumpfiles generated on x86_64 from the + NMI exception stack (functionality intro'd in RHEL3-U5 kernel). +- "kmem -[sS]" beefed up to more accurately verify slab cache chains + and report errors found. +- Fix for ia64 INIT switch-generated backtrace handling when + init_handler_platform() is inlined into ia64_init_handler(); + properly handles both RHEL3 and RHEL4 kernel patches. + BZ #138350 +- Update to enhance ia64 gdb disassembly output so as to + symbolically display call targets from kernel module + text without requiring module debuginfo data. + +* Wed Jul 14 2004 Dave Anderson 3.8-5 +- bump release for fc3 + +* Tue Jul 13 2004 Dave Anderson 3.8-4 +- Fix for gcc 3.4.x/gdb issue where vmlinux was mistakenly presumed non-debug + +* Fri Jun 25 2004 Dave Anderson 3.8-3 +- remove (harmless) error message during ia64 diskdump invocation when + an SMP system gets booted with maxcpus=1 +- several 2.6 kernel specific updates + +* Thu Jun 17 2004 Dave Anderson 3.8-2 +- updated source package to crash-3.8.tar.gz +- diskdump support +- x86_64 processor support + +* Mon Sep 22 2003 Dave Anderson 3.7-5 +- make bt recovery code start fix-up only upon reaching first faulting frame + +* Fri Sep 19 2003 Dave Anderson 3.7-4 +- fix "bt -e" and bt recovery code to recognize new __KERNEL_CS and DS + +* Wed Sep 10 2003 Dave Anderson 3.7-3 +- patch to recognize per-cpu GDT changes that redefine __KERNEL_CS and DS + +* Wed Sep 10 2003 Dave Anderson 3.7-2 +- patches for netdump active_set determination and slab info gathering + +* Wed Aug 20 2003 Dave Anderson 3.7-1 +- updated source package to crash-3.7.tar.gz + +* Wed Jul 23 2003 Dave Anderson 3.6-1 +- removed Packager, Distribution, and Vendor tags +- updated source package to crash-3.6.tar.gz + +* Fri Jul 18 2003 Jay Fenlason 3.5-2 +- remove ppc from arch list, since it doesn't work with ppc64 kernels +- remove alpha from the arch list since we don't build it any more + +* Fri Jul 18 2003 Matt Wilson 3.5-1 +- use %%defattr(-,root,root) + +* Tue Jul 15 2003 Jay Fenlason +- Updated spec file as first step in turning this into a real RPM for taroon. +- Wrote man page.