From owner-svn-src-head@FreeBSD.ORG Sat Sep 8 18:35:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 21C8F106564A; Sat, 8 Sep 2012 18:35:16 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E8B038FC15; Sat, 8 Sep 2012 18:35:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q88IZFNS036112; Sat, 8 Sep 2012 18:35:15 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q88IZFhV036109; Sat, 8 Sep 2012 18:35:15 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201209081835.q88IZFhV036109@svn.freebsd.org> From: Attilio Rao Date: Sat, 8 Sep 2012 18:35:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240246 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Sep 2012 18:35:16 -0000 Author: attilio Date: Sat Sep 8 18:35:15 2012 New Revision: 240246 URL: http://svn.freebsd.org/changeset/base/240246 Log: 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 Modified: head/sys/kern/subr_syscall.c head/sys/kern/subr_trap.c Modified: head/sys/kern/subr_syscall.c ============================================================================== --- head/sys/kern/subr_syscall.c Sat Sep 8 18:29:53 2012 (r240245) +++ head/sys/kern/subr_syscall.c Sat Sep 8 18:35:15 2012 (r240246) @@ -172,27 +172,6 @@ syscallret(struct thread *td, int error, 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); Modified: head/sys/kern/subr_trap.c ============================================================================== --- head/sys/kern/subr_trap.c Sat Sep 8 18:29:53 2012 (r240245) +++ head/sys/kern/subr_trap.c Sat Sep 8 18:35:15 2012 (r240246) @@ -139,8 +139,21 @@ userret(struct thread *td, struct trapfr #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,