git: 8094b35e5769 - stable/14 - amd64: extract code to print fault details from trap_fatal() into a new helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 01 Jan 2025 10:38:12 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8094b35e5769e6f8848ce4fd929f898cacc81bc6 commit 8094b35e5769e6f8848ce4fd929f898cacc81bc6 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-12-24 16:39:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-01-01 10:30:19 +0000 amd64: extract code to print fault details from trap_fatal() into a new helper (cherry picked from commit 5e3ab1894e1ef0520925038f8d4e4a451e841345) --- sys/amd64/amd64/trap.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index d7e365f6874e..396c2abd3f1f 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -109,6 +109,7 @@ void trap_check(struct trapframe *frame); void dblfault_handler(struct trapframe *frame); static int trap_pfault(struct trapframe *, bool, int *, int *); +static void trap_diag(struct trapframe *, vm_offset_t); static void trap_fatal(struct trapframe *, vm_offset_t); #ifdef KDTRACE_HOOKS static bool trap_user_dtrace(struct trapframe *, @@ -152,6 +153,13 @@ static const char *const trap_msg[] = { [T_DTRACE_RET] = "DTrace pid return trap", }; +static const char * +traptype_to_msg(u_int type) +{ + return (type < nitems(trap_msg) ? trap_msg[type] : + "unknown/reserved trap"); +} + static int uprintf_signal; SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, &uprintf_signal, 0, @@ -883,15 +891,12 @@ after_vmfault: } static void -trap_fatal(struct trapframe *frame, vm_offset_t eva) +trap_diag(struct trapframe *frame, vm_offset_t eva) { int code, ss; u_int type; struct soft_segment_descriptor softseg; struct user_segment_descriptor *gdt; -#ifdef KDB - bool handled; -#endif code = frame->tf_err; type = frame->tf_trapno; @@ -951,8 +956,20 @@ trap_fatal(struct trapframe *frame, vm_offset_t eva) printf("r13: %016lx r14: %016lx r15: %016lx\n", frame->tf_r13, frame->tf_r14, frame->tf_r15); + printf("trap number = %d\n", type); +} + +static void +trap_fatal(struct trapframe *frame, vm_offset_t eva) +{ + u_int type; + + type = frame->tf_trapno; + trap_diag(frame, eva); #ifdef KDB if (debugger_on_trap) { + bool handled; + kdb_why = KDB_WHY_TRAP; handled = kdb_trap(type, 0, frame); kdb_why = KDB_WHY_UNSET; @@ -960,9 +977,7 @@ trap_fatal(struct trapframe *frame, vm_offset_t eva) return; } #endif - printf("trap number = %d\n", type); - panic("%s", type < nitems(trap_msg) ? trap_msg[type] : - "unknown/reserved trap"); + panic("%s", traptype_to_msg(type)); } #ifdef KDTRACE_HOOKS