Date: Thu, 24 Jan 2008 06:13:31 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 133972 for review Message-ID: <200801240613.m0O6DVTR081819@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801240613.m0O6DVTR081819>