From owner-svn-src-all@freebsd.org Tue Apr 24 15:04:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 249B1FA8626; Tue, 24 Apr 2018 15:04:08 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C8E9B7BCD5; Tue, 24 Apr 2018 15:04:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3DDF14B88; Tue, 24 Apr 2018 15:04:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3OF47Jc067784; Tue, 24 Apr 2018 15:04:07 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3OF47FR067782; Tue, 24 Apr 2018 15:04:07 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804241504.w3OF47FR067782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 24 Apr 2018 15:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332939 - in stable/11/sys/cddl: contrib/opensolaris/uts/common/dtrace dev/dtrace X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys/cddl: contrib/opensolaris/uts/common/dtrace dev/dtrace X-SVN-Commit-Revision: 332939 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 15:04:08 -0000 Author: markj Date: Tue Apr 24 15:04:07 2018 New Revision: 332939 URL: https://svnweb.freebsd.org/changeset/base/332939 Log: MFC r332364: Assert that dtrace_probe() doesn't re-enter itself. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Apr 24 14:55:22 2018 (r332938) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Apr 24 15:04:07 2018 (r332939) @@ -7116,6 +7116,44 @@ dtrace_store_by_ref(dtrace_difo_t *dp, caddr_t tomax, } /* + * Disables interrupts and sets the per-thread inprobe flag. When DEBUG is + * defined, we also assert that we are not recursing unless the probe ID is an + * error probe. + */ +static dtrace_icookie_t +dtrace_probe_enter(dtrace_id_t id) +{ + dtrace_icookie_t cookie; + + cookie = dtrace_interrupt_disable(); + + /* + * Unless this is an ERROR probe, we are not allowed to recurse in + * dtrace_probe(). Recursing into DTrace probe usually means that a + * function is instrumented that should not have been instrumented or + * that the ordering guarantee of the records will be violated, + * resulting in unexpected output. If there is an exception to this + * assertion, a new case should be added. + */ + ASSERT(curthread->t_dtrace_inprobe == 0 || + id == dtrace_probeid_error); + curthread->t_dtrace_inprobe = 1; + + return (cookie); +} + +/* + * Disables interrupts and clears the per-thread inprobe flag. + */ +static void +dtrace_probe_exit(dtrace_icookie_t cookie) +{ + + curthread->t_dtrace_inprobe = 0; + dtrace_interrupt_enable(cookie); +} + +/* * If you're looking for the epicenter of DTrace, you just found it. This * is the function called by the provider to fire a probe -- from which all * subsequent probe-context DTrace activity emanates. @@ -7149,7 +7187,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t return; #endif - cookie = dtrace_interrupt_disable(); + cookie = dtrace_probe_enter(id); probe = dtrace_probes[id - 1]; cpuid = curcpu; onintr = CPU_ON_INTR(CPU); @@ -7160,7 +7198,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t * We have hit in the predicate cache; we know that * this predicate would evaluate to be false. */ - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); return; } @@ -7172,7 +7210,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t /* * We don't trace anything if we're panicking. */ - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); return; } @@ -7858,7 +7896,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t if (vtime) curthread->t_dtrace_start = dtrace_gethrtime(); - dtrace_interrupt_enable(cookie); + dtrace_probe_exit(cookie); } /* Modified: stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h ============================================================================== --- stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Tue Apr 24 14:55:22 2018 (r332938) +++ stable/11/sys/cddl/dev/dtrace/dtrace_cddl.h Tue Apr 24 15:04:07 2018 (r332939) @@ -46,6 +46,7 @@ typedef struct kdtrace_proc { typedef struct kdtrace_thread { u_int8_t td_dtrace_stop; /* Indicates a DTrace-desired stop */ u_int8_t td_dtrace_sig; /* Signal sent via DTrace's raise() */ + u_int8_t td_dtrace_inprobe; /* Are we in a probe? */ u_int td_predcache; /* DTrace predicate cache */ u_int64_t td_dtrace_vtime; /* DTrace virtual time */ u_int64_t td_dtrace_start; /* DTrace slice start time */ @@ -97,6 +98,7 @@ typedef struct kdtrace_thread { #define t_dtrace_start td_dtrace->td_dtrace_start #define t_dtrace_stop td_dtrace->td_dtrace_stop #define t_dtrace_sig td_dtrace->td_dtrace_sig +#define t_dtrace_inprobe td_dtrace->td_dtrace_inprobe #define t_predcache td_dtrace->td_predcache #define t_dtrace_ft td_dtrace->td_dtrace_ft #define t_dtrace_on td_dtrace->td_dtrace_on