Skip to content

Commit 6c04376

Browse files
committed
x86_64: Add Linux 5.8+ exception functions to check exception frame
Fix for 'bt' command and options on Linux 5.8-rc1 and later kernels that contain merge commit 076f14be7fc942e112c94c841baec44124275cd0. The merged patches changed the name of exception functions that have been used by the crash utility to check the exception frame. Without the patch, the command and options cannot display it. Before: crash> bt PID: 8752 TASK: ffff8f80cb244380 CPU: 2 COMMAND: "insmod" #0 [ffffa3e40187f9f8] machine_kexec at ffffffffab25d267 #1 [ffffa3e40187fa48] __crash_kexec at ffffffffab38e2ed #2 [ffffa3e40187fb10] crash_kexec at ffffffffab38f1dd #3 [ffffa3e40187fb28] oops_end at ffffffffab222cbd #4 [ffffa3e40187fb48] do_trap at ffffffffab21fea1 #5 [ffffa3e40187fb90] do_error_trap at ffffffffab21ff75 #6 [ffffa3e40187fbd0] exc_invalid_op at ffffffffabb76a2c #7 [ffffa3e40187fbf0] asm_exc_invalid_op at ffffffffabc00a72 #8 [ffffa3e40187fc78] init_module at ffffffffc042b018 [invalid] #9 [ffffa3e40187fca0] init_module at ffffffffc042b018 [invalid] #10 [ffffa3e40187fca8] do_one_initcall at ffffffffab202806 #11 [ffffa3e40187fd18] do_init_module at ffffffffab3888ba #12 [ffffa3e40187fd38] load_module at ffffffffab38afde After: crash> bt PID: 8752 TASK: ffff8f80cb244380 CPU: 2 COMMAND: "insmod" #0 [ffffa3e40187f9f8] machine_kexec at ffffffffab25d267 #1 [ffffa3e40187fa48] __crash_kexec at ffffffffab38e2ed #2 [ffffa3e40187fb10] crash_kexec at ffffffffab38f1dd #3 [ffffa3e40187fb28] oops_end at ffffffffab222cbd #4 [ffffa3e40187fb48] do_trap at ffffffffab21fea1 #5 [ffffa3e40187fb90] do_error_trap at ffffffffab21ff75 #6 [ffffa3e40187fbd0] exc_invalid_op at ffffffffabb76a2c #7 [ffffa3e40187fbf0] asm_exc_invalid_op at ffffffffabc00a72 [exception RIP: init_module+24] RIP: ffffffffc042b018 RSP: ffffa3e40187fca8 RFLAGS: 00010246 RAX: 000000000000001c RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff8f80fbd18000 RDI: ffff8f80fbd18000 RBP: ffffffffc042b000 R8: 000000000000029d R9: 000000000000002c R10: 0000000000000000 R11: ffffa3e40187fb58 R12: ffffffffc042d018 R13: ffffa3e40187fdf0 R14: ffffffffc042d000 R15: ffffa3e40187fe90 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #8 [ffffa3e40187fca0] init_module at ffffffffc042b018 [invalid] #9 [ffffa3e40187fca8] do_one_initcall at ffffffffab202806 #10 [ffffa3e40187fd18] do_init_module at ffffffffab3888ba #11 [ffffa3e40187fd38] load_module at ffffffffab38afde Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
1 parent 506da42 commit 6c04376

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,6 +6026,7 @@ struct machine_specific {
60266026
ulong cpu_entry_area_start;
60276027
ulong cpu_entry_area_end;
60286028
ulong page_offset_force;
6029+
char **exception_functions;
60296030
};
60306031

60316032
#define KSYMS_START (0x1)

x86_64.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ static void orc_dump(ulong);
139139

140140
struct machine_specific x86_64_machine_specific = { 0 };
141141

142+
static const char *exception_functions_orig[];
143+
static const char *exception_functions_5_8[];
144+
142145
/*
143146
* Do all necessary machine-specific setup here. This is called several
144147
* times during initialization.
@@ -735,6 +738,12 @@ x86_64_init(int when)
735738
STRUCT_SIZE_INIT(percpu_data, "percpu_data");
736739

737740
GART_init();
741+
742+
if (kernel_symbol_exists("asm_exc_divide_error"))
743+
machdep->machspec->exception_functions = (char **)exception_functions_5_8;
744+
else
745+
machdep->machspec->exception_functions = (char **)exception_functions_orig;
746+
738747
break;
739748

740749
case POST_VM:
@@ -1104,6 +1113,12 @@ x86_64_dump_machdep_table(ulong arg)
11041113
fprintf(fp, "%016lx\n", (ulong)ms->cpu_entry_area_end);
11051114
else
11061115
fprintf(fp, "(unused)\n");
1116+
1117+
fprintf(fp, " excpetion_functions: ");
1118+
if (ms->exception_functions == (char **)exception_functions_5_8)
1119+
fprintf(fp, "excpetion_functions_5_8\n");
1120+
else
1121+
fprintf(fp, "excpetion_functions_orig\n");
11071122
}
11081123

11091124
/*
@@ -3086,7 +3101,7 @@ text_lock_function(char *name, struct bt_info *bt, ulong locktext)
30863101
* zeroentry xen_debug do_debug
30873102
* zeroentry xen_int3 do_int3
30883103
*/
3089-
static const char *exception_functions[] = {
3104+
static const char *exception_functions_orig[] = {
30903105
"invalid_TSS",
30913106
"segment_not_present",
30923107
"alignment_check",
@@ -3109,6 +3124,28 @@ static const char *exception_functions[] = {
31093124
NULL,
31103125
};
31113126

3127+
static const char *exception_functions_5_8[] = {
3128+
"asm_exc_invalid_tss",
3129+
"asm_exc_segment_not_present",
3130+
"asm_exc_alignment_check",
3131+
"asm_exc_general_protection",
3132+
"asm_exc_page_fault",
3133+
"asm_exc_divide_error",
3134+
"asm_exc_overflow",
3135+
"asm_exc_bounds",
3136+
"asm_exc_invalid_op",
3137+
"asm_exc_device_not_available",
3138+
"asm_exc_coproc_segment_overrun",
3139+
"asm_exc_spurious_interrupt_bug",
3140+
"asm_exc_coprocessor_error",
3141+
"asm_exc_simd_coprocessor_error",
3142+
"asm_exc_debug",
3143+
"xen_asm_exc_stack_segment",
3144+
"xen_asm_exc_xen_hypervisor_callback",
3145+
"xen_asm_exc_int3",
3146+
NULL,
3147+
};
3148+
31123149
/*
31133150
* print one entry of a stack trace
31143151
*/
@@ -3185,8 +3222,8 @@ x86_64_print_stack_entry(struct bt_info *bt, FILE *ofp, int level,
31853222
if ((THIS_KERNEL_VERSION >= LINUX(2,6,29)) &&
31863223
(eframe_check == -1) && offset &&
31873224
!(bt->flags & (BT_EXCEPTION_FRAME|BT_START|BT_SCHEDULE))) {
3188-
for (i = 0; exception_functions[i]; i++) {
3189-
if (STREQ(name, exception_functions[i])) {
3225+
for (i = 0; machdep->machspec->exception_functions[i]; i++) {
3226+
if (STREQ(name, machdep->machspec->exception_functions[i])) {
31903227
eframe_check = 8;
31913228
break;
31923229
}

0 commit comments

Comments
 (0)