Index: sys/kern/subr_trap.c =================================================================== --- sys/kern/subr_trap.c (revision 239991) +++ sys/kern/subr_trap.c (working copy) @@ -136,8 +136,24 @@ userret(struct thread *td, struct trapframe *frame * Let the scheduler adjust our priority etc. */ sched_userret(td); +#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, @@ -145,9 +161,6 @@ userret(struct thread *td, struct trapframe *frame __func__, td, p->p_pid, td->td_name, curvnet, (td->td_vnet_lpush != NULL) ? td->td_vnet_lpush : "N/A")); #endif -#ifdef XEN - PT_UPDATES_FLUSH(); -#endif } /* Index: sys/kern/subr_syscall.c =================================================================== --- sys/kern/subr_syscall.c (revision 239991) +++ sys/kern/subr_syscall.c (working copy) @@ -172,27 +172,6 @@ syscallret(struct thread *td, int error, struct sy 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 */ userret(td, td->td_frame);