Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153047507
D55809.id173557.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55809.id173557.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
@@ -242,6 +242,54 @@
return (false);
}
+/*
+ * Buggy application or kernel code has disabled
+ * interrupts and then trapped. Enabling interrupts
+ * now is wrong, but it is better than running with
+ * interrupts disabled until they are accidentally
+ * enabled later.
+ *
+ * trap_intr_dis_u() and trap_intr_dis_k() handle this.
+ */
+
+static void
+trap_intr_dis_u(struct thread *td, struct trapframe *frame)
+{
+ MPASS(TRAPF_USERMODE(frame));
+ if ((frame->tf_rflags & PSL_I) == 0) {
+ uprintf(
+ "pid %ld (%s): trap %d (%s) with interrupts disabled\n",
+ (long)td->td_proc->p_pid, td->td_name, frame->tf_trapno,
+ trap_msg[frame->tf_trapno]);
+ }
+}
+
+static void
+trap_intr_dis_k(struct thread *td, struct trapframe *frame)
+{
+ MPASS(!TRAPF_USERMODE(frame));
+
+ switch (frame->tf_trapno) {
+ case T_NMI:
+ case T_BPTFLT:
+ case T_TRCTRAP:
+ case T_PROTFLT:
+ case T_SEGNPFLT:
+ case T_STKFLT:
+ break;
+ default:
+ printf("kernel trap %d with interrupts disabled\n",
+ frame->tf_trapno);
+
+ /*
+ * We shouldn't enable interrupts while holding a
+ * spin lock.
+ */
+ if (td->td_md.md_spinlock_count == 0)
+ enable_intr();
+ }
+}
+
/*
* Table of handlers for various segment load faults.
*/
@@ -319,46 +367,9 @@
return;
}
- if ((frame->tf_rflags & PSL_I) == 0) {
- /*
- * Buggy application or kernel code has disabled
- * interrupts and then trapped. Enabling interrupts
- * now is wrong, but it is better than running with
- * interrupts disabled until they are accidentally
- * enabled later.
- */
- if (TRAPF_USERMODE(frame)) {
- uprintf(
- "pid %ld (%s): trap %d (%s) "
- "with interrupts disabled\n",
- (long)curproc->p_pid, curthread->td_name, type,
- trap_msg[type]);
- } else {
- switch (type) {
- case T_NMI:
- case T_BPTFLT:
- case T_TRCTRAP:
- case T_PROTFLT:
- case T_SEGNPFLT:
- case T_STKFLT:
- break;
- default:
- printf(
- "kernel trap %d with interrupts disabled\n",
- type);
-
- /*
- * We shouldn't enable interrupts while holding a
- * spin lock.
- */
- if (td->td_md.md_spinlock_count == 0)
- enable_intr();
- }
- }
- }
-
if (TRAPF_USERMODE(frame)) {
/* user trap */
+ trap_intr_dis_u(td, frame);
td->td_pticks = 0;
td->td_frame = frame;
@@ -485,6 +496,7 @@
}
} else {
/* kernel trap */
+ trap_intr_dis_k(td, frame);
KASSERT(cold || td->td_ucred != NULL,
("kernel trap doesn't have ucred"));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 19, 8:11 PM (8 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29581555
Default Alt Text
D55809.id173557.diff (2 KB)
Attached To
Mode
D55809: amd64: move code to check for traps with interrupts disabled into helpers
Attached
Detach File
Event Timeline
Log In to Comment