Move the checks for td_pinned, td_critnest, TDP_NOFAULTING and

TDP_NOSLEEPING leaking from syscallret() to userret() so that also
trap handling is covered. Also, the check on td_locks is not duplicated
between the two functions.

Reported by:	avg
Reviewed by:	kib
MFC after:	1 week
This commit is contained in:
Attilio Rao 2012-09-08 18:35:15 +00:00
parent fbe18392a1
commit 16cbf13b53
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240246
2 changed files with 14 additions and 22 deletions

View File

@ -171,27 +171,6 @@ syscallret(struct thread *td, int error, struct syscall_args *sa __unused)
p = td->td_proc;
/*
* Check for misbehavior.
*/
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallname(p, sa->code));
KASSERT(td->td_critnest == 0,
("System call %s returning in a critical section",
syscallname(p, sa->code)));
KASSERT(td->td_locks == 0,
("System call %s returning with %d locks held",
syscallname(p, sa->code), td->td_locks));
KASSERT((td->td_pflags & TDP_NOFAULTING) == 0,
("System call %s returning with pagefaults disabled",
syscallname(p, sa->code)));
KASSERT((td->td_pflags & TDP_NOSLEEPING) == 0,
("System call %s returning with sleep disabled",
syscallname(p, sa->code)));
KASSERT(td->td_pinned == 0,
("System call %s returning with pinned thread",
syscallname(p, sa->code)));
/*
* Handle reschedule and other end-of-syscall issues
*/

View File

@ -139,8 +139,21 @@ userret(struct thread *td, struct trapframe *frame)
#ifdef XEN
PT_UPDATES_FLUSH();
#endif
/*
* Check for misbehavior.
*/
WITNESS_WARN(WARN_PANIC, NULL, "userret: returning");
KASSERT(td->td_critnest == 0,
("userret: Returning in a critical section"));
KASSERT(td->td_locks == 0,
("userret: Returning with %d locks held.", td->td_locks));
("userret: Returning with %d locks held", td->td_locks));
KASSERT((td->td_pflags & TDP_NOFAULTING) == 0,
("userret: Returning with pagefaults disabled"));
KASSERT((td->td_pflags & TDP_NOSLEEPING) == 0,
("userret: Returning with sleep disabled"));
KASSERT(td->td_pinned == 0,
("userret: Returning with with pinned thread"));
#ifdef VIMAGE
/* Unfortunately td_vnet_lpush needs VNET_DEBUG. */
VNET_ASSERT(curvnet == NULL,