summaryrefslogtreecommitdiffstats
path: root/sys/ia64/ia32/ia32_trap.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-27 22:32:30 +0000
committerjhb <jhb@FreeBSD.org>2006-07-27 22:32:30 +0000
commit12302c47d0774765f92ead9706c43dd6e9b1af80 (patch)
tree47879e45272c43d1dac6fed60572111e89f9a60b /sys/ia64/ia32/ia32_trap.c
parentdc69447236a19f806729d1c133c456528b241db4 (diff)
downloadFreeBSD-src-12302c47d0774765f92ead9706c43dd6e9b1af80.zip
FreeBSD-src-12302c47d0774765f92ead9706c43dd6e9b1af80.tar.gz
Unify the checking for lock misbehavior in the various syscall()
implementations and adjust some of the checks while I'm here: - Add a new check to make sure we don't return from a syscall in a critical section. - Add a new explicit check before userret() to make sure we don't return with any locks held. The advantage here is that we can include the syscall number and name in syscall() whereas that info is not available in userret(). - Drop the mtx_assert()'s of sched_lock and Giant. They are replaced by the more general checks just added. MFC after: 2 weeks
Diffstat (limited to 'sys/ia64/ia32/ia32_trap.c')
-rw-r--r--sys/ia64/ia32/ia32_trap.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/ia64/ia32/ia32_trap.c b/sys/ia64/ia32/ia32_trap.c
index c3cacf5..f63ae94 100644
--- a/sys/ia64/ia32/ia32_trap.c
+++ b/sys/ia64/ia32/ia32_trap.c
@@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <i386/include/psl.h>
-#ifdef WITNESS
extern char *syscallnames[];
-#endif
static void
ia32_syscall(struct trapframe *tf)
@@ -183,6 +181,19 @@ ia32_syscall(struct trapframe *tf)
}
/*
+ * Check for misbehavior.
+ */
+ WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???");
+ KASSERT(td->td_critnest == 0,
+ ("System call %s returning in a critical section",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"));
+ KASSERT(td->td_locks == 0,
+ ("System call %s returning with %d locks held",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???",
+ td->td_locks));
+
+ /*
* End of syscall tracing.
*/
CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
@@ -200,11 +211,6 @@ ia32_syscall(struct trapframe *tf)
STOPEVENT(p, S_SCX, code);
PTRACESTOP_SC(p, td, S_PT_SCX);
-
- WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
- (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???");
- mtx_assert(&sched_lock, MA_NOTOWNED);
- mtx_assert(&Giant, MA_NOTOWNED);
}
/*
OpenPOWER on IntegriCloud