From owner-p4-projects@FreeBSD.ORG Tue Jun 13 00:59:15 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 20B9716A474; Tue, 13 Jun 2006 00:59:15 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AFA2816A41B for ; Tue, 13 Jun 2006 00:59:14 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D34843D46 for ; Tue, 13 Jun 2006 00:59:14 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5D0uvSE053149 for ; Tue, 13 Jun 2006 00:56:57 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5D0uvWD053146 for perforce@freebsd.org; Tue, 13 Jun 2006 00:56:57 GMT (envelope-from jb@freebsd.org) Date: Tue, 13 Jun 2006 00:56:57 GMT Message-Id: <200606130056.k5D0uvWD053146@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 99102 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: Tue, 13 Jun 2006 00:59:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=99102 Change 99102 by jb@jb_freebsd2 on 2006/06/13 00:55:58 Save the invop address in a global variable for ease of access from kdb when system go kaboom gracefully. Ungraceful kabooms cause a reboot. Grumble. Also check a flag to see if a probe is already in progress and save the address just in case we have a chance to look at it before the system go kaboom. This shouldn't happen, but until the port is complete on FreeBSD and the functions called from the probe context meet Sun's design, it can happen. At the moment I think that it is witness in something that makes a bunch of functions uninstrumentable (is that a word?) by fbt reliably. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/i386/dtrace_subr.c#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/i386/dtrace_subr.c#2 (text+ko) ==== @@ -36,7 +36,9 @@ #include #include -extern uintptr_t kernelbase; +extern uintptr_t kernelbase; +extern uintptr_t dtrace_in_probe_addr; +extern int dtrace_in_probe; int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t); @@ -47,7 +49,8 @@ struct dtrace_invop_hdlr *dtih_next; } dtrace_invop_hdlr_t; -dtrace_invop_hdlr_t *dtrace_invop_hdlr; +dtrace_invop_hdlr_t *dtrace_invop_hdlr; +uintptr_t dtrace_invop_addr; int dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax) @@ -55,6 +58,31 @@ dtrace_invop_hdlr_t *hdlr; int rval; + /* + * Save the address in a global variable which can be + * read via the kernel debugger in the event that a + * double fault occurs. + * + * From kdb: p *dtrace_invop_addr + * + * Then look up the value in an objdump of the kernel. + */ + dtrace_invop_addr = addr; + + /* + * An invalid opcode fault should not occur while executing + * a probe because only dtrace_ functions are supposed to + * be called by design. Check here if dtrace_probe() is + * in-progress. If so, that's very bad. Very, very bad. We + * can't call any non-dtrace functions to report this, so + * just save the invalid opcode address and hope that the + * dtrace_ioctl will report it. If the DTrace port is + * working according to Sun's design, this should never + * occur. + */ + if (dtrace_in_probe) + dtrace_in_probe_addr = addr; + for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) { if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0) return (rval);