From owner-p4-projects@FreeBSD.ORG Thu Jan 24 06:13:31 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BB91716A420; Thu, 24 Jan 2008 06:13:31 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 812EF16A417 for ; Thu, 24 Jan 2008 06:13:31 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8122D13C455 for ; Thu, 24 Jan 2008 06:13:31 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0O6DV57081822 for ; Thu, 24 Jan 2008 06:13:31 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0O6DVTR081819 for perforce@freebsd.org; Thu, 24 Jan 2008 06:13:31 GMT (envelope-from imp@freebsd.org) Date: Thu, 24 Jan 2008 06:13:31 GMT Message-Id: <200801240613.m0O6DVTR081819@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 133972 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 06:13:32 -0000 http://perforce.freebsd.org/chv.cgi?CH=133972 Change 133972 by imp@imp_paco-paco on 2008/01/24 06:12:39 Restore the 'oh no' checks just before userret(), per email from John Baldwin. Don't understand his comments about ast() completely yet, so put the rest of his email in as a comment. I think need to track down where trap is called from and put some code in there... Affected files ... .. //depot/projects/mips2-jnpr/src/sys/mips/mips/trap.c#7 edit Differences ... ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/trap.c#7 (text+ko) ==== @@ -291,9 +291,7 @@ static int emulate_unaligned_access(struct trapframe *frame); -#ifdef WITNESS extern char *syscallnames[]; -#endif /* * Handle an exception. @@ -799,6 +797,22 @@ * of being done here under a special check for SYS_ptrace(). */ done: + /* + * 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)); + userret(td, trapframe); #ifdef KTRACE @@ -813,12 +827,48 @@ STOPEVENT(p, S_SCX, code); PTRACESTOP_SC(p, td, S_PT_SCX); + #ifdef GONE_IN_7 - 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); + /* + * XXX ast still need to happen + * + * Mail from jhb@: + * + * ast() is also still relevant in 7 as well. What + * normally happens is that you have the following in + * assembly: + * + * trap_entry: + * setup regs + * call trap + * jmp exittrap + * + * syscall_entry: + * setup regs + * call syscall + * jmp exittrap + * + * exittrap: + * get ready to return from trap + * disable interrupts + * if returning to kernel jmp kernel + * asts: + * if no ASTs are pending jmp kernel + * enable interrupts + * call ast + * disable interrupts + * jmp asts + * kernel: + * restore registers + * reti + * + * or some such. You could do it in C if you wanted, + * but the idea is you want to only return to userland + * once you've verified you have no ASTs with + * interrupts disabled. If you get any AST's while + * returning to userland it's due to SMP and you will + * get an IPI that will post with 'reti' finishes. + */ if (curthread->td_flags & (TDF_ASTPENDING|TDF_NEEDRESCHED)) { ast(trapframe); }