Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144453401
D48186.id148361.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D48186.id148361.diff
View Options
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -107,7 +107,7 @@
void dblfault_handler(struct trapframe *frame);
static int trap_pfault(struct trapframe *, bool, int *, int *);
-static void trap_fatal(struct trapframe *, vm_offset_t);
+static void trap_fatal(struct trapframe *, vm_offset_t, bool, const char *);
#ifdef KDTRACE_HOOKS
static bool trap_user_dtrace(struct trapframe *,
int (**hook)(struct trapframe *));
@@ -242,7 +242,7 @@
}
if (type == T_RESERVED) {
- trap_fatal(frame, 0);
+ trap_fatal(frame, 0, true, NULL);
return;
}
@@ -415,6 +415,19 @@
KASSERT(cold || td->td_ucred != NULL,
("kernel trap doesn't have ucred"));
+
+ /*
+ * Most likely, EFI RT faulted. This check prevents
+ * kdb from handling breakpoints set on the BIOS text,
+ * if such option is ever needed.
+ */
+ if ((td->td_pflags & TDP_EFIRT) != 0 &&
+ curpcb->pcb_onfault != NULL && type != T_PAGEFLT) {
+ frame->tf_rip = (long)curpcb->pcb_onfault;
+ trap_fatal(frame, 0, false, "EFI RT");
+ return;
+ }
+
switch (type) {
case T_PAGEFLT: /* page fault */
(void)trap_pfault(frame, false, NULL, NULL);
@@ -433,7 +446,7 @@
* For now, supporting kernel handler
* registration for FPU traps is overkill.
*/
- trap_fatal(frame, 0);
+ trap_fatal(frame, 0, true, NULL);
return;
case T_STKFLT: /* stack fault */
@@ -578,18 +591,6 @@
* FALLTHROUGH (TRCTRAP kernel mode, kernel address)
*/
case T_BPTFLT:
- /*
- * Most likely, EFI RT hitting INT3. This
- * check prevents kdb from handling
- * breakpoints set on the BIOS text, if such
- * option is ever needed.
- */
- if ((td->td_pflags & TDP_EFIRT) != 0 &&
- curpcb->pcb_onfault != NULL) {
- frame->tf_rip = (long)curpcb->pcb_onfault;
- return;
- }
-
/*
* If KDB is enabled, let it handle the debugger trap.
* Otherwise, debugger traps "can't happen".
@@ -601,7 +602,7 @@
break;
}
- trap_fatal(frame, 0);
+ trap_fatal(frame, 0, true, NULL);
return;
}
@@ -746,7 +747,7 @@
if (td->td_critnest != 0 ||
WITNESS_CHECK(WARN_SLEEPOK | WARN_GIANTOK, NULL,
"Kernel page fault") != 0) {
- trap_fatal(frame, eva);
+ trap_fatal(frame, eva, true, NULL);
return (-1);
}
}
@@ -777,7 +778,7 @@
*/
if (!usermode && (td->td_intr_nesting_level != 0 ||
trap_is_smap(frame) || curpcb->pcb_onfault == NULL)) {
- trap_fatal(frame, eva);
+ trap_fatal(frame, eva, true, NULL);
return (-1);
}
}
@@ -786,7 +787,7 @@
* If the trap was caused by errant bits in the PTE then panic.
*/
if (frame->tf_err & PGEX_RSV) {
- trap_fatal(frame, eva);
+ trap_fatal(frame, eva, true, NULL);
return (-1);
}
@@ -797,7 +798,7 @@
*/
if ((frame->tf_err & PGEX_PK) != 0) {
if (eva > VM_MAXUSER_ADDRESS) {
- trap_fatal(frame, eva);
+ trap_fatal(frame, eva, true, NULL);
return (-1);
}
if (usermode) {
@@ -849,20 +850,24 @@
after_vmfault:
if (td->td_intr_nesting_level == 0 &&
curpcb->pcb_onfault != NULL) {
+ if ((td->td_pflags & TDP_EFIRT) != 0)
+ trap_fatal(frame, eva, false, "EFI RT");
frame->tf_rip = (long)curpcb->pcb_onfault;
return (0);
}
- trap_fatal(frame, eva);
+ trap_fatal(frame, eva, true, NULL);
return (-1);
}
static void
-trap_fatal(struct trapframe *frame, vm_offset_t eva)
+trap_fatal(struct trapframe *frame, vm_offset_t eva, bool fatal,
+ const char *msg_prefix)
{
int code, ss;
u_int type;
struct soft_segment_descriptor softseg;
struct user_segment_descriptor *gdt;
+ const char *msg;
#ifdef KDB
bool handled;
#endif
@@ -925,6 +930,14 @@
printf("r13: %016lx r14: %016lx r15: %016lx\n", frame->tf_r13,
frame->tf_r14, frame->tf_r15);
+ printf("trap number = %d\n", type);
+ msg = type < nitems(trap_msg) ? trap_msg[type] :
+ "unknown/reserved trap";
+ if (!fatal) {
+ printf("%s: %s\n", msg_prefix, msg);
+ return;
+ }
+
#ifdef KDB
if (debugger_on_trap) {
kdb_why = KDB_WHY_TRAP;
@@ -934,9 +947,7 @@
return;
}
#endif
- printf("trap number = %d\n", type);
- panic("%s", type < nitems(trap_msg) ? trap_msg[type] :
- "unknown/reserved trap");
+ panic("%s", msg);
}
#ifdef KDTRACE_HOOKS
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 12:43 PM (15 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28580653
Default Alt Text
D48186.id148361.diff (4 KB)
Attached To
Mode
D48186: amd64 EFI RT: provide fault data on call fault
Attached
Detach File
Event Timeline
Log In to Comment