aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/ia32/ia32_syscall.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2006-07-27 22:32:30 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2006-07-27 22:32:30 +0000
commit22ea1bc57a98ebb5e159f38635e3a3c2423c716f (patch)
tree47879e45272c43d1dac6fed60572111e89f9a60b /sys/amd64/ia32/ia32_syscall.c
parent7abb84313aa738439074b1bb1ebd3def433b32b5 (diff)
downloadsrc-22ea1bc57a98ebb5e159f38635e3a3c2423c716f.tar.gz
src-22ea1bc57a98ebb5e159f38635e3a3c2423c716f.zip
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
Notes
Notes: svn path=/head/; revision=160773
Diffstat (limited to 'sys/amd64/ia32/ia32_syscall.c')
-rw-r--r--sys/amd64/ia32/ia32_syscall.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c
index 5b3086a9d4f5..644235dc3bf9 100644
--- a/sys/amd64/ia32/ia32_syscall.c
+++ b/sys/amd64/ia32/ia32_syscall.c
@@ -244,6 +244,19 @@ ia32_syscall(struct trapframe frame)
}
/*
+ * Check for misbehavior.
+ */
+ WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???");
+ KASSERT(td->td_critnest == 0,
+ ("System call %s returning in a critical section",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???"));
+ KASSERT(td->td_locks == 0,
+ ("System call %s returning with %d locks held",
+ (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???",
+ td->td_locks));
+
+ /*
* Handle reschedule and other end-of-syscall issues
*/
userret(td, &frame);
@@ -263,11 +276,6 @@ ia32_syscall(struct trapframe frame)
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) ? freebsd32_syscallnames[code] : "???");
- mtx_assert(&sched_lock, MA_NOTOWNED);
- mtx_assert(&Giant, MA_NOTOWNED);
}