From owner-svn-src-head@freebsd.org Fri Jun 9 20:26:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97AD0BFC7E7; Fri, 9 Jun 2017 20:26:43 +0000 (UTC) (envelope-from jhibbits@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 mx1.freebsd.org (Postfix) with ESMTPS id 5CCBD7B419; Fri, 9 Jun 2017 20:26:43 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v59KQgOA066724; Fri, 9 Jun 2017 20:26:42 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v59KQgmr066723; Fri, 9 Jun 2017 20:26:42 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201706092026.v59KQgmr066723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Fri, 9 Jun 2017 20:26:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319759 - head/sys/cddl/dev/dtrace/powerpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 09 Jun 2017 20:26:43 -0000 Author: jhibbits Date: Fri Jun 9 20:26:42 2017 New Revision: 319759 URL: https://svnweb.freebsd.org/changeset/base/319759 Log: Follow up r313841 on powerpc Close a potential race in reading the CPU dtrace flags, where a thread can start on one CPU, and partway through retrieving the flags be swapped out, while another thread traps and sets the CPU_DTRACE_NOFAULT. This could cause the first thread to return without handling the fault. Discussed with: markj@ Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c ============================================================================== --- head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c Fri Jun 9 19:57:27 2017 (r319758) +++ head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c Fri Jun 9 20:26:42 2017 (r319759) @@ -267,6 +267,7 @@ dtrace_gethrestime(void) int dtrace_trap(struct trapframe *frame, u_int type) { + uint16_t nofault; /* * A trap can occur while DTrace executes a probe. Before @@ -277,7 +278,11 @@ dtrace_trap(struct trapframe *frame, u_int type) * * Check if DTrace has enabled 'no-fault' mode: */ - if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { + sched_pin(); + nofault = cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT; + sched_unpin(); + if (nofault) { + KASSERT((frame->srr1 & PSL_EE) == 0, ("interrupts enabled")); /* * There are only a couple of trap types that are expected. * All the rest will be handled in the usual way.