From owner-svn-src-all@freebsd.org Sun Jun 26 00:53:32 2016 Return-Path: Delivered-To: svn-src-all@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 A1D00A79C02; Sun, 26 Jun 2016 00:53:32 +0000 (UTC) (envelope-from asomers@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 677CD1EE8; Sun, 26 Jun 2016 00:53:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5Q0rVtB006579; Sun, 26 Jun 2016 00:53:31 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5Q0rVnx006577; Sun, 26 Jun 2016 00:53:31 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201606260053.u5Q0rVnx006577@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 26 Jun 2016 00:53:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302206 - in head: usr.bin/lastcomm/tests usr.sbin/sa/tests X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 00:53:32 -0000 Author: asomers Date: Sun Jun 26 00:53:31 2016 New Revision: 302206 URL: https://svnweb.freebsd.org/changeset/base/302206 Log: Skip lastcomm and sa tests on unsupported architectures usr.bin/lastcom/tests/Makefile usr.sbin/sa/tests/Makefile Set allow_architectures appropriately. These tests depend on golden files that must be generated for each architecture, and haven't yet been generated for all of them. PR: 210566 PR: 204154 Reviewed by: ngie Approved by: re (gjb) MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6960 Modified: head/usr.bin/lastcomm/tests/Makefile head/usr.sbin/sa/tests/Makefile Modified: head/usr.bin/lastcomm/tests/Makefile ============================================================================== --- head/usr.bin/lastcomm/tests/Makefile Sat Jun 25 22:44:36 2016 (r302205) +++ head/usr.bin/lastcomm/tests/Makefile Sun Jun 26 00:53:31 2016 (r302206) @@ -3,6 +3,7 @@ PACKAGE= tests TAP_TESTS_SH= legacy_test +TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" ${PACKAGE}FILES+= v1-amd64-acct.in ${PACKAGE}FILES+= v1-amd64.out Modified: head/usr.sbin/sa/tests/Makefile ============================================================================== --- head/usr.sbin/sa/tests/Makefile Sat Jun 25 22:44:36 2016 (r302205) +++ head/usr.sbin/sa/tests/Makefile Sun Jun 26 00:53:31 2016 (r302206) @@ -3,6 +3,7 @@ PACKAGE= tests TAP_TESTS_SH= legacy_test +TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" ${PACKAGE}FILES+= v1-amd64-sav.in ${PACKAGE}FILES+= v1-amd64-sav.out From owner-svn-src-all@freebsd.org Sun Jun 26 04:18:45 2016 Return-Path: Delivered-To: svn-src-all@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 8AF55A79F41; Sun, 26 Jun 2016 04:18:45 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 405E71FAF; Sun, 26 Jun 2016 04:18:44 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id H1WqbR9OyEWlrH1WrbLZUs; Sat, 25 Jun 2016 22:18:43 -0600 X-Authority-Analysis: v=2.2 cv=P7p4vWIu c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10 a=NEAV23lmAAAA:8 a=KqpIfyakAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=lFXPonph261V7IbAemoA:9 a=Bn2pgwyD2vrAyMmN8A2t:22 a=gdFSoX5FBteAPHjtcXXc:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 3ECE113753; Sat, 25 Jun 2016 21:18:40 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id u5Q4Ico4060230; Sat, 25 Jun 2016 21:18:39 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201606260418.u5Q4Ico4060230@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Jilles Tjoelker cc: Konstantin Belousov , Daniel Eischen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302194 - head/lib/libthr/thread In-Reply-To: Message from Jilles Tjoelker of "Sun, 26 Jun 2016 00:33:38 +0200." <20160625223338.GA22802@stack.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 25 Jun 2016 21:18:38 -0700 X-CMAE-Envelope: MS4wfGEg4iAgLr0LR+uL00awXkjT+GtycOUFPfTEpIE6aMAhzhIzp4SNmhQT+NgM36di8QrpT/dXaKYLjbJVpFD0Y/DVqhrzKlpK+2bt78rmW4ieaboqIcXN YZ+dOy3G0CPi5RJRjxH8TEcqPcbGmEh4QFanu+xocVK27vcGl5oTlI3PHyRLj1qD71giVLhB3kpyYL49N+kEk2VmtVU37ZV/3WmzXZOKfI5TE35p8bL1qzHZ SPuBhz60mkzXaVUo6SYGTKSli/I7baiohPZXx6jGX+DRPjD3PXeatUfOviV/QBGVMr6ITjWYA5KX8zHmVvTFo0gLYa8V4SJWMj9Xkxv8cJIMEoSCgoGdXCij 5MbKvBqM X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 04:18:45 -0000 In message <20160625223338.GA22802@stack.nl>, Jilles Tjoelker writes: > On Sat, Jun 25, 2016 at 08:29:56PM +0300, Konstantin Belousov wrote: > > I already asked re for approval of the reversal and got it. But I am still > > hesitating doing the revert vs. returning EDEADLK for error-checking > > mutexes. > > > My initial mistake was reading the statement about PTHREAD_MUTEX_ERRORCHECK > > returning EDEADLK as the requirement for both functions. It was induced > > by reading the following code in samba: > > https://github.com/samba-team/samba/blob/master/lib/tdb/common/mutex.c#L928 > > I did extracted this into stand-alone test and checked that glibc does > > return EDEADLK in this case. BTW, if somebody has Solaris machine availabl > e > > to test this, I would be grateful. Code is available at > > https://www.kib.kiev.ua/kib/pshared/pthread_samba.c > > > I.e., plain revert would disable the only known to me consumer of the > > robust mutexes. The patch which I mailed last time, returns EDEADLK for > > trylock on ERRORCHECKed mutexes only. And I am tending toward glibc > > compatibility there, over the literal POSIX compliance, but I want to > > see the confirmation from the Klimenko' test first. > > To be bug-compatible with glibc, you'd need to return the wrong > [EDEADLK] error for robust errorcheck mutexes only. Robust > non-errorcheck and non-robust errorcheck mutexes return the correct > [EBUSY]. I have not checked PI and PP mutexes which probably use a > different code path. > > I'm not sure whether we should copy glibc's bug, but if we do it must be > documented in the man page. I'm not happy with it because the bug may > break applications written to the standard; at least, Samba developers > should be contacted first. I think there are advantages both in POSIX and glibc compatibility however I think it more important to be POSIX compatible. Having said that, there may be a compromise. Either setting an environment variable and/or setting a global variable (or call a function) to invoke a glibc-bug emulation mode. Thus linux-only applications could be ported with minimally invasive alterations. Either we break POSIX compatibility (and some existing applications) or we can implement the above which may satisfy both camps. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-all@freebsd.org Sun Jun 26 12:41:04 2016 Return-Path: Delivered-To: svn-src-all@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 2AB9DB81ED6; Sun, 26 Jun 2016 12:41:04 +0000 (UTC) (envelope-from tuexen@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 EDB7921F3; Sun, 26 Jun 2016 12:41:03 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QCf34E064968; Sun, 26 Jun 2016 12:41:03 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QCf3N9064967; Sun, 26 Jun 2016 12:41:03 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606261241.u5QCf3N9064967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 26 Jun 2016 12:41:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302207 - head/sys/netinet X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 12:41:04 -0000 Author: tuexen Date: Sun Jun 26 12:41:02 2016 New Revision: 302207 URL: https://svnweb.freebsd.org/changeset/base/302207 Log: This patch fixes a locking bug when a send() call blocks on an SCTP socket and the association is aborted by the peer. Approved by: re (kib) MFC after: 1 week Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Sun Jun 26 00:53:31 2016 (r302206) +++ head/sys/netinet/sctp_output.c Sun Jun 26 12:41:02 2016 (r302207) @@ -13136,6 +13136,7 @@ sctp_lower_sosend(struct socket *so, asoc, stcb->asoc.total_output_queue_size); } if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + SOCKBUF_UNLOCK(&so->so_snd); goto out_unlocked; } inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * sizeof(struct sctp_data_chunk)); From owner-svn-src-all@freebsd.org Sun Jun 26 13:16:03 2016 Return-Path: Delivered-To: svn-src-all@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 3512DB73430; Sun, 26 Jun 2016 13:16:03 +0000 (UTC) (envelope-from kib@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 05E6121C9; Sun, 26 Jun 2016 13:16:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QDG268079717; Sun, 26 Jun 2016 13:16:02 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QDG25x079716; Sun, 26 Jun 2016 13:16:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606261316.u5QDG25x079716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 13:16:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302208 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 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.22 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: Sun, 26 Jun 2016 13:16:03 -0000 Author: kib Date: Sun Jun 26 13:16:02 2016 New Revision: 302208 URL: https://svnweb.freebsd.org/changeset/base/302208 Log: MFC r302019: Do not access NFS data for reclaimed vnode. Modified: stable/10/sys/fs/nfsclient/nfs_clvnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clvnops.c Sun Jun 26 12:41:02 2016 (r302207) +++ stable/10/sys/fs/nfsclient/nfs_clvnops.c Sun Jun 26 13:16:02 2016 (r302208) @@ -3098,10 +3098,14 @@ nfs_advlock(struct vop_advlock_args *ap) } } if (error == 0 && ap->a_op == F_SETLK) { - /* Mark that a file lock has been acquired. */ - mtx_lock(&np->n_mtx); - np->n_flag |= NHASBEENLOCKED; - mtx_unlock(&np->n_mtx); + error = NFSVOPLOCK(vp, LK_SHARED); + if (error == 0) { + /* Mark that a file lock has been acquired. */ + mtx_lock(&np->n_mtx); + np->n_flag |= NHASBEENLOCKED; + mtx_unlock(&np->n_mtx); + NFSVOPUNLOCK(vp, 0); + } } } return (error); From owner-svn-src-all@freebsd.org Sun Jun 26 13:18:04 2016 Return-Path: Delivered-To: svn-src-all@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 E01E0B734D9; Sun, 26 Jun 2016 13:18:04 +0000 (UTC) (envelope-from kib@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 A8460243D; Sun, 26 Jun 2016 13:18:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QDI3aS079833; Sun, 26 Jun 2016 13:18:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QDI3EV079832; Sun, 26 Jun 2016 13:18:03 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606261318.u5QDI3EV079832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 13:18:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302209 - stable/10/sys/nlm X-SVN-Group: stable-10 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.22 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: Sun, 26 Jun 2016 13:18:05 -0000 Author: kib Date: Sun Jun 26 13:18:03 2016 New Revision: 302209 URL: https://svnweb.freebsd.org/changeset/base/302209 Log: MFC r302020: Handle EDEADLK and EINTR from local adv lock manager. Modified: stable/10/sys/nlm/nlm_advlock.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/nlm/nlm_advlock.c ============================================================================== --- stable/10/sys/nlm/nlm_advlock.c Sun Jun 26 13:16:02 2016 (r302208) +++ stable/10/sys/nlm/nlm_advlock.c Sun Jun 26 13:18:03 2016 (r302209) @@ -713,7 +713,37 @@ nlm_record_lock(struct vnode *vp, int op newfl.l_pid = svid; newfl.l_sysid = NLM_SYSID_CLIENT | sysid; - error = lf_advlockasync(&a, &vp->v_lockf, size); + for (;;) { + error = lf_advlockasync(&a, &vp->v_lockf, size); + if (error == EDEADLK) { + /* + * Locks are associated with the processes and + * not with threads. Suppose we have two + * threads A1 A2 in one process, A1 locked + * file f1, A2 is locking file f2, and A1 is + * unlocking f1. Then remote server may + * already unlocked f1, while local still not + * yet scheduled A1 to make the call to local + * advlock manager. The process B owns lock on + * f2 and issued the lock on f1. Remote would + * grant B the request on f1, but local would + * return EDEADLK. + */ + pause("nlmdlk", 1); + /* XXXKIB allow suspend */ + } else if (error == EINTR) { + /* + * lf_purgelocks() might wake up the lock + * waiter and removed our lock graph edges. + * There is no sense in re-trying recording + * the lock to the local manager after + * reclaim. + */ + error = 0; + break; + } else + break; + } KASSERT(error == 0 || error == ENOENT, ("Failed to register NFS lock locally - error=%d", error)); } From owner-svn-src-all@freebsd.org Sun Jun 26 14:18:30 2016 Return-Path: Delivered-To: svn-src-all@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 26384B812FC; Sun, 26 Jun 2016 14:18:30 +0000 (UTC) (envelope-from kib@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 D1A502BAF; Sun, 26 Jun 2016 14:18:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QEIT9B002963; Sun, 26 Jun 2016 14:18:29 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QEITxu002962; Sun, 26 Jun 2016 14:18:29 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606261418.u5QEITxu002962@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 14:18:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302210 - head/sys/fs/nfsclient X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 14:18:30 -0000 Author: kib Date: Sun Jun 26 14:18:28 2016 New Revision: 302210 URL: https://svnweb.freebsd.org/changeset/base/302210 Log: Clean other flags in ncl_inactive, only. Add comment explaining why other flags should be unset. Suggested and reviewed by: rmacklem Sponsored by: The FreeBSD Foundation MFC after: 12 days Approved by: re (gjb) Modified: head/sys/fs/nfsclient/nfs_clnode.c Modified: head/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 26 13:18:03 2016 (r302209) +++ head/sys/fs/nfsclient/nfs_clnode.c Sun Jun 26 14:18:28 2016 (r302210) @@ -206,7 +206,7 @@ ncl_releasesillyrename(struct vnode *vp, ASSERT_VOP_ELOCKED(vp, "releasesillyrename"); np = VTONFS(vp); - mtx_lock(&np->n_mtx); + mtx_assert(&np->n_mtx, MA_OWNED); if (vp->v_type != VDIR) { sp = np->n_sillyrename; np->n_sillyrename = NULL; @@ -224,14 +224,13 @@ ncl_releasesillyrename(struct vnode *vp, taskqueue_enqueue(taskqueue_thread, &sp->s_task); mtx_lock(&np->n_mtx); } - np->n_flag &= NMODIFIED; - mtx_unlock(&np->n_mtx); } int ncl_inactive(struct vop_inactive_args *ap) { struct vnode *vp = ap->a_vp; + struct nfsnode *np; boolean_t retv; if (NFS_ISV4(vp) && vp->v_type == VREG) { @@ -254,7 +253,17 @@ ncl_inactive(struct vop_inactive_args *a } } + np = VTONFS(vp); + mtx_lock(&np->n_mtx); ncl_releasesillyrename(vp, ap->a_td); + + /* + * NMODIFIED means that there might be dirty/stale buffers + * associated with the NFS vnode. None of the other flags are + * meaningful after the vnode is unused. + */ + np->n_flag &= NMODIFIED; + mtx_unlock(&np->n_mtx); return (0); } @@ -275,7 +284,9 @@ ncl_reclaim(struct vop_reclaim_args *ap) if (nfs_reclaim_p != NULL) nfs_reclaim_p(ap); + mtx_lock(&np->n_mtx); ncl_releasesillyrename(vp, ap->a_td); + mtx_unlock(&np->n_mtx); /* * Destroy the vm object and flush associated pages. From owner-svn-src-all@freebsd.org Sun Jun 26 14:44:03 2016 Return-Path: Delivered-To: svn-src-all@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 52A69B81BDE; Sun, 26 Jun 2016 14:44:03 +0000 (UTC) (envelope-from novel@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 13C1C2A33; Sun, 26 Jun 2016 14:44:03 +0000 (UTC) (envelope-from novel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QEi2Rb013831; Sun, 26 Jun 2016 14:44:02 GMT (envelope-from novel@FreeBSD.org) Received: (from novel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QEi11O013827; Sun, 26 Jun 2016 14:44:01 GMT (envelope-from novel@FreeBSD.org) Message-Id: <201606261444.u5QEi11O013827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: novel set sender to novel@FreeBSD.org using -f From: Roman Bogorodskiy Date: Sun, 26 Jun 2016 14:44:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302211 - in head/usr.sbin: bhyve bhyveload X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 14:44:03 -0000 Author: novel (ports committer) Date: Sun Jun 26 14:44:01 2016 New Revision: 302211 URL: https://svnweb.freebsd.org/changeset/base/302211 Log: bhyve: improve memory size documentation A couple of minor memory size option related nits: - use common name 'memsize' (instead of 'max-size' or just 'size') - bhyve: update usage with memsize unit suffix, drop legacy "MB" unit - bhyveload: update usage with memsize unit suffix - bhyve(8): document default size - bhyveload(8): use memsize formatting like it's done in bhyve(8) Reviewed by: wblock, grehan Approved by: re (kib), wblock, grehan Differential Revision: https://reviews.freebsd.org/D6952 Modified: head/usr.sbin/bhyve/bhyve.8 head/usr.sbin/bhyve/bhyverun.c head/usr.sbin/bhyveload/bhyveload.8 head/usr.sbin/bhyveload/bhyveload.c Modified: head/usr.sbin/bhyve/bhyve.8 ============================================================================== --- head/usr.sbin/bhyve/bhyve.8 Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyve/bhyve.8 Sun Jun 26 14:44:01 2016 (r302211) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 18, 2016 +.Dd June 24, 2016 .Dt BHYVE 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Op Fl c Ar numcpus .Op Fl g Ar gdbport .Op Fl l Ar lpcdev Ns Op , Ns Ar conf -.Op Fl m Ar size Ns Op Ar K|k|M|m|G|g|T|t +.Op Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t .Op Fl p Ar vcpu:hostcpu .Op Fl s Ar slot,emulation Ns Op , Ns Ar conf .Op Fl U Ar uuid @@ -105,7 +105,7 @@ and .Ar com2 and the boot ROM device .Ar bootrom . -.It Fl m Ar size Ns Op Ar K|k|M|m|G|g|T|t +.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t Guest physical memory size in bytes. This must be the same size that was given to .Xr bhyveload 8 . @@ -114,6 +114,9 @@ The size argument may be suffixed with o or lower case) to indicate a multiple of kilobytes, megabytes, gigabytes, or terabytes. If no suffix is given, the value is assumed to be in megabytes. +.Pp +.Ar memsize +defaults to 256M. .It Fl p Ar vcpu:hostcpu Pin guest's virtual CPU .Em vcpu Modified: head/usr.sbin/bhyve/bhyverun.c ============================================================================== --- head/usr.sbin/bhyve/bhyverun.c Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyve/bhyverun.c Sun Jun 26 14:44:01 2016 (r302211) @@ -125,7 +125,7 @@ usage(int code) fprintf(stderr, "Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g ] [-l ]\n" - " %*s [-m mem] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" + " %*s [-m memsize[K|k|M|m|G|g|T|t]] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" " -a: local apic is in xAPIC mode (deprecated)\n" " -A: create ACPI tables\n" " -c: # cpus (default 1)\n" @@ -135,7 +135,7 @@ usage(int code) " -h: help\n" " -H: vmexit from the guest on hlt\n" " -l: LPC device configuration\n" - " -m: memory size in MB\n" + " -m: memory size\n" " -p: pin 'vcpu' to 'hostcpu'\n" " -P: vmexit from the guest on pause\n" " -s: PCI slot config\n" Modified: head/usr.sbin/bhyveload/bhyveload.8 ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.8 Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyveload/bhyveload.8 Sun Jun 26 14:44:01 2016 (r302211) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 26, 2016 +.Dd June 24, 2016 .Dt BHYVELOAD 8 .Os .Sh NAME @@ -42,7 +42,7 @@ guest inside a bhyve virtual machine .Op Fl e Ar name=value .Op Fl h Ar host-path .Op Fl l Ar os-loader -.Op Fl m Ar mem-size +.Op Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t .Ar vmname .Sh DESCRIPTION .Nm @@ -103,16 +103,12 @@ will use which presents a standard .Fx loader. -.It Fl m Ar mem-size Xo -.Sm off -.Op Cm K | k | M | m | G | g | T | t -.Xc -.Sm on -.Ar mem-size +.It Fl m Ar memsize Ns Op Ar K|k|M|m|G|g|T|t +.Ar memsize is the amount of memory allocated to the guest. .Pp The -.Ar mem-size +.Ar memsize argument may be suffixed with one of .Cm K , .Cm M , @@ -123,9 +119,8 @@ or Kilobytes, Megabytes, Gigabytes or Terabytes respectively. .Pp -The default value of -.Ar mem-size -is 256M. +.Ar memsize +defaults to 256M. .It Fl C Include guest memory in the core file when .Nm Modified: head/usr.sbin/bhyveload/bhyveload.c ============================================================================== --- head/usr.sbin/bhyveload/bhyveload.c Sun Jun 26 14:18:28 2016 (r302210) +++ head/usr.sbin/bhyveload/bhyveload.c Sun Jun 26 14:44:01 2016 (r302211) @@ -648,7 +648,7 @@ usage(void) fprintf(stderr, "usage: %s [-S][-c ] [-d ] [-e ]\n" - " %*s [-h ] [-m mem-size] \n", + " %*s [-h ] [-m memsize[K|k|M|m|G|g|T|t]] \n", progname, (int)strlen(progname), ""); exit(1); From owner-svn-src-all@freebsd.org Sun Jun 26 15:54:46 2016 Return-Path: Delivered-To: svn-src-all@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 03A8CB81B5F; Sun, 26 Jun 2016 15:54:46 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-oi0-x231.google.com (mail-oi0-x231.google.com [IPv6:2607:f8b0:4003:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BD61E2D2E; Sun, 26 Jun 2016 15:54:45 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-oi0-x231.google.com with SMTP id r2so173003083oih.2; Sun, 26 Jun 2016 08:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NJRI5u5l8RfW7vkOuNqOA7D3bLJ/iORq9gJ/gcb2n5g=; b=JeIolOZWsEjSBrdnli7lXgnw+BLYvVWeJG2zaprGpvElz3SAHZZlr4HvttBdf/uQCW UMyJJtXRUDeD2Jd5+TGo77OGoQkpWtwxosZkJBDizZTDkm1zrKHYf9A2ban7hRFR8UlJ mEDVvx2yfklaGGm3IwhevAvywXBeyQiJuz2M3+dH02K/qmyciubmiIPOSRXvptEp1ARi Zleb/THbndnuvAFn9diU6JIqfyAclmFVq9ukqWYjL7/g8Zkxblfhk9xdOwfYMqwUep5Z cMDgIiQe06QwR8hTUa+Tr4OK978cTv9+/GvGyd+XuYBCypqWGuPldJ2BAhHysLXoxrQy RqAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NJRI5u5l8RfW7vkOuNqOA7D3bLJ/iORq9gJ/gcb2n5g=; b=JmV43JH0uZ9rH15GPampgJV2qgFFcK664WoMFJMjdy45U95kHt23omknjLXhFP1rPm cST00Cvo16n1lY+Dhc+GStzXV6qDYZ4ATE/EgnhJ3RlrOrTAShFGIIpjBSBB/UbTzTMU Mc1z8I0wcF/Fzpzs2Dd3FQdb9MEnCP8jonWVvEqmi3xSjC2Ux3IxZh/qyBiVJuRcPyD5 HEKisz+bSRT2kdO+STWmfzhot2L4cPRLteIiWdxYwhrxL03qLEUcFUzzCuIfYDKLHsDK 5Hp9fg+2pZHtABo3eLcmpv+U6Gor2h/EXci1Dk6VrRpcrhFZ8a4ZSlvnp2erF4bJdDv1 UFzA== X-Gm-Message-State: ALyK8tJdggwJwnPYsnMoNHd0PV9FcKxlR6JUHPUF6D7mPP5vD+Kpk0FT35T03w1EcvbU34wFsIzQtjnuWVtwmw== X-Received: by 10.157.22.179 with SMTP id c48mr9080352ote.35.1466956484941; Sun, 26 Jun 2016 08:54:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.12.37 with HTTP; Sun, 26 Jun 2016 08:54:44 -0700 (PDT) In-Reply-To: <201606261418.u5QEITxu002962@repo.freebsd.org> References: <201606261418.u5QEITxu002962@repo.freebsd.org> From: Benjamin Kaduk Date: Sun, 26 Jun 2016 10:54:44 -0500 Message-ID: Subject: Re: svn commit: r302210 - head/sys/fs/nfsclient To: Konstantin Belousov Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 15:54:46 -0000 On Sun, Jun 26, 2016 at 9:18 AM, Konstantin Belousov wrote: > Author: kib > Date: Sun Jun 26 14:18:28 2016 > New Revision: 302210 > URL: https://svnweb.freebsd.org/changeset/base/302210 > > Log: > Clean other flags in ncl_inactive, only. Add comment explaining why > other > flags should be unset. > [...] > + > + /* > + * NMODIFIED means that there might be dirty/stale buffers > + * associated with the NFS vnode. None of the other flags are > + * meaningful after the vnode is unused. > + */ > + np->n_flag &= NMODIFIED; > Maybe I am confused, but the commit message reads like this should be '=', not '&='. -Ben > + mtx_unlock(&np->n_mtx); > return (0); > } > > From owner-svn-src-all@freebsd.org Sun Jun 26 16:09:12 2016 Return-Path: Delivered-To: svn-src-all@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 18F0EB81E2B; Sun, 26 Jun 2016 16:09:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F48323ED; Sun, 26 Jun 2016 16:09:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5QG96pF036420 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 26 Jun 2016 19:09:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5QG96pF036420 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5QG96Oi036419; Sun, 26 Jun 2016 19:09:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 26 Jun 2016 19:09:06 +0300 From: Konstantin Belousov To: Benjamin Kaduk Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r302210 - head/sys/fs/nfsclient Message-ID: <20160626160906.GC38613@kib.kiev.ua> References: <201606261418.u5QEITxu002962@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 16:09:12 -0000 On Sun, Jun 26, 2016 at 10:54:44AM -0500, Benjamin Kaduk wrote: > On Sun, Jun 26, 2016 at 9:18 AM, Konstantin Belousov > wrote: > > > Author: kib > > Date: Sun Jun 26 14:18:28 2016 > > New Revision: 302210 > > URL: https://svnweb.freebsd.org/changeset/base/302210 > > > > Log: > > Clean other flags in ncl_inactive, only. Add comment explaining why > > other > > flags should be unset. > > > [...] > > > + > > + /* > > + * NMODIFIED means that there might be dirty/stale buffers > > + * associated with the NFS vnode. None of the other flags are > > + * meaningful after the vnode is unused. > > + */ > > + np->n_flag &= NMODIFIED; > > > > Maybe I am confused, but the commit message reads like this should be '=', > not '&='. The line clears all flags except NMODIFIED, and lefts the NMODIFIED flag intact (it could have been not set there, after all). From owner-svn-src-all@freebsd.org Sun Jun 26 16:28:16 2016 Return-Path: Delivered-To: svn-src-all@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 662ADB82F25; Sun, 26 Jun 2016 16:28:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC3CD2B8F; Sun, 26 Jun 2016 16:28:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5QGSBBk041132 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 26 Jun 2016 19:28:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5QGSBBk041132 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5QGSBt1041131; Sun, 26 Jun 2016 19:28:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 26 Jun 2016 19:28:11 +0300 From: Konstantin Belousov To: Jilles Tjoelker Cc: Daniel Eischen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302194 - head/lib/libthr/thread Message-ID: <20160626162811.GD38613@kib.kiev.ua> References: <201606251130.u5PBUeGC001988@repo.freebsd.org> <20160625171440.GA19698@stack.nl> <20160625172956.GE38613@kib.kiev.ua> <20160625223338.GA22802@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160625223338.GA22802@stack.nl> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 16:28:16 -0000 On Sun, Jun 26, 2016 at 12:33:38AM +0200, Jilles Tjoelker wrote: > To be bug-compatible with glibc, you'd need to return the wrong > [EDEADLK] error for robust errorcheck mutexes only. Robust > non-errorcheck and non-robust errorcheck mutexes return the correct > [EBUSY]. I have not checked PI and PP mutexes which probably use a > different code path. Yes, you are right, I read the glibc code wrong way. > I'm not sure whether we should copy glibc's bug, but if we do it must be > documented in the man page. I'm not happy with it because the bug may > break applications written to the standard; at least, Samba developers > should be contacted first. I tried to send the mail to samba tech list yesterday, but it did not pass. Seems that today I managed it. Still, it is pity that the only real-world consumer of the robust interface cannot exercise our implementation due to this minor issue. From owner-svn-src-all@freebsd.org Sun Jun 26 16:38:44 2016 Return-Path: Delivered-To: svn-src-all@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 38AFEB81101; Sun, 26 Jun 2016 16:38:44 +0000 (UTC) (envelope-from tuexen@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 EED812001; Sun, 26 Jun 2016 16:38:43 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QGchts056128; Sun, 26 Jun 2016 16:38:43 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QGchex056127; Sun, 26 Jun 2016 16:38:43 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606261638.u5QGchex056127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 26 Jun 2016 16:38:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302212 - head/sys/netinet X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 16:38:44 -0000 Author: tuexen Date: Sun Jun 26 16:38:42 2016 New Revision: 302212 URL: https://svnweb.freebsd.org/changeset/base/302212 Log: This patch fixes two bugs related to the SCTP message recovery for messages which have been put on the send queue: * Do not report any DATA or I-DATA chunk padding. * Correctly deal with the I-DATA chunk header instead of the DATA chunk header when the I-DATA extension is used. Approved by: re (kib) MFC after: 1 week Modified: head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Sun Jun 26 14:44:01 2016 (r302211) +++ head/sys/netinet/sctputil.c Sun Jun 26 16:38:42 2016 (r302212) @@ -2933,7 +2933,8 @@ sctp_notify_send_failed(struct sctp_tcb struct sctp_send_failed *ssf; struct sctp_send_failed_event *ssfe; struct sctp_queued_to_read *control; - int length; + struct sctp_chunkhdr *chkhdr; + int notifhdr_len, chk_len, chkhdr_len, padding_len, payload_len; if ((stcb == NULL) || (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && @@ -2942,27 +2943,49 @@ sctp_notify_send_failed(struct sctp_tcb return; } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { - length = sizeof(struct sctp_send_failed_event); + notifhdr_len = sizeof(struct sctp_send_failed_event); } else { - length = sizeof(struct sctp_send_failed); + notifhdr_len = sizeof(struct sctp_send_failed); } - m_notify = sctp_get_mbuf_for_msg(length, 0, M_NOWAIT, 1, MT_DATA); + m_notify = sctp_get_mbuf_for_msg(notifhdr_len, 0, M_NOWAIT, 1, MT_DATA); if (m_notify == NULL) /* no space left */ return; - SCTP_BUF_LEN(m_notify) = 0; + SCTP_BUF_LEN(m_notify) = notifhdr_len; + if (stcb->asoc.idata_supported) { + chkhdr_len = sizeof(struct sctp_idata_chunk); + } else { + chkhdr_len = sizeof(struct sctp_data_chunk); + } + /* Use some defaults in case we can't access the chunk header */ + if (chk->send_size >= chkhdr_len) { + payload_len = chk->send_size - chkhdr_len; + } else { + payload_len = 0; + } + padding_len = 0; + if (chk->data != NULL) { + chkhdr = mtod(chk->data, struct sctp_chunkhdr *); + if (chkhdr != NULL) { + chk_len = ntohs(chkhdr->chunk_length); + if ((chk_len >= chkhdr_len) && + (chk->send_size >= chk_len) && + (chk->send_size - chk_len < 4)) { + padding_len = chk->send_size - chk_len; + payload_len = chk->send_size - chkhdr_len - padding_len; + } + } + } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { ssfe = mtod(m_notify, struct sctp_send_failed_event *); - memset(ssfe, 0, length); + memset(ssfe, 0, notifhdr_len); ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; if (sent) { ssfe->ssfe_flags = SCTP_DATA_SENT; } else { ssfe->ssfe_flags = SCTP_DATA_UNSENT; } - length += chk->send_size; - length -= sizeof(struct sctp_data_chunk); - ssfe->ssfe_length = length; + ssfe->ssfe_length = (uint32_t) (notifhdr_len + payload_len); ssfe->ssfe_error = error; /* not exactly what the user sent in, but should be close :) */ ssfe->ssfe_info.snd_sid = chk->rec.data.stream_number; @@ -2971,39 +2994,33 @@ sctp_notify_send_failed(struct sctp_tcb ssfe->ssfe_info.snd_context = chk->rec.data.context; ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); ssfe->ssfe_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event); } else { ssf = mtod(m_notify, struct sctp_send_failed *); - memset(ssf, 0, length); + memset(ssf, 0, notifhdr_len); ssf->ssf_type = SCTP_SEND_FAILED; if (sent) { ssf->ssf_flags = SCTP_DATA_SENT; } else { ssf->ssf_flags = SCTP_DATA_UNSENT; } - length += chk->send_size; - length -= sizeof(struct sctp_data_chunk); - ssf->ssf_length = length; + ssf->ssf_length = (uint32_t) (notifhdr_len + payload_len); ssf->ssf_error = error; /* not exactly what the user sent in, but should be close :) */ - bzero(&ssf->ssf_info, sizeof(ssf->ssf_info)); ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number; - ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq; + ssf->ssf_info.sinfo_ssn = (uint16_t) chk->rec.data.stream_seq; ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags; ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype; ssf->ssf_info.sinfo_context = chk->rec.data.context; ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); ssf->ssf_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed); } - if (chk->data) { - /* - * trim off the sctp chunk header(it should be there) - */ - if (chk->send_size >= sizeof(struct sctp_data_chunk)) { - m_adj(chk->data, sizeof(struct sctp_data_chunk)); + if (chk->data != NULL) { + /* Trim off the sctp chunk header (it should be there) */ + if (chk->send_size == chkhdr_len + payload_len + padding_len) { + m_adj(chk->data, chkhdr_len); + m_adj(chk->data, -padding_len); sctp_mbuf_crush(chk->data); - chk->send_size -= sizeof(struct sctp_data_chunk); + chk->send_size -= (chkhdr_len + padding_len); } } SCTP_BUF_NEXT(m_notify) = chk->data; @@ -3048,7 +3065,7 @@ sctp_notify_send_failed2(struct sctp_tcb struct sctp_send_failed *ssf; struct sctp_send_failed_event *ssfe; struct sctp_queued_to_read *control; - int length; + int notifhdr_len; if ((stcb == NULL) || (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && @@ -3057,23 +3074,22 @@ sctp_notify_send_failed2(struct sctp_tcb return; } if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { - length = sizeof(struct sctp_send_failed_event); + notifhdr_len = sizeof(struct sctp_send_failed_event); } else { - length = sizeof(struct sctp_send_failed); + notifhdr_len = sizeof(struct sctp_send_failed); } - m_notify = sctp_get_mbuf_for_msg(length, 0, M_NOWAIT, 1, MT_DATA); + m_notify = sctp_get_mbuf_for_msg(notifhdr_len, 0, M_NOWAIT, 1, MT_DATA); if (m_notify == NULL) { /* no space left */ return; } - SCTP_BUF_LEN(m_notify) = 0; + SCTP_BUF_LEN(m_notify) = notifhdr_len; if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { ssfe = mtod(m_notify, struct sctp_send_failed_event *); - memset(ssfe, 0, length); + memset(ssfe, 0, notifhdr_len); ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; ssfe->ssfe_flags = SCTP_DATA_UNSENT; - length += sp->length; - ssfe->ssfe_length = length; + ssfe->ssfe_length = (uint32_t) (notifhdr_len + sp->length); ssfe->ssfe_error = error; /* not exactly what the user sent in, but should be close :) */ ssfe->ssfe_info.snd_sid = sp->stream; @@ -3086,14 +3102,12 @@ sctp_notify_send_failed2(struct sctp_tcb ssfe->ssfe_info.snd_context = sp->context; ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); ssfe->ssfe_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event); } else { ssf = mtod(m_notify, struct sctp_send_failed *); - memset(ssf, 0, length); + memset(ssf, 0, notifhdr_len); ssf->ssf_type = SCTP_SEND_FAILED; ssf->ssf_flags = SCTP_DATA_UNSENT; - length += sp->length; - ssf->ssf_length = length; + ssf->ssf_length = (uint32_t) (notifhdr_len + sp->length); ssf->ssf_error = error; /* not exactly what the user sent in, but should be close :) */ ssf->ssf_info.sinfo_stream = sp->stream; @@ -3107,7 +3121,6 @@ sctp_notify_send_failed2(struct sctp_tcb ssf->ssf_info.sinfo_context = sp->context; ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); ssf->ssf_assoc_id = sctp_get_associd(stcb); - SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed); } SCTP_BUF_NEXT(m_notify) = sp->data; From owner-svn-src-all@freebsd.org Sun Jun 26 17:00:00 2016 Return-Path: Delivered-To: svn-src-all@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 E7678B81641; Sun, 26 Jun 2016 17:00:00 +0000 (UTC) (envelope-from dchagin@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 AB24B2903; Sun, 26 Jun 2016 17:00:00 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QGxxxV063618; Sun, 26 Jun 2016 16:59:59 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QGxx6K063617; Sun, 26 Jun 2016 16:59:59 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201606261659.u5QGxx6K063617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 26 Jun 2016 16:59:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302213 - head/sys/compat/linux X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 17:00:01 -0000 Author: dchagin Date: Sun Jun 26 16:59:59 2016 New Revision: 302213 URL: https://svnweb.freebsd.org/changeset/base/302213 Log: Fix a bug introduced in r283433. [1] Remove unneeded sockaddr conversion before kern_recvit() call as the from argument is used to record result (the source address of the received message) only. [2] In Linux the type of msg_namelen member of struct msghdr is signed but native msg_namelen has a unsigned type (socklen_t). So use the proper storage to fetch fromlen from userspace and than check the user supplied value and return EINVAL if it is less than 0 as a Linux do. Reported by: Thomas Mueller [1] Reviewed by: kib@ Approved by: re (gjb, kib) MFC after: 3 days Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Sun Jun 26 16:38:42 2016 (r302212) +++ head/sys/compat/linux/linux_socket.c Sun Jun 26 16:59:59 2016 (r302213) @@ -1054,18 +1054,16 @@ linux_recvfrom(struct thread *td, struct { struct msghdr msg; struct iovec aiov; - int error; + int error, fromlen; if (PTRIN(args->fromlen) != NULL) { - error = copyin(PTRIN(args->fromlen), &msg.msg_namelen, - sizeof(msg.msg_namelen)); - if (error != 0) - return (error); - - error = linux_to_bsd_sockaddr((struct sockaddr *)PTRIN(args->from), - msg.msg_namelen); + error = copyin(PTRIN(args->fromlen), &fromlen, + sizeof(fromlen)); if (error != 0) return (error); + if (fromlen < 0) + return (EINVAL); + msg.msg_namelen = fromlen; } else msg.msg_namelen = 0; From owner-svn-src-all@freebsd.org Sun Jun 26 18:43:44 2016 Return-Path: Delivered-To: svn-src-all@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 43E00B8185F; Sun, 26 Jun 2016 18:43:44 +0000 (UTC) (envelope-from nwhitehorn@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 F1349227D; Sun, 26 Jun 2016 18:43:43 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QIhheE012291; Sun, 26 Jun 2016 18:43:43 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QIhhnx012289; Sun, 26 Jun 2016 18:43:43 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201606261843.u5QIhhnx012289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sun, 26 Jun 2016 18:43:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302214 - head/sys/powerpc/aim X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 18:43:44 -0000 Author: nwhitehorn Date: Sun Jun 26 18:43:42 2016 New Revision: 302214 URL: https://svnweb.freebsd.org/changeset/base/302214 Log: Enter 64-bit mode as early as possible in the 64-bit PowerPC boot sequence. Most of the effect of setting MSR[SF] is that the CPU will stop ignoring the high 32 bits of registers containing addresses in load/store instructions. As such, the kernel was setting it only when it began to need access to high memory. MSR[SF] also affects the operation of some conditional instructions, however, and so setting it at late times could subtly break code at very early times. This fixes use of the FDT mode in loader, and FDT boot more generally, on 64-bit PowerPC systems. Hardware provided by: IBM LTC Approved by: re (kib) Modified: head/sys/powerpc/aim/aim_machdep.c head/sys/powerpc/aim/locore64.S Modified: head/sys/powerpc/aim/aim_machdep.c ============================================================================== --- head/sys/powerpc/aim/aim_machdep.c Sun Jun 26 16:59:59 2016 (r302213) +++ head/sys/powerpc/aim/aim_machdep.c Sun Jun 26 18:43:42 2016 (r302214) @@ -179,17 +179,6 @@ aim_cpu_init(vm_offset_t toc) trap_offset = 0; cacheline_warn = 0; - #ifdef __powerpc64__ - /* - * Switch to 64-bit mode, if the bootloader didn't, before we start - * using memory beyond what the bootloader might have set up. - * Guaranteed not to cause an implicit branch since we either (a) - * started with a 32-bit bootloader below 4 GB or (b) were already in - * 64-bit mode, making this a no-op. - */ - mtmsrd(mfmsr() | PSL_SF); - #endif - /* Various very early CPU fix ups */ switch (mfpvr() >> 16) { /* Modified: head/sys/powerpc/aim/locore64.S ============================================================================== --- head/sys/powerpc/aim/locore64.S Sun Jun 26 16:59:59 2016 (r302213) +++ head/sys/powerpc/aim/locore64.S Sun Jun 26 18:43:42 2016 (r302214) @@ -76,6 +76,14 @@ btext: */ .text ASENTRY_NOPROF(__start) + /* Set 64-bit mode if not yet set before branching to C */ + mfmsr %r20 + li %r21,1 + insrdi %r20,%r21,1,0 + mtmsrd %r20 + isync + nop /* Make this block a multiple of 8 bytes */ + /* Set up the TOC pointer */ b 0f .align 3 From owner-svn-src-all@freebsd.org Sun Jun 26 18:52:19 2016 Return-Path: Delivered-To: svn-src-all@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 D66FCB81A69; Sun, 26 Jun 2016 18:52:19 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-oi0-x232.google.com (mail-oi0-x232.google.com [IPv6:2607:f8b0:4003:c06::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9B7962819; Sun, 26 Jun 2016 18:52:19 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-oi0-x232.google.com with SMTP id f189so175915298oig.3; Sun, 26 Jun 2016 11:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GjYdoo1ReWzbKmF6F5sJf4dgYIGagw/fkXSPA441vfc=; b=uAP/zN0LV+g1JhWctymmfTRFT7YhZcwC7wMnzYdHufDVNRz6C95r9BzGd1MF3sskP8 cf5BBPcDHjTOn9/SLHfI9IUrttYgN6IGLZErDMZWuJD3SwoxlY8HAKBDrP91YFAeU58m bFgBfJQi6zQ4JCsQrO5UnPfrYOqKWiEL11UxYAqN7JYaaWi+2sDNqBKUTVoc4Ai6XRuB 18RFRvQvDsJH2UjXDXmeXUxkx3xTT7AGwcB+RDMnJkndkKxsKRU0Dxk5wU5W87WmLg6F DnzZ62HZBepHDnsIe5/OeRlkE2WOtPyECtVq9BTKSW+Bb3OxXS/IE3Xb/7hRBB0EWD5E +TBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GjYdoo1ReWzbKmF6F5sJf4dgYIGagw/fkXSPA441vfc=; b=ByeBuarHVI0ssZXEX+HPdZnEPPF9Ojs9UKCxlFbBHiBtnMTwQGqSGXfSuuaJQbAh+p 0xGOKsLgvdDAqz+NV+BSGCME01QreOQd+vrXvurgjOntkjkks9cKxnjhJGi3225SfKos w+9qaVv9EAtm5e2zsYa/Rxdnfa773LeEbYj13o8IQnPYi9FdTTwuv5HDYvqqimOZSRp2 063PJRoQL2Adt/XzKBHz+v9b2ctbHaudfXzm3sF8iSNgO2eedfTeXR70Rl+8s6nKsydB d2eW3Io/UUwm5W7O8QNamu+6hoatAjFKA5iIeH+oOS+aMMyNqMZYcl52OOFob9wyGIBt OWDw== X-Gm-Message-State: ALyK8tLmbTw8PQbZUg//q5kdCQxeaS7Xnm67B6JjUxpKQkcL5OaIcPhx9wOyIb1zhBTvMxvIY0F0yYo8l9Yemw== X-Received: by 10.157.44.145 with SMTP id p17mr8501746otb.184.1466967138906; Sun, 26 Jun 2016 11:52:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.12.37 with HTTP; Sun, 26 Jun 2016 11:52:18 -0700 (PDT) In-Reply-To: References: <201604241053.u3OAr0bn072180@repo.freebsd.org> From: Benjamin Kaduk Date: Sun, 26 Jun 2016 13:52:18 -0500 Message-ID: Subject: Re: svn commit: r298537 - head/etc/rc.d To: Jens Schweikhardt Cc: "svn-src-head@freebsd.org" , Jan Beich , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 18:52:19 -0000 On Sun, Apr 24, 2016 at 12:01 PM, Jan Beich wrote: > Jens Schweikhardt writes: > > > - parenthesize the "case" string for symmetry and improved > > search for matching paren (e.g. with vi's %) > [...] > > case "${state}" in > > - [oO][nN]) > > + ([oO][nN]) > > swapon /dev/zvol/${name} > > ;; > > For style consistency is more important. Why this case is special unlike > the rest of rc.d/* or rc.subr ? > Coming in quite late, I agree. I think this part should be reverted. -Ben From owner-svn-src-all@freebsd.org Sun Jun 26 20:07:26 2016 Return-Path: Delivered-To: svn-src-all@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 108C5B8185B; Sun, 26 Jun 2016 20:07:26 +0000 (UTC) (envelope-from kib@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 DF8CC2AA3; Sun, 26 Jun 2016 20:07:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QK7PTu042641; Sun, 26 Jun 2016 20:07:25 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QK7OG0042634; Sun, 26 Jun 2016 20:07:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606262007.u5QK7OG0042634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 20:07:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302215 - in head/sys: fs/fifofs kern sys X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 20:07:26 -0000 Author: kib Date: Sun Jun 26 20:07:24 2016 New Revision: 302215 URL: https://svnweb.freebsd.org/changeset/base/302215 Log: Rewrite sigdeferstop(9) and sigallowstop(9) into more flexible framework allowing to set the suspension policy for the dynamic block. Extend the currently possible policies of stopping on interruptible sleeps and ignoring such sleeps by two more: do not suspend at interruptible sleeps, but interrupt them with either EINTR or ERESTART. Reviewed by: jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/fs/fifofs/fifo_vnops.c head/sys/kern/kern_sig.c head/sys/kern/kern_thread.c head/sys/kern/subr_trap.c head/sys/sys/mount.h head/sys/sys/proc.h head/sys/sys/signalvar.h Modified: head/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- head/sys/fs/fifofs/fifo_vnops.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/fs/fifofs/fifo_vnops.c Sun Jun 26 20:07:24 2016 (r302215) @@ -194,11 +194,10 @@ fifo_open(ap) if ((ap->a_mode & FREAD) && fip->fi_writers == 0) { gen = fip->fi_wgen; VOP_UNLOCK(vp, 0); - stops_deferred = sigallowstop(); + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); error = msleep(&fip->fi_readers, PIPE_MTX(fpipe), PDROP | PCATCH | PSOCK, "fifoor", 0); - if (stops_deferred) - sigdeferstop(); + sigallowstop(stops_deferred); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0 && gen == fip->fi_wgen) { fip->fi_readers--; @@ -222,11 +221,10 @@ fifo_open(ap) if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { gen = fip->fi_rgen; VOP_UNLOCK(vp, 0); - stops_deferred = sigallowstop(); + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); error = msleep(&fip->fi_writers, PIPE_MTX(fpipe), PDROP | PCATCH | PSOCK, "fifoow", 0); - if (stops_deferred) - sigdeferstop(); + sigallowstop(stops_deferred); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0 && gen == fip->fi_rgen) { fip->fi_writers--; Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/kern_sig.c Sun Jun 26 20:07:24 2016 (r302215) @@ -2596,41 +2596,81 @@ tdsigcleanup(struct thread *td) } +static int +sigdeferstop_curr_flags(int cflags) +{ + + MPASS((cflags & (TDF_SEINTR | TDF_SERESTART)) == 0 || + (cflags & TDF_SBDRY) != 0); + return (cflags & (TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)); +} + /* - * Defer the delivery of SIGSTOP for the current thread. Returns true - * if stops were deferred and false if they were already deferred. + * Defer the delivery of SIGSTOP for the current thread, according to + * the requested mode. Returns previous flags, which must be restored + * by sigallowstop(). + * + * TDF_SBDRY, TDF_SEINTR, and TDF_SERESTART flags are only set and + * cleared by the current thread, which allow the lock-less read-only + * accesses below. */ int -sigdeferstop(void) +sigdeferstop(int mode) { struct thread *td; + int cflags, nflags; td = curthread; - if (td->td_flags & TDF_SBDRY) - return (0); - thread_lock(td); - td->td_flags |= TDF_SBDRY; - thread_unlock(td); - return (1); + cflags = sigdeferstop_curr_flags(td->td_flags); + switch (mode) { + case SIGDEFERSTOP_NOP: + nflags = cflags; + break; + case SIGDEFERSTOP_OFF: + nflags = 0; + break; + case SIGDEFERSTOP_SILENT: + nflags = (cflags | TDF_SBDRY) & ~(TDF_SEINTR | TDF_SERESTART); + break; + case SIGDEFERSTOP_EINTR: + nflags = (cflags | TDF_SBDRY | TDF_SEINTR) & ~TDF_SERESTART; + break; + case SIGDEFERSTOP_ERESTART: + nflags = (cflags | TDF_SBDRY | TDF_SERESTART) & ~TDF_SEINTR; + break; + default: + panic("sigdeferstop: invalid mode %x", mode); + break; + } + if (cflags != nflags) { + thread_lock(td); + td->td_flags = (td->td_flags & ~cflags) | nflags; + thread_unlock(td); + } + return (cflags); } /* - * Permit the delivery of SIGSTOP for the current thread. This does - * not immediately suspend if a stop was posted. Instead, the thread - * will suspend either via ast() or a subsequent interruptible sleep. + * Restores the STOP handling mode, typically permitting the delivery + * of SIGSTOP for the current thread. This does not immediately + * suspend if a stop was posted. Instead, the thread will suspend + * either via ast() or a subsequent interruptible sleep. */ -int -sigallowstop(void) +void +sigallowstop(int prev) { struct thread *td; - int prev; + int cflags; + KASSERT((prev & ~(TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)) == 0, + ("sigallowstop: incorrect previous mode %x", prev)); td = curthread; - thread_lock(td); - prev = (td->td_flags & TDF_SBDRY) != 0; - td->td_flags &= ~TDF_SBDRY; - thread_unlock(td); - return (prev); + cflags = sigdeferstop_curr_flags(td->td_flags); + if (cflags != prev) { + thread_lock(td); + td->td_flags = (td->td_flags & ~cflags) | prev; + thread_unlock(td); + } } /* Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/kern_thread.c Sun Jun 26 20:07:24 2016 (r302215) @@ -894,7 +894,7 @@ thread_suspend_check(int return_instead) { struct thread *td; struct proc *p; - int wakeup_swapper; + int wakeup_swapper, r; td = curthread; p = td->td_proc; @@ -927,7 +927,21 @@ thread_suspend_check(int return_instead) if ((td->td_flags & TDF_SBDRY) != 0) { KASSERT(return_instead, ("TDF_SBDRY set for unsafe thread_suspend_check")); - return (0); + switch (td->td_flags & (TDF_SEINTR | TDF_SERESTART)) { + case 0: + r = 0; + break; + case TDF_SEINTR: + r = EINTR; + break; + case TDF_SERESTART: + r = ERESTART; + break; + default: + panic("both TDF_SEINTR and TDF_SERESTART"); + break; + } + return (r); } /* Modified: head/sys/kern/subr_trap.c ============================================================================== --- head/sys/kern/subr_trap.c Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/kern/subr_trap.c Sun Jun 26 20:07:24 2016 (r302215) @@ -160,7 +160,7 @@ userret(struct thread *td, struct trapfr ("userret: Returning with with pinned thread")); KASSERT(td->td_vp_reserv == 0, ("userret: Returning while holding vnode reservation")); - KASSERT((td->td_flags & TDF_SBDRY) == 0, + KASSERT((td->td_flags & (TDF_SBDRY | TDF_SEINTR | TDF_SERESTART)) == 0, ("userret: Returning with stop signals deferred")); KASSERT(td->td_su == NULL, ("userret: Returning with SU cleanup request not handled")); Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/mount.h Sun Jun 26 20:07:24 2016 (r302215) @@ -653,15 +653,15 @@ vfs_statfs_t __vfs_statfs; #define VFS_PROLOGUE(MP) do { \ struct mount *mp__; \ - int _enable_stops; \ + int _prev_stops; \ \ mp__ = (MP); \ - _enable_stops = (mp__ != NULL && \ - (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) && sigdeferstop()) + _prev_stops = sigdeferstop((mp__ != NULL && \ + (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) ? \ + SIGDEFERSTOP_SILENT : SIGDEFERSTOP_NOP); #define VFS_EPILOGUE(MP) \ - if (_enable_stops) \ - sigallowstop(); \ + sigallowstop(_prev_stops); \ } while (0) #define VFS_MOUNT(MP) ({ \ Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/proc.h Sun Jun 26 20:07:24 2016 (r302215) @@ -395,9 +395,9 @@ do { \ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ #define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ #define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ -#define TDF_UNUSED19 0x00080000 /* --available-- */ +#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ -#define TDF_UNUSED21 0x00200000 /* --available-- */ +#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */ #define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ #define TDF_UNUSED23 0x00800000 /* --available-- */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ Modified: head/sys/sys/signalvar.h ============================================================================== --- head/sys/sys/signalvar.h Sun Jun 26 18:43:42 2016 (r302214) +++ head/sys/sys/signalvar.h Sun Jun 26 20:07:24 2016 (r302215) @@ -325,9 +325,21 @@ extern struct mtx sigio_lock; #define SIGPROCMASK_PROC_LOCKED 0x0002 #define SIGPROCMASK_PS_LOCKED 0x0004 +/* + * Modes for sigdeferstop(). Manages behaviour of + * thread_suspend_check() in the region delimited by + * sigdeferstop()/sigallowstop(). Must be restored to + * SIGDEFERSTOP_OFF before returning to userspace. + */ +#define SIGDEFERSTOP_NOP 0 /* continue doing whatever is done now */ +#define SIGDEFERSTOP_OFF 1 /* stop ignoring STOPs */ +#define SIGDEFERSTOP_SILENT 2 /* silently ignore STOPs */ +#define SIGDEFERSTOP_EINTR 3 /* ignore STOPs, return EINTR */ +#define SIGDEFERSTOP_ERESTART 4 /* ignore STOPs, return ERESTART */ + int cursig(struct thread *td); -int sigdeferstop(void); -int sigallowstop(void); +int sigdeferstop(int mode); +void sigallowstop(int prev); void execsigs(struct proc *p); void gsignal(int pgid, int sig, ksiginfo_t *ksi); void killproc(struct proc *p, char *why); From owner-svn-src-all@freebsd.org Sun Jun 26 20:08:43 2016 Return-Path: Delivered-To: svn-src-all@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 840A1B818DB; Sun, 26 Jun 2016 20:08:43 +0000 (UTC) (envelope-from kib@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 45D462C24; Sun, 26 Jun 2016 20:08:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QK8gXQ042732; Sun, 26 Jun 2016 20:08:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QK8gTx042729; Sun, 26 Jun 2016 20:08:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606262008.u5QK8gTx042729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Jun 2016 20:08:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302216 - in head/sys: kern nlm X-SVN-Group: head 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.22 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: Sun, 26 Jun 2016 20:08:43 -0000 Author: kib Date: Sun Jun 26 20:08:42 2016 New Revision: 302216 URL: https://svnweb.freebsd.org/changeset/base/302216 Log: When sleeping waiting for either local or remote advisory lock, interrupt sleeps with the ERESTART on the suspension attempts. Otherwise, single-threading requests are deferred until the locks are granted for NFS files, which causes hangs. When retrying local registration of the remotely-granted adv lock, allow full suspension and check for suspension, for usual reasons. Reported by: markj, pho Reviewed by: jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/kern/kern_lockf.c head/sys/nlm/nlm_advlock.c head/sys/nlm/nlm_prot_impl.c Modified: head/sys/kern/kern_lockf.c ============================================================================== --- head/sys/kern/kern_lockf.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/kern/kern_lockf.c Sun Jun 26 20:08:42 2016 (r302216) @@ -1378,7 +1378,7 @@ lf_setlock(struct lockf *state, struct l void **cookiep) { static char lockstr[] = "lockf"; - int priority, error; + int error, priority, stops_deferred; #ifdef LOCKF_DEBUG if (lockf_debug & 1) @@ -1466,7 +1466,9 @@ lf_setlock(struct lockf *state, struct l } lock->lf_refs++; + stops_deferred = sigdeferstop(SIGDEFERSTOP_ERESTART); error = sx_sleep(lock, &state->ls_lock, priority, lockstr, 0); + sigallowstop(stops_deferred); if (lf_free_lock(lock)) { error = EDOOFUS; goto out; Modified: head/sys/nlm/nlm_advlock.c ============================================================================== --- head/sys/nlm/nlm_advlock.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/nlm/nlm_advlock.c Sun Jun 26 20:08:42 2016 (r302216) @@ -697,7 +697,8 @@ nlm_record_lock(struct vnode *vp, int op { struct vop_advlockasync_args a; struct flock newfl; - int error; + struct proc *p; + int error, stops_deferred; a.a_vp = vp; a.a_id = NULL; @@ -730,7 +731,12 @@ nlm_record_lock(struct vnode *vp, int op * return EDEADLK. */ pause("nlmdlk", 1); - /* XXXKIB allow suspend */ + p = curproc; + stops_deferred = sigdeferstop(SIGDEFERSTOP_OFF); + PROC_LOCK(p); + thread_suspend_check(0); + PROC_UNLOCK(p); + sigallowstop(stops_deferred); } else if (error == EINTR) { /* * lf_purgelocks() might wake up the lock Modified: head/sys/nlm/nlm_prot_impl.c ============================================================================== --- head/sys/nlm/nlm_prot_impl.c Sun Jun 26 20:07:24 2016 (r302215) +++ head/sys/nlm/nlm_prot_impl.c Sun Jun 26 20:08:42 2016 (r302216) @@ -1356,7 +1356,7 @@ int nlm_wait_lock(void *handle, int timo) { struct nlm_waiting_lock *nw = handle; - int error; + int error, stops_deferred; /* * If the granted message arrived before we got here, @@ -1364,8 +1364,11 @@ nlm_wait_lock(void *handle, int timo) */ mtx_lock(&nlm_global_lock); error = 0; - if (nw->nw_waiting) + if (nw->nw_waiting) { + stops_deferred = sigdeferstop(SIGDEFERSTOP_ERESTART); error = msleep(nw, &nlm_global_lock, PCATCH, "nlmlock", timo); + sigallowstop(stops_deferred); + } TAILQ_REMOVE(&nlm_waiting_locks, nw, nw_link); if (error) { /* From owner-svn-src-all@freebsd.org Sun Jun 26 20:17:40 2016 Return-Path: Delivered-To: svn-src-all@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 DDE4EB81AA6 for ; Sun, 26 Jun 2016 20:17:40 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A7702110 for ; Sun, 26 Jun 2016 20:17:40 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x234.google.com with SMTP id a66so89003792wme.0 for ; Sun, 26 Jun 2016 13:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CL8EES7eSJ52QY0GbUOawNDrxuDEMG+RS17QdVFof1Q=; b=hyUzoGjNbBhtmHsmFvy25+C9j4TVwexyenm+Js0B19xvlgqLpl8e95P2Hra9ZWIanN XSTCfXl7f3snJnrqSJXZFPaDqZFaeowPBiBn+7aOQo93F+NxERR7rjdop180hQNkh10N Cvsih8fPL/e+K9pD04NCs8GApk5oxPN+C+8vY30P8yIu2qbAvxUpJC3BseVXndLZ4Ath /IKxmoGIty52NHSqP9jyfRbjeK7jChUk+doyjz/XcvgW6isDmIMAIzY7i4A6n5F9m3xd MLIkZDnoNBcw8foZZ7dwqK3AtAtoV6szuMngZPy9unUXAUq5btBMJ/+cQljf+q6KjrGe sIXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CL8EES7eSJ52QY0GbUOawNDrxuDEMG+RS17QdVFof1Q=; b=lgvYma/+1AHfKTKVmp6z1NRLznaDP1tgk+9JObayr6WQ/9BhnHhwkXtS9r9eueXjDO /JXd3Lb0zdZr11mZmD3R5BBxqUWRQhZlb1IiiNU24d03CRBjjupudqaAQ/QiUGQbhd57 piZ+5F8+qTLffn2O0iJMaHBpkKL3g4jU2PmAUJeu4h1ThOwB4T9ElNitg+qmLhwPo1ky wReLYwBqgmWtYUsg2lczvLaLElIse6L9lLHIhyZr3n4in1fwIecE4ZHQxI20TyJCG00j RJYVLTEZn4P7oj8R6vH9dN6cREN5dQdYbT2Qfw8lRJuZzarN1IEz6h9J94yhyIf5CINa 9uew== X-Gm-Message-State: ALyK8tJnxhD2i6mZuT8W5AdCcZ+boT9A+v6L9xB7II+gpHfTh5IIu++LS7hccePUwig/v9/j0T8cyHqN53smp8ht X-Received: by 10.194.25.135 with SMTP id c7mr12088414wjg.63.1466972258846; Sun, 26 Jun 2016 13:17:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.45.33 with HTTP; Sun, 26 Jun 2016 13:17:38 -0700 (PDT) In-Reply-To: <201606210451.u5L4ptYP082074@repo.freebsd.org> References: <201606210451.u5L4ptYP082074@repo.freebsd.org> From: Oliver Pinter Date: Sun, 26 Jun 2016 22:17:38 +0200 Message-ID: Subject: Re: svn commit: r302041 - in stable/10/sys: amd64/amd64 amd64/conf conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 i386/conf i386/i386 modules/hyperv/vmbus To: Sepherosa Ziehau Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 20:17:41 -0000 Hi all! Some from these hyper-v commits breaks the build with INVARIANTS enabled kernel on 10-STABLE: ~~~ /vmbus.c:446:30: error: use of undeclared identifier 'Xhv_vmbus_callback' 14:13:13 KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), ~~~ For more details please see this jenkins log: http://jenkins.hardenedbsd.org:8180/jenkins/job/HardenedBSD-10-STABLE-amd64/462/console Btw, does anybody build an INVARIANTS enabled kernel in FreeBSD's jenkins cluster with 10-STABLE? There are some other issues with INVARIANTS, for example ZFS + GELI + 10-STABLE : https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209580 On 6/21/16, Sepherosa Ziehau wrote: > Author: sephe > Date: Tue Jun 21 04:51:55 2016 > New Revision: 302041 > URL: https://svnweb.freebsd.org/changeset/base/302041 > > Log: > MFC 297931,298022 > > 297931 > Expose doreti as a global symbol on amd64 and i386. > > doreti provides the common code path for returning from interrupt > andlers on x86. Exposing doreti as a global symbol allows kernel > modules to include low-level interrupt handlers instead of requiring > all low-level handlers to be statically compiled into the kernel. > > Submitted by: Howard Su > Reviewed by: kib > > 298022 > hyperv: Deprecate HYPERV option by moving Hyper-V IDT vector into > vmbus > > Submitted by: Jun Su > Reviewed by: jhb, kib, sephe > Sponsored by: Microsoft OSTC > Differential Revision: https://reviews.freebsd.org/D5910 > > Added: > stable/10/sys/dev/hyperv/vmbus/amd64/ > - copied from r298022, head/sys/dev/hyperv/vmbus/amd64/ > stable/10/sys/dev/hyperv/vmbus/i386/ > - copied from r298022, head/sys/dev/hyperv/vmbus/i386/ > Modified: > stable/10/sys/amd64/amd64/apic_vector.S > stable/10/sys/amd64/amd64/exception.S > stable/10/sys/amd64/conf/GENERIC > stable/10/sys/conf/files.amd64 > stable/10/sys/conf/files.i386 > stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c > stable/10/sys/i386/conf/GENERIC > stable/10/sys/i386/i386/apic_vector.s > stable/10/sys/i386/i386/exception.s > stable/10/sys/modules/hyperv/vmbus/Makefile > Directory Properties: > stable/10/ (props changed) > > Modified: stable/10/sys/amd64/amd64/apic_vector.S > ============================================================================== > --- stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 02:36:03 > 2016 (r302040) > +++ stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 04:51:55 > 2016 (r302041) > @@ -150,22 +150,6 @@ IDTVEC(xen_intr_upcall) > jmp doreti > #endif > > -#ifdef HYPERV > -/* > - * This is the Hyper-V vmbus channel direct callback interrupt. > - * Only used when it is running on Hyper-V. > - */ > - .text > - SUPERALIGN_TEXT > -IDTVEC(hv_vmbus_callback) > - PUSH_FRAME > - FAKE_MCOUNT(TF_RIP(%rsp)) > - movq %rsp, %rdi > - call hv_vector_handler > - MEXITCOUNT > - jmp doreti > -#endif > - > #ifdef SMP > /* > * Global address space TLB shootdown. > > Modified: stable/10/sys/amd64/amd64/exception.S > ============================================================================== > --- stable/10/sys/amd64/amd64/exception.S Tue Jun 21 02:36:03 > 2016 (r302040) > +++ stable/10/sys/amd64/amd64/exception.S Tue Jun 21 04:51:55 > 2016 (r302041) > @@ -661,6 +661,7 @@ MCOUNT_LABEL(eintr) > .text > SUPERALIGN_TEXT > .type doreti,@function > + .globl doreti > doreti: > FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ > /* > > Modified: stable/10/sys/amd64/conf/GENERIC > ============================================================================== > --- stable/10/sys/amd64/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) > +++ stable/10/sys/amd64/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) > @@ -353,7 +353,6 @@ device virtio_scsi # VirtIO SCSI devic > device virtio_balloon # VirtIO Memory Balloon device > > # HyperV drivers and enchancement support > -# NOTE: HYPERV depends on hyperv. They must be added or removed together. > options HYPERV # Hyper-V kernel infrastructure > device hyperv # HyperV drivers > > > Modified: stable/10/sys/conf/files.amd64 > ============================================================================== > --- stable/10/sys/conf/files.amd64 Tue Jun 21 02:36:03 2016 (r302040) > +++ stable/10/sys/conf/files.amd64 Tue Jun 21 04:51:55 2016 (r302041) > @@ -278,6 +278,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp > dev/hyperv/vmbus/hv_et.c optional hyperv > dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv > dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv > +dev/hyperv/vmbus/amd64/hv_vector.S optional hyperv > dev/kbd/kbd.c optional atkbd | sc | ukbd | vt > dev/lindev/full.c optional lindev > dev/lindev/lindev.c optional lindev > > Modified: stable/10/sys/conf/files.i386 > ============================================================================== > --- stable/10/sys/conf/files.i386 Tue Jun 21 02:36:03 2016 (r302040) > +++ stable/10/sys/conf/files.i386 Tue Jun 21 04:51:55 2016 (r302041) > @@ -254,6 +254,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp > dev/hyperv/vmbus/hv_et.c optional hyperv > dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv > dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv > +dev/hyperv/vmbus/i386/hv_vector.S optional hyperv > dev/ichwd/ichwd.c optional ichwd > dev/if_ndis/if_ndis.c optional ndis > dev/if_ndis/if_ndis_pccard.c optional ndis pccard > > Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c > ============================================================================== > --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 > 02:36:03 2016 (r302040) > +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 > 04:51:55 2016 (r302041) > @@ -370,7 +370,6 @@ vmbus_probe(device_t dev) { > return (BUS_PROBE_DEFAULT); > } > > -#ifdef HYPERV > extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback); > > /** > @@ -430,21 +429,6 @@ vmbus_vector_free(int vector) > setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); > } > > -#else /* HYPERV */ > - > -static int > -vmbus_vector_alloc(void) > -{ > - return(0); > -} > - > -static void > -vmbus_vector_free(int vector) > -{ > -} > - > -#endif /* HYPERV */ > - > static void > vmbus_cpuset_setthread_task(void *xmask, int pending __unused) > { > > Modified: stable/10/sys/i386/conf/GENERIC > ============================================================================== > --- stable/10/sys/i386/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) > +++ stable/10/sys/i386/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) > @@ -362,7 +362,6 @@ device virtio_scsi # VirtIO SCSI devic > device virtio_balloon # VirtIO Memory Balloon device > > # HyperV drivers and enchancement support > -# NOTE: HYPERV depends on hyperv. They must be added or removed together. > options HYPERV # Hyper-V kernel infrastructure > device hyperv # HyperV drivers > > > Modified: stable/10/sys/i386/i386/apic_vector.s > ============================================================================== > --- stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 02:36:03 > 2016 (r302040) > +++ stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 04:51:55 > 2016 (r302041) > @@ -157,25 +157,6 @@ IDTVEC(xen_intr_upcall) > jmp doreti > #endif > > -#ifdef HYPERV > -/* > - * This is the Hyper-V vmbus channel direct callback interrupt. > - * Only used when it is running on Hyper-V. > - */ > - .text > - SUPERALIGN_TEXT > -IDTVEC(hv_vmbus_callback) > - PUSH_FRAME > - SET_KERNEL_SREGS > - cld > - FAKE_MCOUNT(TF_EIP(%esp)) > - pushl %esp > - call hv_vector_handler > - add $4, %esp > - MEXITCOUNT > - jmp doreti > -#endif > - > #ifdef SMP > /* > * Global address space TLB shootdown. > > Modified: stable/10/sys/i386/i386/exception.s > ============================================================================== > --- stable/10/sys/i386/i386/exception.s Tue Jun 21 02:36:03 2016 (r302040) > +++ stable/10/sys/i386/i386/exception.s Tue Jun 21 04:51:55 2016 (r302041) > @@ -344,6 +344,7 @@ MCOUNT_LABEL(eintr) > .text > SUPERALIGN_TEXT > .type doreti,@function > + .globl doreti > doreti: > FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ > doreti_next: > > Modified: stable/10/sys/modules/hyperv/vmbus/Makefile > ============================================================================== > --- stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 02:36:03 > 2016 (r302040) > +++ stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 04:51:55 > 2016 (r302041) > @@ -1,7 +1,7 @@ > # $FreeBSD$ > > .PATH: ${.CURDIR}/../../../dev/hyperv/vmbus \ > - ${.CURDIR}/../../../dev/hyperv/utilities > + ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH} > > KMOD= hv_vmbus > SRCS= hv_channel.c \ > @@ -14,8 +14,17 @@ SRCS= hv_channel.c \ > hv_vmbus_priv.h > SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h > > +# XXX: for assym.s > +SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_hwpmc_hooks.h > opt_compat.h > + > +SRCS+= assym.s \ > + hv_vector.S > + > +hv_vector.o: > + ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ > + ${.IMPSRC} -o ${.TARGET} > + > CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ > - -I${.CURDIR}/../../../dev/hyperv/vmbus \ > - -I${.CURDIR}/../../../dev/hyperv/utilities > + -I${.CURDIR}/../../../dev/hyperv/vmbus > > .include > _______________________________________________ > svn-src-stable-10@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 > To unsubscribe, send any mail to > "svn-src-stable-10-unsubscribe@freebsd.org" > From owner-svn-src-all@freebsd.org Sun Jun 26 20:59:13 2016 Return-Path: Delivered-To: svn-src-all@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 BACBEB812D9; Sun, 26 Jun 2016 20:59:13 +0000 (UTC) (envelope-from delphij@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 590B72635; Sun, 26 Jun 2016 20:59:13 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QKxCMv061994; Sun, 26 Jun 2016 20:59:12 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QKxB2B061980; Sun, 26 Jun 2016 20:59:11 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606262059.u5QKxB2B061980@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 26 Jun 2016 20:59:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r302218 - in vendor/file/dist: . doc magic magic/Magdir src X-SVN-Group: vendor 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.22 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: Sun, 26 Jun 2016 20:59:13 -0000 Author: delphij Date: Sun Jun 26 20:59:11 2016 New Revision: 302218 URL: https://svnweb.freebsd.org/changeset/base/302218 Log: Vendor import of file 5.28. Added: vendor/file/dist/magic/Magdir/ber vendor/file/dist/magic/Magdir/coverage vendor/file/dist/magic/Magdir/pc88 vendor/file/dist/magic/Magdir/pc98 vendor/file/dist/magic/Magdir/x68000 Deleted: vendor/file/dist/src/magic.h Modified: vendor/file/dist/ChangeLog vendor/file/dist/config.h.in vendor/file/dist/configure vendor/file/dist/configure.ac vendor/file/dist/doc/file.man vendor/file/dist/magic/Magdir/c-lang vendor/file/dist/magic/Magdir/console vendor/file/dist/magic/Magdir/database vendor/file/dist/magic/Magdir/elf vendor/file/dist/magic/Magdir/msdos vendor/file/dist/magic/Magdir/msx vendor/file/dist/magic/Magdir/perl vendor/file/dist/magic/Makefile.am vendor/file/dist/magic/Makefile.in vendor/file/dist/src/Makefile.am vendor/file/dist/src/Makefile.in vendor/file/dist/src/apprentice.c vendor/file/dist/src/cdf.c vendor/file/dist/src/compress.c vendor/file/dist/src/der.c vendor/file/dist/src/file.c vendor/file/dist/src/softmagic.c Modified: vendor/file/dist/ChangeLog ============================================================================== --- vendor/file/dist/ChangeLog Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/ChangeLog Sun Jun 26 20:59:11 2016 (r302218) @@ -1,3 +1,15 @@ +2016-06-13 19:40 Christos Zoulas + + * release 5.28 + * fix leak on allocation failure + +2016-06-01 1:20 Christos Zoulas + + * PR/555: Avoid overflow for offset > nbytes + * PR/550: Segv on DER parsing: + - use the correct variable for length + - set offset to 0 on failure. + 2016-05-13 12:00 Christos Zoulas * release 5.27 Modified: vendor/file/dist/config.h.in ============================================================================== --- vendor/file/dist/config.h.in Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/config.h.in Sun Jun 26 20:59:11 2016 (r302218) @@ -328,6 +328,9 @@ # endif #endif +/* Enable zlib compression support */ +#undef ZLIBSUPPORT + /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 Modified: vendor/file/dist/configure ============================================================================== --- vendor/file/dist/configure Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/configure Sun Jun 26 20:59:11 2016 (r302218) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.27. +# Generated by GNU Autoconf 2.69 for file 5.28. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.27' -PACKAGE_STRING='file 5.27' +PACKAGE_VERSION='5.28' +PACKAGE_STRING='file 5.28' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -766,6 +766,7 @@ enable_option_checking enable_silent_rules enable_elf enable_elf_core +enable_zlib enable_fsect_man5 enable_dependency_tracking enable_static @@ -1327,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.27 to adapt to many kinds of systems. +\`configure' configures file 5.28 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1397,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.27:";; + short | recursive ) echo "Configuration of file 5.28:";; esac cat <<\_ACEOF @@ -1409,6 +1410,7 @@ Optional Features: --disable-silent-rules verbose build output (undo: "make V=0") --disable-elf disable builtin ELF support --disable-elf-core disable ELF core file support + --disable-zlib disable zlib compression support [default=auto] --enable-fsect-man5 enable file formats in man section 5 --enable-dependency-tracking do not reject slow dependency extractors @@ -1507,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.27 +file configure 5.28 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2163,7 +2165,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.27, which was +It was created by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3029,7 +3031,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.27' + VERSION='5.28' cat >>confdefs.h <<_ACEOF @@ -3218,6 +3220,16 @@ $as_echo "#define ELFCORE 1" >>confdefs. fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib support" >&5 +$as_echo_n "checking for zlib support... " >&6; } +# Check whether --enable-zlib was given. +if test "${enable_zlib+set}" = set; then : + enableval=$enable_zlib; +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_zlib" >&5 +$as_echo "$enable_zlib" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file formats in man section 5" >&5 $as_echo_n "checking for file formats in man section 5... " >&6; } # Check whether --enable-fsect-man5 was given. @@ -12812,7 +12824,8 @@ fi done -for ac_header in zlib.h +if test "$enable_zlib" != "no"; then + for ac_header in zlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes; then : @@ -12824,6 +12837,7 @@ fi done +fi ac_fn_c_check_type "$LINENO" "sig_t" "ac_cv_type_sig_t" " #ifdef HAVE_SIGNAL_H #include @@ -14400,7 +14414,8 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 +if test "$enable_zlib" != "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 $as_echo_n "checking for gzopen in -lz... " >&6; } if ${ac_cv_lib_z_gzopen+:} false; then : $as_echo_n "(cached) " >&6 @@ -14445,6 +14460,7 @@ _ACEOF fi +fi if test "$MINGW" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for regexec in -lgnurx" >&5 $as_echo_n "checking for regexec in -lgnurx... " >&6; } @@ -14504,6 +14520,16 @@ else fi +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + as_fn_error $? "zlib support requested but not found" "$LINENO" 5 + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + +$as_echo "#define ZLIBSUPPORT 1" >>confdefs.h + +fi + ac_config_files="$ac_config_files Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile" cat >confcache <<\_ACEOF @@ -15049,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.27, which was +This file was extended by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15115,7 +15141,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.27 +file config.status 5.28 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: vendor/file/dist/configure.ac ============================================================================== --- vendor/file/dist/configure.ac Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/configure.ac Sun Jun 26 20:59:11 2016 (r302218) @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.27],[christos@astron.com]) +AC_INIT([file],[5.28],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -34,6 +34,11 @@ fi], [ AC_DEFINE([ELFCORE], 1, [Define for ELF core file support]) ]) +AC_MSG_CHECKING(for zlib support) +AC_ARG_ENABLE(zlib, +[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])]) +AC_MSG_RESULT($enable_zlib) + AC_MSG_CHECKING(for file formats in man section 5) AC_ARG_ENABLE(fsect-man5, [ --enable-fsect-man5 enable file formats in man section 5], @@ -84,7 +89,9 @@ AC_CHECK_HEADERS(stdint.h fcntl.h locale AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h) AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h) -AC_CHECK_HEADERS(zlib.h) +if test "$enable_zlib" != "no"; then + AC_CHECK_HEADERS(zlib.h) +fi AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[ #ifdef HAVE_SIGNAL_H #include @@ -148,7 +155,9 @@ dnl Provide implementation of some requi AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf) dnl Checks for libraries -AC_CHECK_LIB(z,gzopen) +if test "$enable_zlib" != "no"; then + AC_CHECK_LIB(z, gzopen) +fi if test "$MINGW" = 1; then AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW])) fi @@ -156,5 +165,14 @@ fi dnl See if we are cross-compiling AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes) +dnl Final sanity checks +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + AC_MSG_ERROR([zlib support requested but not found]) + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support]) +fi + AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile]) AC_OUTPUT Modified: vendor/file/dist/doc/file.man ============================================================================== --- vendor/file/dist/doc/file.man Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/doc/file.man Sun Jun 26 20:59:11 2016 (r302218) @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.120 2016/03/31 17:51:12 christos Exp $ +.\" $File: file.man,v 1.121 2016/06/07 22:09:20 rrt Exp $ .Dd March 13, 2016 .Dt FILE __CSECTION__ .Os @@ -213,6 +213,9 @@ Prints ELF file details. Consults magic files. .It tar Examines tar files. +.It text +A synonym for +.Sq ascii . .El .It Fl Fl extension Print a slash-separated list of valid extensions for the file type found. Added: vendor/file/dist/magic/Magdir/ber ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/file/dist/magic/Magdir/ber Sun Jun 26 20:59:11 2016 (r302218) @@ -0,0 +1,65 @@ + +#------------------------------------------------------------------------------ +# $File: ber,v 1.1 2016/06/05 00:21:30 christos Exp $ +# ber: file(1) magic for several BER formats used in the mobile +# telecommunications industry (Georg Sauthoff) + +# The file formats are standardized by the GSMA (GSM association). +# They are specified via ASN.1 schemas and some prose. Basic encoding +# rules (BER) is the used encoding. The formats are used for exchanging +# call data records (CDRs) between mobile operators and associated +# parties for roaming clearing purposes and fraud detection. + +# The magic file covers: + +# - TAP files (TD.57) - CDR batches and notifications +# - RAP files (TD.32) - return batches and acknowledgements +# - NRT files (TD.35) - CDR batches for 'near real time' processing + +# +# TAP 3 Files +# TAP -> Transferred Account Procedure +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.57-v32.31.pdf +# TransferBatch short tag +0 byte 0x61 +# BatchControlInfo short tag +>&1 search/b5 \x64 +# Sender long tag #TAP 3.x (BER encoded) +>>&1 search/b8 \x5f\x81\x44 +# 3 block +>>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>>&0 byte x TAP 3.%d Batch (TD.57, Transferred Account) + +# Notification short tag +0 byte 0x62 +# Sender long tag +>2 search/b8 \x5f\x81\x44 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>&0 byte x TAP 3.%d Notification (TD.57, Transferred Account) + + +# NRT Files +# NRT a.k.a. NRTRDE +0 byte 0x61 +# 2 block +>&1 search/b8 \x5f\x29\x01\x02\x5f\x25\x01 +>>&0 byte x NRT 2.%d (TD.35, Near Real Time Roaming Data Exchange) + +# RAP Files +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.32-v6.11.pdf +# Long ReturnBatch tag +0 string \x7f\x84\x16 +# Long RapBatchControlInfo tag +>&1 search/b8 \x7f\x84\x19 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +# 1 block +>>>&1 string/b \x5f\x84\x20\x01\x01\x5f\x84\x1f\x01 +>>>>&0 byte x RAP 1.%d Batch (TD.32, Returned Account Procedure), +>>>&0 byte x TAP 3.%d + +# Long Acknowledgement tag +0 string \x7f\x84\x17 +# Long Sender tag +>&1 search/b5 \x5f\x81\x44 RAP Acknowledgement (TD.32, Returned Account Procedure) Modified: vendor/file/dist/magic/Magdir/c-lang ============================================================================== --- vendor/file/dist/magic/Magdir/c-lang Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/c-lang Sun Jun 26 20:59:11 2016 (r302218) @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: c-lang,v 1.22 2015/10/29 18:49:11 christos Exp $ +# $File: c-lang,v 1.23 2016/05/21 14:28:27 christos Exp $ # c-lang: file(1) magic for C and related languages programs # # The strength is to beat standard HTML @@ -38,7 +38,8 @@ !:strength + 30 !:mime text/x-c++ 0 regex \^class[\ \t\n]+ C++ source text -!:strength + 30 +# But class is reduced to avoid beating php (Jens Schleusener) +!:strength + 13 !:mime text/x-c++ 0 regex \^public: C++ source text !:strength + 30 Modified: vendor/file/dist/magic/Magdir/console ============================================================================== --- vendor/file/dist/magic/Magdir/console Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/console Sun Jun 26 20:59:11 2016 (r302218) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: console,v 1.25 2016/04/18 20:22:10 christos Exp $ +# $File: console,v 1.26 2016/06/12 15:20:37 christos Exp $ # Console game magic # Toby Deshane @@ -56,6 +56,32 @@ >4 lelong <16 UNIF v%d format NES ROM image #------------------------------------------------------------------------------ +# fds: file(1) magic for Famciom Disk System disk images +# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format +# From: David Korth +# TODO: Check "Disk info block" and get info from that in addition to the optional header. + +# Disk info block. (block 1) +0 name nintendo-fds-disk-info-block +>1 string *NINTENDO-HVC* Famicom Disk System disk image: +>23 byte !1 FMC- +>23 byte 1 FSC- +>16 string x \b%.3s +>15 byte x \b, mfr 0x%02X +>20 byte x (Rev.%02u) + +# Headered version. +0 string FDS\x1A +>0x11 string *NINTENDO-HVC* +>>0x10 use nintendo-fds-disk-info-block +>4 byte 1 (%u side) +>4 byte !1 (%u sides) + +# Unheadered version. +1 string *NINTENDO-HVC* +>0 use nintendo-fds-disk-info-block + +#------------------------------------------------------------------------------ # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header # @@ -569,6 +595,15 @@ 0x1C belong 0xC2339F3D Nintendo GameCube disc image: >0 use nintendo-gcn-disc-common +# Type: Nintendo GameCube embedded disc image +# Commonly found on demo discs. +# From: David Korth +# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8 +0 belong 0xAE0F38A2 +>0x0C belong 0x00100000 +>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image: +>>>(8.L) use nintendo-gcn-disc-common + # Type: Nintendo Wii disc image # From: David Korth # Reference: http://wiibrew.org/wiki/Wii_Disc @@ -586,22 +621,15 @@ # Nintendo 3DS file formats. # -# Type: Nintendo 3DS "NCCH" header. -# Contained within either a CXI executable or an NCSD image. -# From: David Korth -# Reference: https://www.3dbrew.org/wiki/NCCH -0 name nintendo-3ds-NCCH ->0x100 string NCCH ->>0x150 string >\0 \b: "%.16s" ->>0x112 leshort x (v%u) ->>0x18C byte 2 (New3DS only) - # Type: Nintendo 3DS "NCSD" image. (game cards and eMMC) # From: David Korth # Reference: https://www.3dbrew.org/wiki/NCSD 0x100 string NCSD >0x118 lequad 0 Nintendo 3DS Game Card image ->>0x1000 use nintendo-3ds-NCCH +# NCCH header for partition 0. (game data) +>>0x1150 string >\0 \b: "%.16s" +>>0x312 byte x (Rev.%02u) +>>0x118C byte 2 (New3DS only) >>0x18D byte 0 (inner device) >>0x18D byte 1 (Card1) >>0x18D byte 2 (Card2) @@ -609,12 +637,74 @@ >0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS) >0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS) +# Nintendo 3DS version code. +# Reference: https://www.3dbrew.org/wiki/Titles +# Format: leshort containing three fields: +# - 6-bit: Major +# - 6-bit: Minor +# - 4-bit: Revision +# NOTE: Only supporting major/minor versions from 0-15 right now. +# NOTE: Should be prefixed with "v". +0 name nintendo-3ds-version-code +# Raw version. +>0 leshort x \b%u, +# Major version. +>0 leshort&0xFC00 0x0000 0 +>0 leshort&0xFC00 0x0400 1 +>0 leshort&0xFC00 0x0800 2 +>0 leshort&0xFC00 0x0C00 3 +>0 leshort&0xFC00 0x1000 4 +>0 leshort&0xFC00 0x1400 5 +>0 leshort&0xFC00 0x1800 6 +>0 leshort&0xFC00 0x1C00 7 +>0 leshort&0xFC00 0x2000 8 +>0 leshort&0xFC00 0x2400 9 +>0 leshort&0xFC00 0x2800 10 +>0 leshort&0xFC00 0x2C00 11 +>0 leshort&0xFC00 0x3000 12 +>0 leshort&0xFC00 0x3400 13 +>0 leshort&0xFC00 0x3800 14 +>0 leshort&0xFC00 0x3C00 15 +# Minor version. +>0 leshort&0x03F0 0x0000 \b.0 +>0 leshort&0x03F0 0x0010 \b.1 +>0 leshort&0x03F0 0x0020 \b.2 +>0 leshort&0x03F0 0x0030 \b.3 +>0 leshort&0x03F0 0x0040 \b.4 +>0 leshort&0x03F0 0x0050 \b.5 +>0 leshort&0x03F0 0x0060 \b.6 +>0 leshort&0x03F0 0x0070 \b.7 +>0 leshort&0x03F0 0x0080 \b.8 +>0 leshort&0x03F0 0x0090 \b.9 +>0 leshort&0x03F0 0x00A0 \b.10 +>0 leshort&0x03F0 0x00B0 \b.11 +>0 leshort&0x03F0 0x00C0 \b.12 +>0 leshort&0x03F0 0x00D0 \b.13 +>0 leshort&0x03F0 0x00E0 \b.14 +>0 leshort&0x03F0 0x00F0 \b.15 +# Revision. +>0 leshort&0x000F x \b.%u + # Type: Nintendo 3DS "NCCH" container. # https://www.3dbrew.org/wiki/NCCH -0x100 string NCCH Nintendo 3DS ->0x18D byte&2 0 File Archive (CFA) ->0x18D byte&2 2 Executable Image (CXI) ->0 use nintendo-3ds-NCCH +0x100 string NCCH Nintendo 3DS +>0x18D byte&2 0 File Archive (CFA) +>0x18D byte&2 2 Executable Image (CXI) +>0x150 string >\0 \b: "%.16s" +>0x18D byte 0x05 +>>0x10E leshort x (Old3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte 0x15 +>>0x10E leshort x (New3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte !0x05 +>>0x18D byte !0x15 +>>>0x112 byte x (v +>>>0x112 use nintendo-3ds-version-code +>>>0x112 byte x \b) +>0x18C byte 2 (New3DS only) # Type: Nintendo 3DS "SMDH" file. (application description) # From: David Korth Added: vendor/file/dist/magic/Magdir/coverage ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/file/dist/magic/Magdir/coverage Sun Jun 26 20:59:11 2016 (r302218) @@ -0,0 +1,91 @@ + +#------------------------------------------------------------------------------ +# $File: coverage,v 1.1 2016/06/05 00:26:32 christos Exp $ +# xoverage: file(1) magic for test coverage data + +# File formats used to store test coverage data +# 2016-05-21, Georg Sauthoff + + +# - GCC gcno - written by GCC at compile time when compiling with +# gcc -ftest-coverage +# - GCC gcda - written by a program that was compiled with +# gcc -fprofile-arcs +# - LLVM raw profiles - generated by a program compiled with +# clang -fprofile-instr-generate -fcoverage-mapping ... +# - LLVM indexed profiles - generated by +# llvm-profdata +# - GCOV reports, i.e. the annotated source code +# - LCOV trace files, i.e. aggregated GCC profiles +# +# GCC coverage tracefiles +# .gcno file are created during compile time, +# while data collected during runtime is stored in .gcda files +# cf. gcov-io.h +# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 6e 6f 34 30 39 2a +0 lelong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 64 61 34 30 39 2a +0 lelong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + + +# LCOV tracefiles +# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php +0 string TN: +>&0 search/64 \nSF:/ LCOV coverage tracefile + + +# Coverage reports generated by gcov +# i.e. source code annoted with coverage information +0 string \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source: +>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph: +>>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data: GCOV coverage report + + +# LLVM coverage files + +# raw data after running a program compiled with: +# `clang -fprofile-instr-generate -fcoverage-mapping ...` +# default name: default.profraw +# magic is: \xFF lprofr \x81 +# cf. http://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html +0 lequad 0xff6c70726f667281 LLVM raw profile data, +>&0 byte x version %d + +# big endian +0 bequad 0xff6c70726f667281 LLVM raw profile data, +>&7 byte x version %d (big-endian) + + +# LLVM indexed instruction profile (as generated by llvm-profdata) +# magic is: reverse(\xFF lprofi \x81) +# cf. http://llvm.org/docs/CoverageMappingFormat.html +# http://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html +# http://llvm.org/docs/CommandGuide/llvm-cov.html +# http://llvm.org/docs/CommandGuide/llvm-profdata.html +0 lequad 0x8169666f72706cff LLVM indexed profile data, +>&0 byte x version %d + +# big endian +0 bequad 0x8169666f72706cff LLVM indexed profile data, +>&7 byte x version %d (big-endian) + Modified: vendor/file/dist/magic/Magdir/database ============================================================================== --- vendor/file/dist/magic/Magdir/database Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/database Sun Jun 26 20:59:11 2016 (r302218) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: database,v 1.48 2016/04/14 20:34:28 christos Exp $ +# $File: database,v 1.49 2016/06/11 17:01:51 christos Exp $ # database: file(1) magic for various databases # # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) @@ -611,3 +611,14 @@ !:ext pan # database name >>>5 pstring x \b, "%s" + +# +# +# askSam Database by Stefan A. Haubenthal +0 string askw40\0 askSam DB + +# +# +# MUIbase Database Tool by Stefan A. Haubenthal +0 string MBSTV\040 MUIbase DB +>6 string x version %s Modified: vendor/file/dist/magic/Magdir/elf ============================================================================== --- vendor/file/dist/magic/Magdir/elf Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/elf Sun Jun 26 20:59:11 2016 (r302218) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: elf,v 1.69 2015/06/16 17:23:08 christos Exp $ +# $File: elf,v 1.70 2016/06/02 12:36:30 christos Exp $ # elf: file(1) magic for ELF executables # # We have to check the byte order flag to see what byte order all the @@ -301,25 +301,23 @@ >>0 use elf-le >5 byte 2 MSB >>0 use \^elf-le -# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed -# like proper ELF, but extracting the string had bad results. ->4 byte <0x80 ->>8 string >\0 (%s) ->8 string \0 ->>7 byte 0 (SYSV) ->>7 byte 1 (HP-UX) ->>7 byte 2 (NetBSD) ->>7 byte 3 (GNU/Linux) ->>7 byte 4 (GNU/Hurd) ->>7 byte 5 (86Open) ->>7 byte 6 (Solaris) ->>7 byte 7 (Monterey) ->>7 byte 8 (IRIX) ->>7 byte 9 (FreeBSD) ->>7 byte 10 (Tru64) ->>7 byte 11 (Novell Modesto) ->>7 byte 12 (OpenBSD) ->8 string \2 ->>7 byte 13 (OpenVMS) ->>7 byte 97 (ARM) ->>7 byte 255 (embedded) +>7 byte 0 (SYSV) +>7 byte 1 (HP-UX) +>7 byte 2 (NetBSD) +>7 byte 3 (GNU/Linux) +>7 byte 4 (GNU/Hurd) +>7 byte 5 (86Open) +>7 byte 6 (Solaris) +>7 byte 7 (Monterey) +>7 byte 8 (IRIX) +>7 byte 9 (FreeBSD) +>7 byte 10 (Tru64) +>7 byte 11 (Novell Modesto) +>7 byte 12 (OpenBSD) +>7 byte 13 (OpenVMS) +>7 byte 14 (HP NonStop Kernel) +>7 byte 15 (AROS Research Operating System) +>7 byte 16 (FenixOS) +>7 byte 17 (Nuxi CloudABI) +>7 byte 97 (ARM) +>7 byte 255 (embedded) Modified: vendor/file/dist/magic/Magdir/msdos ============================================================================== --- vendor/file/dist/magic/Magdir/msdos Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/msdos Sun Jun 26 20:59:11 2016 (r302218) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msdos,v 1.105 2016/03/03 18:58:14 christos Exp $ +# $File: msdos,v 1.106 2016/06/11 00:52:14 christos Exp $ # msdos: file(1) magic for MS-DOS files # @@ -633,47 +633,86 @@ 0 string/b \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for MS Windows # Windows icons -0 name ico-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->4 ubyte !0 \b, %d colors - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG 0 belong 0x00000100 >9 byte 0 ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir +# displays number of icons and information for icon or cursor +0 name cur-ico-dir +# skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with +# 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h +>18 ulelong &0x00000006 +# skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG) +>>(18.l) ulelong x MS Windows +>>>0 ubelong 0x00000100 icon resource +#!:mime image/vnd.microsoft.icon +!:mime image/x-icon +!:ext ico +>>>>4 uleshort x - %d icon +# plural s +>>>>4 uleshort >1 \bs +# 1st icon +>>>>0x06 use ico-entry +# 2nd icon +>>>>4 uleshort >1 +>>>>>0x16 use ico-entry +>>>0 ubelong 0x00000200 cursor resource +#!:mime image/x-cur +!:mime image/x-win-bitmap +!:ext cur +>>>>4 uleshort x - %d icon +>>>>4 uleshort >1 \bs +# 1st cursor +>>>>0x06 use cur-entry +#>>>>0x16 use cur-entry +# display information of one cursor entry +0 name cur-entry +>0 use cur-ico-entry +>4 uleshort x \b, hotspot @%dx +>6 uleshort x \b%d +# display information of one icon entry +0 name ico-entry +>0 use cur-ico-entry +# normally 0 1 but also found 14 +>4 uleshort >1 \b, %d planes +# normally 0 1 but also found some 3, 4, some 6, 8, 24, many 32, two 256 +>6 uleshort >1 \b, %d bits/pixel +# display shared information of cursor or icon entry +0 name cur-ico-entry +>0 byte =0 \b, 256x +>0 byte !0 \b, %dx +>1 byte =0 \b256 +>1 byte !0 \b%d +# number of colors in palette +>2 ubyte !0 \b, %d colors +# reserved 0 FFh +#>3 ubyte x \b, reserved %x +#>8 ulelong x \b, image size %d +# offset of PNG or DIB image +#>12 ulelong x \b, offset 0x%x +# PNG header (\x89PNG) +>(12.l) ubelong =0x89504e47 +>>&-4 indirect x \b with +# DIB image +>(12.l) ubelong !0x89504e47 +#>>&-4 use dib-image # Windows non-animated cursors -0 name cur-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->6 uleshort x \b, hotspot @%dx ->8 uleshort x \b%d - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows ICOn. container for BMP ( only DIB part) +# GRR: line below is too general as it catches also Lotus 1-2-3 files 0 belong 0x00000200 >9 byte 0 ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir # .chr files 0 string/b PK\010\010BGI Borland font Modified: vendor/file/dist/magic/Magdir/msx ============================================================================== --- vendor/file/dist/magic/Magdir/msx Sun Jun 26 20:33:28 2016 (r302217) +++ vendor/file/dist/magic/Magdir/msx Sun Jun 26 20:59:11 2016 (r302218) @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # msx: file(1) magic for the MSX Home Computer -# v1.1 +# v1.3 # Fabio R. Schmidlin ############## MSX Music file formats ############## @@ -99,34 +99,6 @@ >>5 uleshort 0 >>>3 uleshort >0x013D MSX Graph Saurus compressed image -# Maki-chan Graphic format -0 string/b MAKI02\ \ Maki-chan image, ->8 byte x system ID: %c ->9 byte x \b%c ->10 byte x \b%c ->11 byte x \b%c, ->13 search/0x200 \x1A -# >>&3 ubyte 0 , video mode: PC-98 400 lines, 16 analog colors -# >>&3 ubyte 1 , video mode: MSX SC7, 16 analog colors -# >>&3 ubyte 2 , video mode: VM-98 400 lines, 8 analog colors -# >>&3 ubyte 3 , video mode: PC-88 analog, 200 lines, 8 analog colors -# >>&3 ubyte 4 , video mode: 400 lines, 16 digital colors -# >>&3 ubyte 5 , video mode: 200 lines, 16 digital colors -# >>&3 ubyte 6 , video mode: old PC-98 digital 400 lines, 8 colors -# >>&3 ubyte 7 , video mode: PC-88 400 lines, 8 digital colors ->>&8 uleshort+1 x %dx ->>&10 uleshort+1 x \b%d, ->>&3 ubyte&0x82 0x80 256 colors ->>&3 ubyte&0x82 0x00 16 colors ->>&3 ubyte&0x82 0x01 8 colors ->>&3 ubyte&0x04 4 digital ->>&3 ubyte&0x04 0 analog ->>&3 ubyte&0x01 1 \b, 2:1 dot aspect ratio - -# Japanese PIC file -0 string/b PIC\x1A ->4 lelong 0 Japanese PIC image file - # MSX G9B image file 0 string/b G9B >1 uleshort 11 @@ -146,70 +118,152 @@ ############## Other MSX file formats ############## -# MSX ROMs +# MSX internal ROMs +0 ubeshort 0xF3C3 +>2 uleshort <0x4000 +>>8 ubyte 0xC3 +>>>9 uleshort <0x4000 +>>>>0x0B ubeshort 0x00C3 +>>>>>0x0D uleshort <0x4000 +>>>>>>0x0F ubeshort 0x00C3 +>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>0x13 ubeshort 0x00C3 +>>>>>>>>>0x15 uleshort <0x4000 +>>>>>>>>>>0x50 ubyte 0xC3 +>>>>>>>>>>>0x51 uleshort <0x4000 +>>>>>>>>>>>>(9.s) ubyte 0xC3 +>>>>>>>>>>>>>&0 uleshort >0x4000 +>>>>>>>>>>>>>>&0 ubyte 0xC3 MSX BIOS+BASIC +>>>>>>>>>>>>>>>0x002D ubyte+1 <3 \b. version=MSX%d +>>>>>>>>>>>>>>>0x002D ubyte 2 \b, version=MSX2+ +>>>>>>>>>>>>>>>0x002D ubyte 3 \b, version=MSX Turbo-R +>>>>>>>>>>>>>>>0x002D ubyte >3 \b, version=Unknown MSX %d version +>>>>>>>>>>>>>>>0x0006 ubyte x \b, VDP.DR=0x%2x +>>>>>>>>>>>>>>>0x0007 ubyte x \b, VDP.DW=0x%2x +>>>>>>>>>>>>>>>0x002B ubyte&0xF 0 \b, charset=Japanese +>>>>>>>>>>>>>>>0x002B ubyte&0xF 1 \b, charset=International +>>>>>>>>>>>>>>>0x002B ubyte&0xF 2 \b, charset=Korean +>>>>>>>>>>>>>>>0x002B ubyte&0xF >2 \b, charset=Unknown id:%d +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x00 \b, date format=Y-M-D +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x10 \b, date format=M-D-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x20 \b, date format=D-M-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x00 \b, vfreq=60Hz +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x80 \b, vfreq=50Hz +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 0 \b, keyboard=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 1 \b, keyboard=International +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 2 \b, keyboard=French +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 3 \b, keyboard=UK +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 4 \b, keyboard=German +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 5 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 6 \b, keyboard=Spanish +>>>>>>>>>>>>>>>0x002C ubyte&0x0F >6 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x00 \b, basic=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x10 \b, basic=International +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 >0x10 \b, basic=Unknown id:%d +>>>>>>>>>>>>>>>0x002E ubyte&1 1 \b, built-in MIDI + + +0 string/b CD +>2 uleshort >0x10 +>>2 uleshort <0x4000 +>>>4 uleshort <0x4000 +>>>>6 uleshort <0x4000 +>>>>>8 ubyte 0xC3 +>>>>>>9 uleshort <0x4000 +>>>>>>>0x10 ubyte 0xC3 +>>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>>0x14 ubyte 0xC3 +>>>>>>>>>>0x15 uleshort <0x4000 MSX2/2+/TR SubROM + +0 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 +>0x5F0 ubequad 0x8282828244380000 +>>0x150 ubyte 0x38 +>>>0x170 string \20\20\20 +>>>>0x1E32 string ()) +>>>>>0x2130 ubequad 0xA5A5594924231807 +>>>>>0x2138 ubequad 0x4A4A3424488830C0 MSX Kanji Font + + + +# MSX extension ROMs 0 string/b AB >2 uleshort 0x0010 MSX ROM >>2 uleshort x \b, init=0x%4x ->>4 uleshort >0 \b, stat=0x%4x ->>6 uleshort >0 \b, dev=0x%4x +>>4 uleshort >0 \b, stahdl=0x%4x +>>6 uleshort >0 \b, devhdl=0x%4x >>8 uleshort >0 \b, bas=0x%4x >2 uleshort 0x4010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x >2 uleshort 0x8010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x +0 string/b AB\0\0 +>6 uleshort 0 +>>4 uleshort >0x400F MSX-BASIC extension ROM +>>>4 uleshort >0 \b, stahdl=0x%04x +>>>6 uleshort >0 \b, devhdl=0x%04x +>>>0x1C string OPLL \b, MSX-Music +>>>>0x18 string PAC2 \b (external) +>>>>0x18 string APRL \b (internal) + +0 string/b AB\0\0\0\0 +>6 uleshort >0x400F MSX device BIOS +>>6 uleshort >0 \b, devhdl=0x%04x + 0 string/b AB #>2 string 5JSuperLAYDOCK MSX Super Laydock ROM #>3 string @HYDLIDE3MSX MSX Hydlide-3 ROM #>3 string @3\x80IA862 Golvellius MSX1 ROM ->2 uleshort >10 ->>10 string \0\0\0\0\0\0 MSX ROM ->>>0x10 string YZ\0\0\0\0 Konami Game Master 2 MSX ROM ->>>0x10 string CD \b, Konami RC- ->>>>0x12 ubyte x \b%d ->>>>0x13 ubyte/16 x \b%d ->>>>0x13 ubyte&0xF x \b%d ->>>0x10 string EF \b, Konami RC- *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sun Jun 26 21:00:12 2016 Return-Path: Delivered-To: svn-src-all@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 F1FC4B81370; Sun, 26 Jun 2016 21:00:12 +0000 (UTC) (envelope-from delphij@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 A931027AC; Sun, 26 Jun 2016 21:00:12 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5QL0B0S062121; Sun, 26 Jun 2016 21:00:11 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5QL0BaG062120; Sun, 26 Jun 2016 21:00:11 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606262100.u5QL0BaG062120@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 26 Jun 2016 21:00:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r302219 - vendor/file/5.28 X-SVN-Group: vendor 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.22 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: Sun, 26 Jun 2016 21:00:13 -0000 Author: delphij Date: Sun Jun 26 21:00:11 2016 New Revision: 302219 URL: https://svnweb.freebsd.org/changeset/base/302219 Log: Tag file 5.28. Added: vendor/file/5.28/ - copied from r302218, vendor/file/dist/ From owner-svn-src-all@freebsd.org Sun Jun 26 21:08:50 2016 Return-Path: Delivered-To: svn-src-all@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 19103B815C5 for ; Sun, 26 Jun 2016 21:08:50 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9367F2C06 for ; Sun, 26 Jun 2016 21:08:49 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x231.google.com with SMTP id v199so77876421wmv.0 for ; Sun, 26 Jun 2016 14:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Yj3klIjK4sxjXUAdvdcTDqeZlb3pO83nJpEXrC80aCg=; b=LBokRETdgK+gdDF5R8FjbDadMUelrVhb4SqAvDE73XzeSRaRuFJ0TxrFwbS3QsAZ1T veCVMq8zgVp7JysXwlJgzlBkMnHbE1f+P38MTgjTj+2C080Ss6iB+3BqoPnFOshukN/P j5LXOfQ4BV45r5JckbcGzAd1jVClViOlq063Y6UskwkX1Tyk9VsjiJwNNZ3UKAV4Gfoe hRtNOaIURdsxNF9qiv2joMxCnvkAvKrs6ysnOlglf9WKQTqXEQKSOYCMLwbrhDtWa+fm 9FXbVn+USHITA9OLKQac3C9Ybpy4EdhujDTP5BlMoMCvDCUI/l2g7TZ5FabFCL/Z0TRE dFWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Yj3klIjK4sxjXUAdvdcTDqeZlb3pO83nJpEXrC80aCg=; b=Tb127w6i36WAFRz86wR96/8a1QRiMCCA4QbA1VHvv6lLU5fCQJbhHgu/d2IzfC/4vA t7ytlGgDKqAa5hGlsf0SYXvQkVpEMnLzAWkI1XK5b1+cR9MgrSUvKy3boulAnJpYajHk F5zf2KuooC+4yoOhpyYlmy5wKMcg38yOFQ0Aia2cSbWd0YZ7pwez/keSin8ZgHGPAWoi t7sMtt6bOOQwBaBMO8kgL8159Rxat4niTjBBBZy7Bh66kqq4RAk92iiiAhwOl+HcVv9I 4ZM+umtpD3hky+2FyevmTTjK6Iwf769I7aVFiRXFRvRr7X5WIeNlt8Oxh2OzGVUzZVv2 ldYw== X-Gm-Message-State: ALyK8tKWA3+mgrGFB9HppVjFScD0GzqASNnyfs/kNm4Jj1fCkNXtNmx+p+Jm3oo1f3comEELGtSghMHD43o7Wv3U X-Received: by 10.28.30.149 with SMTP id e143mr7141492wme.81.1466975327740; Sun, 26 Jun 2016 14:08:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.45.33 with HTTP; Sun, 26 Jun 2016 14:08:46 -0700 (PDT) In-Reply-To: References: <201606210451.u5L4ptYP082074@repo.freebsd.org> From: Oliver Pinter Date: Sun, 26 Jun 2016 23:08:46 +0200 Message-ID: Subject: Re: svn commit: r302041 - in stable/10/sys: amd64/amd64 amd64/conf conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 i386/conf i386/i386 modules/hyperv/vmbus To: Sepherosa Ziehau Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sun, 26 Jun 2016 21:08:50 -0000 And the possible fix: diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 0430952..4ad96d7 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -404,7 +404,7 @@ vmbus_vector_alloc(void) /* * Search backwards form the highest IDT vector available for use - * as vmbus channel callback vector. We install 'hv_vmbus_callback' + * as vmbus channel callback vector. We install 'vmbus_isr' * handler at that vector and use it to interrupt vcpus. */ vector = APIC_SPURIOUS_INT; @@ -443,7 +443,7 @@ vmbus_vector_free(int vector) ip = &idt[vector]; func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset); - KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), + KASSERT(func == (uintptr_t)&IDTVEC(vmbus_isr), ("invalid vector %d", vector)); setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); On 6/26/16, Oliver Pinter wrote: > Hi all! > > Some from these hyper-v commits breaks the build with INVARIANTS > enabled kernel on 10-STABLE: > > ~~~ > /vmbus.c:446:30: error: use of undeclared identifier 'Xhv_vmbus_callback' > 14:13:13 KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), > ~~~ > > For more details please see this jenkins log: > http://jenkins.hardenedbsd.org:8180/jenkins/job/HardenedBSD-10-STABLE-amd64/462/console > > Btw, does anybody build an INVARIANTS enabled kernel in FreeBSD's > jenkins cluster with 10-STABLE? There are some other issues with > INVARIANTS, for example ZFS + GELI + 10-STABLE : > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209580 > > On 6/21/16, Sepherosa Ziehau wrote: >> Author: sephe >> Date: Tue Jun 21 04:51:55 2016 >> New Revision: 302041 >> URL: https://svnweb.freebsd.org/changeset/base/302041 >> >> Log: >> MFC 297931,298022 >> >> 297931 >> Expose doreti as a global symbol on amd64 and i386. >> >> doreti provides the common code path for returning from interrupt >> andlers on x86. Exposing doreti as a global symbol allows kernel >> modules to include low-level interrupt handlers instead of >> requiring >> all low-level handlers to be statically compiled into the kernel. >> >> Submitted by: Howard Su >> Reviewed by: kib >> >> 298022 >> hyperv: Deprecate HYPERV option by moving Hyper-V IDT vector into >> vmbus >> >> Submitted by: Jun Su >> Reviewed by: jhb, kib, sephe >> Sponsored by: Microsoft OSTC >> Differential Revision: https://reviews.freebsd.org/D5910 >> >> Added: >> stable/10/sys/dev/hyperv/vmbus/amd64/ >> - copied from r298022, head/sys/dev/hyperv/vmbus/amd64/ >> stable/10/sys/dev/hyperv/vmbus/i386/ >> - copied from r298022, head/sys/dev/hyperv/vmbus/i386/ >> Modified: >> stable/10/sys/amd64/amd64/apic_vector.S >> stable/10/sys/amd64/amd64/exception.S >> stable/10/sys/amd64/conf/GENERIC >> stable/10/sys/conf/files.amd64 >> stable/10/sys/conf/files.i386 >> stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c >> stable/10/sys/i386/conf/GENERIC >> stable/10/sys/i386/i386/apic_vector.s >> stable/10/sys/i386/i386/exception.s >> stable/10/sys/modules/hyperv/vmbus/Makefile >> Directory Properties: >> stable/10/ (props changed) >> >> Modified: stable/10/sys/amd64/amd64/apic_vector.S >> ============================================================================== >> --- stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 02:36:03 >> 2016 (r302040) >> +++ stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 04:51:55 >> 2016 (r302041) >> @@ -150,22 +150,6 @@ IDTVEC(xen_intr_upcall) >> jmp doreti >> #endif >> >> -#ifdef HYPERV >> -/* >> - * This is the Hyper-V vmbus channel direct callback interrupt. >> - * Only used when it is running on Hyper-V. >> - */ >> - .text >> - SUPERALIGN_TEXT >> -IDTVEC(hv_vmbus_callback) >> - PUSH_FRAME >> - FAKE_MCOUNT(TF_RIP(%rsp)) >> - movq %rsp, %rdi >> - call hv_vector_handler >> - MEXITCOUNT >> - jmp doreti >> -#endif >> - >> #ifdef SMP >> /* >> * Global address space TLB shootdown. >> >> Modified: stable/10/sys/amd64/amd64/exception.S >> ============================================================================== >> --- stable/10/sys/amd64/amd64/exception.S Tue Jun 21 02:36:03 >> 2016 (r302040) >> +++ stable/10/sys/amd64/amd64/exception.S Tue Jun 21 04:51:55 >> 2016 (r302041) >> @@ -661,6 +661,7 @@ MCOUNT_LABEL(eintr) >> .text >> SUPERALIGN_TEXT >> .type doreti,@function >> + .globl doreti >> doreti: >> FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ >> /* >> >> Modified: stable/10/sys/amd64/conf/GENERIC >> ============================================================================== >> --- stable/10/sys/amd64/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) >> +++ stable/10/sys/amd64/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) >> @@ -353,7 +353,6 @@ device virtio_scsi # VirtIO SCSI devic >> device virtio_balloon # VirtIO Memory Balloon device >> >> # HyperV drivers and enchancement support >> -# NOTE: HYPERV depends on hyperv. They must be added or removed >> together. >> options HYPERV # Hyper-V kernel infrastructure >> device hyperv # HyperV drivers >> >> >> Modified: stable/10/sys/conf/files.amd64 >> ============================================================================== >> --- stable/10/sys/conf/files.amd64 Tue Jun 21 02:36:03 2016 (r302040) >> +++ stable/10/sys/conf/files.amd64 Tue Jun 21 04:51:55 2016 (r302041) >> @@ -278,6 +278,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp >> dev/hyperv/vmbus/hv_et.c optional hyperv >> dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv >> dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv >> +dev/hyperv/vmbus/amd64/hv_vector.S optional hyperv >> dev/kbd/kbd.c optional atkbd | sc | ukbd | vt >> dev/lindev/full.c optional lindev >> dev/lindev/lindev.c optional lindev >> >> Modified: stable/10/sys/conf/files.i386 >> ============================================================================== >> --- stable/10/sys/conf/files.i386 Tue Jun 21 02:36:03 2016 (r302040) >> +++ stable/10/sys/conf/files.i386 Tue Jun 21 04:51:55 2016 (r302041) >> @@ -254,6 +254,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp >> dev/hyperv/vmbus/hv_et.c optional hyperv >> dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv >> dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv >> +dev/hyperv/vmbus/i386/hv_vector.S optional hyperv >> dev/ichwd/ichwd.c optional ichwd >> dev/if_ndis/if_ndis.c optional ndis >> dev/if_ndis/if_ndis_pccard.c optional ndis pccard >> >> Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c >> ============================================================================== >> --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 >> 02:36:03 2016 (r302040) >> +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 >> 04:51:55 2016 (r302041) >> @@ -370,7 +370,6 @@ vmbus_probe(device_t dev) { >> return (BUS_PROBE_DEFAULT); >> } >> >> -#ifdef HYPERV >> extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback); >> >> /** >> @@ -430,21 +429,6 @@ vmbus_vector_free(int vector) >> setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); >> } >> >> -#else /* HYPERV */ >> - >> -static int >> -vmbus_vector_alloc(void) >> -{ >> - return(0); >> -} >> - >> -static void >> -vmbus_vector_free(int vector) >> -{ >> -} >> - >> -#endif /* HYPERV */ >> - >> static void >> vmbus_cpuset_setthread_task(void *xmask, int pending __unused) >> { >> >> Modified: stable/10/sys/i386/conf/GENERIC >> ============================================================================== >> --- stable/10/sys/i386/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) >> +++ stable/10/sys/i386/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) >> @@ -362,7 +362,6 @@ device virtio_scsi # VirtIO SCSI devic >> device virtio_balloon # VirtIO Memory Balloon device >> >> # HyperV drivers and enchancement support >> -# NOTE: HYPERV depends on hyperv. They must be added or removed >> together. >> options HYPERV # Hyper-V kernel infrastructure >> device hyperv # HyperV drivers >> >> >> Modified: stable/10/sys/i386/i386/apic_vector.s >> ============================================================================== >> --- stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 02:36:03 >> 2016 (r302040) >> +++ stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 04:51:55 >> 2016 (r302041) >> @@ -157,25 +157,6 @@ IDTVEC(xen_intr_upcall) >> jmp doreti >> #endif >> >> -#ifdef HYPERV >> -/* >> - * This is the Hyper-V vmbus channel direct callback interrupt. >> - * Only used when it is running on Hyper-V. >> - */ >> - .text >> - SUPERALIGN_TEXT >> -IDTVEC(hv_vmbus_callback) >> - PUSH_FRAME >> - SET_KERNEL_SREGS >> - cld >> - FAKE_MCOUNT(TF_EIP(%esp)) >> - pushl %esp >> - call hv_vector_handler >> - add $4, %esp >> - MEXITCOUNT >> - jmp doreti >> -#endif >> - >> #ifdef SMP >> /* >> * Global address space TLB shootdown. >> >> Modified: stable/10/sys/i386/i386/exception.s >> ============================================================================== >> --- stable/10/sys/i386/i386/exception.s Tue Jun 21 02:36:03 >> 2016 (r302040) >> +++ stable/10/sys/i386/i386/exception.s Tue Jun 21 04:51:55 >> 2016 (r302041) >> @@ -344,6 +344,7 @@ MCOUNT_LABEL(eintr) >> .text >> SUPERALIGN_TEXT >> .type doreti,@function >> + .globl doreti >> doreti: >> FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ >> doreti_next: >> >> Modified: stable/10/sys/modules/hyperv/vmbus/Makefile >> ============================================================================== >> --- stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 02:36:03 >> 2016 (r302040) >> +++ stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 04:51:55 >> 2016 (r302041) >> @@ -1,7 +1,7 @@ >> # $FreeBSD$ >> >> .PATH: ${.CURDIR}/../../../dev/hyperv/vmbus \ >> - ${.CURDIR}/../../../dev/hyperv/utilities >> + ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH} >> >> KMOD= hv_vmbus >> SRCS= hv_channel.c \ >> @@ -14,8 +14,17 @@ SRCS= hv_channel.c \ >> hv_vmbus_priv.h >> SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h >> >> +# XXX: for assym.s >> +SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_hwpmc_hooks.h >> opt_compat.h >> + >> +SRCS+= assym.s \ >> + hv_vector.S >> + >> +hv_vector.o: >> + ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ >> + ${.IMPSRC} -o ${.TARGET} >> + >> CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ >> - -I${.CURDIR}/../../../dev/hyperv/vmbus \ >> - -I${.CURDIR}/../../../dev/hyperv/utilities >> + -I${.CURDIR}/../../../dev/hyperv/vmbus >> >> .include >> _______________________________________________ >> svn-src-stable-10@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 >> To unsubscribe, send any mail to >> "svn-src-stable-10-unsubscribe@freebsd.org" >> > From owner-svn-src-all@freebsd.org Mon Jun 27 01:17:01 2016 Return-Path: Delivered-To: svn-src-all@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 47381A79797; Mon, 27 Jun 2016 01:17:01 +0000 (UTC) (envelope-from sephe@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 169262B60; Mon, 27 Jun 2016 01:17:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5R1H0pu058040; Mon, 27 Jun 2016 01:17:00 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5R1H0JP058038; Mon, 27 Jun 2016 01:17:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606270117.u5R1H0JP058038@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 27 Jun 2016 01:17:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302220 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 01:17:01 -0000 Author: sephe Date: Mon Jun 27 01:17:00 2016 New Revision: 302220 URL: https://svnweb.freebsd.org/changeset/base/302220 Log: hyperv/vmbus: Fix mismerge of r301015 Submitted by: Oliver Pinter Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Sun Jun 26 21:00:11 2016 (r302219) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Mon Jun 27 01:17:00 2016 (r302220) @@ -404,7 +404,7 @@ vmbus_vector_alloc(void) /* * Search backwards form the highest IDT vector available for use - * as vmbus channel callback vector. We install 'hv_vmbus_callback' + * as vmbus channel callback vector. We install 'vmbus_isr' * handler at that vector and use it to interrupt vcpus. */ vector = APIC_SPURIOUS_INT; @@ -443,7 +443,7 @@ vmbus_vector_free(int vector) ip = &idt[vector]; func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset); - KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), + KASSERT(func == (uintptr_t)&IDTVEC(vmbus_isr), ("invalid vector %d", vector)); setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); From owner-svn-src-all@freebsd.org Mon Jun 27 01:17:30 2016 Return-Path: Delivered-To: svn-src-all@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 8D7DAA797FC; Mon, 27 Jun 2016 01:17:30 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-vk0-x243.google.com (mail-vk0-x243.google.com [IPv6:2607:f8b0:400c:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4A4B42CAF; Mon, 27 Jun 2016 01:17:30 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-vk0-x243.google.com with SMTP id v188so26711336vkf.3; Sun, 26 Jun 2016 18:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DsOnVlEzNdl45/fTlrgDjky/My5lXLclZb91aJVd++c=; b=Tvi/p4Q/joM6DyznC5Vu4w8lQx57sKS1ibgxW93OTMgmRIZcHJ5SigZswtjAeqb3VX a65U9Ann7ZZcVX6Xphgbi8NLbRQ6d8PiDRI9L6aWqteZlsOAbeprG3/SloZBs0qbIjac vixqif0Zm7ss0CakqrmJ3nMdRBcngdQw9vFbbxkPAxi2xV6q71xXaX13XL0q16yiMI0v gSnJbBLJwTUNxfDhfNvbouANARDyY6Mzdrc0xEVfK0XpCKG0RNPsa/1EygmeeonQT/jn 6vSLN9+8r6sSwmRjiajHqW1IJXFEG6dauZEiw6x4z8lM+7omgjqFtBRPqlajcOTwTeX1 5T3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=DsOnVlEzNdl45/fTlrgDjky/My5lXLclZb91aJVd++c=; b=d7F1xrrfop/PiYUArQrAWD3dAfXXCWgQLckGLbLn2RRUsetXvSxrXilK56wQ3EnRua jt+MDEQrlnH5T6KOyCD8LbaOHUw+v76+bzJGqPlLkPaqsEV5N0A3e32pQb14LxfQl4l/ SvHLBfK0Fmp+NjyQvqlaERb28ahygkAS/YFWhrb1din1gpsnhItGhoutCNb1G7Vh6QdT u+sDvbk+p/JCtcrjpVO/sg9Wwuz7liaZAgXPnt10VaE/3qqUTJFd+MJWYGmZtoG2dV1a 2eq4hk4xWFMEYOW4hbHWpQY40pJjhGCtOdJiGIXyguIB5M55uhkk6SfAbnyfmC0unXEf +8fA== X-Gm-Message-State: ALyK8tL4IR+nq/qcVKK7AnwW2bYBUcl+am43cqgoYueNSFHs3u2M3cr7NA4QhmxUFBVol4SNVf2ZmeACPvW7rQ== X-Received: by 10.31.191.72 with SMTP id p69mr7463506vkf.11.1466990249167; Sun, 26 Jun 2016 18:17:29 -0700 (PDT) MIME-Version: 1.0 Sender: sepherosa@gmail.com Received: by 10.159.37.1 with HTTP; Sun, 26 Jun 2016 18:17:28 -0700 (PDT) In-Reply-To: References: <201606210451.u5L4ptYP082074@repo.freebsd.org> From: Sepherosa Ziehau Date: Mon, 27 Jun 2016 09:17:28 +0800 X-Google-Sender-Auth: 6cn28PKv-ghoHPVvTADCw8tV96o Message-ID: Subject: Re: svn commit: r302041 - in stable/10/sys: amd64/amd64 amd64/conf conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 i386/conf i386/i386 modules/hyperv/vmbus To: Oliver Pinter Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 01:17:30 -0000 Committed, thank you very much! And sorry for the breakage. On Mon, Jun 27, 2016 at 5:08 AM, Oliver Pinter wrote: > And the possible fix: > > diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c > index 0430952..4ad96d7 100644 > --- a/sys/dev/hyperv/vmbus/vmbus.c > +++ b/sys/dev/hyperv/vmbus/vmbus.c > @@ -404,7 +404,7 @@ vmbus_vector_alloc(void) > > /* > * Search backwards form the highest IDT vector available for use > - * as vmbus channel callback vector. We install 'hv_vmbus_callback' > + * as vmbus channel callback vector. We install 'vmbus_isr' > * handler at that vector and use it to interrupt vcpus. > */ > vector = APIC_SPURIOUS_INT; > @@ -443,7 +443,7 @@ vmbus_vector_free(int vector) > > ip = &idt[vector]; > func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset); > - KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), > + KASSERT(func == (uintptr_t)&IDTVEC(vmbus_isr), > ("invalid vector %d", vector)); > > setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); > > On 6/26/16, Oliver Pinter wrote: >> Hi all! >> >> Some from these hyper-v commits breaks the build with INVARIANTS >> enabled kernel on 10-STABLE: >> >> ~~~ >> /vmbus.c:446:30: error: use of undeclared identifier 'Xhv_vmbus_callback' >> 14:13:13 KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback), >> ~~~ >> >> For more details please see this jenkins log: >> http://jenkins.hardenedbsd.org:8180/jenkins/job/HardenedBSD-10-STABLE-amd64/462/console >> >> Btw, does anybody build an INVARIANTS enabled kernel in FreeBSD's >> jenkins cluster with 10-STABLE? There are some other issues with >> INVARIANTS, for example ZFS + GELI + 10-STABLE : >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209580 >> >> On 6/21/16, Sepherosa Ziehau wrote: >>> Author: sephe >>> Date: Tue Jun 21 04:51:55 2016 >>> New Revision: 302041 >>> URL: https://svnweb.freebsd.org/changeset/base/302041 >>> >>> Log: >>> MFC 297931,298022 >>> >>> 297931 >>> Expose doreti as a global symbol on amd64 and i386. >>> >>> doreti provides the common code path for returning from interrupt >>> andlers on x86. Exposing doreti as a global symbol allows kernel >>> modules to include low-level interrupt handlers instead of >>> requiring >>> all low-level handlers to be statically compiled into the kernel. >>> >>> Submitted by: Howard Su >>> Reviewed by: kib >>> >>> 298022 >>> hyperv: Deprecate HYPERV option by moving Hyper-V IDT vector into >>> vmbus >>> >>> Submitted by: Jun Su >>> Reviewed by: jhb, kib, sephe >>> Sponsored by: Microsoft OSTC >>> Differential Revision: https://reviews.freebsd.org/D5910 >>> >>> Added: >>> stable/10/sys/dev/hyperv/vmbus/amd64/ >>> - copied from r298022, head/sys/dev/hyperv/vmbus/amd64/ >>> stable/10/sys/dev/hyperv/vmbus/i386/ >>> - copied from r298022, head/sys/dev/hyperv/vmbus/i386/ >>> Modified: >>> stable/10/sys/amd64/amd64/apic_vector.S >>> stable/10/sys/amd64/amd64/exception.S >>> stable/10/sys/amd64/conf/GENERIC >>> stable/10/sys/conf/files.amd64 >>> stable/10/sys/conf/files.i386 >>> stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c >>> stable/10/sys/i386/conf/GENERIC >>> stable/10/sys/i386/i386/apic_vector.s >>> stable/10/sys/i386/i386/exception.s >>> stable/10/sys/modules/hyperv/vmbus/Makefile >>> Directory Properties: >>> stable/10/ (props changed) >>> >>> Modified: stable/10/sys/amd64/amd64/apic_vector.S >>> ============================================================================== >>> --- stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 02:36:03 >>> 2016 (r302040) >>> +++ stable/10/sys/amd64/amd64/apic_vector.S Tue Jun 21 04:51:55 >>> 2016 (r302041) >>> @@ -150,22 +150,6 @@ IDTVEC(xen_intr_upcall) >>> jmp doreti >>> #endif >>> >>> -#ifdef HYPERV >>> -/* >>> - * This is the Hyper-V vmbus channel direct callback interrupt. >>> - * Only used when it is running on Hyper-V. >>> - */ >>> - .text >>> - SUPERALIGN_TEXT >>> -IDTVEC(hv_vmbus_callback) >>> - PUSH_FRAME >>> - FAKE_MCOUNT(TF_RIP(%rsp)) >>> - movq %rsp, %rdi >>> - call hv_vector_handler >>> - MEXITCOUNT >>> - jmp doreti >>> -#endif >>> - >>> #ifdef SMP >>> /* >>> * Global address space TLB shootdown. >>> >>> Modified: stable/10/sys/amd64/amd64/exception.S >>> ============================================================================== >>> --- stable/10/sys/amd64/amd64/exception.S Tue Jun 21 02:36:03 >>> 2016 (r302040) >>> +++ stable/10/sys/amd64/amd64/exception.S Tue Jun 21 04:51:55 >>> 2016 (r302041) >>> @@ -661,6 +661,7 @@ MCOUNT_LABEL(eintr) >>> .text >>> SUPERALIGN_TEXT >>> .type doreti,@function >>> + .globl doreti >>> doreti: >>> FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ >>> /* >>> >>> Modified: stable/10/sys/amd64/conf/GENERIC >>> ============================================================================== >>> --- stable/10/sys/amd64/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) >>> +++ stable/10/sys/amd64/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) >>> @@ -353,7 +353,6 @@ device virtio_scsi # VirtIO SCSI devic >>> device virtio_balloon # VirtIO Memory Balloon device >>> >>> # HyperV drivers and enchancement support >>> -# NOTE: HYPERV depends on hyperv. They must be added or removed >>> together. >>> options HYPERV # Hyper-V kernel infrastructure >>> device hyperv # HyperV drivers >>> >>> >>> Modified: stable/10/sys/conf/files.amd64 >>> ============================================================================== >>> --- stable/10/sys/conf/files.amd64 Tue Jun 21 02:36:03 2016 (r302040) >>> +++ stable/10/sys/conf/files.amd64 Tue Jun 21 04:51:55 2016 (r302041) >>> @@ -278,6 +278,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp >>> dev/hyperv/vmbus/hv_et.c optional hyperv >>> dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv >>> dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv >>> +dev/hyperv/vmbus/amd64/hv_vector.S optional hyperv >>> dev/kbd/kbd.c optional atkbd | sc | ukbd | vt >>> dev/lindev/full.c optional lindev >>> dev/lindev/lindev.c optional lindev >>> >>> Modified: stable/10/sys/conf/files.i386 >>> ============================================================================== >>> --- stable/10/sys/conf/files.i386 Tue Jun 21 02:36:03 2016 (r302040) >>> +++ stable/10/sys/conf/files.i386 Tue Jun 21 04:51:55 2016 (r302041) >>> @@ -254,6 +254,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyp >>> dev/hyperv/vmbus/hv_et.c optional hyperv >>> dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv >>> dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv >>> +dev/hyperv/vmbus/i386/hv_vector.S optional hyperv >>> dev/ichwd/ichwd.c optional ichwd >>> dev/if_ndis/if_ndis.c optional ndis >>> dev/if_ndis/if_ndis_pccard.c optional ndis pccard >>> >>> Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c >>> ============================================================================== >>> --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 >>> 02:36:03 2016 (r302040) >>> +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Tue Jun 21 >>> 04:51:55 2016 (r302041) >>> @@ -370,7 +370,6 @@ vmbus_probe(device_t dev) { >>> return (BUS_PROBE_DEFAULT); >>> } >>> >>> -#ifdef HYPERV >>> extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback); >>> >>> /** >>> @@ -430,21 +429,6 @@ vmbus_vector_free(int vector) >>> setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); >>> } >>> >>> -#else /* HYPERV */ >>> - >>> -static int >>> -vmbus_vector_alloc(void) >>> -{ >>> - return(0); >>> -} >>> - >>> -static void >>> -vmbus_vector_free(int vector) >>> -{ >>> -} >>> - >>> -#endif /* HYPERV */ >>> - >>> static void >>> vmbus_cpuset_setthread_task(void *xmask, int pending __unused) >>> { >>> >>> Modified: stable/10/sys/i386/conf/GENERIC >>> ============================================================================== >>> --- stable/10/sys/i386/conf/GENERIC Tue Jun 21 02:36:03 2016 (r302040) >>> +++ stable/10/sys/i386/conf/GENERIC Tue Jun 21 04:51:55 2016 (r302041) >>> @@ -362,7 +362,6 @@ device virtio_scsi # VirtIO SCSI devic >>> device virtio_balloon # VirtIO Memory Balloon device >>> >>> # HyperV drivers and enchancement support >>> -# NOTE: HYPERV depends on hyperv. They must be added or removed >>> together. >>> options HYPERV # Hyper-V kernel infrastructure >>> device hyperv # HyperV drivers >>> >>> >>> Modified: stable/10/sys/i386/i386/apic_vector.s >>> ============================================================================== >>> --- stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 02:36:03 >>> 2016 (r302040) >>> +++ stable/10/sys/i386/i386/apic_vector.s Tue Jun 21 04:51:55 >>> 2016 (r302041) >>> @@ -157,25 +157,6 @@ IDTVEC(xen_intr_upcall) >>> jmp doreti >>> #endif >>> >>> -#ifdef HYPERV >>> -/* >>> - * This is the Hyper-V vmbus channel direct callback interrupt. >>> - * Only used when it is running on Hyper-V. >>> - */ >>> - .text >>> - SUPERALIGN_TEXT >>> -IDTVEC(hv_vmbus_callback) >>> - PUSH_FRAME >>> - SET_KERNEL_SREGS >>> - cld >>> - FAKE_MCOUNT(TF_EIP(%esp)) >>> - pushl %esp >>> - call hv_vector_handler >>> - add $4, %esp >>> - MEXITCOUNT >>> - jmp doreti >>> -#endif >>> - >>> #ifdef SMP >>> /* >>> * Global address space TLB shootdown. >>> >>> Modified: stable/10/sys/i386/i386/exception.s >>> ============================================================================== >>> --- stable/10/sys/i386/i386/exception.s Tue Jun 21 02:36:03 >>> 2016 (r302040) >>> +++ stable/10/sys/i386/i386/exception.s Tue Jun 21 04:51:55 >>> 2016 (r302041) >>> @@ -344,6 +344,7 @@ MCOUNT_LABEL(eintr) >>> .text >>> SUPERALIGN_TEXT >>> .type doreti,@function >>> + .globl doreti >>> doreti: >>> FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */ >>> doreti_next: >>> >>> Modified: stable/10/sys/modules/hyperv/vmbus/Makefile >>> ============================================================================== >>> --- stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 02:36:03 >>> 2016 (r302040) >>> +++ stable/10/sys/modules/hyperv/vmbus/Makefile Tue Jun 21 04:51:55 >>> 2016 (r302041) >>> @@ -1,7 +1,7 @@ >>> # $FreeBSD$ >>> >>> .PATH: ${.CURDIR}/../../../dev/hyperv/vmbus \ >>> - ${.CURDIR}/../../../dev/hyperv/utilities >>> + ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH} >>> >>> KMOD= hv_vmbus >>> SRCS= hv_channel.c \ >>> @@ -14,8 +14,17 @@ SRCS= hv_channel.c \ >>> hv_vmbus_priv.h >>> SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h >>> >>> +# XXX: for assym.s >>> +SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_hwpmc_hooks.h >>> opt_compat.h >>> + >>> +SRCS+= assym.s \ >>> + hv_vector.S >>> + >>> +hv_vector.o: >>> + ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ >>> + ${.IMPSRC} -o ${.TARGET} >>> + >>> CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ >>> - -I${.CURDIR}/../../../dev/hyperv/vmbus \ >>> - -I${.CURDIR}/../../../dev/hyperv/utilities >>> + -I${.CURDIR}/../../../dev/hyperv/vmbus >>> >>> .include >>> _______________________________________________ >>> svn-src-stable-10@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 >>> To unsubscribe, send any mail to >>> "svn-src-stable-10-unsubscribe@freebsd.org" >>> >> -- Tomorrow Will Never Die From owner-svn-src-all@freebsd.org Mon Jun 27 01:29:20 2016 Return-Path: Delivered-To: svn-src-all@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 82603A79B56; Mon, 27 Jun 2016 01:29:20 +0000 (UTC) (envelope-from delphij@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 205682124; Mon, 27 Jun 2016 01:29:20 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5R1TJ0Q062139; Mon, 27 Jun 2016 01:29:19 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5R1TIHg062125; Mon, 27 Jun 2016 01:29:18 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606270129.u5R1TIHg062125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 27 Jun 2016 01:29:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302221 - in head: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/src lib/libmagic X-SVN-Group: head 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.22 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: Mon, 27 Jun 2016 01:29:20 -0000 Author: delphij Date: Mon Jun 27 01:29:17 2016 New Revision: 302221 URL: https://svnweb.freebsd.org/changeset/base/302221 Log: MFV r302218: file 5.28. Relnotes: yes MFC after: 2 weeks Approved by: re (gjb) Added: head/contrib/file/magic/Magdir/ber - copied unchanged from r302218, vendor/file/dist/magic/Magdir/ber head/contrib/file/magic/Magdir/coverage - copied unchanged from r302218, vendor/file/dist/magic/Magdir/coverage head/contrib/file/magic/Magdir/pc88 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/pc88 head/contrib/file/magic/Magdir/pc98 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/pc98 head/contrib/file/magic/Magdir/x68000 - copied unchanged from r302218, vendor/file/dist/magic/Magdir/x68000 Deleted: head/contrib/file/src/magic.h Modified: head/contrib/file/ChangeLog head/contrib/file/config.h.in head/contrib/file/configure head/contrib/file/configure.ac head/contrib/file/doc/file.man head/contrib/file/magic/Magdir/c-lang head/contrib/file/magic/Magdir/console head/contrib/file/magic/Magdir/database head/contrib/file/magic/Magdir/elf head/contrib/file/magic/Magdir/msdos head/contrib/file/magic/Magdir/msx head/contrib/file/magic/Magdir/perl head/contrib/file/magic/Makefile.am head/contrib/file/magic/Makefile.in head/contrib/file/src/Makefile.am head/contrib/file/src/Makefile.in head/contrib/file/src/apprentice.c head/contrib/file/src/cdf.c head/contrib/file/src/compress.c head/contrib/file/src/der.c head/contrib/file/src/file.c head/contrib/file/src/softmagic.c head/lib/libmagic/Makefile head/lib/libmagic/config.h Directory Properties: head/contrib/file/ (props changed) Modified: head/contrib/file/ChangeLog ============================================================================== --- head/contrib/file/ChangeLog Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/ChangeLog Mon Jun 27 01:29:17 2016 (r302221) @@ -1,3 +1,15 @@ +2016-06-13 19:40 Christos Zoulas + + * release 5.28 + * fix leak on allocation failure + +2016-06-01 1:20 Christos Zoulas + + * PR/555: Avoid overflow for offset > nbytes + * PR/550: Segv on DER parsing: + - use the correct variable for length + - set offset to 0 on failure. + 2016-05-13 12:00 Christos Zoulas * release 5.27 Modified: head/contrib/file/config.h.in ============================================================================== --- head/contrib/file/config.h.in Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/config.h.in Mon Jun 27 01:29:17 2016 (r302221) @@ -328,6 +328,9 @@ # endif #endif +/* Enable zlib compression support */ +#undef ZLIBSUPPORT + /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 Modified: head/contrib/file/configure ============================================================================== --- head/contrib/file/configure Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/configure Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.27. +# Generated by GNU Autoconf 2.69 for file 5.28. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.27' -PACKAGE_STRING='file 5.27' +PACKAGE_VERSION='5.28' +PACKAGE_STRING='file 5.28' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -766,6 +766,7 @@ enable_option_checking enable_silent_rules enable_elf enable_elf_core +enable_zlib enable_fsect_man5 enable_dependency_tracking enable_static @@ -1327,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.27 to adapt to many kinds of systems. +\`configure' configures file 5.28 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1397,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.27:";; + short | recursive ) echo "Configuration of file 5.28:";; esac cat <<\_ACEOF @@ -1409,6 +1410,7 @@ Optional Features: --disable-silent-rules verbose build output (undo: "make V=0") --disable-elf disable builtin ELF support --disable-elf-core disable ELF core file support + --disable-zlib disable zlib compression support [default=auto] --enable-fsect-man5 enable file formats in man section 5 --enable-dependency-tracking do not reject slow dependency extractors @@ -1507,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.27 +file configure 5.28 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2163,7 +2165,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.27, which was +It was created by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3029,7 +3031,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.27' + VERSION='5.28' cat >>confdefs.h <<_ACEOF @@ -3218,6 +3220,16 @@ $as_echo "#define ELFCORE 1" >>confdefs. fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib support" >&5 +$as_echo_n "checking for zlib support... " >&6; } +# Check whether --enable-zlib was given. +if test "${enable_zlib+set}" = set; then : + enableval=$enable_zlib; +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_zlib" >&5 +$as_echo "$enable_zlib" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file formats in man section 5" >&5 $as_echo_n "checking for file formats in man section 5... " >&6; } # Check whether --enable-fsect-man5 was given. @@ -12812,7 +12824,8 @@ fi done -for ac_header in zlib.h +if test "$enable_zlib" != "no"; then + for ac_header in zlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes; then : @@ -12824,6 +12837,7 @@ fi done +fi ac_fn_c_check_type "$LINENO" "sig_t" "ac_cv_type_sig_t" " #ifdef HAVE_SIGNAL_H #include @@ -14400,7 +14414,8 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 +if test "$enable_zlib" != "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5 $as_echo_n "checking for gzopen in -lz... " >&6; } if ${ac_cv_lib_z_gzopen+:} false; then : $as_echo_n "(cached) " >&6 @@ -14445,6 +14460,7 @@ _ACEOF fi +fi if test "$MINGW" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for regexec in -lgnurx" >&5 $as_echo_n "checking for regexec in -lgnurx... " >&6; } @@ -14504,6 +14520,16 @@ else fi +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + as_fn_error $? "zlib support requested but not found" "$LINENO" 5 + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + +$as_echo "#define ZLIBSUPPORT 1" >>confdefs.h + +fi + ac_config_files="$ac_config_files Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile" cat >confcache <<\_ACEOF @@ -15049,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.27, which was +This file was extended by file $as_me 5.28, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15115,7 +15141,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.27 +file config.status 5.28 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: head/contrib/file/configure.ac ============================================================================== --- head/contrib/file/configure.ac Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/configure.ac Mon Jun 27 01:29:17 2016 (r302221) @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.27],[christos@astron.com]) +AC_INIT([file],[5.28],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -34,6 +34,11 @@ fi], [ AC_DEFINE([ELFCORE], 1, [Define for ELF core file support]) ]) +AC_MSG_CHECKING(for zlib support) +AC_ARG_ENABLE(zlib, +[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])]) +AC_MSG_RESULT($enable_zlib) + AC_MSG_CHECKING(for file formats in man section 5) AC_ARG_ENABLE(fsect-man5, [ --enable-fsect-man5 enable file formats in man section 5], @@ -84,7 +89,9 @@ AC_CHECK_HEADERS(stdint.h fcntl.h locale AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h) AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h) -AC_CHECK_HEADERS(zlib.h) +if test "$enable_zlib" != "no"; then + AC_CHECK_HEADERS(zlib.h) +fi AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[ #ifdef HAVE_SIGNAL_H #include @@ -148,7 +155,9 @@ dnl Provide implementation of some requi AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf) dnl Checks for libraries -AC_CHECK_LIB(z,gzopen) +if test "$enable_zlib" != "no"; then + AC_CHECK_LIB(z, gzopen) +fi if test "$MINGW" = 1; then AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW])) fi @@ -156,5 +165,14 @@ fi dnl See if we are cross-compiling AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes) +dnl Final sanity checks +if test "$enable_zlib" = "yes"; then + if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then + AC_MSG_ERROR([zlib support requested but not found]) + fi +elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then + AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support]) +fi + AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile]) AC_OUTPUT Modified: head/contrib/file/doc/file.man ============================================================================== --- head/contrib/file/doc/file.man Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/doc/file.man Mon Jun 27 01:29:17 2016 (r302221) @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.120 2016/03/31 17:51:12 christos Exp $ +.\" $File: file.man,v 1.121 2016/06/07 22:09:20 rrt Exp $ .Dd March 13, 2016 .Dt FILE __CSECTION__ .Os @@ -213,6 +213,9 @@ Prints ELF file details. Consults magic files. .It tar Examines tar files. +.It text +A synonym for +.Sq ascii . .El .It Fl Fl extension Print a slash-separated list of valid extensions for the file type found. Copied: head/contrib/file/magic/Magdir/ber (from r302218, vendor/file/dist/magic/Magdir/ber) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/file/magic/Magdir/ber Mon Jun 27 01:29:17 2016 (r302221, copy of r302218, vendor/file/dist/magic/Magdir/ber) @@ -0,0 +1,65 @@ + +#------------------------------------------------------------------------------ +# $File: ber,v 1.1 2016/06/05 00:21:30 christos Exp $ +# ber: file(1) magic for several BER formats used in the mobile +# telecommunications industry (Georg Sauthoff) + +# The file formats are standardized by the GSMA (GSM association). +# They are specified via ASN.1 schemas and some prose. Basic encoding +# rules (BER) is the used encoding. The formats are used for exchanging +# call data records (CDRs) between mobile operators and associated +# parties for roaming clearing purposes and fraud detection. + +# The magic file covers: + +# - TAP files (TD.57) - CDR batches and notifications +# - RAP files (TD.32) - return batches and acknowledgements +# - NRT files (TD.35) - CDR batches for 'near real time' processing + +# +# TAP 3 Files +# TAP -> Transferred Account Procedure +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.57-v32.31.pdf +# TransferBatch short tag +0 byte 0x61 +# BatchControlInfo short tag +>&1 search/b5 \x64 +# Sender long tag #TAP 3.x (BER encoded) +>>&1 search/b8 \x5f\x81\x44 +# 3 block +>>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>>&0 byte x TAP 3.%d Batch (TD.57, Transferred Account) + +# Notification short tag +0 byte 0x62 +# Sender long tag +>2 search/b8 \x5f\x81\x44 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +>>>&0 byte x TAP 3.%d Notification (TD.57, Transferred Account) + + +# NRT Files +# NRT a.k.a. NRTRDE +0 byte 0x61 +# 2 block +>&1 search/b8 \x5f\x29\x01\x02\x5f\x25\x01 +>>&0 byte x NRT 2.%d (TD.35, Near Real Time Roaming Data Exchange) + +# RAP Files +# cf. http://www.gsma.com/newsroom/wp-content/uploads/TD.32-v6.11.pdf +# Long ReturnBatch tag +0 string \x7f\x84\x16 +# Long RapBatchControlInfo tag +>&1 search/b8 \x7f\x84\x19 +# 3 block +>>&64 search/b64 \x5f\x81\x49\x01\x03\x5f\x81\x3d\x01 +# 1 block +>>>&1 string/b \x5f\x84\x20\x01\x01\x5f\x84\x1f\x01 +>>>>&0 byte x RAP 1.%d Batch (TD.32, Returned Account Procedure), +>>>&0 byte x TAP 3.%d + +# Long Acknowledgement tag +0 string \x7f\x84\x17 +# Long Sender tag +>&1 search/b5 \x5f\x81\x44 RAP Acknowledgement (TD.32, Returned Account Procedure) Modified: head/contrib/file/magic/Magdir/c-lang ============================================================================== --- head/contrib/file/magic/Magdir/c-lang Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/c-lang Mon Jun 27 01:29:17 2016 (r302221) @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: c-lang,v 1.22 2015/10/29 18:49:11 christos Exp $ +# $File: c-lang,v 1.23 2016/05/21 14:28:27 christos Exp $ # c-lang: file(1) magic for C and related languages programs # # The strength is to beat standard HTML @@ -38,7 +38,8 @@ !:strength + 30 !:mime text/x-c++ 0 regex \^class[\ \t\n]+ C++ source text -!:strength + 30 +# But class is reduced to avoid beating php (Jens Schleusener) +!:strength + 13 !:mime text/x-c++ 0 regex \^public: C++ source text !:strength + 30 Modified: head/contrib/file/magic/Magdir/console ============================================================================== --- head/contrib/file/magic/Magdir/console Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/console Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: console,v 1.25 2016/04/18 20:22:10 christos Exp $ +# $File: console,v 1.26 2016/06/12 15:20:37 christos Exp $ # Console game magic # Toby Deshane @@ -56,6 +56,32 @@ >4 lelong <16 UNIF v%d format NES ROM image #------------------------------------------------------------------------------ +# fds: file(1) magic for Famciom Disk System disk images +# Reference: http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format +# From: David Korth +# TODO: Check "Disk info block" and get info from that in addition to the optional header. + +# Disk info block. (block 1) +0 name nintendo-fds-disk-info-block +>1 string *NINTENDO-HVC* Famicom Disk System disk image: +>23 byte !1 FMC- +>23 byte 1 FSC- +>16 string x \b%.3s +>15 byte x \b, mfr 0x%02X +>20 byte x (Rev.%02u) + +# Headered version. +0 string FDS\x1A +>0x11 string *NINTENDO-HVC* +>>0x10 use nintendo-fds-disk-info-block +>4 byte 1 (%u side) +>4 byte !1 (%u sides) + +# Unheadered version. +1 string *NINTENDO-HVC* +>0 use nintendo-fds-disk-info-block + +#------------------------------------------------------------------------------ # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header # @@ -569,6 +595,15 @@ 0x1C belong 0xC2339F3D Nintendo GameCube disc image: >0 use nintendo-gcn-disc-common +# Type: Nintendo GameCube embedded disc image +# Commonly found on demo discs. +# From: David Korth +# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8 +0 belong 0xAE0F38A2 +>0x0C belong 0x00100000 +>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image: +>>>(8.L) use nintendo-gcn-disc-common + # Type: Nintendo Wii disc image # From: David Korth # Reference: http://wiibrew.org/wiki/Wii_Disc @@ -586,22 +621,15 @@ # Nintendo 3DS file formats. # -# Type: Nintendo 3DS "NCCH" header. -# Contained within either a CXI executable or an NCSD image. -# From: David Korth -# Reference: https://www.3dbrew.org/wiki/NCCH -0 name nintendo-3ds-NCCH ->0x100 string NCCH ->>0x150 string >\0 \b: "%.16s" ->>0x112 leshort x (v%u) ->>0x18C byte 2 (New3DS only) - # Type: Nintendo 3DS "NCSD" image. (game cards and eMMC) # From: David Korth # Reference: https://www.3dbrew.org/wiki/NCSD 0x100 string NCSD >0x118 lequad 0 Nintendo 3DS Game Card image ->>0x1000 use nintendo-3ds-NCCH +# NCCH header for partition 0. (game data) +>>0x1150 string >\0 \b: "%.16s" +>>0x312 byte x (Rev.%02u) +>>0x118C byte 2 (New3DS only) >>0x18D byte 0 (inner device) >>0x18D byte 1 (Card1) >>0x18D byte 2 (Card2) @@ -609,12 +637,74 @@ >0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS) >0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS) +# Nintendo 3DS version code. +# Reference: https://www.3dbrew.org/wiki/Titles +# Format: leshort containing three fields: +# - 6-bit: Major +# - 6-bit: Minor +# - 4-bit: Revision +# NOTE: Only supporting major/minor versions from 0-15 right now. +# NOTE: Should be prefixed with "v". +0 name nintendo-3ds-version-code +# Raw version. +>0 leshort x \b%u, +# Major version. +>0 leshort&0xFC00 0x0000 0 +>0 leshort&0xFC00 0x0400 1 +>0 leshort&0xFC00 0x0800 2 +>0 leshort&0xFC00 0x0C00 3 +>0 leshort&0xFC00 0x1000 4 +>0 leshort&0xFC00 0x1400 5 +>0 leshort&0xFC00 0x1800 6 +>0 leshort&0xFC00 0x1C00 7 +>0 leshort&0xFC00 0x2000 8 +>0 leshort&0xFC00 0x2400 9 +>0 leshort&0xFC00 0x2800 10 +>0 leshort&0xFC00 0x2C00 11 +>0 leshort&0xFC00 0x3000 12 +>0 leshort&0xFC00 0x3400 13 +>0 leshort&0xFC00 0x3800 14 +>0 leshort&0xFC00 0x3C00 15 +# Minor version. +>0 leshort&0x03F0 0x0000 \b.0 +>0 leshort&0x03F0 0x0010 \b.1 +>0 leshort&0x03F0 0x0020 \b.2 +>0 leshort&0x03F0 0x0030 \b.3 +>0 leshort&0x03F0 0x0040 \b.4 +>0 leshort&0x03F0 0x0050 \b.5 +>0 leshort&0x03F0 0x0060 \b.6 +>0 leshort&0x03F0 0x0070 \b.7 +>0 leshort&0x03F0 0x0080 \b.8 +>0 leshort&0x03F0 0x0090 \b.9 +>0 leshort&0x03F0 0x00A0 \b.10 +>0 leshort&0x03F0 0x00B0 \b.11 +>0 leshort&0x03F0 0x00C0 \b.12 +>0 leshort&0x03F0 0x00D0 \b.13 +>0 leshort&0x03F0 0x00E0 \b.14 +>0 leshort&0x03F0 0x00F0 \b.15 +# Revision. +>0 leshort&0x000F x \b.%u + # Type: Nintendo 3DS "NCCH" container. # https://www.3dbrew.org/wiki/NCCH -0x100 string NCCH Nintendo 3DS ->0x18D byte&2 0 File Archive (CFA) ->0x18D byte&2 2 Executable Image (CXI) ->0 use nintendo-3ds-NCCH +0x100 string NCCH Nintendo 3DS +>0x18D byte&2 0 File Archive (CFA) +>0x18D byte&2 2 Executable Image (CXI) +>0x150 string >\0 \b: "%.16s" +>0x18D byte 0x05 +>>0x10E leshort x (Old3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte 0x15 +>>0x10E leshort x (New3DS System Update v +>>0x10E use nintendo-3ds-version-code +>>0x10E leshort x \b) +>0x18D byte !0x05 +>>0x18D byte !0x15 +>>>0x112 byte x (v +>>>0x112 use nintendo-3ds-version-code +>>>0x112 byte x \b) +>0x18C byte 2 (New3DS only) # Type: Nintendo 3DS "SMDH" file. (application description) # From: David Korth Copied: head/contrib/file/magic/Magdir/coverage (from r302218, vendor/file/dist/magic/Magdir/coverage) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/file/magic/Magdir/coverage Mon Jun 27 01:29:17 2016 (r302221, copy of r302218, vendor/file/dist/magic/Magdir/coverage) @@ -0,0 +1,91 @@ + +#------------------------------------------------------------------------------ +# $File: coverage,v 1.1 2016/06/05 00:26:32 christos Exp $ +# xoverage: file(1) magic for test coverage data + +# File formats used to store test coverage data +# 2016-05-21, Georg Sauthoff + + +# - GCC gcno - written by GCC at compile time when compiling with +# gcc -ftest-coverage +# - GCC gcda - written by a program that was compiled with +# gcc -fprofile-arcs +# - LLVM raw profiles - generated by a program compiled with +# clang -fprofile-instr-generate -fcoverage-mapping ... +# - LLVM indexed profiles - generated by +# llvm-profdata +# - GCOV reports, i.e. the annotated source code +# - LCOV trace files, i.e. aggregated GCC profiles +# +# GCC coverage tracefiles +# .gcno file are created during compile time, +# while data collected during runtime is stored in .gcda files +# cf. gcov-io.h +# https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Gcov-Data-Files.html +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 6f 6e 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 6e 6f 34 30 39 2a +0 lelong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636e6f GCC gcno coverage (-ftest-coverage), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + +# Examples: +# Fedora 23/x86-64/gcc-5.3.1: 61 64 63 67 52 33 30 35 +# Debian 8 PPC64/gcc-4.9.2 : 67 63 64 61 34 30 39 2a +0 lelong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&3 byte x version %c. +>&1 byte x \b%c + +# big endian +0 belong 0x67636461 GCC gcda coverage (-fprofile-arcs), +>&0 byte x version %c. +>&2 byte x \b%c (big-endian) + + +# LCOV tracefiles +# cf. http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php +0 string TN: +>&0 search/64 \nSF:/ LCOV coverage tracefile + + +# Coverage reports generated by gcov +# i.e. source code annoted with coverage information +0 string \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Source: +>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Graph: +>>&0 search/128 \x20\x20\x20\x20\x20\x20\x20\x20-:\x20\x20\x20\ 0:Data: GCOV coverage report + + +# LLVM coverage files + +# raw data after running a program compiled with: +# `clang -fprofile-instr-generate -fcoverage-mapping ...` +# default name: default.profraw +# magic is: \xFF lprofr \x81 +# cf. http://llvm.org/docs/doxygen/html/InstrProfData_8inc_source.html +0 lequad 0xff6c70726f667281 LLVM raw profile data, +>&0 byte x version %d + +# big endian +0 bequad 0xff6c70726f667281 LLVM raw profile data, +>&7 byte x version %d (big-endian) + + +# LLVM indexed instruction profile (as generated by llvm-profdata) +# magic is: reverse(\xFF lprofi \x81) +# cf. http://llvm.org/docs/CoverageMappingFormat.html +# http://llvm.org/docs/doxygen/html/namespacellvm_1_1IndexedInstrProf.html +# http://llvm.org/docs/CommandGuide/llvm-cov.html +# http://llvm.org/docs/CommandGuide/llvm-profdata.html +0 lequad 0x8169666f72706cff LLVM indexed profile data, +>&0 byte x version %d + +# big endian +0 bequad 0x8169666f72706cff LLVM indexed profile data, +>&7 byte x version %d (big-endian) + Modified: head/contrib/file/magic/Magdir/database ============================================================================== --- head/contrib/file/magic/Magdir/database Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/database Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: database,v 1.48 2016/04/14 20:34:28 christos Exp $ +# $File: database,v 1.49 2016/06/11 17:01:51 christos Exp $ # database: file(1) magic for various databases # # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) @@ -611,3 +611,14 @@ !:ext pan # database name >>>5 pstring x \b, "%s" + +# +# +# askSam Database by Stefan A. Haubenthal +0 string askw40\0 askSam DB + +# +# +# MUIbase Database Tool by Stefan A. Haubenthal +0 string MBSTV\040 MUIbase DB +>6 string x version %s Modified: head/contrib/file/magic/Magdir/elf ============================================================================== --- head/contrib/file/magic/Magdir/elf Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/elf Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: elf,v 1.69 2015/06/16 17:23:08 christos Exp $ +# $File: elf,v 1.70 2016/06/02 12:36:30 christos Exp $ # elf: file(1) magic for ELF executables # # We have to check the byte order flag to see what byte order all the @@ -301,25 +301,23 @@ >>0 use elf-le >5 byte 2 MSB >>0 use \^elf-le -# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed -# like proper ELF, but extracting the string had bad results. ->4 byte <0x80 ->>8 string >\0 (%s) ->8 string \0 ->>7 byte 0 (SYSV) ->>7 byte 1 (HP-UX) ->>7 byte 2 (NetBSD) ->>7 byte 3 (GNU/Linux) ->>7 byte 4 (GNU/Hurd) ->>7 byte 5 (86Open) ->>7 byte 6 (Solaris) ->>7 byte 7 (Monterey) ->>7 byte 8 (IRIX) ->>7 byte 9 (FreeBSD) ->>7 byte 10 (Tru64) ->>7 byte 11 (Novell Modesto) ->>7 byte 12 (OpenBSD) ->8 string \2 ->>7 byte 13 (OpenVMS) ->>7 byte 97 (ARM) ->>7 byte 255 (embedded) +>7 byte 0 (SYSV) +>7 byte 1 (HP-UX) +>7 byte 2 (NetBSD) +>7 byte 3 (GNU/Linux) +>7 byte 4 (GNU/Hurd) +>7 byte 5 (86Open) +>7 byte 6 (Solaris) +>7 byte 7 (Monterey) +>7 byte 8 (IRIX) +>7 byte 9 (FreeBSD) +>7 byte 10 (Tru64) +>7 byte 11 (Novell Modesto) +>7 byte 12 (OpenBSD) +>7 byte 13 (OpenVMS) +>7 byte 14 (HP NonStop Kernel) +>7 byte 15 (AROS Research Operating System) +>7 byte 16 (FenixOS) +>7 byte 17 (Nuxi CloudABI) +>7 byte 97 (ARM) +>7 byte 255 (embedded) Modified: head/contrib/file/magic/Magdir/msdos ============================================================================== --- head/contrib/file/magic/Magdir/msdos Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/msdos Mon Jun 27 01:29:17 2016 (r302221) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: msdos,v 1.105 2016/03/03 18:58:14 christos Exp $ +# $File: msdos,v 1.106 2016/06/11 00:52:14 christos Exp $ # msdos: file(1) magic for MS-DOS files # @@ -633,47 +633,86 @@ 0 string/b \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for MS Windows # Windows icons -0 name ico-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->4 ubyte !0 \b, %d colors - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG 0 belong 0x00000100 >9 byte 0 ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows icon resource -!:mime image/x-icon ->>4 use ico-dir +>>0 byte x +>>0 use cur-ico-dir +# displays number of icons and information for icon or cursor +0 name cur-ico-dir +# skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with +# 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h +>18 ulelong &0x00000006 +# skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG) +>>(18.l) ulelong x MS Windows +>>>0 ubelong 0x00000100 icon resource +#!:mime image/vnd.microsoft.icon +!:mime image/x-icon +!:ext ico +>>>>4 uleshort x - %d icon +# plural s +>>>>4 uleshort >1 \bs +# 1st icon +>>>>0x06 use ico-entry +# 2nd icon +>>>>4 uleshort >1 +>>>>>0x16 use ico-entry +>>>0 ubelong 0x00000200 cursor resource +#!:mime image/x-cur +!:mime image/x-win-bitmap +!:ext cur +>>>>4 uleshort x - %d icon +>>>>4 uleshort >1 \bs +# 1st cursor +>>>>0x06 use cur-entry +#>>>>0x16 use cur-entry +# display information of one cursor entry +0 name cur-entry +>0 use cur-ico-entry +>4 uleshort x \b, hotspot @%dx +>6 uleshort x \b%d +# display information of one icon entry +0 name ico-entry +>0 use cur-ico-entry +# normally 0 1 but also found 14 +>4 uleshort >1 \b, %d planes +# normally 0 1 but also found some 3, 4, some 6, 8, 24, many 32, two 256 +>6 uleshort >1 \b, %d bits/pixel +# display shared information of cursor or icon entry +0 name cur-ico-entry +>0 byte =0 \b, 256x +>0 byte !0 \b, %dx +>1 byte =0 \b256 +>1 byte !0 \b%d +# number of colors in palette +>2 ubyte !0 \b, %d colors +# reserved 0 FFh +#>3 ubyte x \b, reserved %x +#>8 ulelong x \b, image size %d +# offset of PNG or DIB image +#>12 ulelong x \b, offset 0x%x +# PNG header (\x89PNG) +>(12.l) ubelong =0x89504e47 +>>&-4 indirect x \b with +# DIB image +>(12.l) ubelong !0x89504e47 +#>>&-4 use dib-image # Windows non-animated cursors -0 name cur-dir -# not entirely accurate, the number of icons is part of the header ->0 byte 1 - 1 icon ->0 ubyte >1 - %d icons ->2 byte 0 \b, 256x ->2 byte !0 \b, %dx ->3 byte 0 \b256 ->3 byte !0 \b%d ->6 uleshort x \b, hotspot @%dx ->8 uleshort x \b%d - +# Update: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/CUR_(file_format) +# Note: similiar to Windows ICOn. container for BMP ( only DIB part) +# GRR: line below is too general as it catches also Lotus 1-2-3 files 0 belong 0x00000200 >9 byte 0 ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x MS Windows cursor resource -!:mime image/x-cur ->>4 use cur-dir +>>0 use cur-ico-dir # .chr files 0 string/b PK\010\010BGI Borland font Modified: head/contrib/file/magic/Magdir/msx ============================================================================== --- head/contrib/file/magic/Magdir/msx Mon Jun 27 01:17:00 2016 (r302220) +++ head/contrib/file/magic/Magdir/msx Mon Jun 27 01:29:17 2016 (r302221) @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # msx: file(1) magic for the MSX Home Computer -# v1.1 +# v1.3 # Fabio R. Schmidlin ############## MSX Music file formats ############## @@ -99,34 +99,6 @@ >>5 uleshort 0 >>>3 uleshort >0x013D MSX Graph Saurus compressed image -# Maki-chan Graphic format -0 string/b MAKI02\ \ Maki-chan image, ->8 byte x system ID: %c ->9 byte x \b%c ->10 byte x \b%c ->11 byte x \b%c, ->13 search/0x200 \x1A -# >>&3 ubyte 0 , video mode: PC-98 400 lines, 16 analog colors -# >>&3 ubyte 1 , video mode: MSX SC7, 16 analog colors -# >>&3 ubyte 2 , video mode: VM-98 400 lines, 8 analog colors -# >>&3 ubyte 3 , video mode: PC-88 analog, 200 lines, 8 analog colors -# >>&3 ubyte 4 , video mode: 400 lines, 16 digital colors -# >>&3 ubyte 5 , video mode: 200 lines, 16 digital colors -# >>&3 ubyte 6 , video mode: old PC-98 digital 400 lines, 8 colors -# >>&3 ubyte 7 , video mode: PC-88 400 lines, 8 digital colors ->>&8 uleshort+1 x %dx ->>&10 uleshort+1 x \b%d, ->>&3 ubyte&0x82 0x80 256 colors ->>&3 ubyte&0x82 0x00 16 colors ->>&3 ubyte&0x82 0x01 8 colors ->>&3 ubyte&0x04 4 digital ->>&3 ubyte&0x04 0 analog ->>&3 ubyte&0x01 1 \b, 2:1 dot aspect ratio - -# Japanese PIC file -0 string/b PIC\x1A ->4 lelong 0 Japanese PIC image file - # MSX G9B image file 0 string/b G9B >1 uleshort 11 @@ -146,70 +118,152 @@ ############## Other MSX file formats ############## -# MSX ROMs +# MSX internal ROMs +0 ubeshort 0xF3C3 +>2 uleshort <0x4000 +>>8 ubyte 0xC3 +>>>9 uleshort <0x4000 +>>>>0x0B ubeshort 0x00C3 +>>>>>0x0D uleshort <0x4000 +>>>>>>0x0F ubeshort 0x00C3 +>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>0x13 ubeshort 0x00C3 +>>>>>>>>>0x15 uleshort <0x4000 +>>>>>>>>>>0x50 ubyte 0xC3 +>>>>>>>>>>>0x51 uleshort <0x4000 +>>>>>>>>>>>>(9.s) ubyte 0xC3 +>>>>>>>>>>>>>&0 uleshort >0x4000 +>>>>>>>>>>>>>>&0 ubyte 0xC3 MSX BIOS+BASIC +>>>>>>>>>>>>>>>0x002D ubyte+1 <3 \b. version=MSX%d +>>>>>>>>>>>>>>>0x002D ubyte 2 \b, version=MSX2+ +>>>>>>>>>>>>>>>0x002D ubyte 3 \b, version=MSX Turbo-R +>>>>>>>>>>>>>>>0x002D ubyte >3 \b, version=Unknown MSX %d version +>>>>>>>>>>>>>>>0x0006 ubyte x \b, VDP.DR=0x%2x +>>>>>>>>>>>>>>>0x0007 ubyte x \b, VDP.DW=0x%2x +>>>>>>>>>>>>>>>0x002B ubyte&0xF 0 \b, charset=Japanese +>>>>>>>>>>>>>>>0x002B ubyte&0xF 1 \b, charset=International +>>>>>>>>>>>>>>>0x002B ubyte&0xF 2 \b, charset=Korean +>>>>>>>>>>>>>>>0x002B ubyte&0xF >2 \b, charset=Unknown id:%d +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x00 \b, date format=Y-M-D +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x10 \b, date format=M-D-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x70 0x20 \b, date format=D-M-Y +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x00 \b, vfreq=60Hz +>>>>>>>>>>>>>>>0x002B ubyte&0x80 0x80 \b, vfreq=50Hz +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 0 \b, keyboard=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 1 \b, keyboard=International +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 2 \b, keyboard=French +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 3 \b, keyboard=UK +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 4 \b, keyboard=German +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 5 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0x0F 6 \b, keyboard=Spanish +>>>>>>>>>>>>>>>0x002C ubyte&0x0F >6 \b, keyboard=Unknown id:%d +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x00 \b, basic=Japanese +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 0x10 \b, basic=International +>>>>>>>>>>>>>>>0x002C ubyte&0xF0 >0x10 \b, basic=Unknown id:%d +>>>>>>>>>>>>>>>0x002E ubyte&1 1 \b, built-in MIDI + + +0 string/b CD +>2 uleshort >0x10 +>>2 uleshort <0x4000 +>>>4 uleshort <0x4000 +>>>>6 uleshort <0x4000 +>>>>>8 ubyte 0xC3 +>>>>>>9 uleshort <0x4000 +>>>>>>>0x10 ubyte 0xC3 +>>>>>>>>0x11 uleshort <0x4000 +>>>>>>>>>0x14 ubyte 0xC3 +>>>>>>>>>>0x15 uleshort <0x4000 MSX2/2+/TR SubROM + +0 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 +>0x5F0 ubequad 0x8282828244380000 +>>0x150 ubyte 0x38 +>>>0x170 string \20\20\20 +>>>>0x1E32 string ()) +>>>>>0x2130 ubequad 0xA5A5594924231807 +>>>>>0x2138 ubequad 0x4A4A3424488830C0 MSX Kanji Font + + + +# MSX extension ROMs 0 string/b AB >2 uleshort 0x0010 MSX ROM >>2 uleshort x \b, init=0x%4x ->>4 uleshort >0 \b, stat=0x%4x ->>6 uleshort >0 \b, dev=0x%4x +>>4 uleshort >0 \b, stahdl=0x%4x +>>6 uleshort >0 \b, devhdl=0x%4x >>8 uleshort >0 \b, bas=0x%4x >2 uleshort 0x4010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x >2 uleshort 0x8010 MSX ROM >>2 uleshort x \b, init=0x%04x ->>4 uleshort >0 \b, stat=0x%04x ->>6 uleshort >0 \b, dev=0x%04x +>>4 uleshort >0 \b, stahdl=0x%04x +>>6 uleshort >0 \b, devhdl=0x%04x >>8 uleshort >0 \b, bas=0x%04x +0 string/b AB\0\0 +>6 uleshort 0 +>>4 uleshort >0x400F MSX-BASIC extension ROM +>>>4 uleshort >0 \b, stahdl=0x%04x +>>>6 uleshort >0 \b, devhdl=0x%04x +>>>0x1C string OPLL \b, MSX-Music +>>>>0x18 string PAC2 \b (external) +>>>>0x18 string APRL \b (internal) + +0 string/b AB\0\0\0\0 +>6 uleshort >0x400F MSX device BIOS +>>6 uleshort >0 \b, devhdl=0x%04x + 0 string/b AB #>2 string 5JSuperLAYDOCK MSX Super Laydock ROM #>3 string @HYDLIDE3MSX MSX Hydlide-3 ROM #>3 string @3\x80IA862 Golvellius MSX1 ROM ->2 uleshort >10 ->>10 string \0\0\0\0\0\0 MSX ROM ->>>0x10 string YZ\0\0\0\0 Konami Game Master 2 MSX ROM ->>>0x10 string CD \b, Konami RC- ->>>>0x12 ubyte x \b%d ->>>>0x13 ubyte/16 x \b%d ->>>>0x13 ubyte&0xF x \b%d ->>>0x10 string EF \b, Konami RC- *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon Jun 27 06:41:12 2016 Return-Path: Delivered-To: svn-src-all@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 66E58B84FB3; Mon, 27 Jun 2016 06:41:12 +0000 (UTC) (envelope-from delphij@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 378BE24CB; Mon, 27 Jun 2016 06:41:12 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5R6fB4b080777; Mon, 27 Jun 2016 06:41:11 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5R6fBT5080776; Mon, 27 Jun 2016 06:41:11 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606270641.u5R6fBT5080776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 27 Jun 2016 06:41:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302222 - head/lib/libmagic X-SVN-Group: head 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.22 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: Mon, 27 Jun 2016 06:41:12 -0000 Author: delphij Date: Mon Jun 27 06:41:11 2016 New Revision: 302222 URL: https://svnweb.freebsd.org/changeset/base/302222 Log: Fix build: explicitly reference the generated magic.h as dependency of mkmagic and point its location. Reported by: jenkins Pointy hat to: delphij MFC after: 2 weeks X-MFC-With: 302221 Approved by: re (kib) Modified: head/lib/libmagic/Makefile Modified: head/lib/libmagic/Makefile ============================================================================== --- head/lib/libmagic/Makefile Mon Jun 27 01:29:17 2016 (r302221) +++ head/lib/libmagic/Makefile Mon Jun 27 06:41:11 2016 (r302222) @@ -19,7 +19,7 @@ INCS= magic.h MAGICPATH?= /usr/share/misc CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H -CFLAGS+= -I${.CURDIR} -I${CONTRDIR}/src +CFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${CONTRDIR}/src WARNS?= 3 @@ -40,8 +40,8 @@ magic.mgc: mkmagic magic CLEANFILES+= mkmagic build-tools: mkmagic -mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${BUILD_TOOLS_META} - ${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} \ +mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} + ${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC:N*.h} \ ${LDADD} FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ From owner-svn-src-all@freebsd.org Mon Jun 27 17:01:28 2016 Return-Path: Delivered-To: svn-src-all@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 497C6B81355; Mon, 27 Jun 2016 17:01:28 +0000 (UTC) (envelope-from slm@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 2614F2E3F; Mon, 27 Jun 2016 17:01:28 +0000 (UTC) (envelope-from slm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RH1R0q020946; Mon, 27 Jun 2016 17:01:27 GMT (envelope-from slm@FreeBSD.org) Received: (from slm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RH1QSB020940; Mon, 27 Jun 2016 17:01:26 GMT (envelope-from slm@FreeBSD.org) Message-Id: <201606271701.u5RH1QSB020940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: slm set sender to slm@FreeBSD.org using -f From: Stephen McConnell Date: Mon, 27 Jun 2016 17:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302225 - stable/10/sys/dev/mps X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 17:01:28 -0000 Author: slm Date: Mon Jun 27 17:01:26 2016 New Revision: 302225 URL: https://svnweb.freebsd.org/changeset/base/302225 Log: MFC r302031 - No log bit in IOCStatus and endian-safe changes. Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and make a few more things endian-safe. - Fix possible use of invalid pointer. It was possible to use an invalid pointer to get the target ID value. To fix this, initialize a local Target ID variable to an invalid value and change that variable to a valid value only if the pointer to the Target ID is not NULL. - No need to set the MPSSAS_SHUTDOWN flag because it's never used. - done_ccb pointer can be used if it is NULL. To prevent this, move check for done_ccb == NULL to before done_ccb is used in mpssas_stop_unit_done(). - Disks can go missing until a reboot is done in some cases. This is due to the DevHandle not being released, which causes the Firmware to not allow that disk to be re-added. Approved by: ken, scottl, ambrisko (mentors) Modified: stable/10/sys/dev/mps/mps.c stable/10/sys/dev/mps/mps_config.c stable/10/sys/dev/mps/mps_sas.c stable/10/sys/dev/mps/mps_sas_lsi.c stable/10/sys/dev/mps/mps_user.c stable/10/sys/dev/mps/mpsvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mps/mps.c ============================================================================== --- stable/10/sys/dev/mps/mps.c Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mps.c Mon Jun 27 17:01:26 2016 (r302225) @@ -1916,9 +1916,10 @@ mps_intr_locked(void *data) */ rel_rep = (MPI2_DIAG_RELEASE_REPLY *)reply; - if (le16toh(rel_rep->IOCStatus) == + if ((le16toh(rel_rep->IOCStatus) & + MPI2_IOCSTATUS_MASK) == MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED) - { + { pBuffer = &sc->fw_diag_buffer_list[ rel_rep->BufferType]; Modified: stable/10/sys/dev/mps/mps_config.c ============================================================================== --- stable/10/sys/dev/mps/mps_config.c Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mps_config.c Mon Jun 27 17:01:26 2016 (r302225) @@ -499,7 +499,8 @@ mps_wd_config_pages(struct mps_softc *sc */ if (mps_config_get_raid_volume_pg0(sc, &mpi_reply, raid_vol_pg0, (u32)raid_vol_pg0->DevHandle)) { - if (mpi_reply.IOCStatus != + if ((le16toh(mpi_reply.IOCStatus) & + MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) { mps_dprint(sc, MPS_FAULT, "Multiple RAID Volume Page0! Direct Drive " Modified: stable/10/sys/dev/mps/mps_sas.c ============================================================================== --- stable/10/sys/dev/mps/mps_sas.c Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mps_sas.c Mon Jun 27 17:01:26 2016 (r302225) @@ -241,6 +241,8 @@ mpssas_alloc_tm(struct mps_softc *sc) void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm) { + int target_id = 0xFFFFFFFF; + if (tm == NULL) return; @@ -251,10 +253,11 @@ mpssas_free_tm(struct mps_softc *sc, str */ if (tm->cm_targ != NULL) { tm->cm_targ->flags &= ~MPSSAS_TARGET_INRESET; + target_id = tm->cm_targ->tid; } if (tm->cm_ccb) { mps_dprint(sc, MPS_INFO, "Unfreezing devq for target ID %d\n", - tm->cm_targ->tid); + target_id); xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE); xpt_free_path(tm->cm_ccb->ccb_h.path); xpt_free_ccb(tm->cm_ccb); @@ -372,12 +375,11 @@ mpssas_remove_volume(struct mps_softc *s return; } - if (reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) { - mps_dprint(sc, MPS_FAULT, + if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) != + MPI2_IOCSTATUS_SUCCESS) { + mps_dprint(sc, MPS_ERROR, "IOCStatus = 0x%x while resetting device 0x%x\n", - reply->IOCStatus, handle); - mpssas_free_tm(sc, tm); - return; + le16toh(reply->IOCStatus), handle); } mps_dprint(sc, MPS_XINFO, @@ -394,7 +396,8 @@ mpssas_remove_volume(struct mps_softc *s * this target id if possible, and so we can assign the same target id * to this device if it comes back in the future. */ - if (reply->IOCStatus == MPI2_IOCSTATUS_SUCCESS) { + if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) == + MPI2_IOCSTATUS_SUCCESS) { targ = tm->cm_targ; targ->handle = 0x0; targ->encl_handle = 0x0; @@ -567,24 +570,22 @@ mpssas_remove_device(struct mps_softc *s "%s: cm_flags = %#x for remove of handle %#04x! " "This should not happen!\n", __func__, tm->cm_flags, handle); - mpssas_free_tm(sc, tm); - return; } if (reply == NULL) { /* XXX retry the remove after the diag reset completes? */ mps_dprint(sc, MPS_FAULT, - "%s NULL reply reseting device 0x%04x\n", __func__, handle); + "%s NULL reply resetting device 0x%04x\n", __func__, + handle); mpssas_free_tm(sc, tm); return; } - if (le16toh(reply->IOCStatus) != MPI2_IOCSTATUS_SUCCESS) { - mps_dprint(sc, MPS_FAULT, + if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) != + MPI2_IOCSTATUS_SUCCESS) { + mps_dprint(sc, MPS_ERROR, "IOCStatus = 0x%x while resetting device 0x%x\n", le16toh(reply->IOCStatus), handle); - mpssas_free_tm(sc, tm); - return; } mps_dprint(sc, MPS_XINFO, "Reset aborted %u commands\n", @@ -662,7 +663,8 @@ mpssas_remove_complete(struct mps_softc * this target id if possible, and so we can assign the same target id * to this device if it comes back in the future. */ - if (le16toh(reply->IOCStatus) == MPI2_IOCSTATUS_SUCCESS) { + if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) == + MPI2_IOCSTATUS_SUCCESS) { targ = tm->cm_targ; targ->handle = 0x0; targ->encl_handle = 0x0; @@ -880,7 +882,6 @@ mps_detach_sas(struct mps_softc *sc) cam_sim_free(sassc->sim, FALSE); } - sassc->flags |= MPSSAS_SHUTDOWN; mps_unlock(sc); if (sassc->devq != NULL) Modified: stable/10/sys/dev/mps/mps_sas_lsi.c ============================================================================== --- stable/10/sys/dev/mps/mps_sas_lsi.c Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mps_sas_lsi.c Mon Jun 27 17:01:26 2016 (r302225) @@ -1161,15 +1161,15 @@ mpssas_stop_unit_done(struct cam_periph struct mpssas_softc *sassc; char path_str[64]; + if (done_ccb == NULL) + return; + sassc = (struct mpssas_softc *)done_ccb->ccb_h.ppriv_ptr1; xpt_path_string(done_ccb->ccb_h.path, path_str, sizeof(path_str)); mps_dprint(sassc->sc, MPS_INFO, "Completing stop unit for %s\n", path_str); - if (done_ccb == NULL) - return; - /* * Nothing more to do except free the CCB and path. If the command * timed out, an abort reset, then target reset will be issued during Modified: stable/10/sys/dev/mps/mps_user.c ============================================================================== --- stable/10/sys/dev/mps/mps_user.c Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mps_user.c Mon Jun 27 17:01:26 2016 (r302225) @@ -1230,12 +1230,14 @@ mps_post_fw_diag_buffer(struct mps_softc * Process POST reply. */ reply = (MPI2_DIAG_BUFFER_POST_REPLY *)cm->cm_reply; - if (reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) { + if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) != + MPI2_IOCSTATUS_SUCCESS) { status = MPS_DIAG_FAILURE; mps_dprint(sc, MPS_FAULT, "%s: post of FW Diag Buffer failed " "with IOCStatus = 0x%x, IOCLogInfo = 0x%x and " - "TransferLength = 0x%x\n", __func__, reply->IOCStatus, - reply->IOCLogInfo, reply->TransferLength); + "TransferLength = 0x%x\n", __func__, + le16toh(reply->IOCStatus), le32toh(reply->IOCLogInfo), + le32toh(reply->TransferLength)); goto done; } @@ -1314,12 +1316,13 @@ mps_release_fw_diag_buffer(struct mps_so * Process RELEASE reply. */ reply = (MPI2_DIAG_RELEASE_REPLY *)cm->cm_reply; - if ((reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) || - pBuffer->owned_by_firmware) { + if (((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) != + MPI2_IOCSTATUS_SUCCESS) || pBuffer->owned_by_firmware) { status = MPS_DIAG_FAILURE; mps_dprint(sc, MPS_FAULT, "%s: release of FW Diag Buffer " "failed with IOCStatus = 0x%x and IOCLogInfo = 0x%x\n", - __func__, reply->IOCStatus, reply->IOCLogInfo); + __func__, le16toh(reply->IOCStatus), + le32toh(reply->IOCLogInfo)); goto done; } Modified: stable/10/sys/dev/mps/mpsvar.h ============================================================================== --- stable/10/sys/dev/mps/mpsvar.h Mon Jun 27 16:14:54 2016 (r302224) +++ stable/10/sys/dev/mps/mpsvar.h Mon Jun 27 17:01:26 2016 (r302225) @@ -33,7 +33,7 @@ #ifndef _MPSVAR_H #define _MPSVAR_H -#define MPS_DRIVER_VERSION "20.00.00.00-fbsd" +#define MPS_DRIVER_VERSION "21.00.00.00-fbsd" #define MPS_DB_MAX_WAIT 2500 From owner-svn-src-all@freebsd.org Mon Jun 27 20:18:50 2016 Return-Path: Delivered-To: svn-src-all@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 71602B84BB1; Mon, 27 Jun 2016 20:18:50 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-qt0-x236.google.com (mail-qt0-x236.google.com [IPv6:2607:f8b0:400d:c0d::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 292432532; Mon, 27 Jun 2016 20:18:50 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-qt0-x236.google.com with SMTP id c34so27889232qte.0; Mon, 27 Jun 2016 13:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iQQhMCaXchsH9crFQCj1roY5472mQjnW88KSQBtZqxc=; b=ocWDSDqYKKWJM28i65a3XJg1iVgM4ttt3nc03O/Xl3NTnmvV4Xa9Z26B1kUZCuTBI1 j3YRMzJ8xMgWvRKeoHzlBR30wLQbW8jNwmkRYxzZRwa0lOwlqqJb7LZeT+HJUWOYFGkM u9YmNsQWn7XQ+imryE519qx0ZHzQ+/cB1QMtkjWq4B57uj7mmtxn1lQBx+CshFEE3Fe6 aE9CfI0MMd5I7pz54Fl32IAikdcoq5yTlY3aKgwTqL4+ZoU+MZtVNR8Nn29y/ldd0m39 Vn1W2gJe+oTtj9RX6nTic+ZVlQJv9KUO77Cm6fQ2D8eCoFudfWmrulwnGJNsG3Fn2vrf HRxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iQQhMCaXchsH9crFQCj1roY5472mQjnW88KSQBtZqxc=; b=VqL9xC3hU/iZp62rOQqvWwuOlxBzAiHF5MBNQuTpBgW0PYEhSdbuaJ0dbN8YCJFOQk K00N6NPoUv98sGD+eVSTXhsj8asbxAW7hG7NYTUXuBKeOid9R5Hyu7LbK3uF3cW5z3g6 fQ3GtU1kKk40+PgJ44d2x+DqLurLSwCuJpHpsP82rV6XQ8kZvl+MIto7Whhj0UHZ5uvg TKDIQiXpVoyBvrzaGHf9mLI0+1kESClhKotIimpvWTE3cpBI1EM3iLmxsWf2npK52lFx cs8e5MzdLnHHlpyYoMETIlwRSUQ7jmft65XZ6gxGI/8C2Xd3/HJ+0TkPdy9x1REvIPD7 UZMg== X-Gm-Message-State: ALyK8tIKC4SyD+bxM03Hb/3iqKQYIqffpE+BJciiXaMvA4w/R/VMD4IQMhA31jzvlhEygu2ruNXTMY0aQqEvaw== X-Received: by 10.237.39.167 with SMTP id a36mr26576151qtd.103.1467058729215; Mon, 27 Jun 2016 13:18:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.148.131 with HTTP; Mon, 27 Jun 2016 13:18:48 -0700 (PDT) In-Reply-To: <201606262008.u5QK8gTx042729@repo.freebsd.org> References: <201606262008.u5QK8gTx042729@repo.freebsd.org> From: Ngie Cooper Date: Mon, 27 Jun 2016 13:18:48 -0700 Message-ID: Subject: Re: svn commit: r302216 - in head/sys: kern nlm To: Konstantin Belousov Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 20:18:50 -0000 On Sun, Jun 26, 2016 at 1:08 PM, Konstantin Belousov wrote: > Author: kib > Date: Sun Jun 26 20:08:42 2016 > New Revision: 302216 > URL: https://svnweb.freebsd.org/changeset/base/302216 > > Log: > When sleeping waiting for either local or remote advisory lock, > interrupt sleeps with the ERESTART on the suspension attempts. > Otherwise, single-threading requests are deferred until the locks are > granted for NFS files, which causes hangs. > > When retrying local registration of the remotely-granted adv lock, > allow full suspension and check for suspension, for usual reasons. > > Reported by: markj, pho > Reviewed by: jilles > Tested by: pho > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > Approved by: re (gjb) One of the NetBSD tests seems to be failing now: https://jenkins.freebsd.org/job/FreeBSD_HEAD/334/testReport/junit/sys.kern/lockf_test/randlock/ . Thanks, -Ngie From owner-svn-src-all@freebsd.org Mon Jun 27 20:31:57 2016 Return-Path: Delivered-To: svn-src-all@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 9220FB8502E; Mon, 27 Jun 2016 20:31:57 +0000 (UTC) (envelope-from bdrewery@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 62B032CED; Mon, 27 Jun 2016 20:31:57 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RKVunJ000500; Mon, 27 Jun 2016 20:31:56 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RKVuG6000499; Mon, 27 Jun 2016 20:31:56 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272031.u5RKVuG6000499@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 20:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302226 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 20:31:57 -0000 Author: bdrewery Date: Mon Jun 27 20:31:56 2016 New Revision: 302226 URL: https://svnweb.freebsd.org/changeset/base/302226 Log: MFC r296285: Correct a comment. Modified: stable/10/sys/kern/kern_exec.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 17:01:26 2016 (r302225) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 20:31:56 2016 (r302226) @@ -671,7 +671,7 @@ interpret: * Don't honor setuid/setgid if the filesystem prohibits it or if * the process is being traced. * - * We disable setuid/setgid/etc in compatibility mode on the basis + * We disable setuid/setgid/etc in capability mode on the basis * that most setugid applications are not written with that * environment in mind, and will therefore almost certainly operate * incorrectly. In principle there's no reason that setugid From owner-svn-src-all@freebsd.org Mon Jun 27 20:38:39 2016 Return-Path: Delivered-To: svn-src-all@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 7D8A9B851BD; Mon, 27 Jun 2016 20:38:39 +0000 (UTC) (envelope-from bdrewery@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 4A1B72136; Mon, 27 Jun 2016 20:38:39 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RKccLt000911; Mon, 27 Jun 2016 20:38:38 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RKccZY000910; Mon, 27 Jun 2016 20:38:38 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272038.u5RKccZY000910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 20:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302227 - stable/10/sys/security/audit X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 20:38:39 -0000 Author: bdrewery Date: Mon Jun 27 20:38:38 2016 New Revision: 302227 URL: https://svnweb.freebsd.org/changeset/base/302227 Log: MFC r280121: audit: fix cred assignment when A_SETPMASK is used Modified: stable/10/sys/security/audit/audit_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/10/sys/security/audit/audit_syscalls.c Mon Jun 27 20:31:56 2016 (r302226) +++ stable/10/sys/security/audit/audit_syscalls.c Mon Jun 27 20:38:38 2016 (r302227) @@ -461,7 +461,7 @@ sys_auditon(struct thread *td, struct au udata.au_aupinfo.ap_mask.am_success; newcred->cr_audit.ai_mask.am_failure = udata.au_aupinfo.ap_mask.am_failure; - td->td_proc->p_ucred = newcred; + tp->p_ucred = newcred; PROC_UNLOCK(tp); crfree(oldcred); break; From owner-svn-src-all@freebsd.org Mon Jun 27 20:54:04 2016 Return-Path: Delivered-To: svn-src-all@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 22847B85667; Mon, 27 Jun 2016 20:54:04 +0000 (UTC) (envelope-from pfg@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 D92F02B38; Mon, 27 Jun 2016 20:54:03 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RKs3iZ008084; Mon, 27 Jun 2016 20:54:03 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RKs2pD008082; Mon, 27 Jun 2016 20:54:02 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201606272054.u5RKs2pD008082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 27 Jun 2016 20:54:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302228 - in stable/10: sys/sys usr.bin/sed X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 20:54:04 -0000 Author: pfg Date: Mon Jun 27 20:54:02 2016 New Revision: 302228 URL: https://svnweb.freebsd.org/changeset/base/302228 Log: sed(1): convert sed to use REG_STARTEND more explicitly. Summarizing the findings in the OpenBSD list: This solves a reproduceable issue with very recent Mesa where REG_NOTBOL combined with a match at the begin of the string causes our regex library to treat the word as not begin of word. Bump __FreeBSD_version: JIC we hit the issue in recent Mesa ports. PR: 209352, 209387 (exp-run) Taken from: openbsd-tech (Martijn van Duren) MFC after: 1 month Modified: stable/10/sys/sys/param.h stable/10/usr.bin/sed/process.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Mon Jun 27 20:38:38 2016 (r302227) +++ stable/10/sys/sys/param.h Mon Jun 27 20:54:02 2016 (r302228) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1003504 /* Master, propagated to newvers */ +#define __FreeBSD_version 1003505 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, Modified: stable/10/usr.bin/sed/process.c ============================================================================== --- stable/10/usr.bin/sed/process.c Mon Jun 27 20:38:38 2016 (r302227) +++ stable/10/usr.bin/sed/process.c Mon Jun 27 20:54:02 2016 (r302228) @@ -70,7 +70,8 @@ static inline int applies(struct s_comm static void do_tr(struct s_tr *); static void flush_appends(void); static void lputs(char *, size_t); -static int regexec_e(regex_t *, const char *, int, int, size_t); +static int regexec_e(regex_t *, const char *, int, int, size_t, + size_t); static void regsub(SPACE *, char *, char *); static int substitute(struct s_command *); @@ -271,7 +272,7 @@ new: if (!nflag && !pd) * (lastline, linenumber, ps). */ #define MATCH(a) \ - ((a)->type == AT_RE ? regexec_e((a)->u.r, ps, 0, 1, psl) : \ + ((a)->type == AT_RE ? regexec_e((a)->u.r, ps, 0, 1, 0, psl) : \ (a)->type == AT_LINE ? linenum == (a)->u.l : lastline()) /* @@ -371,6 +372,7 @@ substitute(struct s_command *cp) regex_t *re; regoff_t slen; int lastempty, n; + size_t le = 0; char *s; s = ps; @@ -382,7 +384,7 @@ substitute(struct s_command *cp) linenum, fname, cp->u.s->maxbref); } } - if (!regexec_e(re, s, 0, 0, psl)) + if (!regexec_e(re, s, 0, 0, 0, psl)) return (0); SS.len = 0; /* Clean substitute space. */ @@ -392,28 +394,30 @@ substitute(struct s_command *cp) do { /* Copy the leading retained string. */ - if (n <= 1 && match[0].rm_so) - cspace(&SS, s, match[0].rm_so, APPEND); + if (n <= 1 && match[0].rm_so - le) + cspace(&SS, s, match[0].rm_so - le, APPEND); /* Skip zero-length matches right after other matches. */ - if (lastempty || match[0].rm_so || + if (lastempty || (match[0].rm_so - le) || match[0].rm_so != match[0].rm_eo) { if (n <= 1) { /* Want this match: append replacement. */ - regsub(&SS, s, cp->u.s->new); + regsub(&SS, ps, cp->u.s->new); if (n == 1) n = -1; } else { /* Want a later match: append original. */ - if (match[0].rm_eo) - cspace(&SS, s, match[0].rm_eo, APPEND); + if (match[0].rm_eo - le) + cspace(&SS, s, match[0].rm_eo - le, + APPEND); n--; } } /* Move past this match. */ - s += match[0].rm_eo; - slen -= match[0].rm_eo; + s += (match[0].rm_eo - le); + slen -= (match[0].rm_eo - le); + le = match[0].rm_eo; /* * After a zero-length match, advance one byte, @@ -424,13 +428,15 @@ substitute(struct s_command *cp) slen = -1; else slen--; - if (*s != '\0') + if (*s != '\0') { cspace(&SS, s++, 1, APPEND); + le++; + } lastempty = 1; } else lastempty = 0; - } while (n >= 0 && slen >= 0 && regexec_e(re, s, REG_NOTBOL, 0, slen)); + } while (n >= 0 && slen >= 0 && regexec_e(re, ps, 0, 0, le, psl)); /* Did not find the requested number of matches. */ if (n > 1) @@ -640,7 +646,7 @@ lputs(char *s, size_t len) static int regexec_e(regex_t *preg, const char *string, int eflags, int nomatch, - size_t slen) + size_t start, size_t stop) { int eval; @@ -651,8 +657,8 @@ regexec_e(regex_t *preg, const char *str defpreg = preg; /* Set anchors */ - match[0].rm_so = 0; - match[0].rm_eo = slen; + match[0].rm_so = start; + match[0].rm_eo = stop; eval = regexec(defpreg, string, nomatch ? 0 : maxnsub + 1, match, eflags | REG_STARTEND); From owner-svn-src-all@freebsd.org Mon Jun 27 21:25:03 2016 Return-Path: Delivered-To: svn-src-all@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 E816EB85EA8; Mon, 27 Jun 2016 21:25:03 +0000 (UTC) (envelope-from bdrewery@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 B34BE24F9; Mon, 27 Jun 2016 21:25:03 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLP2Cd019145; Mon, 27 Jun 2016 21:25:02 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLP1JC019131; Mon, 27 Jun 2016 21:25:01 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272125.u5RLP1JC019131@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:25:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302229 - in stable/10/sys: compat/linux kern security/audit security/mac security/mac_lomac sys X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:25:04 -0000 Author: bdrewery Date: Mon Jun 27 21:25:01 2016 New Revision: 302229 URL: https://svnweb.freebsd.org/changeset/base/302229 Log: MFC r280130: cred: add proc_set_cred helper Modified: stable/10/sys/compat/linux/linux_misc.c stable/10/sys/compat/linux/linux_uid16.c stable/10/sys/kern/init_main.c stable/10/sys/kern/kern_exec.c stable/10/sys/kern/kern_exit.c stable/10/sys/kern/kern_fork.c stable/10/sys/kern/kern_jail.c stable/10/sys/kern/kern_loginclass.c stable/10/sys/kern/kern_prot.c stable/10/sys/kern/sys_capability.c stable/10/sys/security/audit/audit_syscalls.c stable/10/sys/security/mac/mac_syscalls.c stable/10/sys/security/mac_lomac/mac_lomac.c stable/10/sys/sys/ucred.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/linux/linux_misc.c ============================================================================== --- stable/10/sys/compat/linux/linux_misc.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/compat/linux/linux_misc.c Mon Jun 27 21:25:01 2016 (r302229) @@ -1338,7 +1338,7 @@ linux_setgroups(struct thread *td, struc newcred->cr_ngroups = 1; setsugid(p); - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); error = 0; Modified: stable/10/sys/compat/linux/linux_uid16.c ============================================================================== --- stable/10/sys/compat/linux/linux_uid16.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/compat/linux/linux_uid16.c Mon Jun 27 21:25:01 2016 (r302229) @@ -214,7 +214,7 @@ linux_setgroups16(struct thread *td, str newcred->cr_ngroups = 1; setsugid(td->td_proc); - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); error = 0; Modified: stable/10/sys/kern/init_main.c ============================================================================== --- stable/10/sys/kern/init_main.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/init_main.c Mon Jun 27 21:25:01 2016 (r302229) @@ -437,6 +437,7 @@ proc0_init(void *dummy __unused) { struct proc *p; struct thread *td; + struct ucred *newcred; vm_paddr_t pageablemem; int i; @@ -513,19 +514,20 @@ proc0_init(void *dummy __unused) callout_init(&td->td_slpcallout, CALLOUT_MPSAFE); /* Create credentials. */ - p->p_ucred = crget(); - p->p_ucred->cr_ngroups = 1; /* group 0 */ - p->p_ucred->cr_uidinfo = uifind(0); - p->p_ucred->cr_ruidinfo = uifind(0); - p->p_ucred->cr_prison = &prison0; - p->p_ucred->cr_loginclass = loginclass_find("default"); + newcred = crget(); + newcred->cr_ngroups = 1; /* group 0 */ + newcred->cr_uidinfo = uifind(0); + newcred->cr_ruidinfo = uifind(0); + newcred->cr_prison = &prison0; + newcred->cr_loginclass = loginclass_find("default"); + proc_set_cred(p, newcred); #ifdef AUDIT - audit_cred_kproc0(p->p_ucred); + audit_cred_kproc0(newcred); #endif #ifdef MAC - mac_cred_create_swapper(p->p_ucred); + mac_cred_create_swapper(newcred); #endif - td->td_ucred = crhold(p->p_ucred); + td->td_ucred = crhold(newcred); /* Create sigacts. */ p->p_sigacts = sigacts_alloc(); @@ -844,7 +846,7 @@ create_init(const void *udata __unused) #ifdef AUDIT audit_cred_proc1(newcred); #endif - initproc->p_ucred = newcred; + proc_set_cred(initproc, newcred); PROC_UNLOCK(initproc); sx_xunlock(&proctree_lock); crfree(oldcred); Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:25:01 2016 (r302229) @@ -751,7 +751,7 @@ interpret: */ change_svuid(newcred, newcred->cr_uid); change_svgid(newcred, newcred->cr_gid); - p->p_ucred = newcred; + proc_set_cred(p, newcred); } else { if (oldcred->cr_uid == oldcred->cr_ruid && oldcred->cr_gid == oldcred->cr_rgid) @@ -777,7 +777,7 @@ interpret: PROC_LOCK(p); change_svuid(newcred, newcred->cr_uid); change_svgid(newcred, newcred->cr_gid); - p->p_ucred = newcred; + proc_set_cred(p, newcred); } } Modified: stable/10/sys/kern/kern_exit.c ============================================================================== --- stable/10/sys/kern/kern_exit.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_exit.c Mon Jun 27 21:25:01 2016 (r302229) @@ -937,7 +937,7 @@ proc_reap(struct thread *td, struct proc * Free credentials, arguments, and sigacts. */ crfree(p->p_ucred); - p->p_ucred = NULL; + proc_set_cred(p, NULL); pargs_drop(p->p_args); p->p_args = NULL; sigacts_free(p->p_sigacts); Modified: stable/10/sys/kern/kern_fork.c ============================================================================== --- stable/10/sys/kern/kern_fork.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_fork.c Mon Jun 27 21:25:01 2016 (r302229) @@ -413,7 +413,8 @@ do_fork(struct thread *td, int flags, st p2->p_treeflag = 0; p2->p_filemon = NULL; - p2->p_ucred = crhold(td->td_ucred); + crhold(td->td_ucred); + proc_set_cred(p2, td->td_ucred); /* Tell the prison that we exist. */ prison_proc_hold(p2->p_ucred->cr_prison); @@ -913,7 +914,7 @@ fork1(struct thread *td, int flags, int * XXX: This is ugly; when we copy resource usage, we need to bump * per-cred resource counters. */ - newproc->p_ucred = p1->p_ucred; + proc_set_cred(newproc, p1->p_ucred); /* * Initialize resource accounting for the child process. Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_jail.c Mon Jun 27 21:25:01 2016 (r302229) @@ -2476,7 +2476,7 @@ do_jail_attach(struct thread *td, struct PROC_LOCK(p); oldcred = crcopysafe(p, newcred); newcred->cr_prison = pr; - p->p_ucred = newcred; + proc_set_cred(p, newcred); setsugid(p); PROC_UNLOCK(p); #ifdef RACCT Modified: stable/10/sys/kern/kern_loginclass.c ============================================================================== --- stable/10/sys/kern/kern_loginclass.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_loginclass.c Mon Jun 27 21:25:01 2016 (r302229) @@ -205,7 +205,7 @@ sys_setloginclass(struct thread *td, str PROC_LOCK(p); oldcred = crcopysafe(p, newcred); newcred->cr_loginclass = newlc; - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); Modified: stable/10/sys/kern/kern_prot.c ============================================================================== --- stable/10/sys/kern/kern_prot.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/kern_prot.c Mon Jun 27 21:25:01 2016 (r302229) @@ -582,7 +582,7 @@ sys_setuid(struct thread *td, struct set change_euid(newcred, uip); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); @@ -641,7 +641,7 @@ sys_seteuid(struct thread *td, struct se change_euid(newcred, euip); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); uifree(euip); crfree(oldcred); @@ -741,7 +741,7 @@ sys_setgid(struct thread *td, struct set change_egid(newcred, gid); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); @@ -787,7 +787,7 @@ sys_setegid(struct thread *td, struct se change_egid(newcred, egid); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); @@ -860,7 +860,7 @@ kern_setgroups(struct thread *td, u_int crsetgroups_locked(newcred, ngrp, groups); } setsugid(p); - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); @@ -923,7 +923,7 @@ sys_setreuid(register struct thread *td, change_svuid(newcred, newcred->cr_uid); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); @@ -990,7 +990,7 @@ sys_setregid(register struct thread *td, change_svgid(newcred, newcred->cr_groups[0]); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); @@ -1064,7 +1064,7 @@ sys_setresuid(register struct thread *td change_svuid(newcred, suid); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); @@ -1143,7 +1143,7 @@ sys_setresgid(register struct thread *td change_svgid(newcred, sgid); setsugid(p); } - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); @@ -1956,6 +1956,31 @@ cred_update_thread(struct thread *td) crfree(cred); } +/* + * Change process credentials. + * Callers are responsible for providing the reference for current credentials + * and for freeing old ones. + * + * Process has to be locked except when it does not have credentials (as it + * should not be visible just yet) or when newcred is NULL (as this can be + * only used when the process is about to be freed, at which point it should + * not be visible anymore). + */ +struct ucred * +proc_set_cred(struct proc *p, struct ucred *newcred) +{ + struct ucred *oldcred; + + if (newcred == NULL) + MPASS(p->p_state == PRS_ZOMBIE); + else if (p->p_ucred != NULL) + PROC_LOCK_ASSERT(p, MA_OWNED); + + oldcred = p->p_ucred; + p->p_ucred = newcred; + return (oldcred); +} + struct ucred * crcopysafe(struct proc *p, struct ucred *cr) { Modified: stable/10/sys/kern/sys_capability.c ============================================================================== --- stable/10/sys/kern/sys_capability.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/kern/sys_capability.c Mon Jun 27 21:25:01 2016 (r302229) @@ -105,7 +105,7 @@ sys_cap_enter(struct thread *td, struct oldcred = p->p_ucred; crcopy(newcred, oldcred); newcred->cr_flags |= CRED_FLAG_CAPMODE; - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); return (0); Modified: stable/10/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/10/sys/security/audit/audit_syscalls.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/security/audit/audit_syscalls.c Mon Jun 27 21:25:01 2016 (r302229) @@ -461,7 +461,7 @@ sys_auditon(struct thread *td, struct au udata.au_aupinfo.ap_mask.am_success; newcred->cr_audit.ai_mask.am_failure = udata.au_aupinfo.ap_mask.am_failure; - tp->p_ucred = newcred; + proc_set_cred(tp, newcred); PROC_UNLOCK(tp); crfree(oldcred); break; @@ -600,7 +600,7 @@ sys_setauid(struct thread *td, struct se if (error) goto fail; newcred->cr_audit.ai_auid = id; - td->td_proc->p_ucred = newcred; + proc_set_cred(td->td_proc, newcred); PROC_UNLOCK(td->td_proc); crfree(oldcred); return (0); @@ -671,7 +671,7 @@ sys_setaudit(struct thread *td, struct s newcred->cr_audit.ai_termid.at_addr[0] = ai.ai_termid.machine; newcred->cr_audit.ai_termid.at_port = ai.ai_termid.port; newcred->cr_audit.ai_termid.at_type = AU_IPv4; - td->td_proc->p_ucred = newcred; + proc_set_cred(td->td_proc, newcred); PROC_UNLOCK(td->td_proc); crfree(oldcred); return (0); @@ -728,7 +728,7 @@ sys_setaudit_addr(struct thread *td, str if (error) goto fail; newcred->cr_audit = aia; - td->td_proc->p_ucred = newcred; + proc_set_cred(td->td_proc, newcred); PROC_UNLOCK(td->td_proc); crfree(oldcred); return (0); Modified: stable/10/sys/security/mac/mac_syscalls.c ============================================================================== --- stable/10/sys/security/mac/mac_syscalls.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/security/mac/mac_syscalls.c Mon Jun 27 21:25:01 2016 (r302229) @@ -208,7 +208,7 @@ sys___mac_set_proc(struct thread *td, st setsugid(p); crcopy(newcred, oldcred); mac_cred_relabel(newcred, intlabel); - p->p_ucred = newcred; + proc_set_cred(p, newcred); PROC_UNLOCK(p); crfree(oldcred); Modified: stable/10/sys/security/mac_lomac/mac_lomac.c ============================================================================== --- stable/10/sys/security/mac_lomac/mac_lomac.c Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/security/mac_lomac/mac_lomac.c Mon Jun 27 21:25:01 2016 (r302229) @@ -2275,7 +2275,7 @@ lomac_thread_userret(struct thread *td) crcopy(newcred, oldcred); crhold(newcred); lomac_copy(&subj->mac_lomac, SLOT(newcred->cr_label)); - p->p_ucred = newcred; + proc_set_cred(p, newcred); crfree(oldcred); dodrop = 1; out: Modified: stable/10/sys/sys/ucred.h ============================================================================== --- stable/10/sys/sys/ucred.h Mon Jun 27 20:54:02 2016 (r302228) +++ stable/10/sys/sys/ucred.h Mon Jun 27 21:25:01 2016 (r302229) @@ -106,6 +106,7 @@ struct ucred *crcopysafe(struct proc *p, struct ucred *crdup(struct ucred *cr); void crextend(struct ucred *cr, int n); void cred_update_thread(struct thread *td); +struct ucred *proc_set_cred(struct proc *p, struct ucred *cr); void crfree(struct ucred *cr); struct ucred *crget(void); struct ucred *crhold(struct ucred *cr); From owner-svn-src-all@freebsd.org Mon Jun 27 21:30:38 2016 Return-Path: Delivered-To: svn-src-all@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 C9AF7B85F8F; Mon, 27 Jun 2016 21:30:38 +0000 (UTC) (envelope-from bdrewery@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 969F22755; Mon, 27 Jun 2016 21:30:38 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLUba8020595; Mon, 27 Jun 2016 21:30:37 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLUbeQ020593; Mon, 27 Jun 2016 21:30:37 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272130.u5RLUbeQ020593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:30:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302230 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:30:38 -0000 Author: bdrewery Date: Mon Jun 27 21:30:37 2016 New Revision: 302230 URL: https://svnweb.freebsd.org/changeset/base/302230 Log: MFC r273351: Plug unnecessary binvp NULL initialization and test. Modified: stable/10/sys/kern/kern_exec.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:25:01 2016 (r302229) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:30:37 2016 (r302230) @@ -372,7 +372,7 @@ do_execve(td, args, mac_p) struct vnode *tracevp = NULL; struct ucred *tracecred = NULL; #endif - struct vnode *textvp = NULL, *binvp = NULL; + struct vnode *textvp = NULL, *binvp; cap_rights_t rights; int credential_changing; int textset; @@ -446,7 +446,7 @@ interpret: if (error) goto exec_fail; - binvp = nd.ni_vp; + binvp = nd.ni_vp; imgp->vp = binvp; } else { AUDIT_ARG_FD(args->fd); @@ -865,7 +865,7 @@ done1: */ if (textvp != NULL) vrele(textvp); - if (binvp && error != 0) + if (error != 0) vrele(binvp); #ifdef KTRACE if (tracevp != NULL) From owner-svn-src-all@freebsd.org Mon Jun 27 21:35:20 2016 Return-Path: Delivered-To: svn-src-all@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 B51B6B8439C; Mon, 27 Jun 2016 21:35:20 +0000 (UTC) (envelope-from bdrewery@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 81E532DB6; Mon, 27 Jun 2016 21:35:20 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLZJo9024128; Mon, 27 Jun 2016 21:35:19 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLZJxP024127; Mon, 27 Jun 2016 21:35:19 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272135.u5RLZJxP024127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:35:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302231 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:35:20 -0000 Author: bdrewery Date: Mon Jun 27 21:35:19 2016 New Revision: 302231 URL: https://svnweb.freebsd.org/changeset/base/302231 Log: MFC r285512: exec plug a redundant vref + vrele of the image vnode Modified: stable/10/sys/kern/kern_exec.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:30:37 2016 (r302230) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:35:19 2016 (r302231) @@ -613,9 +613,6 @@ interpret: vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - /* Get a reference to the vnode prior to locking the proc */ - VREF(binvp); - /* * For security and other reasons, signal handlers cannot * be shared after an exec. The new process gets a copy of the old @@ -782,8 +779,8 @@ interpret: } /* - * Store the vp for use in procfs. This vnode was referenced prior - * to locking the proc lock. + * Store the vp for use in procfs. This vnode was referenced by namei + * or fgetvp_exec. */ textvp = p->p_textvp; p->p_textvp = binvp; @@ -865,8 +862,6 @@ done1: */ if (textvp != NULL) vrele(textvp); - if (error != 0) - vrele(binvp); #ifdef KTRACE if (tracevp != NULL) vrele(tracevp); @@ -892,7 +887,10 @@ exec_fail_dealloc: NDFREE(&nd, NDF_ONLY_PNBUF); if (imgp->opened) VOP_CLOSE(imgp->vp, FREAD, td->td_ucred, td); - vput(imgp->vp); + if (error != 0) + vput(imgp->vp); + else + VOP_UNLOCK(imgp->vp, 0); } if (imgp->object != NULL) From owner-svn-src-all@freebsd.org Mon Jun 27 21:37:31 2016 Return-Path: Delivered-To: svn-src-all@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 69EAAB84492; Mon, 27 Jun 2016 21:37:31 +0000 (UTC) (envelope-from bdrewery@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 2B70E2F60; Mon, 27 Jun 2016 21:37:31 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLbUfo024240; Mon, 27 Jun 2016 21:37:30 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLbUYd024239; Mon, 27 Jun 2016 21:37:30 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272137.u5RLbUYd024239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:37:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302232 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:37:31 -0000 Author: bdrewery Date: Mon Jun 27 21:37:30 2016 New Revision: 302232 URL: https://svnweb.freebsd.org/changeset/base/302232 Log: MFC r285513: exec: textvp -> oldtextvp; binvp -> newtextvp Modified: stable/10/sys/kern/kern_exec.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:35:19 2016 (r302231) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:37:30 2016 (r302232) @@ -372,7 +372,7 @@ do_execve(td, args, mac_p) struct vnode *tracevp = NULL; struct ucred *tracecred = NULL; #endif - struct vnode *textvp = NULL, *binvp; + struct vnode *oldtextvp = NULL, *newtextvp; cap_rights_t rights; int credential_changing; int textset; @@ -446,20 +446,20 @@ interpret: if (error) goto exec_fail; - binvp = nd.ni_vp; - imgp->vp = binvp; + newtextvp = nd.ni_vp; + imgp->vp = newtextvp; } else { AUDIT_ARG_FD(args->fd); /* * Descriptors opened only with O_EXEC or O_RDONLY are allowed. */ error = fgetvp_exec(td, args->fd, - cap_rights_init(&rights, CAP_FEXECVE), &binvp); + cap_rights_init(&rights, CAP_FEXECVE), &newtextvp); if (error) goto exec_fail; - vn_lock(binvp, LK_EXCLUSIVE | LK_RETRY); - AUDIT_ARG_VNODE1(binvp); - imgp->vp = binvp; + vn_lock(newtextvp, LK_EXCLUSIVE | LK_RETRY); + AUDIT_ARG_VNODE1(newtextvp); + imgp->vp = newtextvp; } /* @@ -536,13 +536,13 @@ interpret: if (args->fname != NULL) NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC - mac_execve_interpreter_enter(binvp, &interpvplabel); + mac_execve_interpreter_enter(newtextvp, &interpvplabel); #endif if (imgp->opened) { - VOP_CLOSE(binvp, FREAD, td->td_ucred, td); + VOP_CLOSE(newtextvp, FREAD, td->td_ucred, td); imgp->opened = 0; } - vput(binvp); + vput(newtextvp); vm_object_deallocate(imgp->object); imgp->object = NULL; /* set new name to that of the interpreter */ @@ -643,7 +643,7 @@ interpret: if (args->fname) bcopy(nd.ni_cnd.cn_nameptr, p->p_comm, min(nd.ni_cnd.cn_namelen, MAXCOMLEN)); - else if (vn_commname(binvp, p->p_comm, sizeof(p->p_comm)) != 0) + else if (vn_commname(newtextvp, p->p_comm, sizeof(p->p_comm)) != 0) bcopy(fexecv_proc_title, p->p_comm, sizeof(fexecv_proc_title)); bcopy(p->p_comm, td->td_name, sizeof(td->td_name)); #ifdef KTR @@ -782,8 +782,8 @@ interpret: * Store the vp for use in procfs. This vnode was referenced by namei * or fgetvp_exec. */ - textvp = p->p_textvp; - p->p_textvp = binvp; + oldtextvp = p->p_textvp; + p->p_textvp = newtextvp; #ifdef KDTRACE_HOOKS /* @@ -860,8 +860,8 @@ done1: /* * Handle deferred decrement of ref counts. */ - if (textvp != NULL) - vrele(textvp); + if (oldtextvp != NULL) + vrele(oldtextvp); #ifdef KTRACE if (tracevp != NULL) vrele(tracevp); From owner-svn-src-all@freebsd.org Mon Jun 27 21:44:29 2016 Return-Path: Delivered-To: svn-src-all@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 E149EB84915; Mon, 27 Jun 2016 21:44:29 +0000 (UTC) (envelope-from bdrewery@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 A241D27DC; Mon, 27 Jun 2016 21:44:29 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLiSKw027800; Mon, 27 Jun 2016 21:44:28 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLiSuk027793; Mon, 27 Jun 2016 21:44:28 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272144.u5RLiSuk027793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:44:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302233 - in stable/10/sys: kern net netinet rpc ufs/ufs X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:44:30 -0000 Author: bdrewery Date: Mon Jun 27 21:44:27 2016 New Revision: 302233 URL: https://svnweb.freebsd.org/changeset/base/302233 Log: MFC r297391: Remove some NULL checks for M_WAITOK allocations. Modified: stable/10/sys/kern/imgact_elf.c stable/10/sys/kern/kern_exec.c stable/10/sys/kern/kern_linker.c stable/10/sys/net/rtsock.c stable/10/sys/netinet/tcp_subr.c stable/10/sys/rpc/rpc_generic.c stable/10/sys/ufs/ufs/ufs_extattr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/imgact_elf.c ============================================================================== --- stable/10/sys/kern/imgact_elf.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/kern/imgact_elf.c Mon Jun 27 21:44:27 2016 (r302233) @@ -1325,10 +1325,6 @@ __elfN(coredump)(struct thread *td, stru * and write it out following the notes. */ hdr = malloc(hdrsize, M_TEMP, M_WAITOK); - if (hdr == NULL) { - error = EINVAL; - goto done; - } error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize, ¬elst, notesz, gzfile); Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:44:27 2016 (r302233) @@ -1498,8 +1498,6 @@ exec_register(execsw_arg) for (es = execsw; *es; es++) count++; newexecsw = malloc(count * sizeof(*es), M_TEMP, M_WAITOK); - if (newexecsw == NULL) - return (ENOMEM); xs = newexecsw; if (execsw) for (es = execsw; *es; es++) @@ -1532,8 +1530,6 @@ exec_unregister(execsw_arg) if (*es != execsw_arg) count++; newexecsw = malloc(count * sizeof(*es), M_TEMP, M_WAITOK); - if (newexecsw == NULL) - return (ENOMEM); xs = newexecsw; for (es = execsw; *es; es++) if (*es != execsw_arg) Modified: stable/10/sys/kern/kern_linker.c ============================================================================== --- stable/10/sys/kern/kern_linker.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/kern/kern_linker.c Mon Jun 27 21:44:27 2016 (r302233) @@ -1762,8 +1762,6 @@ linker_hints_lookup(const char *path, in goto bad; } hints = malloc(vattr.va_size, M_TEMP, M_WAITOK); - if (hints == NULL) - goto bad; error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)hints, vattr.va_size, 0, UIO_SYSSPACE, IO_NODELOCKED, cred, NOCRED, &reclen, td); if (error) Modified: stable/10/sys/net/rtsock.c ============================================================================== --- stable/10/sys/net/rtsock.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/net/rtsock.c Mon Jun 27 21:44:27 2016 (r302233) @@ -301,8 +301,6 @@ rts_attach(struct socket *so, int proto, /* XXX */ rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO); - if (rp == NULL) - return ENOBUFS; so->so_pcb = (caddr_t)rp; so->so_fibnum = td->td_proc->p_fibnum; Modified: stable/10/sys/netinet/tcp_subr.c ============================================================================== --- stable/10/sys/netinet/tcp_subr.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/netinet/tcp_subr.c Mon Jun 27 21:44:27 2016 (r302233) @@ -1285,8 +1285,6 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS) return (error); inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK); - if (inp_list == NULL) - return (ENOMEM); INP_INFO_RLOCK(&V_tcbinfo); for (inp = LIST_FIRST(V_tcbinfo.ipi_listhead), i = 0; Modified: stable/10/sys/rpc/rpc_generic.c ============================================================================== --- stable/10/sys/rpc/rpc_generic.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/rpc/rpc_generic.c Mon Jun 27 21:44:27 2016 (r302233) @@ -390,15 +390,11 @@ __rpc_uaddr2taddr_af(int af, const char } ret = (struct netbuf *)malloc(sizeof *ret, M_RPC, M_WAITOK); - if (ret == NULL) - goto out; switch (af) { case AF_INET: sin = (struct sockaddr_in *)malloc(sizeof *sin, M_RPC, M_WAITOK); - if (sin == NULL) - goto out; memset(sin, 0, sizeof *sin); sin->sin_family = AF_INET; sin->sin_port = htons(port); @@ -415,8 +411,6 @@ __rpc_uaddr2taddr_af(int af, const char case AF_INET6: sin6 = (struct sockaddr_in6 *)malloc(sizeof *sin6, M_RPC, M_WAITOK); - if (sin6 == NULL) - goto out; memset(sin6, 0, sizeof *sin6); sin6->sin6_family = AF_INET6; sin6->sin6_port = htons(port); @@ -433,8 +427,6 @@ __rpc_uaddr2taddr_af(int af, const char case AF_LOCAL: sun = (struct sockaddr_un *)malloc(sizeof *sun, M_RPC, M_WAITOK); - if (sun == NULL) - goto out; memset(sun, 0, sizeof *sun); sun->sun_family = AF_LOCAL; strncpy(sun->sun_path, addrstr, sizeof(sun->sun_path) - 1); Modified: stable/10/sys/ufs/ufs/ufs_extattr.c ============================================================================== --- stable/10/sys/ufs/ufs/ufs_extattr.c Mon Jun 27 21:37:30 2016 (r302232) +++ stable/10/sys/ufs/ufs/ufs_extattr.c Mon Jun 27 21:44:27 2016 (r302233) @@ -599,8 +599,6 @@ ufs_extattr_enable(struct ufsmount *ump, attribute = malloc(sizeof(struct ufs_extattr_list_entry), M_UFS_EXTATTR, M_WAITOK); - if (attribute == NULL) - return (ENOMEM); if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) { error = EOPNOTSUPP; From owner-svn-src-all@freebsd.org Mon Jun 27 21:50:36 2016 Return-Path: Delivered-To: svn-src-all@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 04D8CB84C36; Mon, 27 Jun 2016 21:50:36 +0000 (UTC) (envelope-from bdrewery@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 C36962FB1; Mon, 27 Jun 2016 21:50:35 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLoZpL028197; Mon, 27 Jun 2016 21:50:35 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLoULA028150; Mon, 27 Jun 2016 21:50:30 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272150.u5RLoULA028150@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 21:50:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302234 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 21:50:36 -0000 Author: bdrewery Date: Mon Jun 27 21:50:30 2016 New Revision: 302234 URL: https://svnweb.freebsd.org/changeset/base/302234 Log: MFC r298819: sys/kern: spelling fixes in comments. Modified: stable/10/sys/kern/bus_if.m stable/10/sys/kern/imgact_binmisc.c stable/10/sys/kern/inflate.c stable/10/sys/kern/kern_condvar.c stable/10/sys/kern/kern_descrip.c stable/10/sys/kern/kern_exec.c stable/10/sys/kern/kern_fork.c stable/10/sys/kern/kern_jail.c stable/10/sys/kern/kern_linker.c stable/10/sys/kern/kern_lock.c stable/10/sys/kern/kern_lockf.c stable/10/sys/kern/kern_mbuf.c stable/10/sys/kern/kern_mtxpool.c stable/10/sys/kern/kern_prot.c stable/10/sys/kern/kern_rctl.c stable/10/sys/kern/kern_rmlock.c stable/10/sys/kern/kern_sysctl.c stable/10/sys/kern/kern_tc.c stable/10/sys/kern/kern_timeout.c stable/10/sys/kern/link_elf_obj.c stable/10/sys/kern/linker_if.m stable/10/sys/kern/sched_4bsd.c stable/10/sys/kern/subr_blist.c stable/10/sys/kern/subr_bus.c stable/10/sys/kern/subr_devstat.c stable/10/sys/kern/subr_mbpool.c stable/10/sys/kern/subr_mchain.c stable/10/sys/kern/subr_msgbuf.c stable/10/sys/kern/subr_prof.c stable/10/sys/kern/subr_scanf.c stable/10/sys/kern/subr_uio.c stable/10/sys/kern/subr_witness.c stable/10/sys/kern/sysv_sem.c stable/10/sys/kern/tty.c stable/10/sys/kern/tty_pts.c stable/10/sys/kern/uipc_mbuf2.c stable/10/sys/kern/uipc_socket.c stable/10/sys/kern/vfs_cache.c stable/10/sys/kern/vfs_cluster.c stable/10/sys/kern/vfs_lookup.c stable/10/sys/kern/vfs_mountroot.c stable/10/sys/kern/vfs_subr.c stable/10/sys/kern/vnode_if.src Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/bus_if.m ============================================================================== --- stable/10/sys/kern/bus_if.m Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/bus_if.m Mon Jun 27 21:50:30 2016 (r302234) @@ -121,7 +121,7 @@ METHOD void probe_nomatch { * @param _child the child device whose instance variable is * being read * @param _index the instance variable to read - * @param _result a loction to recieve the instance variable + * @param _result a location to receive the instance variable * value * * @retval 0 success @@ -374,7 +374,7 @@ METHOD int release_resource { * triggers * @param _arg a value to use as the single argument in calls * to @p _intr - * @param _cookiep a pointer to a location to recieve a cookie + * @param _cookiep a pointer to a location to receive a cookie * value that may be used to remove the interrupt * handler */ @@ -445,9 +445,9 @@ METHOD int set_resource { * @param _child the device which owns the resource * @param _type the type of resource * @param _rid the resource identifier - * @param _start the address of a location to recieve the start + * @param _start the address of a location to receive the start * index of the resource range - * @param _count the address of a location to recieve the size + * @param _count the address of a location to receive the size * of the resource range */ METHOD int get_resource { Modified: stable/10/sys/kern/imgact_binmisc.c ============================================================================== --- stable/10/sys/kern/imgact_binmisc.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/imgact_binmisc.c Mon Jun 27 21:50:30 2016 (r302234) @@ -708,7 +708,7 @@ imgact_binmisc_exec(struct image_params break; case ' ': - /* Replace space with NUL to seperate arguments. */ + /* Replace space with NUL to separate arguments. */ *d++ = '\0'; break; Modified: stable/10/sys/kern/inflate.c ============================================================================== --- stable/10/sys/kern/inflate.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/inflate.c Mon Jun 27 21:50:30 2016 (r302234) @@ -206,7 +206,7 @@ extern void kzipfree (void*); end-of-block. Note however that the static length tree defines 288 codes just to fill out the Huffman codes. Codes 286 and 287 cannot be used though, since there is no length base or extra bits - defined for them. Similarily, there are up to 30 distance codes. + defined for them. Similarly, there are up to 30 distance codes. However, static trees define 32 codes (all 5 bits) to fill out the Huffman codes, but the last two had better not show up in the data. 7. Unzip can check dynamic Huffman blocks for complete code sets. @@ -335,7 +335,7 @@ static const ush mask[] = { where NEEDBITS makes sure that b has at least j bits in it, and DUMPBITS removes the bits from b. The macros use the variable k for the number of bits in b. Normally, b and k are register - variables for speed, and are initialized at the begining of a + variables for speed, and are initialized at the beginning of a routine that uses these macros from a global bit buffer and count. In order to not ask for more bits than there are in the compressed Modified: stable/10/sys/kern/kern_condvar.c ============================================================================== --- stable/10/sys/kern/kern_condvar.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_condvar.c Mon Jun 27 21:50:30 2016 (r302234) @@ -163,7 +163,7 @@ _cv_wait(struct cv *cvp, struct lock_obj /* * Wait on a condition variable. This function differs from cv_wait by - * not aquiring the mutex after condition variable was signaled. + * not acquiring the mutex after condition variable was signaled. */ void _cv_wait_unlock(struct cv *cvp, struct lock_object *lock) Modified: stable/10/sys/kern/kern_descrip.c ============================================================================== --- stable/10/sys/kern/kern_descrip.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_descrip.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1525,7 +1525,7 @@ fdgrowtable_exp(struct filedesc *fdp, in } /* - * Grow the file table to accomodate (at least) nfd descriptors. + * Grow the file table to accommodate (at least) nfd descriptors. */ static void fdgrowtable(struct filedesc *fdp, int nfd) @@ -1730,7 +1730,7 @@ fdavail(struct thread *td, int n) } /* - * Create a new open file structure and allocate a file decriptor for the + * Create a new open file structure and allocate a file descriptor for the * process that refers to it. We add one reference to the file for the * descriptor table and one reference for resultfp. This is to prevent us * being preempted and the entry in the descriptor table closed after we @@ -2448,7 +2448,7 @@ fget_unlocked(struct filedesc *fdp, int * * File's rights will be checked against the capability rights mask. * - * If an error occured the non-zero error is returned and *fpp is set to + * If an error occurred the non-zero error is returned and *fpp is set to * NULL. Otherwise *fpp is held and set and zero is returned. Caller is * responsible for fdrop(). */ Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 21:50:30 2016 (r302234) @@ -416,7 +416,7 @@ do_execve(td, args, mac_p) /* * Translate the file name. namei() returns a vnode pointer - * in ni_vp amoung other things. + * in ni_vp among other things. * * XXXAUDIT: It would be desirable to also audit the name of the * interpreter if this is an interpreted binary. Modified: stable/10/sys/kern/kern_fork.c ============================================================================== --- stable/10/sys/kern/kern_fork.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_fork.c Mon Jun 27 21:50:30 2016 (r302234) @@ -900,7 +900,7 @@ fork1(struct thread *td, int flags, int /* * The swap reservation failed. The accounting * from the entries of the copied vm2 will be - * substracted in vmspace_free(), so force the + * subtracted in vmspace_free(), so force the * reservation there. */ swap_reserve_force(mem_charged); Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_jail.c Mon Jun 27 21:50:30 2016 (r302234) @@ -4072,7 +4072,7 @@ prison_priv_check(struct ucred *cred, in return (0); /* - * Allow jailed root to set certian IPv4/6 (option) headers. + * Allow jailed root to set certain IPv4/6 (option) headers. */ case PRIV_NETINET_SETHDROPTS: return (0); @@ -4313,7 +4313,7 @@ SYSCTL_UINT(_security_jail, OID_AUTO, ja #endif /* - * Default parameters for jail(2) compatability. For historical reasons, + * Default parameters for jail(2) compatibility. For historical reasons, * the sysctl names have varying similarity to the parameter names. Prisons * just see their own parameters, and can't change them. */ Modified: stable/10/sys/kern/kern_linker.c ============================================================================== --- stable/10/sys/kern/kern_linker.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_linker.c Mon Jun 27 21:50:30 2016 (r302234) @@ -948,7 +948,7 @@ linker_debug_search_symbol_name(caddr_t * * Note that we do not obey list locking protocols here. We really don't need * DDB to hang because somebody's got the lock held. We'll take the chance - * that the files list is inconsistant instead. + * that the files list is inconsistent instead. */ #ifdef DDB int @@ -2036,7 +2036,7 @@ linker_load_dependencies(linker_file_t l int ver, error = 0, count; /* - * All files are dependant on /kernel. + * All files are dependent on /kernel. */ sx_assert(&kld_sx, SA_XLOCKED); if (linker_kernel_file) { Modified: stable/10/sys/kern/kern_lock.c ============================================================================== --- stable/10/sys/kern/kern_lock.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_lock.c Mon Jun 27 21:50:30 2016 (r302234) @@ -286,7 +286,7 @@ wakeupshlk(struct lock *lk, const char * * exclusive waiters bit anyway. * Please note that lk_exslpfail count may be lying about * the real number of waiters with the LK_SLEEPFAIL flag on - * because they may be used in conjuction with interruptible + * because they may be used in conjunction with interruptible * sleeps so lk_exslpfail might be considered an 'upper limit' * bound, including the edge cases. */ @@ -1063,7 +1063,7 @@ __lockmgr_args(struct lock *lk, u_int fl * Please note that lk_exslpfail count may be lying * about the real number of waiters with the * LK_SLEEPFAIL flag on because they may be used in - * conjuction with interruptible sleeps so + * conjunction with interruptible sleeps so * lk_exslpfail might be considered an 'upper limit' * bound, including the edge cases. */ @@ -1176,7 +1176,7 @@ __lockmgr_args(struct lock *lk, u_int fl * Please note that lk_exslpfail count may be * lying about the real number of waiters with * the LK_SLEEPFAIL flag on because they may - * be used in conjuction with interruptible + * be used in conjunction with interruptible * sleeps so lk_exslpfail might be considered * an 'upper limit' bound, including the edge * cases. Modified: stable/10/sys/kern/kern_lockf.c ============================================================================== --- stable/10/sys/kern/kern_lockf.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_lockf.c Mon Jun 27 21:50:30 2016 (r302234) @@ -362,7 +362,7 @@ lf_free_lock(struct lockf_entry *lock) struct lock_owner *lo = lock->lf_owner; if (lo) { KASSERT(LIST_EMPTY(&lock->lf_outedges), - ("freeing lock with dependancies")); + ("freeing lock with dependencies")); KASSERT(LIST_EMPTY(&lock->lf_inedges), ("freeing lock with dependants")); sx_xlock(&lf_lock_owners_lock); @@ -827,7 +827,7 @@ lf_purgelocks(struct vnode *vp, struct l /* * We can just free all the active locks since they - * will have no dependancies (we removed them all + * will have no dependencies (we removed them all * above). We don't need to bother locking since we * are the last thread using this state structure. */ @@ -1112,7 +1112,7 @@ lf_insert_lock(struct lockf *state, stru /* * Wake up a sleeping lock and remove it from the pending list now - * that all its dependancies have been resolved. The caller should + * that all its dependencies have been resolved. The caller should * arrange for the lock to be added to the active list, adjusting any * existing locks for the same owner as needed. */ @@ -1137,9 +1137,9 @@ lf_wakeup_lock(struct lockf *state, stru } /* - * Re-check all dependant locks and remove edges to locks that we no + * Re-check all dependent locks and remove edges to locks that we no * longer block. If 'all' is non-zero, the lock has been removed and - * we must remove all the dependancies, otherwise it has simply been + * we must remove all the dependencies, otherwise it has simply been * reduced but remains active. Any pending locks which have been been * unblocked are added to 'granted' */ @@ -1165,7 +1165,7 @@ lf_update_dependancies(struct lockf *sta } /* - * Set the start of an existing active lock, updating dependancies and + * Set the start of an existing active lock, updating dependencies and * adding any newly woken locks to 'granted'. */ static void @@ -1181,7 +1181,7 @@ lf_set_start(struct lockf *state, struct } /* - * Set the end of an existing active lock, updating dependancies and + * Set the end of an existing active lock, updating dependencies and * adding any newly woken locks to 'granted'. */ static void @@ -1204,7 +1204,7 @@ lf_set_end(struct lockf *state, struct l * pending locks as a result of downgrading/unlocking. We simply * activate the newly granted locks by looping. * - * Since the new lock already has its dependancies set up, we always + * Since the new lock already has its dependencies set up, we always * add it to the list (unless its an unlock request). This may * fragment the lock list in some pathological cases but its probably * not a real problem. @@ -1332,7 +1332,7 @@ lf_cancel_lock(struct lockf *state, stru * may allow some other pending lock to become * active. Consider this case: * - * Owner Action Result Dependancies + * Owner Action Result Dependencies * * A: lock [0..0] succeeds * B: lock [2..2] succeeds @@ -1840,7 +1840,7 @@ lf_split(struct lockf *state, struct loc /* * This cannot cause a deadlock since any edges we would add * to splitlock already exist in lock1. We must be sure to add - * necessary dependancies to splitlock before we reduce lock1 + * necessary dependencies to splitlock before we reduce lock1 * otherwise we may accidentally grant a pending lock that * was blocked by the tail end of lock1. */ Modified: stable/10/sys/kern/kern_mbuf.c ============================================================================== --- stable/10/sys/kern/kern_mbuf.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_mbuf.c Mon Jun 27 21:50:30 2016 (r302234) @@ -92,7 +92,7 @@ __FBSDID("$FreeBSD$"); * * Whenever an object is allocated from the underlying global * memory pool it gets pre-initialized with the _zinit_ functions. - * When the Keg's are overfull objects get decomissioned with + * When the Keg's are overfull objects get decommissioned with * _zfini_ functions and free'd back to the global memory pool. * */ Modified: stable/10/sys/kern/kern_mtxpool.c ============================================================================== --- stable/10/sys/kern/kern_mtxpool.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_mtxpool.c Mon Jun 27 21:50:30 2016 (r302234) @@ -39,7 +39,7 @@ * * Disadvantages: * - should generally only be used as leaf mutexes. - * - pool/pool dependancy ordering cannot be depended on. + * - pool/pool dependency ordering cannot be depended on. * - possible L1 cache mastersip contention between cpus. */ Modified: stable/10/sys/kern/kern_prot.c ============================================================================== --- stable/10/sys/kern/kern_prot.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_prot.c Mon Jun 27 21:50:30 2016 (r302234) @@ -147,7 +147,7 @@ sys_getpgrp(struct thread *td, struct ge return (0); } -/* Get an arbitary pid's process group id */ +/* Get an arbitrary pid's process group id */ #ifndef _SYS_SYSPROTO_H_ struct getpgid_args { pid_t pid; @@ -178,7 +178,7 @@ sys_getpgid(struct thread *td, struct ge } /* - * Get an arbitary pid's session id. + * Get an arbitrary pid's session id. */ #ifndef _SYS_SYSPROTO_H_ struct getsid_args { Modified: stable/10/sys/kern/kern_rctl.c ============================================================================== --- stable/10/sys/kern/kern_rctl.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_rctl.c Mon Jun 27 21:50:30 2016 (r302234) @@ -310,7 +310,7 @@ rctl_pcpu_available(const struct proc *p /* * Return slightly less than actual value of the available - * %cpu resource. This makes %cpu throttling more agressive + * %cpu resource. This makes %cpu throttling more aggressive * and lets us act sooner than the limits are already exceeded. */ if (limit != 0) { Modified: stable/10/sys/kern/kern_rmlock.c ============================================================================== --- stable/10/sys/kern/kern_rmlock.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_rmlock.c Mon Jun 27 21:50:30 2016 (r302234) @@ -370,7 +370,7 @@ _rm_rlock_hard(struct rmlock *rm, struct } /* - * We allow readers to aquire a lock even if a writer is blocked if + * We allow readers to acquire a lock even if a writer is blocked if * the lock is recursive and the reader already holds the lock. */ if ((rm->lock_object.lo_flags & LO_RECURSABLE) != 0) { Modified: stable/10/sys/kern/kern_sysctl.c ============================================================================== --- stable/10/sys/kern/kern_sysctl.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_sysctl.c Mon Jun 27 21:50:30 2016 (r302234) @@ -172,7 +172,7 @@ sysctl_register_oid(struct sysctl_oid *o * * NOTE: DO NOT change the starting value here, change it in * , and make sure it is at least 256 to - * accomodate e.g. net.inet.raw as a static sysctl node. + * accommodate e.g. net.inet.raw as a static sysctl node. */ if (oid_number < 0) { static int newoid; @@ -295,7 +295,7 @@ sysctl_ctx_free(struct sysctl_ctx_list * } /* * Restore deregistered entries, either from the end, - * or from the place where error occured. + * or from the place where error occurred. * e contains the entry that was not unregistered */ if (error) Modified: stable/10/sys/kern/kern_tc.c ============================================================================== --- stable/10/sys/kern/kern_tc.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_tc.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1855,7 +1855,7 @@ inittimecounter(void *dummy) * Set the initial timeout to * max(1, ). * People should probably not use the sysctl to set the timeout - * to smaller than its inital value, since that value is the + * to smaller than its initial value, since that value is the * smallest reasonable one. If they want better timestamps they * should use the non-"get"* functions. */ Modified: stable/10/sys/kern/kern_timeout.c ============================================================================== --- stable/10/sys/kern/kern_timeout.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/kern_timeout.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1397,7 +1397,7 @@ _callout_init_lock(c, lock, flags) * which set the timer can do the maintanence the timer was for as close * as possible to the originally intended time. Testing this code for a * week showed that resuming from a suspend resulted in 22 to 25 timers - * firing, which seemed independant on whether the suspend was 2 hours or + * firing, which seemed independent on whether the suspend was 2 hours or * 2 days. Your milage may vary. - Ken Key */ void Modified: stable/10/sys/kern/link_elf_obj.c ============================================================================== --- stable/10/sys/kern/link_elf_obj.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/link_elf_obj.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1099,7 +1099,7 @@ relocate_file(elf_file_t ef) } /* - * Only clean SHN_FBSD_CACHED for successfull return. If we + * Only clean SHN_FBSD_CACHED for successful return. If we * modified symbol table for the object but found an * unresolved symbol, there is no reason to roll back. */ Modified: stable/10/sys/kern/linker_if.m ============================================================================== --- stable/10/sys/kern/linker_if.m Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/linker_if.m Mon Jun 27 21:50:30 2016 (r302234) @@ -89,7 +89,7 @@ METHOD int lookup_set { }; # -# Unload a file, releasing dependancies and freeing storage. +# Unload a file, releasing dependencies and freeing storage. # METHOD void unload { linker_file_t file; Modified: stable/10/sys/kern/sched_4bsd.c ============================================================================== --- stable/10/sys/kern/sched_4bsd.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/sched_4bsd.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1393,7 +1393,7 @@ sched_add(struct thread *td, int flags) * or kicking off another CPU as it won't help and may hinder. * In the YIEDLING case, we are about to run whoever is being * put in the queue anyhow, and in the OURSELF case, we are - * puting ourself on the run queue which also only happens + * putting ourself on the run queue which also only happens * when we are about to yield. */ if ((flags & SRQ_YIELDING) == 0) { Modified: stable/10/sys/kern/subr_blist.c ============================================================================== --- stable/10/sys/kern/subr_blist.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_blist.c Mon Jun 27 21:50:30 2016 (r302234) @@ -57,8 +57,8 @@ * The non-blocking features of the blist code are used in the swap code * (vm/swap_pager.c). * - * LAYOUT: The radix tree is layed out recursively using a - * linear array. Each meta node is immediately followed (layed out + * LAYOUT: The radix tree is laid out recursively using a + * linear array. Each meta node is immediately followed (laid out * sequentially in memory) by BLIST_META_RADIX lower level nodes. This * is a recursive structure but one that can be easily scanned through * a very simple 'skip' calculation. In order to support large radixes, Modified: stable/10/sys/kern/subr_bus.c ============================================================================== --- stable/10/sys/kern/subr_bus.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_bus.c Mon Jun 27 21:50:30 2016 (r302234) @@ -4564,7 +4564,7 @@ root_setup_intr(device_t dev, device_t c } /* - * If we get here, assume that the device is permanant and really is + * If we get here, assume that the device is permanent and really is * present in the system. Removable bus drivers are expected to intercept * this call long before it gets here. We return -1 so that drivers that * really care can check vs -1 or some ERRNO returned higher in the food Modified: stable/10/sys/kern/subr_devstat.c ============================================================================== --- stable/10/sys/kern/subr_devstat.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_devstat.c Mon Jun 27 21:50:30 2016 (r302234) @@ -391,7 +391,7 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS) * XXX devstat_generation should really be "volatile" but that * XXX freaks out the sysctl macro below. The places where we * XXX change it and inspect it are bracketed in the mutex which - * XXX guarantees us proper write barriers. I don't belive the + * XXX guarantees us proper write barriers. I don't believe the * XXX compiler is allowed to optimize mygen away across calls * XXX to other functions, so the following is belived to be safe. */ Modified: stable/10/sys/kern/subr_mbpool.c ============================================================================== --- stable/10/sys/kern/subr_mbpool.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_mbpool.c Mon Jun 27 21:50:30 2016 (r302234) @@ -289,7 +289,7 @@ mbp_ext_free(struct mbuf *m, void *buf, } /* - * Free all buffers that are marked as beeing on the card + * Free all buffers that are marked as being on the card */ void mbp_card_free(struct mbpool *p) Modified: stable/10/sys/kern/subr_mchain.c ============================================================================== --- stable/10/sys/kern/subr_mchain.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_mchain.c Mon Jun 27 21:50:30 2016 (r302234) @@ -101,7 +101,7 @@ mb_fixhdr(struct mbchain *mbp) /* * Check if object of size 'size' fit to the current position and * allocate new mbuf if not. Advance pointers and increase length of mbuf(s). - * Return pointer to the object placeholder or NULL if any error occured. + * Return pointer to the object placeholder or NULL if any error occurred. * Note: size should be <= MLEN */ caddr_t Modified: stable/10/sys/kern/subr_msgbuf.c ============================================================================== --- stable/10/sys/kern/subr_msgbuf.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_msgbuf.c Mon Jun 27 21:50:30 2016 (r302234) @@ -50,7 +50,7 @@ static u_int msgbuf_cksum(struct msgbuf /* * Timestamps in msgbuf are useful when trying to diagnose when core dumps - * or other actions occured. + * or other actions occurred. */ static int msgbuf_show_timestamp = 0; SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW | CTLFLAG_TUN, Modified: stable/10/sys/kern/subr_prof.c ============================================================================== --- stable/10/sys/kern/subr_prof.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_prof.c Mon Jun 27 21:50:30 2016 (r302234) @@ -269,7 +269,7 @@ kmstartup(dummy) * without much risk of reducing the profiling times below what they * would be when profiling is not configured. Abbreviate: * ab = minimum time between MC1 and MC3 - * a = minumum time between MC1 and MC2 + * a = minimum time between MC1 and MC2 * b = minimum time between MC2 and MC3 * cd = minimum time between ME1 and ME3 * c = minimum time between ME1 and ME2 Modified: stable/10/sys/kern/subr_scanf.c ============================================================================== --- stable/10/sys/kern/subr_scanf.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_scanf.c Mon Jun 27 21:50:30 2016 (r302234) @@ -603,7 +603,7 @@ doswitch: * z', but treats `a-a' as `the letter a, the * character -, and the letter a'. * - * For compatibility, the `-' is not considerd + * For compatibility, the `-' is not considered * to define a range if the character following * it is either a close bracket (required by ANSI) * or is not numerically greater than the character Modified: stable/10/sys/kern/subr_uio.c ============================================================================== --- stable/10/sys/kern/subr_uio.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_uio.c Mon Jun 27 21:50:30 2016 (r302234) @@ -468,7 +468,7 @@ copyout_map(struct thread *td, vm_offset lim_max(td->td_proc, RLIMIT_DATA)); PROC_UNLOCK(td->td_proc); - /* round size up to page boundry */ + /* round size up to page boundary */ size = (vm_size_t)round_page(sz); error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, Modified: stable/10/sys/kern/subr_witness.c ============================================================================== --- stable/10/sys/kern/subr_witness.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/subr_witness.c Mon Jun 27 21:50:30 2016 (r302234) @@ -2898,7 +2898,7 @@ witness_lock_order_add(struct witness *p return (1); } -/* Call this whenver the structure of the witness graph changes. */ +/* Call this whenever the structure of the witness graph changes. */ static void witness_increment_graph_generation(void) { Modified: stable/10/sys/kern/sysv_sem.c ============================================================================== --- stable/10/sys/kern/sysv_sem.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/sysv_sem.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1153,7 +1153,7 @@ sys_semop(struct thread *td, struct semo if ((error = sem_prison_cansee(rpr, semakptr)) != 0) goto done2; /* - * Initial pass thru sops to see what permissions are needed. + * Initial pass through sops to see what permissions are needed. * Also perform any checks that don't need repeating on each * attempt to satisfy the request vector. */ Modified: stable/10/sys/kern/tty.c ============================================================================== --- stable/10/sys/kern/tty.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/tty.c Mon Jun 27 21:50:30 2016 (r302234) @@ -397,7 +397,7 @@ tty_wait_background(struct tty *tp, stru PROC_LOCK(p); /* * The process should only sleep, when: - * - This terminal is the controling terminal + * - This terminal is the controlling terminal * - Its process group is not the foreground process * group * - The parent process isn't waiting for the child to Modified: stable/10/sys/kern/tty_pts.c ============================================================================== --- stable/10/sys/kern/tty_pts.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/tty_pts.c Mon Jun 27 21:50:30 2016 (r302234) @@ -123,7 +123,7 @@ ptsdev_read(struct file *fp, struct uio /* * Implement packet mode. When packet mode is turned on, * the first byte contains a bitmask of events that - * occured (start, stop, flush, window size, etc). + * occurred (start, stop, flush, window size, etc). */ if (psc->pts_flags & PTS_PKT && psc->pts_pkt) { pkt = psc->pts_pkt; Modified: stable/10/sys/kern/uipc_mbuf2.c ============================================================================== --- stable/10/sys/kern/uipc_mbuf2.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/uipc_mbuf2.c Mon Jun 27 21:50:30 2016 (r302234) @@ -141,7 +141,7 @@ m_pulldown(struct mbuf *m, int off, int * Ideally, the requirement should only be (iii). * * If we're writable, we're sure we're writable, because the ref. count - * cannot increase from 1, as that would require posession of mbuf + * cannot increase from 1, as that would require possession of mbuf * n by someone else (which is impossible). However, if we're _not_ * writable, we may eventually become writable )if the ref. count drops * to 1), but we'll fail to notice it unless we re-evaluate Modified: stable/10/sys/kern/uipc_socket.c ============================================================================== --- stable/10/sys/kern/uipc_socket.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/uipc_socket.c Mon Jun 27 21:50:30 2016 (r302234) @@ -186,7 +186,7 @@ MALLOC_DEFINE(M_PCB, "pcb", "protocol co /* * Limit on the number of connections in the listen queue waiting * for accept(2). - * NB: The orginal sysctl somaxconn is still available but hidden + * NB: The original sysctl somaxconn is still available but hidden * to prevent confusion about the actual purpose of this number. */ static int somaxconn = SOMAXCONN; @@ -1091,7 +1091,7 @@ sosend_dgram(struct socket *so, struct s } /* * XXX all the SBS_CANTSENDMORE checks previously done could be out - * of date. We could have recieved a reset packet in an interrupt or + * of date. We could have received a reset packet in an interrupt or * maybe we slept while doing page faults in uiomove() etc. We could * probably recheck again inside the locking protection here, but * there are probably other places that this also happens. We must @@ -1271,7 +1271,7 @@ restart: } /* * XXX all the SBS_CANTSENDMORE checks previously - * done could be out of date. We could have recieved + * done could be out of date. We could have received * a reset packet in an interrupt or maybe we slept * while doing page faults in uiomove() etc. We * could probably recheck again inside the locking Modified: stable/10/sys/kern/vfs_cache.c ============================================================================== --- stable/10/sys/kern/vfs_cache.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vfs_cache.c Mon Jun 27 21:50:30 2016 (r302234) @@ -150,7 +150,7 @@ struct namecache_ts { */ /* - * Structures associated with name cacheing. + * Structures associated with name caching. */ #define NCHHASH(hash) \ (&nchashtbl[(hash) & nchash]) @@ -460,7 +460,7 @@ cache_zap(ncp) * cnp pointing to the name of the entry being sought. If the lookup * succeeds, the vnode is returned in *vpp, and a status of -1 is * returned. If the lookup determines that the name does not exist - * (negative cacheing), a status of ENOENT is returned. If the lookup + * (negative caching), a status of ENOENT is returned. If the lookup * fails, a status of zero is returned. If the directory vnode is * recycled out from under us due to a forced unmount, a status of * ENOENT is returned. Modified: stable/10/sys/kern/vfs_cluster.c ============================================================================== --- stable/10/sys/kern/vfs_cluster.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vfs_cluster.c Mon Jun 27 21:50:30 2016 (r302234) @@ -540,7 +540,7 @@ cluster_callback(bp) int error = 0; /* - * Must propogate errors to all the components. + * Must propagate errors to all the components. */ if (bp->b_ioflags & BIO_ERROR) error = bp->b_error; Modified: stable/10/sys/kern/vfs_lookup.c ============================================================================== --- stable/10/sys/kern/vfs_lookup.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vfs_lookup.c Mon Jun 27 21:50:30 2016 (r302234) @@ -1127,7 +1127,7 @@ NDFREE(struct nameidata *ndp, const u_in * Determine if there is a suitable alternate filename under the specified * prefix for the specified path. If the create flag is set, then the * alternate prefix will be used so long as the parent directory exists. - * This is used by the various compatiblity ABIs so that Linux binaries prefer + * This is used by the various compatibility ABIs so that Linux binaries prefer * files under /compat/linux for example. The chosen path (whether under * the prefix or under /) is returned in a kernel malloc'd buffer pointed * to by pathbuf. The caller is responsible for free'ing the buffer from Modified: stable/10/sys/kern/vfs_mountroot.c ============================================================================== --- stable/10/sys/kern/vfs_mountroot.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vfs_mountroot.c Mon Jun 27 21:50:30 2016 (r302234) @@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$"); * * If the environment variable vfs.root.mountfrom is a space separated list, * each list element is tried in turn and the root filesystem will be mounted - * from the first one that suceeds. + * from the first one that succeeds. * * The environment variable vfs.root.mountfrom.options is a comma delimited * set of string mount options. These mount options must be parseable Modified: stable/10/sys/kern/vfs_subr.c ============================================================================== --- stable/10/sys/kern/vfs_subr.c Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vfs_subr.c Mon Jun 27 21:50:30 2016 (r302234) @@ -501,7 +501,7 @@ vfs_busy(struct mount *mp, int flags) MNT_ILOCK(mp); MNT_REF(mp); /* - * If mount point is currenly being unmounted, sleep until the + * If mount point is currently being unmounted, sleep until the * mount point fate is decided. If thread doing the unmounting fails, * it will clear MNTK_UNMOUNT flag before waking us up, indicating * that this mount point has survived the unmount attempt and vfs_busy @@ -797,7 +797,7 @@ vattr_null(struct vattr *vap) * the buffer cache may have references on the vnode, a directory * vnode may still have references due to the namei cache representing * underlying files, or the vnode may be in active use. It is not - * desireable to reuse such vnodes. These conditions may cause the + * desirable to reuse such vnodes. These conditions may cause the * number of vnodes to reach some minimum value regardless of what * you set kern.maxvnodes to. Do not set kern.maxvnodes too low. */ @@ -3669,7 +3669,7 @@ destroy_vpollinfo(struct vpollinfo *vi) } /* - * Initalize per-vnode helper structure to hold poll-related state. + * Initialize per-vnode helper structure to hold poll-related state. */ void v_addpollinfo(struct vnode *vp) @@ -4080,7 +4080,7 @@ extattr_check_cred(struct vnode *vp, int #ifdef DEBUG_VFS_LOCKS /* - * This only exists to supress warnings from unlocked specfs accesses. It is + * This only exists to suppress warnings from unlocked specfs accesses. It is * no longer ok to have an unlocked VFS. */ #define IGNORE_LOCK(vp) (panicstr != NULL || (vp) == NULL || \ Modified: stable/10/sys/kern/vnode_if.src ============================================================================== --- stable/10/sys/kern/vnode_if.src Mon Jun 27 21:44:27 2016 (r302233) +++ stable/10/sys/kern/vnode_if.src Mon Jun 27 21:50:30 2016 (r302234) @@ -35,7 +35,7 @@ # is a specification of the locking protocol used by each vop call. # The first column is the name of the variable, the remaining three # columns are in, out and error respectively. The "in" column defines -# the lock state on input, the "out" column defines the state on succesful +# the lock state on input, the "out" column defines the state on successful # return, and the "error" column defines the locking state on error exit. # # The locking value can take the following values: From owner-svn-src-all@freebsd.org Mon Jun 27 21:52:19 2016 Return-Path: Delivered-To: svn-src-all@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 39166B84DB3; Mon, 27 Jun 2016 21:52:19 +0000 (UTC) (envelope-from kib@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 04AA12418; Mon, 27 Jun 2016 21:52:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLqIOa031067; Mon, 27 Jun 2016 21:52:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLqHRV031059; Mon, 27 Jun 2016 21:52:17 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272152.u5RLqHRV031059@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 21:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302235 - in head/sys: kern sys X-SVN-Group: head 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.22 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: Mon, 27 Jun 2016 21:52:19 -0000 Author: kib Date: Mon Jun 27 21:52:17 2016 New Revision: 302235 URL: https://svnweb.freebsd.org/changeset/base/302235 Log: When filt_proc() removes event from the knlist due to the process exiting (NOTE_EXIT->knlist_remove_inevent()), two things happen: - knote kn_knlist pointer is reset - INFLUX knote is removed from the process knlist. And, there are two consequences: - KN_LIST_UNLOCK() on such knote is nop - there is nothing which would block exit1() from processing past the knlist_destroy() (and knlist_destroy() resets knlist lock pointers). Both consequences result either in leaked process lock, or dereferencing NULL function pointers for locking. Handle this by stopping embedding the process knlist into struct proc. Instead, the knlist is allocated together with struct proc, but marked as autodestroy on the zombie reap, by knlist_detach() function. The knlist is freed when last kevent is removed from the list, in particular, at the zombie reap time if the list is empty. As result, the knlist_remove_inevent() is no longer needed and removed. Other changes: In filt_procattach(), clear NOTE_EXEC and NOTE_FORK desired events from kn_sfflags for knote registered by kernel to only get NOTE_CHILD notifications. The flags leak resulted in excessive NOTE_EXEC/NOTE_FORK reports. Fix immediate note activation in filt_procattach(). Condition should be either the immediate CHILD_NOTE activation, or immediate NOTE_EXIT report for the exiting process. In knote_fork(), do not perform racy check for KN_INFLUX before kq lock is taken. Besides being racy, it did not accounted for notes just added by scan (KN_SCAN). Some minor and incomplete style fixes. Analyzed and tested by: Eric Badger Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Differential revision: https://reviews.freebsd.org/D6859 Modified: head/sys/kern/init_main.c head/sys/kern/kern_event.c head/sys/kern/kern_exec.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_sig.c head/sys/sys/event.h head/sys/sys/proc.h Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/init_main.c Mon Jun 27 21:52:17 2016 (r302235) @@ -482,7 +482,7 @@ proc0_init(void *dummy __unused) p->p_flag = P_SYSTEM | P_INMEM | P_KPROC; p->p_flag2 = 0; p->p_state = PRS_NORMAL; - knlist_init_mtx(&p->p_klist, &p->p_mtx); + p->p_klist = knlist_alloc(&p->p_mtx); STAILQ_INIT(&p->p_ktr); p->p_nice = NZERO; /* pid_max cannot be greater than PID_MAX */ Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_event.c Mon Jun 27 21:52:17 2016 (r302235) @@ -227,14 +227,33 @@ SYSCTL_UINT(_kern, OID_AUTO, kq_calloutm #define KQ_NOTOWNED(kq) do { \ mtx_assert(&(kq)->kq_lock, MA_NOTOWNED); \ } while (0) -#define KN_LIST_LOCK(kn) do { \ - if (kn->kn_knlist != NULL) \ - kn->kn_knlist->kl_lock(kn->kn_knlist->kl_lockarg); \ -} while (0) -#define KN_LIST_UNLOCK(kn) do { \ - if (kn->kn_knlist != NULL) \ - kn->kn_knlist->kl_unlock(kn->kn_knlist->kl_lockarg); \ -} while (0) + +static struct knlist * +kn_list_lock(struct knote *kn) +{ + struct knlist *knl; + + knl = kn->kn_knlist; + if (knl != NULL) + knl->kl_lock(knl->kl_lockarg); + return (knl); +} + +static void +kn_list_unlock(struct knlist *knl) +{ + bool do_free; + + if (knl == NULL) + return; + do_free = knl->kl_autodestroy && knlist_empty(knl); + knl->kl_unlock(knl->kl_lockarg); + if (do_free) { + knlist_destroy(knl); + free(knl, M_KQUEUE); + } +} + #define KNL_ASSERT_LOCK(knl, islocked) do { \ if (islocked) \ KNL_ASSERT_LOCKED(knl); \ @@ -350,16 +369,16 @@ static int filt_procattach(struct knote *kn) { struct proc *p; - int immediate; int error; + bool exiting, immediate; - immediate = 0; + exiting = immediate = false; p = pfind(kn->kn_id); if (p == NULL && (kn->kn_sfflags & NOTE_EXIT)) { p = zpfind(kn->kn_id); - immediate = 1; + exiting = true; } else if (p != NULL && (p->p_flag & P_WEXIT)) { - immediate = 1; + exiting = true; } if (p == NULL) @@ -380,8 +399,8 @@ filt_procattach(struct knote *kn) kn->kn_flags &= ~EV_FLAG2; kn->kn_data = kn->kn_sdata; /* ppid */ kn->kn_fflags = NOTE_CHILD; - kn->kn_sfflags &= ~NOTE_EXIT; - immediate = 1; /* Force immediate activation of child note. */ + kn->kn_sfflags &= ~(NOTE_EXIT | NOTE_EXEC | NOTE_FORK); + immediate = true; /* Force immediate activation of child note. */ } /* * Internal flag indicating registration done by kernel (for other than @@ -391,8 +410,7 @@ filt_procattach(struct knote *kn) kn->kn_flags &= ~EV_FLAG1; } - if (immediate == 0) - knlist_add(&p->p_klist, kn, 1); + knlist_add(p->p_klist, kn, 1); /* * Immediately activate any child notes or, in the case of a zombie @@ -400,7 +418,7 @@ filt_procattach(struct knote *kn) * case where the target process, e.g. a child, dies before the kevent * is registered. */ - if (immediate && filt_proc(kn, NOTE_EXIT)) + if (immediate || (exiting && filt_proc(kn, NOTE_EXIT))) KNOTE_ACTIVATE(kn, 0); PROC_UNLOCK(p); @@ -420,10 +438,8 @@ filt_procattach(struct knote *kn) static void filt_procdetach(struct knote *kn) { - struct proc *p; - p = kn->kn_ptr.p_proc; - knlist_remove(&p->p_klist, kn, 0); + knlist_remove(kn->kn_knlist, kn, 0); kn->kn_ptr.p_proc = NULL; } @@ -444,8 +460,6 @@ filt_proc(struct knote *kn, long hint) /* Process is gone, so flag the event as finished. */ if (event == NOTE_EXIT) { - if (!(kn->kn_status & KN_DETACHED)) - knlist_remove_inevent(&p->p_klist, kn); kn->kn_flags |= EV_EOF | EV_ONESHOT; kn->kn_ptr.p_proc = NULL; if (kn->kn_fflags & NOTE_EXIT) @@ -479,12 +493,6 @@ knote_fork(struct knlist *list, int pid) list->kl_lock(list->kl_lockarg); SLIST_FOREACH(kn, &list->kl_list, kn_selnext) { - /* - * XXX - Why do we skip the kn if it is _INFLUX? Does this - * mean we will not properly wake up some notes? - */ - if ((kn->kn_status & KN_INFLUX) == KN_INFLUX) - continue; kq = kn->kn_kq; KQ_LOCK(kq); if ((kn->kn_status & (KN_INFLUX | KN_SCAN)) == KN_INFLUX) { @@ -525,7 +533,8 @@ knote_fork(struct knlist *list, int pid) */ kev.ident = pid; kev.filter = kn->kn_filter; - kev.flags = kn->kn_flags | EV_ADD | EV_ENABLE | EV_ONESHOT | EV_FLAG2; + kev.flags = kn->kn_flags | EV_ADD | EV_ENABLE | EV_ONESHOT | + EV_FLAG2; kev.fflags = kn->kn_sfflags; kev.data = kn->kn_id; /* parent */ kev.udata = kn->kn_kevent.udata;/* preserve udata */ @@ -1137,6 +1146,7 @@ kqueue_register(struct kqueue *kq, struc struct filterops *fops; struct file *fp; struct knote *kn, *tkn; + struct knlist *knl; cap_rights_t rights; int error, filt, event; int haskqglobal, filedesc_unlock; @@ -1146,6 +1156,7 @@ kqueue_register(struct kqueue *kq, struc fp = NULL; kn = NULL; + knl = NULL; error = 0; haskqglobal = 0; filedesc_unlock = 0; @@ -1300,7 +1311,7 @@ findkn: knote_drop(kn, td); goto done; } - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); goto done_ev_add; } else { /* No matching knote and the EV_ADD flag is not set. */ @@ -1331,7 +1342,7 @@ findkn: */ kn->kn_status |= KN_INFLUX | KN_SCAN; KQ_UNLOCK(kq); - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); kn->kn_kevent.udata = kev->udata; if (!fops->f_isfd && fops->f_touch != NULL) { fops->f_touch(kn, kev, EVENT_REGISTER); @@ -1365,7 +1376,7 @@ done_ev_add: KN_ACTIVE) knote_enqueue(kn); kn->kn_status &= ~(KN_INFLUX | KN_SCAN); - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); KQ_UNLOCK_FLUX(kq); done: @@ -1535,6 +1546,7 @@ kqueue_scan(struct kqueue *kq, int maxev { struct kevent *kevp; struct knote *kn, *marker; + struct knlist *knl; sbintime_t asbt, rsbt; int count, error, haskqglobal, influx, nkev, touch; @@ -1660,7 +1672,7 @@ retry: KQ_UNLOCK(kq); if ((kn->kn_status & KN_KQUEUE) == KN_KQUEUE) KQ_GLOBAL_LOCK(&kq_global, haskqglobal); - KN_LIST_LOCK(kn); + knl = kn_list_lock(kn); if (kn->kn_fop->f_event(kn, 0) == 0) { KQ_LOCK(kq); KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal); @@ -1668,7 +1680,7 @@ retry: ~(KN_QUEUED | KN_ACTIVE | KN_INFLUX | KN_SCAN); kq->kq_count--; - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); influx = 1; continue; } @@ -1697,7 +1709,7 @@ retry: TAILQ_INSERT_TAIL(&kq->kq_head, kn, kn_tqe); kn->kn_status &= ~(KN_INFLUX | KN_SCAN); - KN_LIST_UNLOCK(kn); + kn_list_unlock(knl); influx = 1; } @@ -2062,7 +2074,8 @@ knlist_add(struct knlist *knl, struct kn } static void -knlist_remove_kq(struct knlist *knl, struct knote *kn, int knlislocked, int kqislocked) +knlist_remove_kq(struct knlist *knl, struct knote *kn, int knlislocked, + int kqislocked) { KASSERT(!(!!kqislocked && !knlislocked), ("kq locked w/o knl locked")); KNL_ASSERT_LOCK(knl, knlislocked); @@ -2075,7 +2088,7 @@ knlist_remove_kq(struct knlist *knl, str SLIST_REMOVE(&knl->kl_list, kn, knote, kn_selnext); kn->kn_knlist = NULL; if (!knlislocked) - knl->kl_unlock(knl->kl_lockarg); + kn_list_unlock(knl); if (!kqislocked) KQ_LOCK(kn->kn_kq); kn->kn_status |= KN_DETACHED; @@ -2093,17 +2106,6 @@ knlist_remove(struct knlist *knl, struct knlist_remove_kq(knl, kn, islocked, 0); } -/* - * remove knote from the specified knlist while in f_event handler. - */ -void -knlist_remove_inevent(struct knlist *knl, struct knote *kn) -{ - - knlist_remove_kq(knl, kn, 1, - (kn->kn_status & KN_HASKQLOCK) == KN_HASKQLOCK); -} - int knlist_empty(struct knlist *knl) { @@ -2202,6 +2204,7 @@ knlist_init(struct knlist *knl, void *lo else knl->kl_assert_unlocked = kl_assert_unlocked; + knl->kl_autodestroy = false; SLIST_INIT(&knl->kl_list); } @@ -2212,6 +2215,16 @@ knlist_init_mtx(struct knlist *knl, stru knlist_init(knl, lock, NULL, NULL, NULL, NULL); } +struct knlist * +knlist_alloc(struct mtx *lock) +{ + struct knlist *knl; + + knl = malloc(sizeof(struct knlist), M_KQUEUE, M_WAITOK); + knlist_init_mtx(knl, lock); + return (knl); +} + void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock) { @@ -2237,6 +2250,18 @@ knlist_destroy(struct knlist *knl) SLIST_INIT(&knl->kl_list); } +void +knlist_detach(struct knlist *knl) +{ + + KNL_ASSERT_LOCKED(knl); + knl->kl_autodestroy = true; + if (knlist_empty(knl)) { + knlist_destroy(knl); + free(knl, M_KQUEUE); + } +} + /* * Even if we are locked, we may need to drop the lock to allow any influx * knotes time to "settle". @@ -2247,6 +2272,7 @@ knlist_cleardel(struct knlist *knl, stru struct knote *kn, *kn2; struct kqueue *kq; + KASSERT(!knl->kl_autodestroy, ("cleardel for autodestroy %p", knl)); if (islocked) KNL_ASSERT_LOCKED(knl); else { Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_exec.c Mon Jun 27 21:52:17 2016 (r302235) @@ -832,7 +832,7 @@ interpret: * Notify others that we exec'd, and clear the P_INEXEC flag * as we're now a bona fide freshly-execed process. */ - KNOTE_LOCKED(&p->p_klist, NOTE_EXEC); + KNOTE_LOCKED(p->p_klist, NOTE_EXEC); p->p_flag &= ~P_INEXEC; /* clear "fork but no exec" flag, as we _are_ execing */ Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_exit.c Mon Jun 27 21:52:17 2016 (r302235) @@ -512,7 +512,7 @@ exit1(struct thread *td, int rval, int s /* * Notify interested parties of our demise. */ - KNOTE_LOCKED(&p->p_klist, NOTE_EXIT); + KNOTE_LOCKED(p->p_klist, NOTE_EXIT); #ifdef KDTRACE_HOOKS int reason = CLD_EXITED; @@ -524,13 +524,6 @@ exit1(struct thread *td, int rval, int s #endif /* - * Just delete all entries in the p_klist. At this point we won't - * report any more events, and there are nasty race conditions that - * can beat us if we don't. - */ - knlist_clear(&p->p_klist, 1); - - /* * If this is a process with a descriptor, we may not need to deliver * a signal to the parent. proctree_lock is held over * procdesc_exit() to serialize concurrent calls to close() and @@ -603,12 +596,6 @@ exit1(struct thread *td, int rval, int s PROC_UNLOCK(p->p_pptr); /* - * Hopefully no one will try to deliver a signal to the process this - * late in the game. - */ - knlist_destroy(&p->p_klist); - - /* * Save our children's rusage information in our exit rusage. */ PROC_STATLOCK(p); @@ -853,6 +840,11 @@ proc_reap(struct thread *td, struct proc procdesc_reap(p); sx_xunlock(&proctree_lock); + PROC_LOCK(p); + knlist_detach(p->p_klist); + p->p_klist = NULL; + PROC_UNLOCK(p); + /* * Removal from allproc list and process group list paired with * PROC_LOCK which was executed during that time should guarantee Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_fork.c Mon Jun 27 21:52:17 2016 (r302235) @@ -748,7 +748,7 @@ do_fork(struct thread *td, struct fork_r /* * Tell any interested parties about the new process. */ - knote_fork(&p1->p_klist, p2->p_pid); + knote_fork(p1->p_klist, p2->p_pid); SDT_PROBE3(proc, , , create, p2, p1, fr->fr_flags); if (fr->fr_flags & RFPROCDESC) { @@ -950,7 +950,7 @@ fork1(struct thread *td, struct fork_req #ifdef MAC mac_proc_init(newproc); #endif - knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx); + newproc->p_klist = knlist_alloc(&newproc->p_mtx); STAILQ_INIT(&newproc->p_ktr); /* We have to lock the process tree while we look for a pid. */ Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/kern/kern_sig.c Mon Jun 27 21:52:17 2016 (r302235) @@ -2112,7 +2112,7 @@ tdsendsignal(struct proc *p, struct thre } ps = p->p_sigacts; - KNOTE_LOCKED(&p->p_klist, NOTE_SIGNAL | sig); + KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig); prop = sigprop(sig); if (td == NULL) { @@ -3542,7 +3542,7 @@ filt_sigattach(struct knote *kn) kn->kn_ptr.p_proc = p; kn->kn_flags |= EV_CLEAR; /* automatically set */ - knlist_add(&p->p_klist, kn, 0); + knlist_add(p->p_klist, kn, 0); return (0); } @@ -3552,7 +3552,7 @@ filt_sigdetach(struct knote *kn) { struct proc *p = kn->kn_ptr.p_proc; - knlist_remove(&p->p_klist, kn, 0); + knlist_remove(p->p_klist, kn, 0); } /* Modified: head/sys/sys/event.h ============================================================================== --- head/sys/sys/event.h Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/sys/event.h Mon Jun 27 21:52:17 2016 (r302235) @@ -158,7 +158,8 @@ struct knlist { void (*kl_unlock)(void *); void (*kl_assert_locked)(void *); void (*kl_assert_unlocked)(void *); - void *kl_lockarg; /* argument passed to kl_lockf() */ + void *kl_lockarg; /* argument passed to lock functions */ + bool kl_autodestroy; }; @@ -258,9 +259,10 @@ struct rwlock; extern void knote(struct knlist *list, long hint, int lockflags); extern void knote_fork(struct knlist *list, int pid); +extern struct knlist *knlist_alloc(struct mtx *lock); +extern void knlist_detach(struct knlist *knl); extern void knlist_add(struct knlist *knl, struct knote *kn, int islocked); extern void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); -extern void knlist_remove_inevent(struct knlist *knl, struct knote *kn); extern int knlist_empty(struct knlist *knl); extern void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), void (*kl_unlock)(void *), Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Mon Jun 27 21:50:30 2016 (r302234) +++ head/sys/sys/proc.h Mon Jun 27 21:52:17 2016 (r302235) @@ -611,7 +611,7 @@ struct proc { /* End area that is copied on creation. */ #define p_endcopy p_xsig struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */ - struct knlist p_klist; /* (c) Knotes attached to this proc. */ + struct knlist *p_klist; /* (c) Knotes attached to this proc. */ int p_numthreads; /* (c) Number of threads. */ struct mdproc p_md; /* Any machine-dependent fields. */ struct callout p_itcallout; /* (h + c) Interval timer callout. */ From owner-svn-src-all@freebsd.org Mon Jun 27 21:54:21 2016 Return-Path: Delivered-To: svn-src-all@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 28C0DB84E5C; Mon, 27 Jun 2016 21:54:21 +0000 (UTC) (envelope-from kib@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 D2BD425EE; Mon, 27 Jun 2016 21:54:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RLsKCS031835; Mon, 27 Jun 2016 21:54:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RLsKNI031834; Mon, 27 Jun 2016 21:54:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272154.u5RLsKNI031834@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 21:54:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302236 - head/sys/vm X-SVN-Group: head 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.22 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: Mon, 27 Jun 2016 21:54:21 -0000 Author: kib Date: Mon Jun 27 21:54:19 2016 New Revision: 302236 URL: https://svnweb.freebsd.org/changeset/base/302236 Log: If the vm_fault() handler raced with the vm_object_collapse() sleepable scan, iteration over the shadow chain looking for a page could find an OBJ_DEAD object. Such state of the mapping is only transient, the dead object will be terminated and removed from the chain shortly. We must not return KERN_PROTECTION_FAILURE unless the object type is changed to OBJT_DEAD in the chain, indicating that paging on this address is really impossible. Returning KERN_PROTECTION_FAILURE prematurely causes spurious SIGSEGV delivered to processes, or kernel accesses to UVA spuriously failing with EFAULT. If the object with OBJ_DEAD flag is found, only return KERN_PROTECTION_FAILURE when object type is already OBJT_DEAD. Otherwise, sleep a tick and retry the fault handling. Ideally, we would wait until the OBJ_DEAD flag is resolved, e.g. by waiting until the paging on this object is finished. But to do so, we need to reference the dead object, while vm_object_collapse() insists on owning the final reference on the collapsed object. This could be fixed by e.g. changing the assert to shared reference release between vm_fault() and vm_object_collapse(), but it seems to be too much complications for rare boundary condition. PR: 204426 Tested by: pho Reviewed by: alc Sponsored by: The FreeBSD Foundation X-Differential revision: https://reviews.freebsd.org/D6085 MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Mon Jun 27 21:52:17 2016 (r302235) +++ head/sys/vm/vm_fault.c Mon Jun 27 21:54:19 2016 (r302236) @@ -292,7 +292,7 @@ vm_fault_hold(vm_map_t map, vm_offset_t struct faultstate fs; struct vnode *vp; vm_page_t m; - int ahead, behind, cluster_offset, error, locked; + int ahead, behind, cluster_offset, dead, error, locked; hardfault = 0; growstack = TRUE; @@ -421,11 +421,18 @@ fast_failed: fs.pindex = fs.first_pindex; while (TRUE) { /* - * If the object is dead, we stop here + * If the object is marked for imminent termination, + * we retry here, since the collapse pass has raced + * with us. Otherwise, if we see terminally dead + * object, return fail. */ - if (fs.object->flags & OBJ_DEAD) { + if ((fs.object->flags & OBJ_DEAD) != 0) { + dead = fs.object->type == OBJT_DEAD; unlock_and_deallocate(&fs); - return (KERN_PROTECTION_FAILURE); + if (dead) + return (KERN_PROTECTION_FAILURE); + pause("vmf_de", 1); + goto RetryFault; } /* From owner-svn-src-all@freebsd.org Mon Jun 27 22:10:09 2016 Return-Path: Delivered-To: svn-src-all@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 B544BB852A9; Mon, 27 Jun 2016 22:10:09 +0000 (UTC) (envelope-from bdrewery@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 798822CD9; Mon, 27 Jun 2016 22:10:09 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RMA86P035916; Mon, 27 Jun 2016 22:10:08 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RMA7JZ035903; Mon, 27 Jun 2016 22:10:07 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272210.u5RMA7JZ035903@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 22:10:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302237 - in stable/10/sys: cam/ctl compat/linux kern netinet security/mac X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 22:10:09 -0000 Author: bdrewery Date: Mon Jun 27 22:10:07 2016 New Revision: 302237 URL: https://svnweb.freebsd.org/changeset/base/302237 Log: MFC r292384: Fix style issues around existing SDT probes. ** Changes to sys/netinet/in_kdtrace.c and sys/netinet/in_kdtrace.h skipped. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c stable/10/sys/compat/linux/linux_dtrace.h stable/10/sys/kern/kern_exec.c stable/10/sys/kern/kern_exit.c stable/10/sys/kern/kern_fork.c stable/10/sys/kern/kern_proc.c stable/10/sys/kern/kern_racct.c stable/10/sys/kern/kern_sig.c stable/10/sys/kern/kern_timeout.c stable/10/sys/kern/vfs_cache.c stable/10/sys/netinet/sctp_cc_functions.c stable/10/sys/security/mac/mac_framework.c stable/10/sys/security/mac/mac_internal.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Mon Jun 27 22:10:07 2016 (r302237) @@ -613,10 +613,10 @@ ctl_be_block_flush_file(struct ctl_be_bl ctl_complete_beio(beio); } -SDT_PROBE_DEFINE1(cbb, kernel, read, file_start, "uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, write, file_start, "uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, read, file_done,"uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, write, file_done, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , read, file_start, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , write, file_start, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , read, file_done,"uint64_t"); +SDT_PROBE_DEFINE1(cbb, , write, file_done, "uint64_t"); static void ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, @@ -641,10 +641,10 @@ ctl_be_block_dispatch_file(struct ctl_be bzero(&xuio, sizeof(xuio)); if (beio->bio_cmd == BIO_READ) { - SDT_PROBE(cbb, kernel, read, file_start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, file_start); xuio.uio_rw = UIO_READ; } else { - SDT_PROBE(cbb, kernel, write, file_start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, file_start); xuio.uio_rw = UIO_WRITE; } xuio.uio_offset = beio->io_offset; @@ -687,7 +687,7 @@ ctl_be_block_dispatch_file(struct ctl_be error = VOP_READ(be_lun->vn, &xuio, flags, file_data->cred); VOP_UNLOCK(be_lun->vn, 0); - SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, file_done); if (error == 0 && xuio.uio_resid > 0) { /* * If we red less then requested (EOF), then @@ -736,7 +736,7 @@ ctl_be_block_dispatch_file(struct ctl_be VOP_UNLOCK(be_lun->vn, 0); vn_finished_write(mountpoint); - SDT_PROBE(cbb, kernel, write, file_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, file_done); } mtx_lock(&be_lun->io_lock); @@ -872,10 +872,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be bzero(&xuio, sizeof(xuio)); if (beio->bio_cmd == BIO_READ) { - SDT_PROBE(cbb, kernel, read, file_start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, file_start); xuio.uio_rw = UIO_READ; } else { - SDT_PROBE(cbb, kernel, write, file_start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, file_start); xuio.uio_rw = UIO_WRITE; } xuio.uio_offset = beio->io_offset; @@ -906,9 +906,9 @@ ctl_be_block_dispatch_zvol(struct ctl_be error = ENXIO; if (beio->bio_cmd == BIO_READ) - SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, file_done); else - SDT_PROBE(cbb, kernel, write, file_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, file_done); mtx_lock(&be_lun->io_lock); devstat_end_transaction(beio->lun->disk_stats, beio->io_len, @@ -1504,10 +1504,10 @@ ctl_be_block_cw_dispatch(struct ctl_be_b } } -SDT_PROBE_DEFINE1(cbb, kernel, read, start, "uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, write, start, "uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, read, alloc_done, "uint64_t"); -SDT_PROBE_DEFINE1(cbb, kernel, write, alloc_done, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , read, start, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , write, start, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , read, alloc_done, "uint64_t"); +SDT_PROBE_DEFINE1(cbb, , write, alloc_done, "uint64_t"); static void ctl_be_block_next(struct ctl_be_block_io *beio) @@ -1552,9 +1552,9 @@ ctl_be_block_dispatch(struct ctl_be_bloc lbalen = ARGS(io); if (lbalen->flags & CTL_LLF_WRITE) { - SDT_PROBE(cbb, kernel, write, start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, start); } else { - SDT_PROBE(cbb, kernel, read, start, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, start); } beio = ctl_alloc_beio(softc); @@ -1641,10 +1641,10 @@ ctl_be_block_dispatch(struct ctl_be_bloc * need to get the data from the user first. */ if (beio->bio_cmd == BIO_READ) { - SDT_PROBE(cbb, kernel, read, alloc_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , read, alloc_done); be_lun->dispatch(be_lun, beio); } else { - SDT_PROBE(cbb, kernel, write, alloc_done, 0, 0, 0, 0, 0); + SDT_PROBE0(cbb, , write, alloc_done); #ifdef CTL_TIME_IO getbinuptime(&io->io_hdr.dma_start_bt); #endif Modified: stable/10/sys/compat/linux/linux_dtrace.h ============================================================================== --- stable/10/sys/compat/linux/linux_dtrace.h Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/compat/linux/linux_dtrace.h Mon Jun 27 22:10:07 2016 (r302237) @@ -72,8 +72,8 @@ #define LIN_SDT_PROBE_DEFINE5(a, b, c, d, e, f, g, h) _LIN_SDT_PROBE_DEFINE5(\ LINUX_DTRACE, a, b, c, d, e, f, g, h) -#define LIN_SDT_PROBE0(a, b, c) SDT_PROBE1(LINUX_DTRACE, a, b, \ - c, 0) +#define LIN_SDT_PROBE0(a, b, c) SDT_PROBE0(LINUX_DTRACE, a, b, \ + c) #define LIN_SDT_PROBE1(a, b, c, d) SDT_PROBE1(LINUX_DTRACE, a, b, \ c, d) #define LIN_SDT_PROBE2(a, b, c, d, e) SDT_PROBE2(LINUX_DTRACE, a, b, \ Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 22:10:07 2016 (r302237) @@ -96,9 +96,9 @@ dtrace_execexit_func_t dtrace_fasttrap_e #endif SDT_PROVIDER_DECLARE(proc); -SDT_PROBE_DEFINE1(proc, kernel, , exec, "char *"); -SDT_PROBE_DEFINE1(proc, kernel, , exec__failure, "int"); -SDT_PROBE_DEFINE1(proc, kernel, , exec__success, "char *"); +SDT_PROBE_DEFINE1(proc, , , exec, "char *"); +SDT_PROBE_DEFINE1(proc, , , exec__failure, "int"); +SDT_PROBE_DEFINE1(proc, , , exec__success, "char *"); MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments"); @@ -426,7 +426,7 @@ do_execve(td, args, mac_p) | AUDITVNODE1, UIO_SYSSPACE, args->fname, td); } - SDT_PROBE1(proc, kernel, , exec, args->fname); + SDT_PROBE1(proc, , , exec, args->fname); interpret: if (args->fname != NULL) { @@ -845,7 +845,7 @@ interpret: vfs_mark_atime(imgp->vp, td->td_ucred); - SDT_PROBE1(proc, kernel, , exec__success, args->fname); + SDT_PROBE1(proc, , , exec__success, args->fname); VOP_UNLOCK(imgp->vp, 0); done1: @@ -917,7 +917,7 @@ exec_fail: p->p_flag &= ~P_INEXEC; PROC_UNLOCK(p); - SDT_PROBE1(proc, kernel, , exec__failure, error); + SDT_PROBE1(proc, , , exec__failure, error); done2: #ifdef MAC Modified: stable/10/sys/kern/kern_exit.c ============================================================================== --- stable/10/sys/kern/kern_exit.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_exit.c Mon Jun 27 22:10:07 2016 (r302237) @@ -95,7 +95,7 @@ dtrace_execexit_func_t dtrace_fasttrap_e #endif SDT_PROVIDER_DECLARE(proc); -SDT_PROBE_DEFINE1(proc, kernel, , exit, "int"); +SDT_PROBE_DEFINE1(proc, , , exit, "int"); /* Hook for NFS teardown procedure. */ void (*nlminfo_release_p)(struct proc *p); @@ -564,7 +564,7 @@ exit1(struct thread *td, int rv) reason = CLD_DUMPED; else if (WIFSIGNALED(rv)) reason = CLD_KILLED; - SDT_PROBE1(proc, kernel, , exit, reason); + SDT_PROBE1(proc, , , exit, reason); #endif /* Modified: stable/10/sys/kern/kern_fork.c ============================================================================== --- stable/10/sys/kern/kern_fork.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_fork.c Mon Jun 27 22:10:07 2016 (r302237) @@ -90,8 +90,7 @@ dtrace_fork_func_t dtrace_fasttrap_fork; #endif SDT_PROVIDER_DECLARE(proc); -SDT_PROBE_DEFINE3(proc, kernel, , create, "struct proc *", - "struct proc *", "int"); +SDT_PROBE_DEFINE3(proc, , , create, "struct proc *", "struct proc *", "int"); #ifndef _SYS_SYSPROTO_H_ struct fork_args { @@ -755,7 +754,7 @@ do_fork(struct thread *td, int flags, st * Tell any interested parties about the new process. */ knote_fork(&p1->p_klist, p2->p_pid); - SDT_PROBE3(proc, kernel, , create, p2, p1, flags); + SDT_PROBE3(proc, , , create, p2, p1, flags); /* * Wait until debugger is attached to child. Modified: stable/10/sys/kern/kern_proc.c ============================================================================== --- stable/10/sys/kern/kern_proc.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_proc.c Mon Jun 27 22:10:07 2016 (r302237) @@ -92,18 +92,15 @@ __FBSDID("$FreeBSD$"); #endif SDT_PROVIDER_DEFINE(proc); -SDT_PROBE_DEFINE4(proc, kernel, ctor, entry, "struct proc *", "int", - "void *", "int"); -SDT_PROBE_DEFINE4(proc, kernel, ctor, return, "struct proc *", "int", - "void *", "int"); -SDT_PROBE_DEFINE4(proc, kernel, dtor, entry, "struct proc *", "int", - "void *", "struct thread *"); -SDT_PROBE_DEFINE3(proc, kernel, dtor, return, "struct proc *", "int", - "void *"); -SDT_PROBE_DEFINE3(proc, kernel, init, entry, "struct proc *", "int", +SDT_PROBE_DEFINE4(proc, , ctor, entry, "struct proc *", "int", "void *", "int"); -SDT_PROBE_DEFINE3(proc, kernel, init, return, "struct proc *", "int", +SDT_PROBE_DEFINE4(proc, , ctor, return, "struct proc *", "int", "void *", "int"); +SDT_PROBE_DEFINE4(proc, , dtor, entry, "struct proc *", "int", "void *", + "struct thread *"); +SDT_PROBE_DEFINE3(proc, , dtor, return, "struct proc *", "int", "void *"); +SDT_PROBE_DEFINE3(proc, , init, entry, "struct proc *", "int", "int"); +SDT_PROBE_DEFINE3(proc, , init, return, "struct proc *", "int", "int"); MALLOC_DEFINE(M_PGRP, "pgrp", "process group header"); MALLOC_DEFINE(M_SESSION, "session", "session header"); @@ -196,9 +193,9 @@ proc_ctor(void *mem, int size, void *arg struct proc *p; p = (struct proc *)mem; - SDT_PROBE4(proc, kernel, ctor , entry, p, size, arg, flags); + SDT_PROBE4(proc, , ctor , entry, p, size, arg, flags); EVENTHANDLER_INVOKE(process_ctor, p); - SDT_PROBE4(proc, kernel, ctor , return, p, size, arg, flags); + SDT_PROBE4(proc, , ctor , return, p, size, arg, flags); return (0); } @@ -214,7 +211,7 @@ proc_dtor(void *mem, int size, void *arg /* INVARIANTS checks go here */ p = (struct proc *)mem; td = FIRST_THREAD_IN_PROC(p); - SDT_PROBE4(proc, kernel, dtor, entry, p, size, arg, td); + SDT_PROBE4(proc, , dtor, entry, p, size, arg, td); if (td != NULL) { #ifdef INVARIANTS KASSERT((p->p_numthreads == 1), @@ -227,7 +224,7 @@ proc_dtor(void *mem, int size, void *arg EVENTHANDLER_INVOKE(process_dtor, p); if (p->p_ksi != NULL) KASSERT(! KSI_ONQ(p->p_ksi), ("SIGCHLD queue")); - SDT_PROBE3(proc, kernel, dtor, return, p, size, arg); + SDT_PROBE3(proc, , dtor, return, p, size, arg); } /* @@ -239,7 +236,7 @@ proc_init(void *mem, int size, int flags struct proc *p; p = (struct proc *)mem; - SDT_PROBE3(proc, kernel, init, entry, p, size, flags); + SDT_PROBE3(proc, , init, entry, p, size, flags); p->p_sched = (struct p_sched *)&p[1]; bzero(&p->p_mtx, sizeof(struct mtx)); mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK); @@ -250,7 +247,7 @@ proc_init(void *mem, int size, int flags EVENTHANDLER_INVOKE(process_init, p); p->p_stats = pstats_alloc(); p->p_pgrp = NULL; - SDT_PROBE3(proc, kernel, init, return, p, size, flags); + SDT_PROBE3(proc, , init, return, p, size, flags); return (0); } Modified: stable/10/sys/kern/kern_racct.c ============================================================================== --- stable/10/sys/kern/kern_racct.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_racct.c Mon Jun 27 22:10:07 2016 (r302237) @@ -104,30 +104,32 @@ static void racct_add_cred_locked(struct uint64_t amount); SDT_PROVIDER_DEFINE(racct); -SDT_PROBE_DEFINE3(racct, kernel, rusage, add, "struct proc *", "int", - "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, add__failure, +SDT_PROBE_DEFINE3(racct, , rusage, add, "struct proc *", "int", "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, add__cred, "struct ucred *", - "int", "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, add__force, "struct proc *", - "int", "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, set, "struct proc *", "int", - "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, set__failure, +SDT_PROBE_DEFINE3(racct, , rusage, add__failure, "struct proc *", "int", "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, sub, "struct proc *", "int", - "uint64_t"); -SDT_PROBE_DEFINE3(racct, kernel, rusage, sub__cred, "struct ucred *", - "int", "uint64_t"); -SDT_PROBE_DEFINE1(racct, kernel, racct, create, "struct racct *"); -SDT_PROBE_DEFINE1(racct, kernel, racct, destroy, "struct racct *"); -SDT_PROBE_DEFINE2(racct, kernel, racct, join, "struct racct *", +SDT_PROBE_DEFINE3(racct, , rusage, add__cred, + "struct ucred *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, , rusage, add__force, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, , rusage, set, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, , rusage, set__failure, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, , rusage, sub, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, , rusage, sub__cred, + "struct ucred *", "int", "uint64_t"); +SDT_PROBE_DEFINE1(racct, , racct, create, "struct racct *"); -SDT_PROBE_DEFINE2(racct, kernel, racct, join__failure, - "struct racct *", "struct racct *"); -SDT_PROBE_DEFINE2(racct, kernel, racct, leave, "struct racct *", +SDT_PROBE_DEFINE1(racct, , racct, destroy, "struct racct *"); +SDT_PROBE_DEFINE2(racct, , racct, join, + "struct racct *", "struct racct *"); +SDT_PROBE_DEFINE2(racct, , racct, join__failure, + "struct racct *", "struct racct *"); +SDT_PROBE_DEFINE2(racct, , racct, leave, + "struct racct *", "struct racct *"); int racct_types[] = { [RACCT_CPU] = @@ -447,7 +449,7 @@ racct_create(struct racct **racctp) if (!racct_enable) return; - SDT_PROBE1(racct, kernel, racct, create, racctp); + SDT_PROBE1(racct, , racct, create, racctp); KASSERT(*racctp == NULL, ("racct already allocated")); @@ -462,7 +464,7 @@ racct_destroy_locked(struct racct **racc ASSERT_RACCT_ENABLED(); - SDT_PROBE1(racct, kernel, racct, destroy, racctp); + SDT_PROBE1(racct, , racct, destroy, racctp); mtx_assert(&racct_lock, MA_OWNED); KASSERT(racctp != NULL, ("NULL racctp")); @@ -540,7 +542,7 @@ racct_add_locked(struct proc *p, int res ASSERT_RACCT_ENABLED(); - SDT_PROBE3(racct, kernel, rusage, add, p, resource, amount); + SDT_PROBE3(racct, , rusage, add, p, resource, amount); /* * We need proc lock to dereference p->p_ucred. @@ -550,8 +552,7 @@ racct_add_locked(struct proc *p, int res #ifdef RCTL error = rctl_enforce(p, resource, amount); if (error && RACCT_IS_DENIABLE(resource)) { - SDT_PROBE3(racct, kernel, rusage, add__failure, p, resource, - amount); + SDT_PROBE3(racct, , rusage, add__failure, p, resource, amount); return (error); } #endif @@ -586,7 +587,7 @@ racct_add_cred_locked(struct ucred *cred ASSERT_RACCT_ENABLED(); - SDT_PROBE3(racct, kernel, rusage, add__cred, cred, resource, amount); + SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount); racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, amount); for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) @@ -624,7 +625,7 @@ racct_add_force(struct proc *p, int reso if (!racct_enable) return; - SDT_PROBE3(racct, kernel, rusage, add__force, p, resource, amount); + SDT_PROBE3(racct, , rusage, add__force, p, resource, amount); /* * We need proc lock to dereference p->p_ucred. @@ -648,7 +649,7 @@ racct_set_locked(struct proc *p, int res ASSERT_RACCT_ENABLED(); - SDT_PROBE3(racct, kernel, rusage, set, p, resource, amount); + SDT_PROBE3(racct, , rusage, set, p, resource, amount); /* * We need proc lock to dereference p->p_ucred. @@ -680,8 +681,8 @@ racct_set_locked(struct proc *p, int res if (diff_proc > 0) { error = rctl_enforce(p, resource, diff_proc); if (error && RACCT_IS_DENIABLE(resource)) { - SDT_PROBE3(racct, kernel, rusage, set__failure, p, - resource, amount); + SDT_PROBE3(racct, , rusage, set__failure, p, resource, + amount); return (error); } } @@ -724,7 +725,7 @@ racct_set_force_locked(struct proc *p, i ASSERT_RACCT_ENABLED(); - SDT_PROBE3(racct, kernel, rusage, set, p, resource, amount); + SDT_PROBE3(racct, , rusage, set, p, resource, amount); /* * We need proc lock to dereference p->p_ucred. @@ -835,7 +836,7 @@ racct_sub(struct proc *p, int resource, if (!racct_enable) return; - SDT_PROBE3(racct, kernel, rusage, sub, p, resource, amount); + SDT_PROBE3(racct, , rusage, sub, p, resource, amount); /* * We need proc lock to dereference p->p_ucred. @@ -862,7 +863,7 @@ racct_sub_cred_locked(struct ucred *cred ASSERT_RACCT_ENABLED(); - SDT_PROBE3(racct, kernel, rusage, sub__cred, cred, resource, amount); + SDT_PROBE3(racct, , rusage, sub__cred, cred, resource, amount); #ifdef notyet KASSERT(RACCT_CAN_DROP(resource), Modified: stable/10/sys/kern/kern_sig.c ============================================================================== --- stable/10/sys/kern/kern_sig.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_sig.c Mon Jun 27 22:10:07 2016 (r302237) @@ -94,11 +94,11 @@ __FBSDID("$FreeBSD$"); #define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ SDT_PROVIDER_DECLARE(proc); -SDT_PROBE_DEFINE3(proc, kernel, , signal__send, "struct thread *", - "struct proc *", "int"); -SDT_PROBE_DEFINE2(proc, kernel, , signal__clear, "int", - "ksiginfo_t *"); -SDT_PROBE_DEFINE3(proc, kernel, , signal__discard, +SDT_PROBE_DEFINE3(proc, , , signal__send, + "struct thread *", "struct proc *", "int"); +SDT_PROBE_DEFINE2(proc, , , signal__clear, + "int", "ksiginfo_t *"); +SDT_PROBE_DEFINE3(proc, , , signal__discard, "struct thread *", "struct proc *", "int"); static int coredump(struct thread *); @@ -1291,7 +1291,7 @@ kern_sigtimedwait(struct thread *td, sig reschedule_signals(p, new_block, 0); if (error == 0) { - SDT_PROBE2(proc, kernel, , signal__clear, sig, ksi); + SDT_PROBE2(proc, , , signal__clear, sig, ksi); if (ksi->ksi_code == SI_TIMER) itimer_accept(p, ksi->ksi_timerid, ksi); @@ -2108,7 +2108,7 @@ tdsendsignal(struct proc *p, struct thre } else sigqueue = &td->td_sigqueue; - SDT_PROBE3(proc, kernel, , signal__send, td, p, sig); + SDT_PROBE3(proc, , , signal__send, td, p, sig); /* * If the signal is being ignored, @@ -2119,7 +2119,7 @@ tdsendsignal(struct proc *p, struct thre */ mtx_lock(&ps->ps_mtx); if (SIGISMEMBER(ps->ps_sigignore, sig)) { - SDT_PROBE3(proc, kernel, , signal__discard, td, p, sig); + SDT_PROBE3(proc, , , signal__discard, td, p, sig); mtx_unlock(&ps->ps_mtx); if (ksi && (ksi->ksi_flags & KSI_INS)) Modified: stable/10/sys/kern/kern_timeout.c ============================================================================== --- stable/10/sys/kern/kern_timeout.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/kern_timeout.c Mon Jun 27 22:10:07 2016 (r302237) @@ -69,10 +69,8 @@ DPCPU_DECLARE(sbintime_t, hardclocktime) #endif SDT_PROVIDER_DEFINE(callout_execute); -SDT_PROBE_DEFINE1(callout_execute, kernel, , callout__start, - "struct callout *"); -SDT_PROBE_DEFINE1(callout_execute, kernel, , callout__end, - "struct callout *"); +SDT_PROBE_DEFINE1(callout_execute, , , callout__start, "struct callout *"); +SDT_PROBE_DEFINE1(callout_execute, , , callout__end, "struct callout *"); #ifdef CALLOUT_PROFILING static int avg_depth; @@ -681,9 +679,9 @@ softclock_call_cc(struct callout *c, str sbt1 = sbinuptime(); #endif THREAD_NO_SLEEPING(); - SDT_PROBE1(callout_execute, kernel, , callout__start, c); + SDT_PROBE1(callout_execute, , , callout__start, c); c_func(c_arg); - SDT_PROBE1(callout_execute, kernel, , callout__end, c); + SDT_PROBE1(callout_execute, , , callout__end, c); THREAD_SLEEPING_OK(); #if defined(DIAGNOSTIC) || defined(CALLOUT_PROFILING) sbt2 = sbinuptime(); Modified: stable/10/sys/kern/vfs_cache.c ============================================================================== --- stable/10/sys/kern/vfs_cache.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/kern/vfs_cache.c Mon Jun 27 22:10:07 2016 (r302237) @@ -418,7 +418,6 @@ cache_zap(ncp) rw_assert(&cache_lock, RA_WLOCKED); CTR2(KTR_VFS, "cache_zap(%p) vp %p", ncp, ncp->nc_vp); -#ifdef KDTRACE_HOOKS if (ncp->nc_vp != NULL) { SDT_PROBE3(vfs, namecache, zap, done, ncp->nc_dvp, nc_get_name(ncp), ncp->nc_vp); @@ -426,7 +425,6 @@ cache_zap(ncp) SDT_PROBE2(vfs, namecache, zap_negative, done, ncp->nc_dvp, nc_get_name(ncp)); } -#endif vp = NULL; LIST_REMOVE(ncp, nc_hash); if (ncp->nc_flag & NCF_ISDOTDOT) { Modified: stable/10/sys/netinet/sctp_cc_functions.c ============================================================================== --- stable/10/sys/netinet/sctp_cc_functions.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/netinet/sctp_cc_functions.c Mon Jun 27 22:10:07 2016 (r302237) @@ -95,7 +95,7 @@ sctp_set_initial_cc_param(struct sctp_tc } sctp_enforce_cwnd_limit(assoc, net); net->ssthresh = assoc->peers_rwnd; - SDT_PROBE(sctp, cwnd, net, init, + SDT_PROBE5(sctp, cwnd, net, init, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, 0, net->cwnd); if (SCTP_BASE_SYSCTL(sctp_logging_level) & @@ -193,7 +193,7 @@ sctp_cwnd_update_after_fr(struct sctp_tc } net->cwnd = net->ssthresh; sctp_enforce_cwnd_limit(asoc, net); - SDT_PROBE(sctp, cwnd, net, fr, + SDT_PROBE5(sctp, cwnd, net, fr, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, old_cwnd, net->cwnd); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { @@ -261,7 +261,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct */ /* Probe point 5 */ probepoint |= ((5 << 16) | 1); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -282,7 +282,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -306,7 +306,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct */ /* Probe point 6 */ probepoint |= ((6 << 16) | 0); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -318,7 +318,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -349,7 +349,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct */ /* Probe point 7 */ probepoint |= ((7 << 16) | net->cc_mod.rtcc.ret_from_eq); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -398,7 +398,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st /* We caused it maybe.. back off? */ /* PROBE POINT 1 */ probepoint |= ((1 << 16) | 1); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -416,7 +416,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st } /* Probe point 2 */ probepoint |= ((2 << 16) | 0); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -429,7 +429,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -453,7 +453,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st /* bw & rtt decreased */ /* Probe point 3 */ probepoint |= ((3 << 16) | 0); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -465,7 +465,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -485,7 +485,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st /* The bw decreased but rtt stayed the same */ /* Probe point 4 */ probepoint |= ((4 << 16) | 0); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -497,7 +497,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, st oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -535,7 +535,7 @@ cc_bw_increase(struct sctp_tcb *stcb, st */ /* PROBE POINT 0 */ probepoint = (((uint64_t) net->cwnd) << 32); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -547,7 +547,7 @@ cc_bw_increase(struct sctp_tcb *stcb, st oth |= net->cc_mod.rtcc.step_cnt; oth <<= 16; oth |= net->cc_mod.rtcc.last_step_state; - SDT_PROBE(sctp, cwnd, net, rttstep, + SDT_PROBE5(sctp, cwnd, net, rttstep, vtag, ((net->cc_mod.rtcc.lbw << 32) | nbw), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -647,7 +647,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struc /* Can't determine do not change */ probepoint |= ((0xd << 16) | inst_ind); } - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((nbw << 32) | inst_bw), ((net->cc_mod.rtcc.lbw_rtt << 32) | rtt), @@ -807,7 +807,7 @@ sctp_cwnd_update_after_sack_common(struc (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, nbw, ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -906,7 +906,7 @@ sctp_cwnd_update_after_sack_common(struc sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); } - SDT_PROBE(sctp, cwnd, net, ack, + SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -969,7 +969,7 @@ sctp_cwnd_update_after_sack_common(struc } net->cwnd += incr; sctp_enforce_cwnd_limit(asoc, net); - SDT_PROBE(sctp, cwnd, net, ack, + SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -1001,7 +1001,7 @@ sctp_cwnd_update_exit_pf_common(struct s old_cwnd = net->cwnd; net->cwnd = net->mtu; - SDT_PROBE(sctp, cwnd, net, ack, + SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, old_cwnd, net->cwnd); SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n", @@ -1072,7 +1072,7 @@ sctp_cwnd_update_after_timeout(struct sc } net->cwnd = net->mtu; net->partial_bytes_acked = 0; - SDT_PROBE(sctp, cwnd, net, to, + SDT_PROBE5(sctp, cwnd, net, to, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -1132,7 +1132,7 @@ sctp_cwnd_update_after_ecn_echo_common(s net->RTO <<= 1; } net->cwnd = net->ssthresh; - SDT_PROBE(sctp, cwnd, net, ecn, + SDT_PROBE5(sctp, cwnd, net, ecn, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -1251,7 +1251,7 @@ sctp_cwnd_update_after_packet_dropped(st sctp_enforce_cwnd_limit(&stcb->asoc, net); if (net->cwnd - old_cwnd != 0) { /* log only changes */ - SDT_PROBE(sctp, cwnd, net, pd, + SDT_PROBE5(sctp, cwnd, net, pd, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -1274,7 +1274,7 @@ sctp_cwnd_update_after_output(struct sct if (burst_limit) { net->cwnd = (net->flight_size + (burst_limit * net->mtu)); sctp_enforce_cwnd_limit(&stcb->asoc, net); - SDT_PROBE(sctp, cwnd, net, bl, + SDT_PROBE5(sctp, cwnd, net, bl, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -1350,7 +1350,7 @@ sctp_cwnd_new_rtcc_transmission_begins(s probepoint = (((uint64_t) net->cwnd) << 32); /* Probe point 8 */ probepoint |= ((8 << 16) | 0); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((net->cc_mod.rtcc.lbw << 32) | 0), ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt), @@ -1413,7 +1413,7 @@ sctp_set_rtcc_initial_cc_param(struct sc vtag = (net->rtt << 32) | (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport); - SDT_PROBE(sctp, cwnd, net, rttvar, + SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, 0, 0, Modified: stable/10/sys/security/mac/mac_framework.c ============================================================================== --- stable/10/sys/security/mac/mac_framework.c Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/security/mac/mac_framework.c Mon Jun 27 22:10:07 2016 (r302237) @@ -94,11 +94,11 @@ __FBSDID("$FreeBSD$"); SDT_PROVIDER_DEFINE(mac); SDT_PROVIDER_DEFINE(mac_framework); -SDT_PROBE_DEFINE2(mac, kernel, policy, modevent, "int", +SDT_PROBE_DEFINE2(mac, , policy, modevent, "int", "struct mac_policy_conf *"); -SDT_PROBE_DEFINE1(mac, kernel, policy, register, +SDT_PROBE_DEFINE1(mac, , policy, register, "struct mac_policy_conf *"); -SDT_PROBE_DEFINE1(mac, kernel, policy, unregister, +SDT_PROBE_DEFINE1(mac, , policy, unregister, "struct mac_policy_conf *"); /* @@ -445,7 +445,7 @@ mac_policy_register(struct mac_policy_co (*(mpc->mpc_ops->mpo_init))(mpc); mac_policy_update(); - SDT_PROBE(mac, kernel, policy, register, mpc, 0, 0, 0, 0); + SDT_PROBE1(mac, , policy, register, mpc); printf("Security policy loaded: %s (%s)\n", mpc->mpc_fullname, mpc->mpc_name); @@ -492,7 +492,7 @@ mac_policy_unregister(struct mac_policy_ mac_policy_update(); mac_policy_xunlock(); - SDT_PROBE(mac, kernel, policy, unregister, mpc, 0, 0, 0, 0); + SDT_PROBE1(mac, , policy, unregister, mpc); printf("Security policy unload: %s (%s)\n", mpc->mpc_fullname, mpc->mpc_name); @@ -518,7 +518,7 @@ mac_policy_modevent(module_t mod, int ty } #endif - SDT_PROBE(mac, kernel, policy, modevent, type, mpc, 0, 0, 0); + SDT_PROBE2(mac, , policy, modevent, type, mpc); switch (type) { case MOD_LOAD: if (mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_NOTLATE && Modified: stable/10/sys/security/mac/mac_internal.h ============================================================================== --- stable/10/sys/security/mac/mac_internal.h Mon Jun 27 21:54:19 2016 (r302236) +++ stable/10/sys/security/mac/mac_internal.h Mon Jun 27 22:10:07 2016 (r302237) @@ -74,35 +74,35 @@ SDT_PROVIDER_DECLARE(mac); /* MAC Frame SDT_PROVIDER_DECLARE(mac_framework); /* Entry points to MAC. */ #define MAC_CHECK_PROBE_DEFINE4(name, arg0, arg1, arg2, arg3) \ - SDT_PROBE_DEFINE5(mac_framework, kernel, name, mac__check__err, \ + SDT_PROBE_DEFINE5(mac_framework, , name, mac__check__err, \ "int", arg0, arg1, arg2, arg3); \ - SDT_PROBE_DEFINE5(mac_framework, kernel, name, mac__check__ok, \ + SDT_PROBE_DEFINE5(mac_framework, , name, mac__check__ok, \ "int", arg0, arg1, arg2, arg3); #define MAC_CHECK_PROBE_DEFINE3(name, arg0, arg1, arg2) \ - SDT_PROBE_DEFINE4(mac_framework, kernel, name, mac__check__err, \ + SDT_PROBE_DEFINE4(mac_framework, , name, mac__check__err, \ "int", arg0, arg1, arg2); \ - SDT_PROBE_DEFINE4(mac_framework, kernel, name, mac__check__ok, \ + SDT_PROBE_DEFINE4(mac_framework, , name, mac__check__ok, \ "int", arg0, arg1, arg2); #define MAC_CHECK_PROBE_DEFINE2(name, arg0, arg1) \ - SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac__check__err, \ + SDT_PROBE_DEFINE3(mac_framework, , name, mac__check__err, \ "int", arg0, arg1); \ - SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac__check__ok, \ + SDT_PROBE_DEFINE3(mac_framework, , name, mac__check__ok, \ "int", arg0, arg1); #define MAC_CHECK_PROBE_DEFINE1(name, arg0) \ - SDT_PROBE_DEFINE2(mac_framework, kernel, name, mac__check__err, \ + SDT_PROBE_DEFINE2(mac_framework, , name, mac__check__err, \ "int", arg0); \ - SDT_PROBE_DEFINE2(mac_framework, kernel, name, mac__check__ok, \ + SDT_PROBE_DEFINE2(mac_framework, , name, mac__check__ok, \ "int", arg0); #define MAC_CHECK_PROBE4(name, error, arg0, arg1, arg2, arg3) do { \ if (error) { \ - SDT_PROBE(mac_framework, kernel, name, mac__check__err, \ + SDT_PROBE5(mac_framework, , name, mac__check__err, \ error, arg0, arg1, arg2, arg3); \ } else { \ - SDT_PROBE(mac_framework, kernel, name, mac__check__ok, \ + SDT_PROBE5(mac_framework, , name, mac__check__ok, \ 0, arg0, arg1, arg2, arg3); \ } \ } while (0) @@ -116,18 +116,18 @@ SDT_PROVIDER_DECLARE(mac_framework); /* #endif #define MAC_GRANT_PROBE_DEFINE2(name, arg0, arg1) \ - SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac__grant__err, \ + SDT_PROBE_DEFINE3(mac_framework, , name, mac__grant__err, \ "int", arg0, arg1); \ - SDT_PROBE_DEFINE3(mac_framework, kernel, name, mac__grant__ok, \ + SDT_PROBE_DEFINE3(mac_framework, , name, mac__grant__ok, \ "int", arg0, arg1); #define MAC_GRANT_PROBE2(name, error, arg0, arg1) do { \ if (error) { \ - SDT_PROBE(mac_framework, kernel, name, mac__grant__err, \ - error, arg0, arg1, 0, 0); \ + SDT_PROBE3(mac_framework, , name, mac__grant__err, \ + error, arg0, arg1); \ } else { \ - SDT_PROBE(mac_framework, kernel, name, mac__grant__ok, \ - error, arg0, arg1, 0, 0); \ + SDT_PROBE3(mac_framework, , name, mac__grant__ok, \ + error, arg0, arg1); \ } \ } while (0) From owner-svn-src-all@freebsd.org Mon Jun 27 22:12:13 2016 Return-Path: Delivered-To: svn-src-all@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 085D2B85432; Mon, 27 Jun 2016 22:12:13 +0000 (UTC) (envelope-from bdrewery@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 D93122078; Mon, 27 Jun 2016 22:12:12 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RMCCAf038690; Mon, 27 Jun 2016 22:12:12 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RMCBxJ038688; Mon, 27 Jun 2016 22:12:11 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272212.u5RMCBxJ038688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 22:12:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302238 - in stable/10/sys: kern sys X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 22:12:13 -0000 Author: bdrewery Date: Mon Jun 27 22:12:11 2016 New Revision: 302238 URL: https://svnweb.freebsd.org/changeset/base/302238 Log: MFC r300792,r300851,r301580: r300792: exec: Add credential change information into imgp for process_exec hook. r300851: exec: get rid of one vnode lock/unlock pair in do_execve r301580: Old process credentials for setuid execve must not be dereferenced when the process credentials were not changed. This can happen if an error occured trying to activate the setuid binary. And on error, if new credentials were not yet assigned, they must be freed to not create the leak. Modified: stable/10/sys/kern/kern_exec.c stable/10/sys/sys/imgact.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 22:10:07 2016 (r302237) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 22:12:11 2016 (r302238) @@ -359,7 +359,7 @@ do_execve(td, args, mac_p) { struct proc *p = td->td_proc; struct nameidata nd; - struct ucred *newcred = NULL, *oldcred; + struct ucred *oldcred; struct uidinfo *euip = NULL; register_t *stack_base; int error, i; @@ -367,7 +367,7 @@ do_execve(td, args, mac_p) struct vattr attr; int (*img_first)(struct image_params *); struct pargs *oldargs = NULL, *newargs = NULL; - struct sigacts *oldsigacts, *newsigacts; + struct sigacts *oldsigacts = NULL, *newsigacts = NULL; #ifdef KTRACE struct vnode *tracevp = NULL; struct ucred *tracecred = NULL; @@ -407,6 +407,7 @@ do_execve(td, args, mac_p) imgp->proc = p; imgp->attr = &attr; imgp->args = args; + oldcred = p->p_ucred; #ifdef MAC error = mac_execve_enter(imgp, mac_p); @@ -488,6 +489,87 @@ interpret: goto exec_fail_dealloc; imgp->proc->p_osrel = 0; + + /* + * Implement image setuid/setgid. + * + * Determine new credentials before attempting image activators + * so that it can be used by process_exec handlers to determine + * credential/setid changes. + * + * Don't honor setuid/setgid if the filesystem prohibits it or if + * the process is being traced. + * + * We disable setuid/setgid/etc in capability mode on the basis + * that most setugid applications are not written with that + * environment in mind, and will therefore almost certainly operate + * incorrectly. In principle there's no reason that setugid + * applications might not be useful in capability mode, so we may want + * to reconsider this conservative design choice in the future. + * + * XXXMAC: For the time being, use NOSUID to also prohibit + * transitions on the file system. + */ + credential_changing = 0; + credential_changing |= (attr.va_mode & S_ISUID) && + oldcred->cr_uid != attr.va_uid; + credential_changing |= (attr.va_mode & S_ISGID) && + oldcred->cr_gid != attr.va_gid; +#ifdef MAC + will_transition = mac_vnode_execve_will_transition(oldcred, imgp->vp, + interpvplabel, imgp); + credential_changing |= will_transition; +#endif + + if (credential_changing && +#ifdef CAPABILITY_MODE + ((oldcred->cr_flags & CRED_FLAG_CAPMODE) == 0) && +#endif + (imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 && + (p->p_flag & P_TRACED) == 0) { + imgp->credential_setid = true; + VOP_UNLOCK(imgp->vp, 0); + imgp->newcred = crdup(oldcred); + if (attr.va_mode & S_ISUID) { + euip = uifind(attr.va_uid); + change_euid(imgp->newcred, euip); + } + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + if (attr.va_mode & S_ISGID) + change_egid(imgp->newcred, attr.va_gid); + /* + * Implement correct POSIX saved-id behavior. + * + * XXXMAC: Note that the current logic will save the + * uid and gid if a MAC domain transition occurs, even + * though maybe it shouldn't. + */ + change_svuid(imgp->newcred, imgp->newcred->cr_uid); + change_svgid(imgp->newcred, imgp->newcred->cr_gid); + } else { + /* + * Implement correct POSIX saved-id behavior. + * + * XXX: It's not clear that the existing behavior is + * POSIX-compliant. A number of sources indicate that the + * saved uid/gid should only be updated if the new ruid is + * not equal to the old ruid, or the new euid is not equal + * to the old euid and the new euid is not equal to the old + * ruid. The FreeBSD code always updates the saved uid/gid. + * Also, this code uses the new (replaced) euid and egid as + * the source, which may or may not be the right ones to use. + */ + if (oldcred->cr_svuid != oldcred->cr_uid || + oldcred->cr_svgid != oldcred->cr_gid) { + VOP_UNLOCK(imgp->vp, 0); + imgp->newcred = crdup(oldcred); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + change_svuid(imgp->newcred, imgp->newcred->cr_uid); + change_svgid(imgp->newcred, imgp->newcred->cr_gid); + } + } + /* The new credentials are installed into the process later. */ + /* * If the current process has a special image activator it * wants to try first, call it. For example, emulating shell @@ -545,6 +627,11 @@ interpret: vput(newtextvp); vm_object_deallocate(imgp->object); imgp->object = NULL; + imgp->credential_setid = false; + if (imgp->newcred != NULL) { + crfree(imgp->newcred); + imgp->newcred = NULL; + } /* set new name to that of the interpreter */ NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, imgp->interpreter_name, td); @@ -611,8 +698,6 @@ interpret: bcopy(imgp->args->begin_argv, newargs->ar_args, i); } - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - /* * For security and other reasons, signal handlers cannot * be shared after an exec. The new process gets a copy of the old @@ -623,15 +708,13 @@ interpret: oldsigacts = p->p_sigacts; newsigacts = sigacts_alloc(); sigacts_copy(newsigacts, oldsigacts); - } else { - oldsigacts = NULL; - newsigacts = NULL; /* satisfy gcc */ } + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + PROC_LOCK(p); if (oldsigacts) p->p_sigacts = newsigacts; - oldcred = p->p_ucred; /* Stop profiling */ stopprofclock(p); @@ -663,38 +746,9 @@ interpret: } /* - * Implement image setuid/setgid. - * - * Don't honor setuid/setgid if the filesystem prohibits it or if - * the process is being traced. - * - * We disable setuid/setgid/etc in capability mode on the basis - * that most setugid applications are not written with that - * environment in mind, and will therefore almost certainly operate - * incorrectly. In principle there's no reason that setugid - * applications might not be useful in capability mode, so we may want - * to reconsider this conservative design choice in the future. - * - * XXXMAC: For the time being, use NOSUID to also prohibit - * transitions on the file system. + * Implement image setuid/setgid installation. */ - credential_changing = 0; - credential_changing |= (attr.va_mode & S_ISUID) && oldcred->cr_uid != - attr.va_uid; - credential_changing |= (attr.va_mode & S_ISGID) && oldcred->cr_gid != - attr.va_gid; -#ifdef MAC - will_transition = mac_vnode_execve_will_transition(oldcred, imgp->vp, - interpvplabel, imgp); - credential_changing |= will_transition; -#endif - - if (credential_changing && -#ifdef CAPABILITY_MODE - ((oldcred->cr_flags & CRED_FLAG_CAPMODE) == 0) && -#endif - (imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 && - (p->p_flag & P_TRACED) == 0) { + if (imgp->credential_setid) { /* * Turn off syscall tracing for set-id programs, except for * root. Record any set-id flags first to make sure that @@ -720,62 +774,28 @@ interpret: VOP_UNLOCK(imgp->vp, 0); setugidsafety(td); error = fdcheckstd(td); - if (error != 0) - goto done1; - newcred = crdup(oldcred); - euip = uifind(attr.va_uid); vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + if (error != 0) + goto exec_fail_dealloc; PROC_LOCK(p); - /* - * Set the new credentials. - */ - if (attr.va_mode & S_ISUID) - change_euid(newcred, euip); - if (attr.va_mode & S_ISGID) - change_egid(newcred, attr.va_gid); #ifdef MAC if (will_transition) { - mac_vnode_execve_transition(oldcred, newcred, imgp->vp, - interpvplabel, imgp); + mac_vnode_execve_transition(oldcred, imgp->newcred, + imgp->vp, interpvplabel, imgp); } #endif - /* - * Implement correct POSIX saved-id behavior. - * - * XXXMAC: Note that the current logic will save the - * uid and gid if a MAC domain transition occurs, even - * though maybe it shouldn't. - */ - change_svuid(newcred, newcred->cr_uid); - change_svgid(newcred, newcred->cr_gid); - proc_set_cred(p, newcred); } else { if (oldcred->cr_uid == oldcred->cr_ruid && oldcred->cr_gid == oldcred->cr_rgid) p->p_flag &= ~P_SUGID; - /* - * Implement correct POSIX saved-id behavior. - * - * XXX: It's not clear that the existing behavior is - * POSIX-compliant. A number of sources indicate that the - * saved uid/gid should only be updated if the new ruid is - * not equal to the old ruid, or the new euid is not equal - * to the old euid and the new euid is not equal to the old - * ruid. The FreeBSD code always updates the saved uid/gid. - * Also, this code uses the new (replaced) euid and egid as - * the source, which may or may not be the right ones to use. - */ - if (oldcred->cr_svuid != oldcred->cr_uid || - oldcred->cr_svgid != oldcred->cr_gid) { - PROC_UNLOCK(p); - VOP_UNLOCK(imgp->vp, 0); - newcred = crdup(oldcred); - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - PROC_LOCK(p); - change_svuid(newcred, newcred->cr_uid); - change_svgid(newcred, newcred->cr_gid); - proc_set_cred(p, newcred); - } + } + /* + * Set the new credentials. + */ + if (imgp->newcred != NULL) { + proc_set_cred(p, imgp->newcred); + crfree(oldcred); + oldcred = NULL; } /* @@ -847,38 +867,7 @@ interpret: SDT_PROBE1(proc, , , exec__success, args->fname); - VOP_UNLOCK(imgp->vp, 0); -done1: - /* - * Free any resources malloc'd earlier that we didn't use. - */ - if (euip != NULL) - uifree(euip); - if (newcred != NULL) - crfree(oldcred); - - /* - * Handle deferred decrement of ref counts. - */ - if (oldtextvp != NULL) - vrele(oldtextvp); -#ifdef KTRACE - if (tracevp != NULL) - vrele(tracevp); - if (tracecred != NULL) - crfree(tracecred); -#endif - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - pargs_drop(oldargs); - pargs_drop(newargs); - if (oldsigacts != NULL) - sigacts_free(oldsigacts); - exec_fail_dealloc: - - /* - * free various allocated resources - */ if (imgp->firstpage != NULL) exec_unmap_first_page(imgp); @@ -908,24 +897,43 @@ exec_fail_dealloc: * the S_EXEC bit set. */ STOPEVENT(p, S_EXEC, 0); - goto done2; - } - + } else { exec_fail: - /* we're done here, clear P_INEXEC */ - PROC_LOCK(p); - p->p_flag &= ~P_INEXEC; - PROC_UNLOCK(p); + /* we're done here, clear P_INEXEC */ + PROC_LOCK(p); + p->p_flag &= ~P_INEXEC; + PROC_UNLOCK(p); + + SDT_PROBE1(proc, , , exec__failure, error); + } - SDT_PROBE1(proc, , , exec__failure, error); + if (imgp->newcred != NULL && oldcred != NULL) + crfree(imgp->newcred); -done2: #ifdef MAC mac_execve_exit(imgp); mac_execve_interpreter_exit(interpvplabel); #endif exec_free_args(args); + /* + * Handle deferred decrement of ref counts. + */ + if (oldtextvp != NULL) + vrele(oldtextvp); +#ifdef KTRACE + if (tracevp != NULL) + vrele(tracevp); + if (tracecred != NULL) + crfree(tracecred); +#endif + pargs_drop(oldargs); + pargs_drop(newargs); + if (oldsigacts != NULL) + sigacts_free(oldsigacts); + if (euip != NULL) + uifree(euip); + if (error && imgp->vmspace_destroyed) { /* sorry, no more process anymore. exit gracefully */ exit1(td, W_EXITCODE(0, SIGABRT)); Modified: stable/10/sys/sys/imgact.h ============================================================================== --- stable/10/sys/sys/imgact.h Mon Jun 27 22:10:07 2016 (r302237) +++ stable/10/sys/sys/imgact.h Mon Jun 27 22:12:11 2016 (r302238) @@ -38,6 +38,8 @@ #define MAXSHELLCMDLEN PAGE_SIZE +struct ucred; + struct image_args { char *buf; /* pointer to string buffer */ char *begin_argv; /* beginning of argv in buf */ @@ -81,6 +83,8 @@ struct image_params { int pagesizeslen; vm_prot_t stack_prot; u_long stack_sz; + struct ucred *newcred; /* new credentials if changing */ + bool credential_setid; /* true if becoming setid */ }; #ifdef _KERNEL From owner-svn-src-all@freebsd.org Mon Jun 27 22:13:44 2016 Return-Path: Delivered-To: svn-src-all@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 BB86EB854A5; Mon, 27 Jun 2016 22:13:44 +0000 (UTC) (envelope-from bdrewery@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 731722230; Mon, 27 Jun 2016 22:13:44 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RMDhua039361; Mon, 27 Jun 2016 22:13:43 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RMDhKx039360; Mon, 27 Jun 2016 22:13:43 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272213.u5RMDhKx039360@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 22:13:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302239 - stable/10/sys/kern X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 22:13:44 -0000 Author: bdrewery Date: Mon Jun 27 22:13:43 2016 New Revision: 302239 URL: https://svnweb.freebsd.org/changeset/base/302239 Log: MFC r300793: exec: Provide execpath in imgp for the process_exec hook. Modified: stable/10/sys/kern/kern_exec.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Mon Jun 27 22:12:11 2016 (r302238) +++ stable/10/sys/kern/kern_exec.c Mon Jun 27 22:13:43 2016 (r302239) @@ -571,6 +571,19 @@ interpret: /* The new credentials are installed into the process later. */ /* + * Do the best to calculate the full path to the image file. + */ + if (args->fname != NULL && args->fname[0] == '/') + imgp->execpath = args->fname; + else { + VOP_UNLOCK(imgp->vp, 0); + if (vn_fullpath(td, imgp->vp, &imgp->execpath, + &imgp->freepath) != 0) + imgp->execpath = args->fname; + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } + + /* * If the current process has a special image activator it * wants to try first, call it. For example, emulating shell * scripts differently. @@ -632,6 +645,9 @@ interpret: crfree(imgp->newcred); imgp->newcred = NULL; } + imgp->execpath = NULL; + free(imgp->freepath, M_TEMP); + imgp->freepath = NULL; /* set new name to that of the interpreter */ NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, imgp->interpreter_name, td); @@ -645,14 +661,6 @@ interpret: */ VOP_UNLOCK(imgp->vp, 0); - /* - * Do the best to calculate the full path to the image file. - */ - if (imgp->auxargs != NULL && - ((args->fname != NULL && args->fname[0] == '/') || - vn_fullpath(td, imgp->vp, &imgp->execpath, &imgp->freepath) != 0)) - imgp->execpath = args->fname; - if (disallow_high_osrel && P_OSREL_MAJOR(p->p_osrel) > P_OSREL_MAJOR(__FreeBSD_version)) { error = ENOEXEC; From owner-svn-src-all@freebsd.org Mon Jun 27 22:18:53 2016 Return-Path: Delivered-To: svn-src-all@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 E7475B8559E; Mon, 27 Jun 2016 22:18:53 +0000 (UTC) (envelope-from bdrewery@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 B685D2692; Mon, 27 Jun 2016 22:18:53 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RMIq4N039831; Mon, 27 Jun 2016 22:18:52 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RMIqpk039829; Mon, 27 Jun 2016 22:18:52 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272218.u5RMIqpk039829@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 22:18:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r302240 - in stable/9: share/man/man4 sys/dev/filemon X-SVN-Group: stable-9 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.22 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: Mon, 27 Jun 2016 22:18:54 -0000 Author: bdrewery Date: Mon Jun 27 22:18:52 2016 New Revision: 302240 URL: https://svnweb.freebsd.org/changeset/base/302240 Log: Mark filemon(4) as "experimental" for 9 since it has many unfixed stability, performance, and audit issues that have not been MFC'd. Modified: stable/9/share/man/man4/filemon.4 stable/9/sys/dev/filemon/filemon.c Modified: stable/9/share/man/man4/filemon.4 ============================================================================== --- stable/9/share/man/man4/filemon.4 Mon Jun 27 22:13:43 2016 (r302239) +++ stable/9/share/man/man4/filemon.4 Mon Jun 27 22:18:52 2016 (r302240) @@ -211,3 +211,7 @@ does not make sense to have daemons for. .Pp Unloading the module may panic the system, thus requires using .Ic kldunload -f . +.Pp +.Nm +is still experimental with +.Fx 9 . Modified: stable/9/sys/dev/filemon/filemon.c ============================================================================== --- stable/9/sys/dev/filemon/filemon.c Mon Jun 27 22:13:43 2016 (r302239) +++ stable/9/sys/dev/filemon/filemon.c Mon Jun 27 22:18:52 2016 (r302240) @@ -291,6 +291,7 @@ filemon_modevent(module_t mod __unused, switch (type) { case MOD_LOAD: + printf("WARNING: Filemon is still experimental for FreeBSD 9.\n"); filemon_load(data); break; From owner-svn-src-all@freebsd.org Mon Jun 27 22:21:31 2016 Return-Path: Delivered-To: svn-src-all@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 113CBB85723; Mon, 27 Jun 2016 22:21:31 +0000 (UTC) (envelope-from bdrewery@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 C4CB62A3A; Mon, 27 Jun 2016 22:21:30 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RMLTHI040849; Mon, 27 Jun 2016 22:21:29 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RMLT7I040847; Mon, 27 Jun 2016 22:21:29 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606272221.u5RMLT7I040847@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 27 Jun 2016 22:21:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302241 - stable/10/sys/dev/filemon X-SVN-Group: stable-10 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.22 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: Mon, 27 Jun 2016 22:21:31 -0000 Author: bdrewery Date: Mon Jun 27 22:21:29 2016 New Revision: 302241 URL: https://svnweb.freebsd.org/changeset/base/302241 Log: MFC r300809,r300890,r300891: r300809: filemon exec: Use imgp->execpath rather than vn_fullpath(9). r300890: exec: Cease tracing if credentials will change with the new image. r300891: Write to the log using the tracer's credentials. Modified: stable/10/sys/dev/filemon/filemon.c stable/10/sys/dev/filemon/filemon_wrapper.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/filemon/filemon.c ============================================================================== --- stable/10/sys/dev/filemon/filemon.c Mon Jun 27 22:18:52 2016 (r302240) +++ stable/10/sys/dev/filemon/filemon.c Mon Jun 27 22:21:29 2016 (r302241) @@ -85,6 +85,7 @@ MALLOC_DEFINE(M_FILEMON, "filemon", "Fil struct filemon { struct sx lock; /* Lock for this filemon. */ struct file *fp; /* Output file pointer. */ + struct ucred *cred; /* Credential of tracer. */ char fname1[MAXPATHLEN]; /* Temporary filename buffer. */ char fname2[MAXPATHLEN]; /* Temporary filename buffer. */ char msgbufr[1024]; /* Output message buffer. */ @@ -121,6 +122,8 @@ filemon_release(struct filemon *filemon) */ sx_assert(&filemon->lock, SA_UNLOCKED); + if (filemon->cred != NULL) + crfree(filemon->cred); sx_destroy(&filemon->lock); free(filemon, M_FILEMON); } @@ -304,6 +307,9 @@ filemon_attach_proc(struct filemon *file KASSERT((p->p_flag & P_WEXIT) == 0, ("%s: filemon %p attaching to exiting process %p", __func__, filemon, p)); + KASSERT((p->p_flag & P_INEXEC) == 0, + ("%s: filemon %p attaching to execing process %p", + __func__, filemon, p)); if (p->p_filemon == filemon) return (0); @@ -381,8 +387,8 @@ filemon_ioctl(struct cdev *dev, u_long c /* Invalidate any existing processes already set. */ filemon_untrack_processes(filemon); - error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT, - &p); + error = pget(*((pid_t *)data), + PGET_CANDEBUG | PGET_NOTWEXIT | PGET_NOTINEXEC, &p); if (error == 0) { KASSERT(p->p_filemon != filemon, ("%s: proc %p didn't untrack filemon %p", @@ -403,7 +409,7 @@ filemon_ioctl(struct cdev *dev, u_long c static int filemon_open(struct cdev *dev, int oflags __unused, int devtype __unused, - struct thread *td __unused) + struct thread *td) { int error; struct filemon *filemon; @@ -412,6 +418,7 @@ filemon_open(struct cdev *dev, int oflag M_WAITOK | M_ZERO); sx_init(&filemon->lock, "filemon"); refcount_init(&filemon->refcnt, 1); + filemon->cred = crhold(td->td_ucred); error = devfs_set_cdevpriv(filemon, filemon_dtr); if (error != 0) Modified: stable/10/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- stable/10/sys/dev/filemon/filemon_wrapper.c Mon Jun 27 22:18:52 2016 (r302240) +++ stable/10/sys/dev/filemon/filemon_wrapper.c Mon Jun 27 22:21:29 2016 (r302241) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ filemon_output(struct filemon *filemon, if (filemon->fp->f_type == DTYPE_VNODE) bwillwrite(); - error = fo_write(filemon->fp, &auio, curthread->td_ucred, 0, curthread); + error = fo_write(filemon->fp, &auio, filemon->cred, 0, curthread); if (error != 0 && filemon->error == 0) filemon->error = error; } @@ -103,24 +104,35 @@ filemon_event_process_exec(void *arg __u struct image_params *imgp) { struct filemon *filemon; - char *fullpath, *freepath; size_t len; if ((filemon = filemon_proc_get(p)) != NULL) { - fullpath = ""; - freepath = NULL; - - vn_fullpath(curthread, imgp->vp, &fullpath, &freepath); - len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr), "E %d %s\n", - p->p_pid, fullpath); + p->p_pid, + imgp->execpath != NULL ? imgp->execpath : ""); filemon_output(filemon, filemon->msgbufr, len); - filemon_drop(filemon); + /* If the credentials changed then cease tracing. */ + if (imgp->newcred != NULL && + imgp->credential_setid && + priv_check_cred(filemon->cred, + PRIV_DEBUG_DIFFCRED, 0) != 0) { + /* + * It may have changed to NULL already, but + * will not be re-attached by anything else. + */ + if (p->p_filemon != NULL) { + KASSERT(p->p_filemon == filemon, + ("%s: proc %p didn't have expected" + " filemon %p", __func__, p, filemon)); + filemon_proc_drop(p); + } + } - free(freepath, M_TEMP); + + filemon_drop(filemon); } } From owner-svn-src-all@freebsd.org Mon Jun 27 23:34:54 2016 Return-Path: Delivered-To: svn-src-all@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 A184EB81609; Mon, 27 Jun 2016 23:34:54 +0000 (UTC) (envelope-from kib@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 731B62BBF; Mon, 27 Jun 2016 23:34:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5RNYrpP069390; Mon, 27 Jun 2016 23:34:53 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5RNYrAG069388; Mon, 27 Jun 2016 23:34:53 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606272334.u5RNYrAG069388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 27 Jun 2016 23:34:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302242 - in head/sys: kern sys X-SVN-Group: head 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.22 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: Mon, 27 Jun 2016 23:34:54 -0000 Author: kib Date: Mon Jun 27 23:34:53 2016 New Revision: 302242 URL: https://svnweb.freebsd.org/changeset/base/302242 Log: Fix userspace build after r302235: do not expose bool field of the structure, change it to int. The real fix is to sanitize user-visible definitions in sys/event.h, e.g. the affected struct knlist is of no use for userspace programs. Reported and tested by: jkim Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Modified: head/sys/kern/kern_event.c head/sys/sys/event.h Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Mon Jun 27 22:21:29 2016 (r302241) +++ head/sys/kern/kern_event.c Mon Jun 27 23:34:53 2016 (r302242) @@ -2204,7 +2204,7 @@ knlist_init(struct knlist *knl, void *lo else knl->kl_assert_unlocked = kl_assert_unlocked; - knl->kl_autodestroy = false; + knl->kl_autodestroy = 0; SLIST_INIT(&knl->kl_list); } @@ -2255,7 +2255,7 @@ knlist_detach(struct knlist *knl) { KNL_ASSERT_LOCKED(knl); - knl->kl_autodestroy = true; + knl->kl_autodestroy = 1; if (knlist_empty(knl)) { knlist_destroy(knl); free(knl, M_KQUEUE); Modified: head/sys/sys/event.h ============================================================================== --- head/sys/sys/event.h Mon Jun 27 22:21:29 2016 (r302241) +++ head/sys/sys/event.h Mon Jun 27 23:34:53 2016 (r302242) @@ -159,7 +159,7 @@ struct knlist { void (*kl_assert_locked)(void *); void (*kl_assert_unlocked)(void *); void *kl_lockarg; /* argument passed to lock functions */ - bool kl_autodestroy; + int kl_autodestroy; }; From owner-svn-src-all@freebsd.org Mon Jun 27 23:46:36 2016 Return-Path: Delivered-To: svn-src-all@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 10A38B81817; Mon, 27 Jun 2016 23:46:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF8C8202F; Mon, 27 Jun 2016 23:46:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5RNkO5A032930 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 28 Jun 2016 02:46:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5RNkO5A032930 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5RNkO8j032929; Tue, 28 Jun 2016 02:46:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 28 Jun 2016 02:46:24 +0300 From: Konstantin Belousov To: Ngie Cooper Cc: jilles@freebsd.org, "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r302216 - in head/sys: kern nlm Message-ID: <20160627234624.GV38613@kib.kiev.ua> References: <201606262008.u5QK8gTx042729@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Wfe1KbQWcwuymTys" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 27 Jun 2016 23:46:36 -0000 --Wfe1KbQWcwuymTys Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 27, 2016 at 01:18:48PM -0700, Ngie Cooper wrote: > On Sun, Jun 26, 2016 at 1:08 PM, Konstantin Belousov wrote: > > Author: kib > > Date: Sun Jun 26 20:08:42 2016 > > New Revision: 302216 > > URL: https://svnweb.freebsd.org/changeset/base/302216 > > > > Log: > > When sleeping waiting for either local or remote advisory lock, > > interrupt sleeps with the ERESTART on the suspension attempts. > > Otherwise, single-threading requests are deferred until the locks are > > granted for NFS files, which causes hangs. > > > > When retrying local registration of the remotely-granted adv lock, > > allow full suspension and check for suspension, for usual reasons. > > > > Reported by: markj, pho > > Reviewed by: jilles > > Tested by: pho > > Sponsored by: The FreeBSD Foundation > > MFC after: 2 weeks > > Approved by: re (gjb) > > One of the NetBSD tests seems to be failing now: > https://jenkins.freebsd.org/job/FreeBSD_HEAD/334/testReport/junit/sys.kern/lockf_test/randlock/ > . Indeed. The reason is that TDF_SBDRY + TDF_SERESTART (or TDF_SEINTR) combination should be treated almost as if TDF_SBDRY is not set, at least for the purposes of filtering out stops. It must not allow the real stop to occur at a protected sleep point, though. The committed revision lacks updates to kern_sig.c to kick the sleeping thread in TDF_SERESTART condition to make it runnable to reach boundary. I attached the distilled case from the NetBSD test below. Another good test case to illustrate that is to do in one terminal echo 123 >/tmp/1 lockf /tmp/1 sleep 100000 and in another lockf /tmp/1 date ^Z This should have failed in similar way on NFS only, before the changes. The patch attached fixed both cases for me. --Wfe1KbQWcwuymTys Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="1.patch" diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 424f316..059103dc 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -107,7 +107,7 @@ static int killpg1(struct thread *td, int sig, int pgid, int all, static int issignal(struct thread *td); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); -static void sig_suspend_threads(struct thread *, struct proc *, int); +static int sig_suspend_threads(struct thread *, struct proc *, int); static int filt_sigattach(struct knote *kn); static void filt_sigdetach(struct knote *kn); static int filt_signal(struct knote *kn, long hint); @@ -2327,7 +2327,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) p->p_flag |= P_STOPPED_SIG; p->p_xsig = sig; PROC_SLOCK(p); - sig_suspend_threads(td, p, 1); + wakeup_swapper = sig_suspend_threads(td, p, 1); if (p->p_numthreads == p->p_suspcount) { /* * only thread sending signal to another @@ -2341,6 +2341,8 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) sigqueue_delete_proc(p, p->p_xsig); } else PROC_SUNLOCK(p); + if (wakeup_swapper) + kick_proc0(); goto out; } } else { @@ -2421,7 +2423,8 @@ tdsigwakeup(struct thread *td, int sig, sig_t action, int intrval) * Don't awaken a sleeping thread for SIGSTOP if the * STOP signal is deferred. */ - if ((prop & SA_STOP) && (td->td_flags & TDF_SBDRY)) + if ((prop & SA_STOP) != 0 && (td->td_flags & (TDF_SBDRY | + TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) goto out; /* @@ -2449,14 +2452,16 @@ out: kick_proc0(); } -static void +static int sig_suspend_threads(struct thread *td, struct proc *p, int sending) { struct thread *td2; + int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); + wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; @@ -2465,11 +2470,18 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending) if (td2->td_flags & TDF_SBDRY) { /* * Once a thread is asleep with - * TDF_SBDRY set, it should never + * TDF_SBDRY and without TDF_SERESTART + * or TDF_SEINTR set, it should never * become suspended due to this check. */ KASSERT(!TD_IS_SUSPENDED(td2), ("thread with deferred stops suspended")); + if ((td2->td_flags & (TDF_SERESTART | + TDF_SEINTR)) != 0 && sending) { + wakeup_swapper |= sleepq_abort(td, + (td2->td_flags & TDF_SERESTART) + != 0 ? ERESTART : EINTR); + } } else if (!TD_IS_SUSPENDED(td2)) { thread_suspend_one(td2); } @@ -2483,6 +2495,7 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending) } thread_unlock(td2); } + return (wakeup_swapper); } int @@ -2705,7 +2718,8 @@ issignal(struct thread *td) SIGSETOR(sigpending, p->p_sigqueue.sq_signals); SIGSETNAND(sigpending, td->td_sigmask); - if (p->p_flag & P_PPWAIT || td->td_flags & TDF_SBDRY) + if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & + (TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) SIG_STOPSIGMASK(sigpending); if (SIGISEMPTY(sigpending)) /* no signal to send */ return (0); --Wfe1KbQWcwuymTys-- From owner-svn-src-all@freebsd.org Tue Jun 28 00:37:36 2016 Return-Path: Delivered-To: svn-src-all@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 3DD81AC5222; Tue, 28 Jun 2016 00:37:36 +0000 (UTC) (envelope-from kib@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 16F512627; Tue, 28 Jun 2016 00:37:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5S0bZWl091709; Tue, 28 Jun 2016 00:37:35 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5S0bZ28091707; Tue, 28 Jun 2016 00:37:35 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606280037.u5S0bZ28091707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 00:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302243 - stable/10/sys/vm X-SVN-Group: stable-10 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.22 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, 28 Jun 2016 00:37:36 -0000 Author: kib Date: Tue Jun 28 00:37:34 2016 New Revision: 302243 URL: https://svnweb.freebsd.org/changeset/base/302243 Log: MFC r302063: Avoid the active object marking for vm.vmtotal sysctl. Modified: stable/10/sys/vm/vm_meter.c stable/10/sys/vm/vm_object.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_meter.c ============================================================================== --- stable/10/sys/vm/vm_meter.c Mon Jun 27 23:34:53 2016 (r302242) +++ stable/10/sys/vm/vm_meter.c Tue Jun 28 00:37:34 2016 (r302243) @@ -93,29 +93,31 @@ SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CT CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history"); +/* + * This function aims to determine if the object is mapped, + * specifically, if it is referenced by a vm_map_entry. Because + * objects occasionally acquire transient references that do not + * represent a mapping, the method used here is inexact. However, it + * has very low overhead and is good enough for the advisory + * vm.vmtotal sysctl. + */ +static bool +is_object_active(vm_object_t obj) +{ + + return (obj->ref_count > obj->shadow_count); +} + static int vmtotal(SYSCTL_HANDLER_ARGS) { - struct proc *p; struct vmtotal total; - vm_map_entry_t entry; vm_object_t object; - vm_map_t map; - int paging; + struct proc *p; struct thread *td; - struct vmspace *vm; bzero(&total, sizeof(total)); - /* - * Mark all objects as inactive. - */ - mtx_lock(&vm_object_list_mtx); - TAILQ_FOREACH(object, &vm_object_list, object_list) { - VM_OBJECT_WLOCK(object); - vm_object_clear_flag(object, OBJ_ACTIVE); - VM_OBJECT_WUNLOCK(object); - } - mtx_unlock(&vm_object_list_mtx); + /* * Calculate process statistics. */ @@ -136,11 +138,15 @@ vmtotal(SYSCTL_HANDLER_ARGS) case TDS_INHIBITED: if (TD_IS_SWAPPED(td)) total.t_sw++; - else if (TD_IS_SLEEPING(td) && - td->td_priority <= PZERO) - total.t_dw++; - else - total.t_sl++; + else if (TD_IS_SLEEPING(td)) { + if (td->td_priority <= PZERO) + total.t_dw++; + else + total.t_sl++; + if (td->td_wchan == + &cnt.v_free_count) + total.t_pw++; + } break; case TDS_CAN_RUN: @@ -158,29 +164,6 @@ vmtotal(SYSCTL_HANDLER_ARGS) } } PROC_UNLOCK(p); - /* - * Note active objects. - */ - paging = 0; - vm = vmspace_acquire_ref(p); - if (vm == NULL) - continue; - map = &vm->vm_map; - vm_map_lock_read(map); - for (entry = map->header.next; - entry != &map->header; entry = entry->next) { - if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) || - (object = entry->object.vm_object) == NULL) - continue; - VM_OBJECT_WLOCK(object); - vm_object_set_flag(object, OBJ_ACTIVE); - paging |= object->paging_in_progress; - VM_OBJECT_WUNLOCK(object); - } - vm_map_unlock_read(map); - vmspace_free(vm); - if (paging) - total.t_pw++; } sx_sunlock(&allproc_lock); /* @@ -206,9 +189,18 @@ vmtotal(SYSCTL_HANDLER_ARGS) */ continue; } + if (object->ref_count == 1 && + (object->flags & OBJ_NOSPLIT) != 0) { + /* + * Also skip otherwise unreferenced swap + * objects backing tmpfs vnodes, and POSIX or + * SysV shared memory. + */ + continue; + } total.t_vm += object->size; total.t_rm += object->resident_page_count; - if (object->flags & OBJ_ACTIVE) { + if (is_object_active(object)) { total.t_avm += object->size; total.t_arm += object->resident_page_count; } @@ -216,7 +208,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) /* shared object */ total.t_vmshr += object->size; total.t_rmshr += object->resident_page_count; - if (object->flags & OBJ_ACTIVE) { + if (is_object_active(object)) { total.t_avmshr += object->size; total.t_armshr += object->resident_page_count; } Modified: stable/10/sys/vm/vm_object.h ============================================================================== --- stable/10/sys/vm/vm_object.h Mon Jun 27 23:34:53 2016 (r302242) +++ stable/10/sys/vm/vm_object.h Tue Jun 28 00:37:34 2016 (r302243) @@ -181,7 +181,6 @@ struct vm_object { */ #define OBJ_FICTITIOUS 0x0001 /* (c) contains fictitious pages */ #define OBJ_UNMANAGED 0x0002 /* (c) contains unmanaged pages */ -#define OBJ_ACTIVE 0x0004 /* active objects */ #define OBJ_DEAD 0x0008 /* dead objects (during rundown) */ #define OBJ_NOSPLIT 0x0010 /* dont split this object */ #define OBJ_PIPWNT 0x0040 /* paging in progress wanted */ From owner-svn-src-all@freebsd.org Tue Jun 28 03:11:08 2016 Return-Path: Delivered-To: svn-src-all@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 C120AB859CD; Tue, 28 Jun 2016 03:11:08 +0000 (UTC) (envelope-from pfg@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 9251B2967; Tue, 28 Jun 2016 03:11:08 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5S3B7Ys049738; Tue, 28 Jun 2016 03:11:07 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5S3B7ET049737; Tue, 28 Jun 2016 03:11:07 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201606280311.u5S3B7ET049737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 28 Jun 2016 03:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302244 - stable/10/usr.bin/sed X-SVN-Group: stable-10 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.22 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, 28 Jun 2016 03:11:08 -0000 Author: pfg Date: Tue Jun 28 03:11:07 2016 New Revision: 302244 URL: https://svnweb.freebsd.org/changeset/base/302244 Log: MFC r301138: sed(1): convert sed to use REG_STARTEND more explicitly. This is a followup to previous r302228, which only merged the incomplete r300684 causing a regression. Reported by: mi PR: 209387 Taken from: openbsd-tech (Martijn van Duren) Modified: stable/10/usr.bin/sed/process.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/sed/process.c ============================================================================== --- stable/10/usr.bin/sed/process.c Tue Jun 28 00:37:34 2016 (r302243) +++ stable/10/usr.bin/sed/process.c Tue Jun 28 03:11:07 2016 (r302244) @@ -384,7 +384,7 @@ substitute(struct s_command *cp) linenum, fname, cp->u.s->maxbref); } } - if (!regexec_e(re, s, 0, 0, 0, psl)) + if (!regexec_e(re, ps, 0, 0, 0, psl)) return (0); SS.len = 0; /* Clean substitute space. */ @@ -394,7 +394,7 @@ substitute(struct s_command *cp) do { /* Copy the leading retained string. */ - if (n <= 1 && match[0].rm_so - le) + if (n <= 1 && (match[0].rm_so > le)) cspace(&SS, s, match[0].rm_so - le, APPEND); /* Skip zero-length matches right after other matches. */ @@ -415,8 +415,8 @@ substitute(struct s_command *cp) } /* Move past this match. */ - s += (match[0].rm_eo - le); - slen -= (match[0].rm_eo - le); + s = ps + match[0].rm_eo; + slen = psl - match[0].rm_eo; le = match[0].rm_eo; /* @@ -436,7 +436,8 @@ substitute(struct s_command *cp) } else lastempty = 0; - } while (n >= 0 && slen >= 0 && regexec_e(re, ps, 0, 0, le, psl)); + } while (n >= 0 && slen >= 0 && + regexec_e(re, ps, REG_NOTBOL, 0, le, psl)); /* Did not find the requested number of matches. */ if (n > 1) From owner-svn-src-all@freebsd.org Tue Jun 28 07:47:43 2016 Return-Path: Delivered-To: svn-src-all@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 89DD7B85CB1; Tue, 28 Jun 2016 07:47:43 +0000 (UTC) (envelope-from cy@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 56DDD2FDA; Tue, 28 Jun 2016 07:47:43 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5S7lgvD051545; Tue, 28 Jun 2016 07:47:42 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5S7lgMq051544; Tue, 28 Jun 2016 07:47:42 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201606280747.u5S7lgMq051544@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 28 Jun 2016 07:47:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302246 - head/lib/libc/tests/ssp X-SVN-Group: head 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.22 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, 28 Jun 2016 07:47:43 -0000 Author: cy Date: Tue Jun 28 07:47:42 2016 New Revision: 302246 URL: https://svnweb.freebsd.org/changeset/base/302246 Log: This commit addresses regression introduceded in r302177 (WITH_SYSTEM_COMPILER: Enable by default) and it's prerequisite: r300354, caused i386 builds to fail when cross-built on an amd64 host. Reviewed by: bdrewery, delphij, gjb Approved by: re (gjb) Modified: head/lib/libc/tests/ssp/Makefile Modified: head/lib/libc/tests/ssp/Makefile ============================================================================== --- head/lib/libc/tests/ssp/Makefile Tue Jun 28 07:11:27 2016 (r302245) +++ head/lib/libc/tests/ssp/Makefile Tue Jun 28 07:47:42 2016 (r302246) @@ -1,5 +1,9 @@ # $FreeBSD$ +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.include +# XXX --- + .include NO_WERROR= @@ -34,7 +38,17 @@ PROGS+= h_memset .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" .if ${COMPILER_TYPE} == "clang" && ${MK_TOOLCHAIN} == "yes" .if ${COMPILER_VERSION} < 30500 || 30700 <= ${COMPILER_VERSION} + +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.if ${MACHINE_CPUARCH} == ${_HOST_ARCH} +# XXX --- + PROGS+= h_raw + +# XXX This is a workaround to allow i386 to cross-compile on an amd64 host. +.endif +# XXX --- + .endif .endif .endif From owner-svn-src-all@freebsd.org Tue Jun 28 13:37:03 2016 Return-Path: Delivered-To: svn-src-all@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 819DCB85A2C; Tue, 28 Jun 2016 13:37:03 +0000 (UTC) (envelope-from jtl@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 4FF132217; Tue, 28 Jun 2016 13:37:03 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SDb28I082558; Tue, 28 Jun 2016 13:37:02 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SDb2rh082554; Tue, 28 Jun 2016 13:37:02 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201606281337.u5SDb2rh082554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 28 Jun 2016 13:37:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302247 - in head: share/man/man4 share/man/man9 tools/build/options X-SVN-Group: head 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.22 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, 28 Jun 2016 13:37:03 -0000 Author: jtl Date: Tue Jun 28 13:37:01 2016 New Revision: 302247 URL: https://svnweb.freebsd.org/changeset/base/302247 Log: Document support for alternate TCP stacks. Differential Revision: https://reviews.freebsd.org/D6940 Reviewed by: hiren Approved by: re (gjb) Sponsored by: Juniper Networks Added: head/share/man/man9/tcp_functions.9 (contents, props changed) head/tools/build/options/WITH_EXTRA_TCP_STACKS (contents, props changed) Modified: head/share/man/man4/tcp.4 head/share/man/man9/Makefile Modified: head/share/man/man4/tcp.4 ============================================================================== --- head/share/man/man4/tcp.4 Tue Jun 28 07:47:42 2016 (r302246) +++ head/share/man/man4/tcp.4 Tue Jun 28 13:37:01 2016 (r302247) @@ -34,7 +34,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd May 19, 2016 +.Dd June 28, 2016 .Dt TCP 4 .Os .Sh NAME @@ -119,7 +119,7 @@ supports a number of socket options whic .Xr setsockopt 2 and tested with .Xr getsockopt 2 : -.Bl -tag -width ".Dv TCP_CONGESTION" +.Bl -tag -width ".Dv TCP_FUNCTION_BLK" .It Dv TCP_INFO Information about a socket's underlying TCP session may be retrieved by passing the read-only option @@ -148,6 +148,20 @@ connection. See .Xr mod_cc 4 for details. +.It Dv TCP_FUNCTION_BLK +Select or query the set of functions that TCP will use for this connection. +This allows a user to select an alternate TCP stack. +The alternate TCP stack must already be loaded in the kernel. +To list the available TCP stacks, see +.Va functions_available +in the +.Sx MIB Variables +section further down. +To list the default TCP stack, see +.Va functions_default +in the +.Sx MIB Variables +section. .It Dv TCP_KEEPINIT This .Xr setsockopt 2 @@ -568,6 +582,10 @@ Number of times default MSS was used in .It Va pmtud_blackhole_failed Number of connections for which retransmits continued even after MSS downshift. +.It Va functions_available +List of available TCP function blocks (TCP stacks). +.It Va functions_default +The default TCP function block (TCP stack). .El .Sh ERRORS A socket operation may fail with one of the following errors returned: @@ -599,6 +617,10 @@ exists; .It Bq Er EAFNOSUPPORT when an attempt is made to bind or connect a socket to a multicast address. +.It Bq Er EINVAL +when trying to change TCP function blocks at an invalid point in the session; +.It Bq Er ENOENT +when trying to use a TCP function block that is not available; .El .Sh SEE ALSO .Xr getsockopt 2 , Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Tue Jun 28 07:47:42 2016 (r302246) +++ head/share/man/man9/Makefile Tue Jun 28 13:37:01 2016 (r302247) @@ -284,6 +284,7 @@ MAN= accept_filter.9 \ sysctl_ctx_init.9 \ SYSINIT.9 \ taskqueue.9 \ + tcp_functions.9 \ thread_exit.9 \ time.9 \ timeout.9 \ @@ -1734,6 +1735,8 @@ MLINKS+=taskqueue.9 TASK_INIT.9 \ taskqueue.9 taskqueue_start_threads_pinned.9 \ taskqueue.9 taskqueue_unblock.9 \ taskqueue.9 TIMEOUT_TASK_INIT.9 +MLINKS+=tcp_functions.9 register_tcp_functions.9 \ + tcp_functions.9 deregister_tcp_functions.9 MLINKS+=time.9 boottime.9 \ time.9 time_second.9 \ time.9 time_uptime.9 Added: head/share/man/man9/tcp_functions.9 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man9/tcp_functions.9 Tue Jun 28 13:37:01 2016 (r302247) @@ -0,0 +1,285 @@ +.\" +.\" Copyright (c) 2016 Jonathan Looney +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR +.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd June 28, 2016 +.Dt TCP_FUNCTIONS 9 +.Os +.Sh NAME +.Nm tcp_functions +.Nd Alternate TCP Stack Framework +.Sh SYNOPSIS +.In netinet/tcp.h +.In netinet/tcp_var.h +.Ft int +.Fn register_tcp_functions "struct tcp_function_block *blk" "int wait" +.Ft int +.Fn deregister_tcp_functions "struct tcp_function_block *blk" +.Sh DESCRIPTION +The +.Nm +framework allows a kernel developer to implement alternate TCP stacks. +The alternate stacks can be compiled in the kernel or can be implemented in +loadable kernel modules. +This functionality is intended to encourage experimentation with the TCP stack +and to allow alternate behaviors to be deployed for different TCP connections +on a single system. +.Pp +A system administrator can set a system default stack. +By default, all TCP connections will use the system default stack. +Additionally, users can specify a particular stack to use on a per-connection +basis. +(See +.Xr tcp 4 +for details on setting the system default stack, or selecting a specific stack +for a given connection.) +.Pp +This man page treats "TCP stacks" as synonymous with "function blocks". +This is intentional. +A "TCP stack" is a collection of functions that implement a set of behavior. +Therefore, an alternate "function block" defines an alternate "TCP stack". +.Pp +.Nm +modules must call the +.Fn register_tcp_functions +function during initialization and successfully call the +.Fn deregister_tcp_functions +function prior to allowing the module to be unloaded. +.Pp +The +.Fn register_tcp_functions +function requests that the system add a specified function block to the system. +.Pp +The +.Fn deregister_tcp_functions +function requests that the system remove a specified function block from the +system. +If the call fails because sockets are still using the specified function block, +the system will mark the function block as being in the process of being +removed. +This will prevent additional sockets from using the specified function block. +However, it will not impact sockets that are already using the function block. +.Pp +The +.Fa blk +argument is a pointer to a +.Vt "struct tcp_function_block" , +which is explained below (see +.Sx Function Block Structure ) . +The +.Fa wait +argument is used as the +.Fa flags +argument to +.Xr malloc 9 , +and must be set to one of the valid values defined in that man page. +.Ss Function Block Structure +The +.Fa blk argument is a pointer to a +.Vt "struct tcp_function_block" , +which has the following members: +.Bd -literal -offset indent +struct tcp_function_block { + char tfb_tcp_block_name[TCP_FUNCTION_NAME_LEN_MAX]; + int (*tfb_tcp_output)(struct tcpcb *); + void (*tfb_tcp_do_segment)(struct mbuf *, struct tcphdr *, + struct socket *, struct tcpcb *, + int, int, uint8_t, + int); + int (*tfb_tcp_ctloutput)(struct socket *so, + struct sockopt *sopt, + struct inpcb *inp, struct tcpcb *tp); + /* Optional memory allocation/free routine */ + void (*tfb_tcp_fb_init)(struct tcpcb *); + void (*tfb_tcp_fb_fini)(struct tcpcb *); + /* Optional timers, must define all if you define one */ + int (*tfb_tcp_timer_stop_all)(struct tcpcb *); + void (*tfb_tcp_timer_activate)(struct tcpcb *, + uint32_t, u_int); + int (*tfb_tcp_timer_active)(struct tcpcb *, uint32_t); + void (*tfb_tcp_timer_stop)(struct tcpcb *, uint32_t); + void (*tfb_tcp_rexmit_tmr)(struct tcpcb *); + volatile uint32_t tfb_refcnt; + uint32_t tfb_flags; +}; +.Ed +.Pp +The +.Va tfb_tcp_block_name +field identifies the unique name of the TCP stack, and should be no longer than +TCP_FUNCTION_NAME_LEN_MAX-1 characters in length. +.Pp +The +.Va tfb_tcp_output , +.Va tfb_tcp_do_segment , +and +.Va tfb_tcp_ctloutput +fields are pointers to functions that perform the equivalent actions +as the default +.Fn tcp_output , +.Fn tcp_do_segment , +and +.Fn tcp_default_ctloutput +functions, respectively. +Each of these function pointers must be non-NULL. +.Pp +If a TCP stack needs to initialize data when a socket first selects the TCP +stack (or, when the socket is first opened), it should set a non-NULL +pointer in the +.Va tfb_tcp_fb_init +field. +Likewise, if a TCP stack needs to cleanup data when a socket stops using the +TCP stack (or, when the socket is closed), it should set a non-NULL pointer +in the +.Va tfb_tcp_fb_fini +field. +.Pp +If the TCP stack implements additional timers, the TCP stack should set a +non-NULL pointer in the +.Va tfb_tcp_timer_stop_all , +.Va tfb_tcp_timer_activate , +.Va tfb_tcp_timer_active , +and +.Va tfb_tcp_timer_stop +fields. +These fields should all be +.Dv NULL +or should all contain pointers to functions. +The +.Va tfb_tcp_timer_activate , +.Va tfb_tcp_timer_active , +and +.Va tfb_tcp_timer_stop +functions will be called when the +.Fn tcp_timer_activate , +.Fn tcp_timer_active , +and +.Fn tcp_timer_stop +functions, respectively, are called with a timer type other than the standard +types. +The functions defined by the TCP stack have the same semantics (both for +arguments and return values) as the normal timer functions they supplement. +.Pp +Additionally, a stack may define its own actions to take when the retransmit +timer fires by setting a non-NULL function pointer in the +.Va tfb_tcp_rexmit_tmr +field. +This function is called very early in the process of handling a retransmit +timer. +However, care must be taken to ensure the retransmit timer leaves the +TCP control block in a valid state for the remainder of the retransmit +timer logic. +.Pp +The +.Va tfb_refcnt +and +.Va tfb_flags +fields are used by the kernel's TCP code and will be initialized when the +TCP stack is registered. +.Ss Requirements for Alternate TCP Stacks +If the TCP stack needs to store data beyond what is stored in the default +TCP control block, the TCP stack can initialize its own per-connection storage. +The +.Va t_fb_ptr +field in the +.Vt "struct tcpcb" +control block structure has been reserved to hold a pointer to this +per-connection storage. +If the TCP stack uses this alternate storage, it should understand that the +value of the +.Va t_fb_ptr +pointer may not be initialized to +.Dv NULL . +Therefore, it should use a +.Va tfb_tcp_fb_init +function to initialize this field. +Additionally, it should use a +.Va tfb_tcp_fb_fini +function to deallocate storage when the socket is closed. +.Pp +It is understood that alternate TCP stacks may keep different sets of data. +However, in order to ensure that data is available to both the user and the +rest of the system in a standardized format, alternate TCP stacks must +update all fields in the TCP control block to the greatest extent practical. +.Sh RETURN VALUES +The +.Fn register_tcp_functions +and +.Fn deregister_tcp_functions +functions return zero on success and non-zero on failure. +In particular, the +.Fn deregister_tcp_functions +will return +.Er EBUSY +until no more connections are using the specified TCP stack. +A module calling +.Fn deregister_tcp_functions +must be prepared to wait until all connections have stopped using the +specified TCP stack. +.Sh ERRORS +The +.Fn register_tcp_functions +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Any of the members of the +.Fa blk +argument are set incorrectly. +.It Bq Er ENOMEM +The function could not allocate memory for its internal data. +.It Bq Er EALREADY +A function block is already registered with the same name. +.El +The +.Fn deregister_tcp_functions +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The +.Fa blk +argument references the kernel's compiled-in default function block. +.It Bq Er EBUSY +The function block is still in use by one or more sockets, or is defined as +the current default function block. +.It Bq Er ENOENT +The +.Fa blk +argument references a function block that is not currently registered. +.Sh SEE ALSO +.Xr malloc 9 , +.Xr tcp 4 +.Sh HISTORY +This framework first appeared in +.Fx 11.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +framework was written by +.An Randall Stewart Aq Mt rrs@FreeBSD.org . +.Pp +This manual page was written by +.An Jonathan Looney Aq Mt jtl@FreeBSD.org . Added: head/tools/build/options/WITH_EXTRA_TCP_STACKS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_EXTRA_TCP_STACKS Tue Jun 28 13:37:01 2016 (r302247) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build extra TCP stack modules. From owner-svn-src-all@freebsd.org Tue Jun 28 13:42:51 2016 Return-Path: Delivered-To: svn-src-all@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 BB4CCB85BDA; Tue, 28 Jun 2016 13:42:51 +0000 (UTC) (envelope-from jtl@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 880BC2793; Tue, 28 Jun 2016 13:42:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SDgorn086244; Tue, 28 Jun 2016 13:42:50 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SDgoMD086243; Tue, 28 Jun 2016 13:42:50 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201606281342.u5SDgoMD086243@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 28 Jun 2016 13:42:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302248 - head/share/man/man5 X-SVN-Group: head 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.22 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, 28 Jun 2016 13:42:51 -0000 Author: jtl Date: Tue Jun 28 13:42:50 2016 New Revision: 302248 URL: https://svnweb.freebsd.org/changeset/base/302248 Log: Regenerate for WITH_EXTRA_TCP_STACKS updates. Approved by: re (gjb) Sponsored by: Juniper Networks Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Tue Jun 28 13:37:01 2016 (r302247) +++ head/share/man/man5/src.conf.5 Tue Jun 28 13:42:50 2016 (r302248) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 292283 2015-12-15 18:42:30Z bdrewery .\" $FreeBSD$ -.Dd June 24, 2016 +.Dd June 28, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -633,6 +633,9 @@ An alternate bootstrap tool chain must b .\" from FreeBSD: head/tools/build/options/WITHOUT_EXAMPLES 156938 2006-03-21 09:06:24Z ru Set to avoid installing examples to .Pa /usr/share/examples/ . +.It Va WITH_EXTRA_TCP_STACKS +.\" from FreeBSD: head/tools/build/options/WITH_EXTRA_TCP_STACKS 302247 2016-06-28 13:37:01Z jtl +Set to build extra TCP stack modules. .It Va WITHOUT_FDT .\" from FreeBSD: head/tools/build/options/WITHOUT_FDT 221539 2011-05-06 19:10:27Z ru Set to not build Flattened Device Tree support as part of the base system. From owner-svn-src-all@freebsd.org Tue Jun 28 16:41:51 2016 Return-Path: Delivered-To: svn-src-all@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 C0330B859D6; Tue, 28 Jun 2016 16:41:51 +0000 (UTC) (envelope-from kib@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 983192969; Tue, 28 Jun 2016 16:41:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGfocH061451; Tue, 28 Jun 2016 16:41:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGfoTq061450; Tue, 28 Jun 2016 16:41:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281641.u5SGfoTq061450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:41:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302250 - head/sys/kern X-SVN-Group: head 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.22 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, 28 Jun 2016 16:41:51 -0000 Author: kib Date: Tue Jun 28 16:41:50 2016 New Revision: 302250 URL: https://svnweb.freebsd.org/changeset/base/302250 Log: Complete r302215. TDF_SBDRY | TDF_SERESTART and TDF_SBDRY | TDF_SEINTR flags values, unlike TDF_SBDRY, must be treated almost as if TDF_SBDRY is not set for STOP signal delivery. The only difference is that sig_suspend_threads() should abort the sleep instead of doing immediate suspension. Reported by: ngie Sponsored by: The FreeBSD Foundation MFC after: 12 days Approved by: re (gjb) Modified: head/sys/kern/kern_sig.c Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Tue Jun 28 16:41:02 2016 (r302249) +++ head/sys/kern/kern_sig.c Tue Jun 28 16:41:50 2016 (r302250) @@ -107,7 +107,7 @@ static int killpg1(struct thread *td, in static int issignal(struct thread *td); static int sigprop(int sig); static void tdsigwakeup(struct thread *, int, sig_t, int); -static void sig_suspend_threads(struct thread *, struct proc *, int); +static int sig_suspend_threads(struct thread *, struct proc *, int); static int filt_sigattach(struct knote *kn); static void filt_sigdetach(struct knote *kn); static int filt_signal(struct knote *kn, long hint); @@ -2327,7 +2327,7 @@ tdsendsignal(struct proc *p, struct thre p->p_flag |= P_STOPPED_SIG; p->p_xsig = sig; PROC_SLOCK(p); - sig_suspend_threads(td, p, 1); + wakeup_swapper = sig_suspend_threads(td, p, 1); if (p->p_numthreads == p->p_suspcount) { /* * only thread sending signal to another @@ -2341,6 +2341,8 @@ tdsendsignal(struct proc *p, struct thre sigqueue_delete_proc(p, p->p_xsig); } else PROC_SUNLOCK(p); + if (wakeup_swapper) + kick_proc0(); goto out; } } else { @@ -2421,7 +2423,8 @@ tdsigwakeup(struct thread *td, int sig, * Don't awaken a sleeping thread for SIGSTOP if the * STOP signal is deferred. */ - if ((prop & SA_STOP) && (td->td_flags & TDF_SBDRY)) + if ((prop & SA_STOP) != 0 && (td->td_flags & (TDF_SBDRY | + TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) goto out; /* @@ -2449,14 +2452,16 @@ out: kick_proc0(); } -static void +static int sig_suspend_threads(struct thread *td, struct proc *p, int sending) { struct thread *td2; + int wakeup_swapper; PROC_LOCK_ASSERT(p, MA_OWNED); PROC_SLOCK_ASSERT(p, MA_OWNED); + wakeup_swapper = 0; FOREACH_THREAD_IN_PROC(p, td2) { thread_lock(td2); td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; @@ -2465,11 +2470,18 @@ sig_suspend_threads(struct thread *td, s if (td2->td_flags & TDF_SBDRY) { /* * Once a thread is asleep with - * TDF_SBDRY set, it should never + * TDF_SBDRY and without TDF_SERESTART + * or TDF_SEINTR set, it should never * become suspended due to this check. */ KASSERT(!TD_IS_SUSPENDED(td2), ("thread with deferred stops suspended")); + if ((td2->td_flags & (TDF_SERESTART | + TDF_SEINTR)) != 0 && sending) { + wakeup_swapper |= sleepq_abort(td, + (td2->td_flags & TDF_SERESTART) + != 0 ? ERESTART : EINTR); + } } else if (!TD_IS_SUSPENDED(td2)) { thread_suspend_one(td2); } @@ -2483,6 +2495,7 @@ sig_suspend_threads(struct thread *td, s } thread_unlock(td2); } + return (wakeup_swapper); } int @@ -2705,7 +2718,8 @@ issignal(struct thread *td) SIGSETOR(sigpending, p->p_sigqueue.sq_signals); SIGSETNAND(sigpending, td->td_sigmask); - if (p->p_flag & P_PPWAIT || td->td_flags & TDF_SBDRY) + if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & + (TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) SIG_STOPSIGMASK(sigpending); if (SIGISEMPTY(sigpending)) /* no signal to send */ return (0); From owner-svn-src-all@freebsd.org Tue Jun 28 16:42:41 2016 Return-Path: Delivered-To: svn-src-all@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 7A985B85A4B; Tue, 28 Jun 2016 16:42:41 +0000 (UTC) (envelope-from kib@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 32C612B46; Tue, 28 Jun 2016 16:42:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGgeTW061530; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGge18061528; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281642.u5SGge18061528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:42:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302251 - head/sys/kern X-SVN-Group: head 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.22 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, 28 Jun 2016 16:42:41 -0000 Author: kib Date: Tue Jun 28 16:42:40 2016 New Revision: 302251 URL: https://svnweb.freebsd.org/changeset/base/302251 Log: Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use private mtx in resettodr(), no implementation of CLOCK_SETTIME() is allowed to sleep. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) X-Differential revision: https://reviews.freebsd.org/D6825 Modified: head/sys/kern/subr_clock.c head/sys/kern/subr_rtc.c Modified: head/sys/kern/subr_clock.c ============================================================================== --- head/sys/kern/subr_clock.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_clock.c Tue Jun 28 16:42:40 2016 (r302251) @@ -67,8 +67,8 @@ sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ resettodr(); return (error); } -SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT|CTLFLAG_RW, - &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", +SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT | CTLFLAG_RW | + CTLFLAG_MPSAFE, &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "Local offset from UTC in seconds"); static int ct_debug; Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_rtc.c Tue Jun 28 16:42:40 2016 (r302251) @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #ifdef FFCLOCK #include @@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$"); static device_t clock_dev = NULL; static long clock_res; static struct timespec clock_adj; +static struct mtx resettodr_lock; +MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF); /* XXX: should be kern. now, it's no longer machdep. */ static int disable_rtc_set; @@ -168,11 +172,14 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; + mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) + error = CLOCK_SETTIME(clock_dev, &ts); + mtx_unlock(&resettodr_lock); + if (error != 0) printf("warning: clock_settime failed (%d), time-of-day clock " "not adjusted to system time\n", error); } From owner-svn-src-all@freebsd.org Tue Jun 28 16:43:24 2016 Return-Path: Delivered-To: svn-src-all@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 73ECFB85AAF; Tue, 28 Jun 2016 16:43:24 +0000 (UTC) (envelope-from kib@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 50D7D2CD1; Tue, 28 Jun 2016 16:43:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SGhN43061607; Tue, 28 Jun 2016 16:43:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGhNsi061606; Tue, 28 Jun 2016 16:43:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281643.u5SGhNsi061606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:43:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302252 - head/sys/kern X-SVN-Group: head 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.22 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, 28 Jun 2016 16:43:24 -0000 Author: kib Date: Tue Jun 28 16:43:23 2016 New Revision: 302252 URL: https://svnweb.freebsd.org/changeset/base/302252 Log: Currently the ntptime code and resettodr() are Giant-locked. In particular, the Giant is supposed to protect against parallel ntp_adjtime(2) invocations. But, for instance, sys_ntp_adjtime() does copyout(9) under Giant and then examines time_status to return syscall result. Since copyout(9) could sleep, the syscall result might be inconsistent. Another and more important issue is that if PPS is configured, hardpps(9) is executed without any protection against the parallel top-level code invocation. Potentially, this may result in the inconsistent state of the ntptime state variables, but I cannot say how serious such distortion is. The non-functional splclock() call in sys_ntp_adjtime() protected against clock interrupts calling hardpps() in the pre-SMP era. Modernize the locking. A mutex protects ntptime data. Due to the hardpps() KPI legitimately serving from the interrupt filters (and e.g. uart(4) does call it from filter), the lock cannot be sleepable mutex if PPS_SYNC is defined. Otherwise, use normal sleepable mutex to reduce interrupt latency. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Differential revision: https://reviews.freebsd.org/D6825 Modified: head/sys/kern/kern_ntptime.c Modified: head/sys/kern/kern_ntptime.c ============================================================================== --- head/sys/kern/kern_ntptime.c Tue Jun 28 16:42:40 2016 (r302251) +++ head/sys/kern/kern_ntptime.c Tue Jun 28 16:43:23 2016 (r302252) @@ -162,6 +162,30 @@ static l_fp time_adj; /* tick adjust ( static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ +static struct mtx ntpadj_lock; +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", +#ifdef PPS_SYNC + MTX_SPIN +#else + MTX_DEF +#endif +); + +/* + * When PPS_SYNC is defined, hardpps() function is provided which can + * be legitimately called from interrupt filters. Due to this, use + * spinlock for ntptime state protection, otherwise sleepable mutex is + * adequate. + */ +#ifdef PPS_SYNC +#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) +#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) +#else +#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) +#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) +#endif +#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) + #ifdef PPS_SYNC /* * The following variables are used when a pulse-per-second (PPS) signal @@ -203,11 +227,12 @@ static long pps_errcnt; /* calibration static void ntp_init(void); static void hardupdate(long offset); static void ntp_gettime1(struct ntptimeval *ntvp); -static int ntp_is_time_error(void); +static bool ntp_is_time_error(int tsl); -static int -ntp_is_time_error(void) +static bool +ntp_is_time_error(int tsl) { + /* * Status word error decode. If any of these conditions occur, * an error is returned, instead of the status word. Most @@ -216,30 +241,29 @@ ntp_is_time_error(void) * * Hardware or software error */ - if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) || + if ((tsl & (STA_UNSYNC | STA_CLOCKERR)) || /* * PPS signal lost when either time or frequency synchronization * requested */ - (time_status & (STA_PPSFREQ | STA_PPSTIME) && - !(time_status & STA_PPSSIGNAL)) || + (tsl & (STA_PPSFREQ | STA_PPSTIME) && + !(tsl & STA_PPSSIGNAL)) || /* * PPS jitter exceeded when time synchronization requested */ - (time_status & STA_PPSTIME && - time_status & STA_PPSJITTER) || + (tsl & STA_PPSTIME && tsl & STA_PPSJITTER) || /* * PPS wander exceeded or calibration error when frequency * synchronization requested */ - (time_status & STA_PPSFREQ && - time_status & (STA_PPSWANDER | STA_PPSERROR))) - return (1); + (tsl & STA_PPSFREQ && + tsl & (STA_PPSWANDER | STA_PPSERROR))) + return (true); - return (0); + return (false); } static void @@ -247,7 +271,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - GIANT_REQUIRED; + NTPADJ_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -257,7 +281,7 @@ ntp_gettime1(struct ntptimeval *ntvp) ntvp->tai = time_tai; ntvp->time_state = time_state; - if (ntp_is_time_error()) + if (ntp_is_time_error(time_status)) ntvp->time_state = TIME_ERROR; } @@ -278,9 +302,9 @@ sys_ntp_gettime(struct thread *td, struc { struct ntptimeval ntv; - mtx_lock(&Giant); + NTPADJ_LOCK(); ntp_gettime1(&ntv); - mtx_unlock(&Giant); + NTPADJ_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -291,14 +315,17 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ + NTPADJ_LOCK(); ntp_gettime1(&ntv); + NTPADJ_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW, 0, ""); -SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", ""); +SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE | CTLFLAG_RD | + CTLFLAG_MPSAFE, 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval", + ""); #ifdef PPS_SYNC SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, @@ -308,10 +335,12 @@ SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_ SYSCTL_LONG(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD, &time_monitor, 0, "Last time offset scaled (ns)"); -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD, - &pps_freq, sizeof(pps_freq), "I", "Scaled frequency offset (ns/sec)"); -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, - &time_freq, sizeof(time_freq), "I", "Frequency offset (ns/sec)"); +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, + &pps_freq, 0, + "Scaled frequency offset (ns/sec)"); +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD | CTLFLAG_MPSAFE, + &time_freq, 0, + "Frequency offset (ns/sec)"); #endif /* @@ -333,12 +362,11 @@ sys_ntp_adjtime(struct thread *td, struc struct timex ntv; /* temporary structure */ long freq; /* frequency ns/s) */ int modes; /* mode bits from structure */ - int s; /* caller priority */ - int error; + int error, retval; error = copyin((caddr_t)uap->tp, (caddr_t)&ntv, sizeof(ntv)); if (error) - return(error); + return (error); /* * Update selected clock variables - only the superuser can @@ -349,13 +377,12 @@ sys_ntp_adjtime(struct thread *td, struc * the STA_PLL bit in the status word is cleared, the state and * status words are reset to the initial values at boot. */ - mtx_lock(&Giant); modes = ntv.modes; if (modes) error = priv_check(td, PRIV_NTP_ADJTIME); - if (error) - goto done2; - s = splclock(); + if (error != 0) + return (error); + NTPADJ_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -456,19 +483,12 @@ sys_ntp_adjtime(struct thread *td, struc ntv.jitcnt = pps_jitcnt; ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ - splx(s); + retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; + NTPADJ_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); - if (error) - goto done2; - - if (ntp_is_time_error()) - td->td_retval[0] = TIME_ERROR; - else - td->td_retval[0] = time_state; - -done2: - mtx_unlock(&Giant); + if (error == 0) + td->td_retval[0] = retval; return (error); } @@ -620,7 +640,7 @@ ntp_update_second(int64_t *adjustment, t * probably be integrated with the code that does that. */ static void -ntp_init() +ntp_init(void) { /* @@ -670,6 +690,8 @@ hardupdate(offset) long mtemp; l_fp ftemp; + NTPADJ_ASSERT_LOCKED(); + /* * Select how the phase is to be controlled and from which * source. If the PPS signal is present and enabled to @@ -750,6 +772,8 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; + NTPADJ_LOCK(); + /* * The signal is first processed by a range gate and frequency * discriminator. The range gate rejects noise spikes outside @@ -770,9 +794,8 @@ hardpps(tsp, nsec) u_sec++; } v_nsec = u_nsec - pps_tf[0].tv_nsec; - if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - - MAXFREQ) - return; + if (u_sec == pps_tf[0].tv_sec && v_nsec < NANOSECOND - MAXFREQ) + goto out; pps_tf[2] = pps_tf[1]; pps_tf[1] = pps_tf[0]; pps_tf[0].tv_sec = u_sec; @@ -793,7 +816,7 @@ hardpps(tsp, nsec) u_nsec += NANOSECOND; pps_fcount += u_nsec; if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) - return; + goto out; time_status &= ~STA_PPSJITTER; /* @@ -839,7 +862,7 @@ hardpps(tsp, nsec) * timecounter running faster than 1 GHz the lower bound is 2ns, just * to avoid a nonsensical threshold of zero. */ - if (u_nsec > lmax(pps_jitter << PPS_POPCORN, + if (u_nsec > lmax(pps_jitter << PPS_POPCORN, 2 * (NANOSECOND / (long)qmin(NANOSECOND, tc_getfrequency())))) { time_status |= STA_PPSJITTER; pps_jitcnt++; @@ -850,7 +873,7 @@ hardpps(tsp, nsec) pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG; u_sec = pps_tf[0].tv_sec - pps_lastsec; if (u_sec < (1 << pps_shift)) - return; + goto out; /* * At the end of the calibration interval the difference between @@ -867,11 +890,10 @@ hardpps(tsp, nsec) pps_lastsec = pps_tf[0].tv_sec; pps_fcount = 0; u_nsec = MAXFREQ << pps_shift; - if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << - pps_shift)) { + if (v_nsec > u_nsec || v_nsec < -u_nsec || u_sec != (1 << pps_shift)) { time_status |= STA_PPSERROR; pps_errcnt++; - return; + goto out; } /* @@ -932,6 +954,9 @@ hardpps(tsp, nsec) L_LINT(pps_freq, -MAXFREQ); if (time_status & STA_PPSFREQ) time_freq = pps_freq; + +out: + NTPADJ_UNLOCK(); } #endif /* PPS_SYNC */ @@ -965,27 +990,29 @@ int kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) { struct timeval atv; + int64_t ltr, ltw; int error; - mtx_lock(&Giant); - if (olddelta) { - atv.tv_sec = time_adjtime / 1000000; - atv.tv_usec = time_adjtime % 1000000; + if (delta != NULL) { + error = priv_check(td, PRIV_ADJTIME); + if (error != 0) + return (error); + ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; + } + NTPADJ_LOCK(); + ltr = time_adjtime; + if (delta != NULL) + time_adjtime = ltw; + NTPADJ_UNLOCK(); + if (olddelta != NULL) { + atv.tv_sec = ltr / 1000000; + atv.tv_usec = ltr % 1000000; if (atv.tv_usec < 0) { atv.tv_usec += 1000000; atv.tv_sec--; } *olddelta = atv; } - if (delta) { - if ((error = priv_check(td, PRIV_ADJTIME))) { - mtx_unlock(&Giant); - return (error); - } - time_adjtime = (int64_t)delta->tv_sec * 1000000 + - delta->tv_usec; - } - mtx_unlock(&Giant); return (0); } @@ -996,11 +1023,12 @@ static void periodic_resettodr(void *arg __unused) { - if (!ntp_is_time_error()) { - mtx_lock(&Giant); + /* + * Read of time_status is lock-less, which is fine since + * ntp_is_time_error() operates on the consistent read value. + */ + if (!ntp_is_time_error(time_status)) resettodr(); - mtx_unlock(&Giant); - } if (resettodr_period > 0) callout_schedule(&resettodr_callout, resettodr_period * hz); } @@ -1010,11 +1038,9 @@ shutdown_resettodr(void *arg __unused, i { callout_drain(&resettodr_callout); - if (resettodr_period > 0 && !ntp_is_time_error()) { - mtx_lock(&Giant); + /* Another unlocked read of time_status */ + if (resettodr_period > 0 && !ntp_is_time_error(time_status)) resettodr(); - mtx_unlock(&Giant); - } } static int @@ -1036,9 +1062,9 @@ done: return (0); } -SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RWTUN, - &resettodr_period, 1800, sysctl_resettodr_period, "I", - "Save system time to RTC with this period (in seconds)"); +SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT | CTLFLAG_RWTUN | + CTLFLAG_MPSAFE, &resettodr_period, 1800, sysctl_resettodr_period, "I", + "Save system time to RTC with this period (in seconds)"); static void start_periodic_resettodr(void *arg __unused) From owner-svn-src-all@freebsd.org Tue Jun 28 18:08:48 2016 Return-Path: Delivered-To: svn-src-all@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 AD7A4B85177; Tue, 28 Jun 2016 18:08:48 +0000 (UTC) (envelope-from sbruno@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 7759C2B4C; Tue, 28 Jun 2016 18:08:48 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SI8lXK091907; Tue, 28 Jun 2016 18:08:47 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SI8l7h091906; Tue, 28 Jun 2016 18:08:47 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201606281808.u5SI8l7h091906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 28 Jun 2016 18:08:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302253 - head/sys/cam/scsi X-SVN-Group: head 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.22 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, 28 Jun 2016 18:08:48 -0000 Author: sbruno Date: Tue Jun 28 18:08:47 2016 New Revision: 302253 URL: https://svnweb.freebsd.org/changeset/base/302253 Log: Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. PR: 202625 Submitted by: niakrisn@gmail.com Reviewed by: scottl Approved by: re (hrs) MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 (r302252) +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; + scsi_ulto2b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-all@freebsd.org Tue Jun 28 18:17:59 2016 Return-Path: Delivered-To: svn-src-all@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 A4105B855EA; Tue, 28 Jun 2016 18:17:59 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7287622CC; Tue, 28 Jun 2016 18:17:59 +0000 (UTC) (envelope-from ken@kdm.org) Received: from [10.0.0.27] (mbp2013-wired.int.kdm.org [10.0.0.27]) (authenticated bits=0) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPSA id u5SIHpfu016242 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Jun 2016 14:17:52 -0400 (EDT) (envelope-from ken@kdm.org) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r302253 - head/sys/cam/scsi From: Ken Merry In-Reply-To: <201606281808.u5SI8l7h091906@repo.freebsd.org> Date: Tue, 28 Jun 2016 14:17:51 -0400 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> References: <201606281808.u5SI8l7h091906@repo.freebsd.org> To: Sean Bruno X-Mailer: Apple Mail (2.3124) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [96.89.93.250]); Tue, 28 Jun 2016 14:17:52 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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, 28 Jun 2016 18:17:59 -0000 This is incorrect. It should be scsi_ulto4b() instead. The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, = and the length field in the CDB structure is 4 bytes long. Sorry I didn=E2=80=99t get around to commenting on the PR, otherwise I = would have caught this previously. Ken =E2=80=94=20 Ken Merry ken@FreeBSD.ORG > On Jun 28, 2016, at 2:08 PM, Sean Bruno wrote: >=20 > Author: sbruno > Date: Tue Jun 28 18:08:47 2016 > New Revision: 302253 > URL: https://svnweb.freebsd.org/changeset/base/302253 >=20 > Log: > Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length. >=20 > PR: 202625 > Submitted by: niakrisn@gmail.com > Reviewed by: scottl > Approved by: re (hrs) > MFC after: 2 weeks >=20 > Modified: > head/sys/cam/scsi/scsi_all.c >=20 > Modified: head/sys/cam/scsi/scsi_all.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 = (r302252) > +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 = (r302253) > @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s > scsi_cmd->opcode =3D PERSISTENT_RES_OUT; > scsi_cmd->action =3D service_action; > scsi_cmd->scope_type =3D scope | res_type; > + scsi_ulto2b(dxfer_len, scsi_cmd->length); >=20 > cam_fill_csio(csio, > retries, >=20 From owner-svn-src-all@freebsd.org Tue Jun 28 18:27:32 2016 Return-Path: Delivered-To: svn-src-all@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 8E428B8587E; Tue, 28 Jun 2016 18:27:32 +0000 (UTC) (envelope-from sbruno@freebsd.org) Received: from mail.ignoranthack.me (ignoranthack.me [199.102.79.106]) (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 54BCA2AA3; Tue, 28 Jun 2016 18:27:31 +0000 (UTC) (envelope-from sbruno@freebsd.org) Received: from [10.246.10.193] (wsip-98-172-74-163.ph.ph.cox.net [98.172.74.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sbruno@ignoranthack.me) by mail.ignoranthack.me (Postfix) with ESMTPSA id 5840C1928BE; Tue, 28 Jun 2016 18:27:30 +0000 (UTC) Subject: Re: svn commit: r302253 - head/sys/cam/scsi To: Ken Merry References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org From: Sean Bruno Message-ID: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> Date: Tue, 28 Jun 2016 11:27:25 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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, 28 Jun 2016 18:27:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN Content-Type: multipart/mixed; boundary="PBdfnsehepddkOiHhRCiQT1clEj7VDdQV" From: Sean Bruno To: Ken Merry Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org Message-ID: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> Subject: Re: svn commit: r302253 - head/sys/cam/scsi References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> In-Reply-To: <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> --PBdfnsehepddkOiHhRCiQT1clEj7VDdQV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/28/16 11:17, Ken Merry wrote: > This is incorrect. It should be scsi_ulto4b() instead. >=20 > The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, = and the length field in the CDB structure is 4 bytes long. >=20 > Sorry I didn=E2=80=99t get around to commenting on the PR, otherwise I = would have caught this previously. >=20 > Ken > =E2=80=94=20 > Ken Merry > ken@FreeBSD.ORG Ok, I shall revert this then generate a new diff for your review and submission to re for commit. sean >=20 >=20 >=20 >> On Jun 28, 2016, at 2:08 PM, Sean Bruno wrote: >> >> Author: sbruno >> Date: Tue Jun 28 18:08:47 2016 >> New Revision: 302253 >> URL: https://svnweb.freebsd.org/changeset/base/302253 >> >> Log: >> Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.= >> >> PR: 202625 >> Submitted by: niakrisn@gmail.com >> Reviewed by: scottl >> Approved by: re (hrs) >> MFC after: 2 weeks >> >> Modified: >> head/sys/cam/scsi/scsi_all.c >> >> Modified: head/sys/cam/scsi/scsi_all.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 16:43:23 2016 (r302252) >> +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) >> @@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s >> scsi_cmd->opcode =3D PERSISTENT_RES_OUT; >> scsi_cmd->action =3D service_action; >> scsi_cmd->scope_type =3D scope | res_type; >> + scsi_ulto2b(dxfer_len, scsi_cmd->length); >> >> cam_fill_csio(csio, >> retries, >> >=20 >=20 --PBdfnsehepddkOiHhRCiQT1clEj7VDdQV-- --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAEBCgBmBQJXcsGNXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRCQUFENDYzMkU3MTIxREU4RDIwOTk3REQx MjAxRUZDQTFFNzI3RTY0AAoJEBIB78oecn5kO8sH/jj/kZtjbrUShl8qJl52ladK mYy20MTzg91m8+f+Rr0rJrMloJQn2JaueFv06AXhocwNxsW0AUcREhSFF/Lo7wX9 Ldo0WUQ497NOAuxrwDHXabGsKJ/rSDkHgwoPQZxZqMQuaMNCFVcnFyTsUptSEDUl 1X5DGyu9bJnnGvC5JQ8E7LFGJ/wD/Ong/CeWW6gjZv9XjjsKh6JnqXXE0QEuDSwU ubKKyF/tLxeRqBok0j/eMdYcekZVpFBvl5m+Tv4r6RbX3RHK1eud2SzW99cAMUXY DFF07+sINpJ7QBh2R29IbmkwT7KalWzbXsOLt7gEDYAVARewv5DVi5VZpbKzHLg= =0N52 -----END PGP SIGNATURE----- --cfEVp7xlLAglfLvFbi8v9pLtXVFw9VidN-- From owner-svn-src-all@freebsd.org Tue Jun 28 18:28:40 2016 Return-Path: Delivered-To: svn-src-all@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 C1284B8595C; Tue, 28 Jun 2016 18:28:40 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 88DAB2C38; Tue, 28 Jun 2016 18:28:40 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (localhost [127.0.0.1]) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPS id u5SIScY0016434 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 28 Jun 2016 14:28:38 -0400 (EDT) (envelope-from ken@mithlond.kdm.org) Received: (from ken@localhost) by mithlond.kdm.org (8.15.2/8.14.9/Submit) id u5SISc5L016433; Tue, 28 Jun 2016 14:28:38 -0400 (EDT) (envelope-from ken) Date: Tue, 28 Jun 2016 14:28:38 -0400 From: "Kenneth D. Merry" To: Sean Bruno Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, re@freebsd.org Subject: Re: svn commit: r302253 - head/sys/cam/scsi Message-ID: <20160628182838.GA16229@mithlond.kdm.org> References: <201606281808.u5SI8l7h091906@repo.freebsd.org> <71476326-3FAC-4E49-884F-0A2F38177D99@kdm.org> <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46721328-61de-e78b-b627-42b06c63e156@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [127.0.0.1]); Tue, 28 Jun 2016 14:28:38 -0400 (EDT) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mithlond.kdm.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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, 28 Jun 2016 18:28:40 -0000 On Tue, Jun 28, 2016 at 11:27:25 -0700, Sean Bruno wrote: > > > On 06/28/16 11:17, Ken Merry wrote: > > This is incorrect. It should be scsi_ulto4b() instead. > > > > The dxfer_len argument to scsi_persistent_reserve_out() is a uint32_t, and the length field in the CDB structure is 4 bytes long. > > > > Sorry I didn???t get around to commenting on the PR, otherwise I would have caught this previously. > > > > Ken > > ??? > > Ken Merry > > ken@FreeBSD.ORG > > Ok, I shall revert this then generate a new diff for your review and > submission to re for commit. Thanks! Ken -- Kenneth Merry ken@FreeBSD.ORG From owner-svn-src-all@freebsd.org Tue Jun 28 18:32:17 2016 Return-Path: Delivered-To: svn-src-all@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 4A115B85ADE; Tue, 28 Jun 2016 18:32:17 +0000 (UTC) (envelope-from sbruno@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 0CB9F2009; Tue, 28 Jun 2016 18:32:16 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SIWG9Z002534; Tue, 28 Jun 2016 18:32:16 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SIWGnb002533; Tue, 28 Jun 2016 18:32:16 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201606281832.u5SIWGnb002533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 28 Jun 2016 18:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302254 - head/sys/cam/scsi X-SVN-Group: head 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.22 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, 28 Jun 2016 18:32:17 -0000 Author: sbruno Date: Tue Jun 28 18:32:15 2016 New Revision: 302254 URL: https://svnweb.freebsd.org/changeset/base/302254 Log: Revert svn r302253 at the request/review of Ken M. This commit is incorrect. PR: 202625 Approved by: re (implicit) Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:08:47 2016 (r302253) +++ head/sys/cam/scsi/scsi_all.c Tue Jun 28 18:32:15 2016 (r302254) @@ -8788,7 +8788,6 @@ scsi_persistent_reserve_out(struct ccb_s scsi_cmd->opcode = PERSISTENT_RES_OUT; scsi_cmd->action = service_action; scsi_cmd->scope_type = scope | res_type; - scsi_ulto2b(dxfer_len, scsi_cmd->length); cam_fill_csio(csio, retries, From owner-svn-src-all@freebsd.org Tue Jun 28 19:53:17 2016 Return-Path: Delivered-To: svn-src-all@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 E31B2B86239; Tue, 28 Jun 2016 19:53:17 +0000 (UTC) (envelope-from bdrewery@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 B01112E42; Tue, 28 Jun 2016 19:53:17 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SJrGi4033444; Tue, 28 Jun 2016 19:53:16 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SJrGmi033442; Tue, 28 Jun 2016 19:53:16 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606281953.u5SJrGmi033442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Tue, 28 Jun 2016 19:53:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302255 - in head/lib/libc: rpc yp X-SVN-Group: head 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.22 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, 28 Jun 2016 19:53:18 -0000 Author: bdrewery Date: Tue Jun 28 19:53:16 2016 New Revision: 302255 URL: https://svnweb.freebsd.org/changeset/base/302255 Log: Use on crypto.x and rpc.x from the source tree. This fixes the build when DESTDIR may be blank or not yet populated. It also fixes reproducibility. Submitted by: brooks Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D6455 Modified: head/lib/libc/rpc/Makefile.inc head/lib/libc/yp/Makefile.inc Modified: head/lib/libc/rpc/Makefile.inc ============================================================================== --- head/lib/libc/rpc/Makefile.inc Tue Jun 28 18:32:15 2016 (r302254) +++ head/lib/libc/rpc/Makefile.inc Tue Jun 28 19:53:16 2016 (r302255) @@ -33,7 +33,7 @@ CFLAGS+= -I${LIBC_SRCTOP}/rpc CLEANFILES+= crypt_clnt.c crypt_xdr.c crypt.h -RPCDIR= ${DESTDIR}/usr/include/rpcsvc +RPCDIR= ${SRCTOP}/include/rpcsvc RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C crypt_clnt.c: ${RPCDIR}/crypt.x crypt.h Modified: head/lib/libc/yp/Makefile.inc ============================================================================== --- head/lib/libc/yp/Makefile.inc Tue Jun 28 18:32:15 2016 (r302254) +++ head/lib/libc/yp/Makefile.inc Tue Jun 28 19:53:16 2016 (r302255) @@ -9,7 +9,7 @@ CLEANFILES+= yp.h yp_xdr.c SYM_MAPS+= ${LIBC_SRCTOP}/yp/Symbol.map -RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x +RPCSRC= ${SRCTOP}/include/rpcsvc/yp.x RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C yp_xdr.c: ${RPCSRC} From owner-svn-src-all@freebsd.org Tue Jun 28 20:10:31 2016 Return-Path: Delivered-To: svn-src-all@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 E6ECDB865E7; Tue, 28 Jun 2016 20:10:31 +0000 (UTC) (envelope-from phk@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 B435927E0; Tue, 28 Jun 2016 20:10:31 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5SKAUwD037549; Tue, 28 Jun 2016 20:10:30 GMT (envelope-from phk@FreeBSD.org) Received: (from phk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SKAUFk037548; Tue, 28 Jun 2016 20:10:30 GMT (envelope-from phk@FreeBSD.org) Message-Id: <201606282010.u5SKAUFk037548@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phk set sender to phk@FreeBSD.org using -f From: Poul-Henning Kamp Date: Tue, 28 Jun 2016 20:10:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302256 - head/sbin/natd X-SVN-Group: head 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.22 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, 28 Jun 2016 20:10:32 -0000 Author: phk Date: Tue Jun 28 20:10:30 2016 New Revision: 302256 URL: https://svnweb.freebsd.org/changeset/base/302256 Log: Do not coredump if the packet is too long in the global (non-interface associated) instance. The result is that the packet is dropped without an indication that smaller MTU is advisable, which is not optimal, but better than a NULL pointer deref. Approved by: re (glebius) Modified: head/sbin/natd/natd.c Modified: head/sbin/natd/natd.c ============================================================================== --- head/sbin/natd/natd.c Tue Jun 28 19:53:16 2016 (r302255) +++ head/sbin/natd/natd.c Tue Jun 28 20:10:30 2016 (r302256) @@ -618,7 +618,7 @@ static void DoGlobal (int fd) if (wrote != bytes) { - if (errno == EMSGSIZE) { + if (errno == EMSGSIZE && mip != NULL) { if (mip->ifMTU != -1) SendNeedFragIcmp (icmpSock, From owner-svn-src-all@freebsd.org Wed Jun 29 01:50:32 2016 Return-Path: Delivered-To: svn-src-all@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 3899DB82EA8; Wed, 29 Jun 2016 01:50:32 +0000 (UTC) (envelope-from bdrewery@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 E3D1E2C5B; Wed, 29 Jun 2016 01:50:31 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T1oVlf062111; Wed, 29 Jun 2016 01:50:31 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T1oVMe062109; Wed, 29 Jun 2016 01:50:31 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201606290150.u5T1oVMe062109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 29 Jun 2016 01:50:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302257 - head X-SVN-Group: head 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.22 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: Wed, 29 Jun 2016 01:50:32 -0000 Author: bdrewery Date: Wed Jun 29 01:50:30 2016 New Revision: 302257 URL: https://svnweb.freebsd.org/changeset/base/302257 Log: WITH_SYSTEM_COMPILER: Avoid using GCC4.8+ logic on native GCC4.2 platforms. As the XXX notes, these should really be checking MK_GNUCXX since there is already a version check in share/mk/src.opts.mk to disable it. Fixing that here is more complex though. This could also be using X_COMPILER_FEATURES but uses X_COMPILER_VERSION to keep in sync with the src.opts.mk logic. Tested by: andreast Sponsored by: EMC / Isilon Storage Division Approved by: re (gjb) Modified: head/Makefile.inc1 head/Makefile.libcompat Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Tue Jun 28 20:10:30 2016 (r302256) +++ head/Makefile.inc1 Wed Jun 29 01:50:30 2016 (r302257) @@ -549,8 +549,10 @@ TARGET_ABI= gnueabi XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib # Force using libc++ for external GCC. # XXX: This should be checking MK_GNUCXX == no +.if ${X_COMPILER_VERSION} >= 40800 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ -L${WORLDTMP}/../lib/libc++ +.endif .else TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0 Modified: head/Makefile.libcompat ============================================================================== --- head/Makefile.libcompat Tue Jun 28 20:10:30 2016 (r302256) +++ head/Makefile.libcompat Wed Jun 29 01:50:30 2016 (r302257) @@ -81,8 +81,8 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/ LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include # Force using libc++ for external GCC. # XXX: This should be checking MK_GNUCXX == no -.if ${MK_CROSS_COMPILER} == "no" || \ - (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") +.if ${X_COMPILER_VERSION} >= 40800 && (${MK_CROSS_COMPILER} == "no" || \ + (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")) LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++ .endif From owner-svn-src-all@freebsd.org Wed Jun 29 05:21:27 2016 Return-Path: Delivered-To: svn-src-all@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 67685B845AD; Wed, 29 Jun 2016 05:21:27 +0000 (UTC) (envelope-from bz@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 3000D25AE; Wed, 29 Jun 2016 05:21:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T5LQdX040398; Wed, 29 Jun 2016 05:21:26 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T5LQO7040397; Wed, 29 Jun 2016 05:21:26 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606290521.u5T5LQO7040397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 29 Jun 2016 05:21:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302258 - head/sys/net X-SVN-Group: head 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.22 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: Wed, 29 Jun 2016 05:21:27 -0000 Author: bz Date: Wed Jun 29 05:21:25 2016 New Revision: 302258 URL: https://svnweb.freebsd.org/changeset/base/302258 Log: Several device drivers call if_alloc() and then do further checks and will cal if_free() in case of conflict, error, .. if_free() however sets the VNET instance from the ifp->if_vnet which was not yet initialized but would only in if_attach(). Fix this by setting the curvnet from where we allocate the interface in if_alloc(). if_attach() will later overwrite this as needed. We do not set the home_vnet early on as we only want to prevent the if_free() panic but not change any of the other housekeeping, e.g., triggered through ifioctl()s. Reviewed by: brooks Approved by: re (gjb) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7010 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Wed Jun 29 01:50:30 2016 (r302257) +++ head/sys/net/if.c Wed Jun 29 05:21:25 2016 (r302258) @@ -455,6 +455,9 @@ if_alloc(u_char type) ifp->if_index = idx; ifp->if_type = type; ifp->if_alloctype = type; +#ifdef VIMAGE + ifp->if_vnet = curvnet; +#endif if (if_com_alloc[type] != NULL) { ifp->if_l2com = if_com_alloc[type](type, ifp); if (ifp->if_l2com == NULL) { From owner-svn-src-all@freebsd.org Wed Jun 29 06:04:46 2016 Return-Path: Delivered-To: svn-src-all@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 61AD3B84E99; Wed, 29 Jun 2016 06:04:46 +0000 (UTC) (envelope-from dchagin@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 30FE52881; Wed, 29 Jun 2016 06:04:46 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T64jIi058073; Wed, 29 Jun 2016 06:04:45 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T64jKY058072; Wed, 29 Jun 2016 06:04:45 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201606290604.u5T64jKY058072@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Wed, 29 Jun 2016 06:04:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302259 - stable/10/sys/compat/linux X-SVN-Group: stable-10 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.22 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: Wed, 29 Jun 2016 06:04:46 -0000 Author: dchagin Date: Wed Jun 29 06:04:45 2016 New Revision: 302259 URL: https://svnweb.freebsd.org/changeset/base/302259 Log: MFC r302213: Fix a bug introduced in r283433. [1] Remove unneeded sockaddr conversion before kern_recvit() call as the from argument is used to record result (the source address of the received message) only. [2] In Linux the type of msg_namelen member of struct msghdr is signed but native msg_namelen has a unsigned type (socklen_t). So use the proper storage to fetch fromlen from userspace and than check the user supplied value and return EINVAL if it is less than 0 as a Linux do. Reported by: Thomas Mueller [1] Tested by: Thomas Mueller [both] Reviewed by: kib@ Modified: stable/10/sys/compat/linux/linux_socket.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/linux/linux_socket.c ============================================================================== --- stable/10/sys/compat/linux/linux_socket.c Wed Jun 29 05:21:25 2016 (r302258) +++ stable/10/sys/compat/linux/linux_socket.c Wed Jun 29 06:04:45 2016 (r302259) @@ -1040,18 +1040,16 @@ linux_recvfrom(struct thread *td, struct { struct msghdr msg; struct iovec aiov; - int error; + int error, fromlen; if (PTRIN(args->fromlen) != NULL) { - error = copyin(PTRIN(args->fromlen), &msg.msg_namelen, - sizeof(msg.msg_namelen)); - if (error != 0) - return (error); - - error = linux_to_bsd_sockaddr((struct sockaddr *)PTRIN(args->from), - msg.msg_namelen); + error = copyin(PTRIN(args->fromlen), &fromlen, + sizeof(fromlen)); if (error != 0) return (error); + if (fromlen < 0) + return (EINVAL); + msg.msg_namelen = fromlen; } else msg.msg_namelen = 0; From owner-svn-src-all@freebsd.org Wed Jun 29 06:24:33 2016 Return-Path: Delivered-To: svn-src-all@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 43574B863D5; Wed, 29 Jun 2016 06:24:33 +0000 (UTC) (envelope-from delphij@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 01B6A2480; Wed, 29 Jun 2016 06:24:32 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6OWUH065498; Wed, 29 Jun 2016 06:24:32 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6OUvD065481; Wed, 29 Jun 2016 06:24:30 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201606290624.u5T6OUvD065481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Wed, 29 Jun 2016 06:24:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r302260 - in vendor/expat/dist: . doc examples lib tests tests/benchmark xmlwf X-SVN-Group: vendor 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.22 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: Wed, 29 Jun 2016 06:24:33 -0000 Author: delphij Date: Wed Jun 29 06:24:30 2016 New Revision: 302260 URL: https://svnweb.freebsd.org/changeset/base/302260 Log: Vendor import of expat 2.2.0 (trimmed). Added: vendor/expat/dist/configure.ac vendor/expat/dist/doc/xmlwf.xml - copied, changed from r302259, vendor/expat/dist/doc/xmlwf.sgml Deleted: vendor/expat/dist/configure.in vendor/expat/dist/doc/xmlwf.sgml Modified: vendor/expat/dist/COPYING vendor/expat/dist/Changes vendor/expat/dist/MANIFEST vendor/expat/dist/Makefile.in vendor/expat/dist/README vendor/expat/dist/doc/expat.png (contents, props changed) vendor/expat/dist/doc/reference.html vendor/expat/dist/doc/xmlwf.1 vendor/expat/dist/examples/elements.c vendor/expat/dist/examples/outline.c vendor/expat/dist/expat_config.h.in vendor/expat/dist/lib/expat.h vendor/expat/dist/lib/expat_external.h vendor/expat/dist/lib/internal.h vendor/expat/dist/lib/xmlparse.c vendor/expat/dist/lib/xmlrole.c vendor/expat/dist/lib/xmltok.c vendor/expat/dist/lib/xmltok.h vendor/expat/dist/lib/xmltok_impl.c vendor/expat/dist/tests/benchmark/README.txt vendor/expat/dist/tests/chardata.c vendor/expat/dist/tests/minicheck.c vendor/expat/dist/tests/minicheck.h vendor/expat/dist/tests/runtests.c vendor/expat/dist/tests/xmltest.sh vendor/expat/dist/xmlwf/codepage.c vendor/expat/dist/xmlwf/readfilemap.c vendor/expat/dist/xmlwf/unixfilemap.c vendor/expat/dist/xmlwf/xmlfile.c vendor/expat/dist/xmlwf/xmlwf.c Modified: vendor/expat/dist/COPYING ============================================================================== --- vendor/expat/dist/COPYING Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/COPYING Wed Jun 29 06:24:30 2016 (r302260) @@ -1,6 +1,5 @@ -Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - and Clark Cooper -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers. +Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper +Copyright (c) 2001-2016 Expat maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Modified: vendor/expat/dist/Changes ============================================================================== --- vendor/expat/dist/Changes Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/Changes Wed Jun 29 06:24:30 2016 (r302260) @@ -1,3 +1,67 @@ +Release 2.2.0 Tue June 21 2016 + Security fixes: + #537 CVE-2016-0718 -- Fix crash on malformed input + CVE-2016-4472 -- Improve insufficient fix to CVE-2015-1283 / + CVE-2015-2716 introduced with Expat 2.1.1 + #499 CVE-2016-5300 -- Use more entropy for hash initialization + than the original fix to CVE-2012-0876 + #519 CVE-2012-6702 -- Resolve troublesome internal call to srand + that was introduced with Expat 2.1.0 + when addressing CVE-2012-0876 (issue #496) + + Bug fixes: + Fix uninitialized reads of size 1 + (e.g. in little2_updatePosition) + Fix detection of UTF-8 character boundaries + + Other changes: + #532 Fix compilation for Visual Studio 2010 (keyword "C99") + Autotools: Resolve use of "$<" to better support bmake + Autotools: Add QA script "qa.sh" (and make target "qa") + Autotools: Respect CXXFLAGS if given + Autotools: Fix "make run-xmltest" + Autotools: Have "make run-xmltest" check for expected output + p90 CMake: Fix static build (BUILD_shared=OFF) on Windows + #536 CMake: Add soversion, support -DNO_SONAME=yes to bypass + #323 CMake: Add suffix "d" to differentiate debug from release + CMake: Define WIN32 with CMake on Windows + Annotate memory allocators for GCC + Address all currently known compile warnings + Make sure that API symbols remain visible despite + -fvisibility=hidden + Remove executable flag from source files + Resolve COMPILED_FROM_DSP in favor of WIN32 + + Special thanks to: + Björn Lindahl + Christian Heimes + Cristian Rodríguez + Daniel Krügler + Gustavo Grieco + Karl Waclawek + László Böszörményi + Marco Grassi + Pascal Cuoq + Sergei Nikulov + Thomas Beutlich + Warren Young + Yann Droneaud + +Release 2.1.1 Sat March 12 2016 + Security fixes: + #582: CVE-2015-1283 - Multiple integer overflows in XML_GetBuffer + + Bug fixes: + #502: Fix potential null pointer dereference + #520: Symbol XML_SetHashSalt was not exported + Output of "xmlwf -h" was incomplete + + Other changes: + #503: Document behavior of calling XML_SetHashSalt with salt 0 + Minor improvements to man page xmlwf(1) + Improvements to the experimental CMake build system + libtool now invoked with --verbose + Release 2.1.0 Sat March 24 2012 - Bug Fixes: #1742315: Harmful XML_ParserCreateNS suggestion. @@ -23,7 +87,7 @@ Release 2.1.0 Sat March 24 2012 #3312568: CMake support. #3446384: Report byte offsets for attr names and values. - New Features / API changes: - Added new API member XML_SetHashSalt() that allows setting an intial + Added new API member XML_SetHashSalt() that allows setting an initial value (salt) for hash calculations. This is part of the fix for bug #3496608 to randomize hash parameters. When compiled with XML_ATTR_INFO defined, adds new API member Modified: vendor/expat/dist/MANIFEST ============================================================================== --- vendor/expat/dist/MANIFEST Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/MANIFEST Wed Jun 29 06:24:30 2016 (r302260) @@ -44,7 +44,7 @@ doc/reference.html doc/style.css doc/valid-xhtml10.png doc/xmlwf.1 -doc/xmlwf.sgml +doc/xmlwf.xml CMakeLists.txt CMake.README COPYING @@ -54,7 +54,7 @@ MANIFEST Makefile.in README configure -configure.in +configure.ac expat_config.h.in expat_config.h.cmake expat.pc.in Modified: vendor/expat/dist/Makefile.in ============================================================================== --- vendor/expat/dist/Makefile.in Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/Makefile.in Wed Jun 29 06:24:30 2016 (r302260) @@ -42,7 +42,7 @@ INSTALL_DATA = @INSTALL_DATA@ mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs MANFILE = $(srcdir)/doc/xmlwf.1 -APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h +APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h expat_config.h LIBRARY = libexpat.la DESTDIR = $(INSTALL_ROOT) @@ -51,7 +51,7 @@ default: buildlib xmlwf/xmlwf@EXEEXT@ buildlib: $(LIBRARY) expat.pc -all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline +all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline $(MANFILE) clean: cd lib && rm -f $(LIBRARY) *.@OBJEXT@ *.lo && rm -rf .libs _libs @@ -77,7 +77,10 @@ check: tests/runtests tests/runtestspp tests/runtests tests/runtestspp -install: xmlwf/xmlwf@EXEEXT@ installlib +$(MANFILE): + $(MAKE) -C doc xmlwf.1 + +install: xmlwf/xmlwf@EXEEXT@ installlib $(MANFILE) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) xmlwf/xmlwf@EXEEXT@ $(DESTDIR)$(bindir)/xmlwf $(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(man1dir) @@ -116,7 +119,7 @@ CXXFLAGS = @CXXFLAGS@ VSNFLAG = -version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@ ### autoconf this? -LTFLAGS = --silent +LTFLAGS = --verbose COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(DEFS) $(CPPFLAGS) CXXCOMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) $(DEFS) $(CPPFLAGS) @@ -154,11 +157,11 @@ xmlwf/xmlwf@EXEEXT@: $(XMLWF_OBJS) $(LIB examples/elements.@OBJEXT@: examples/elements.c examples/elements: examples/elements.@OBJEXT@ $(LIBRARY) - $(LINK_EXE) $< $(LIBRARY) + $(LINK_EXE) examples/elements.@OBJEXT@ $(LIBRARY) examples/outline.@OBJEXT@: examples/outline.c examples/outline: examples/outline.@OBJEXT@ $(LIBRARY) - $(LINK_EXE) $< $(LIBRARY) + $(LINK_EXE) examples/outline.@OBJEXT@ $(LIBRARY) tests/chardata.@OBJEXT@: tests/chardata.c tests/chardata.h tests/minicheck.@OBJEXT@: tests/minicheck.c tests/minicheck.h @@ -180,11 +183,19 @@ tests/xmlts.zip: wget --output-document=tests/xmlts.zip \ http://www.w3.org/XML/Test/xmlts20080827.zip -tests/XML-Test-Suite: tests/xmlts.zip +tests/xmlconf: tests/xmlts.zip cd tests && unzip -q xmlts.zip -run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/XML-Test-Suite - tests/xmltest.sh +run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/xmlconf + tests/xmltest.sh 2>&1 | tee tests/xmltest.log + diff -u tests/xmltest.log.expected tests/xmltest.log + +.PHONY: qa +qa: + ./qa.sh address + ./qa.sh memory + ./qa.sh undefined + ./qa.sh coverage .SUFFIXES: .c .cpp .lo .@OBJEXT@ Modified: vendor/expat/dist/README ============================================================================== --- vendor/expat/dist/README Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/README Wed Jun 29 06:24:30 2016 (r302260) @@ -1,5 +1,5 @@ - Expat, Release 2.1.0 + Expat, Release 2.2.0 This is Expat, a C library for parsing XML, written by James Clark. Expat is a stream-oriented XML parser. This means that you register @@ -114,7 +114,7 @@ Note for Solaris users: The "ar" comman "/usr/ccs/bin", which is not in the default PATH. You will need to add this to your path for the "make" command, and probably also switch to GNU make (the "make" found in /usr/ccs/bin does not seem to work -properly -- appearantly it does not understand .PHONY directives). If +properly -- apparently it does not understand .PHONY directives). If you're using ksh or bash, use this command to build: PATH=/usr/ccs/bin:$PATH make Added: vendor/expat/dist/configure.ac ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/expat/dist/configure.ac Wed Jun 29 06:24:30 2016 (r302260) @@ -0,0 +1,157 @@ +dnl configuration script for expat +dnl Process this file with autoconf to produce a configure script. +dnl +dnl Copyright 2000 Clark Cooper +dnl +dnl This file is part of EXPAT. +dnl +dnl EXPAT is free software; you can redistribute it and/or modify it +dnl under the terms of the License (based on the MIT/X license) contained +dnl in the file COPYING that comes with this distribution. +dnl + +dnl Ensure that Expat is configured with autoconf 2.58 or newer +AC_PREREQ(2.58) + +dnl Get the version number of Expat, using m4's esyscmd() command to run +dnl the command at m4-generation time. This allows us to create an m4 +dnl symbol holding the correct version number. AC_INIT() requires the +dnl version number at m4-time, rather than when ./configure is run, so +dnl all this must happen as part of m4, not as part of the shell code +dnl contained in ./configure. +dnl +dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate +dnl test. I believe this test will work, but I don't have a place with non- +dnl GNU M4 to test it right now. +define([expat_version], ifdef([__gnu__], + [esyscmd(conftools/get-version.sh lib/expat.h)], + [2.2.x])) +AC_INIT(expat, expat_version, expat-bugs@libexpat.org) +undefine([expat_version]) + +AC_CONFIG_SRCDIR(Makefile.in) +AC_CONFIG_AUX_DIR(conftools) +AC_CONFIG_MACRO_DIR([m4]) + + +dnl +dnl Increment LIBREVISION if source code has changed at all +dnl +dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 +dnl +dnl If the API changes compatibly (i.e. simply adding a new function +dnl without changing or removing earlier interfaces), then increment LIBAGE. +dnl +dnl If the API changes incompatibly set LIBAGE back to 0 +dnl + +LIBCURRENT=7 # sync +LIBREVISION=2 # with +LIBAGE=6 # CMakeLists.txt! + +AC_CONFIG_HEADER(expat_config.h) + +sinclude(conftools/ac_c_bigendian_cross.m4) + +AC_LIBTOOL_WIN32_DLL +AC_PROG_LIBTOOL + +AC_SUBST(LIBCURRENT) +AC_SUBST(LIBREVISION) +AC_SUBST(LIBAGE) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL + +if test "$GCC" = yes ; then + dnl + dnl Be careful about adding the -fexceptions option; some versions of + dnl GCC don't support it and it causes extra warnings that are only + dnl distracting; avoid. + dnl + OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes" + CFLAGS="$OLDCFLAGS -fexceptions" + AC_MSG_CHECKING(whether $CC accepts -fexceptions) + AC_TRY_LINK( , , + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS") + if test "x$CXXFLAGS" = x ; then + CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'` + fi +fi + +dnl Checks for header files. +AC_HEADER_STDC + +dnl Checks for typedefs, structures, and compiler characteristics. + +dnl Note: Avoid using AC_C_BIGENDIAN because it does not +dnl work in a cross compile. +AC_C_BIGENDIAN_CROSS + +AC_C_CONST +AC_TYPE_SIZE_T +AC_CHECK_FUNCS(memmove bcopy) + +dnl Only needed for xmlwf: +AC_CHECK_HEADERS(fcntl.h unistd.h) +AC_TYPE_OFF_T +AC_FUNC_MMAP + +if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then + FILEMAP=unixfilemap +else + FILEMAP=readfilemap +fi +AC_SUBST(FILEMAP) + +dnl Needed for the test support code; this was found at +dnl http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html + +# AC_CPP_FUNC +# ------------------ # +# Checks to see if ANSI C99 CPP variable __func__ works. +# If not, perhaps __FUNCTION__ works instead. +# If not, we'll just define __func__ to "". +AC_DEFUN([AC_CPP_FUNC], +[AC_REQUIRE([AC_PROG_CC_STDC])dnl +AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], +[[char *foo = __func__;]])], + [ac_cv_cpp_func=yes], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], +[[char *foo = __FUNCTION__;]])], + [ac_cv_cpp_func=__FUNCTION__], + [ac_cv_cpp_func=no])])]) +if test $ac_cv_cpp_func = __FUNCTION__; then + AC_DEFINE(__func__,__FUNCTION__, + [Define to __FUNCTION__ or "" if `__func__' does not conform to +ANSI C.]) +elif test $ac_cv_cpp_func = no; then + AC_DEFINE(__func__,"", + [Define to __FUNCTION__ or "" if `__func__' does not conform to +ANSI C.]) +fi +])# AC_CPP_FUNC + +AC_CPP_FUNC + + +dnl Some basic configuration: +AC_DEFINE([XML_NS], 1, + [Define to make XML Namespaces functionality available.]) +AC_DEFINE([XML_DTD], 1, + [Define to make parameter entity parsing functionality available.]) +AC_DEFINE([XML_CONTEXT_BYTES], 1024, + [Define to specify how much context to retain around the current parse point.]) + +AC_CONFIG_FILES([Makefile expat.pc]) +AC_OUTPUT + +abs_srcdir="`cd $srcdir && pwd`" +abs_builddir="`pwd`" +if test "$abs_srcdir" != "$abs_builddir"; then + make mkdir-init +fi Modified: vendor/expat/dist/doc/expat.png ============================================================================== Binary file (source and/or target). No diff available. Modified: vendor/expat/dist/doc/reference.html ============================================================================== --- vendor/expat/dist/doc/reference.html Wed Jun 29 06:04:45 2016 (r302259) +++ vendor/expat/dist/doc/reference.html Wed Jun 29 06:24:30 2016 (r302260) @@ -2151,8 +2151,12 @@ Helps in preventing DoS attacks based on function behavior. In order to have an effect this must be called before parsing has started. Returns 1 if successful, 0 when called after XML_Parse or XML_ParseBuffer. -

Note: This call is optional, as the parser will auto-generate a new -random salt value if no value has been set at the start of parsing.

+

Note:This call is optional, as the parser will auto-generate +a new random salt value if no value has been set at the start of parsing. +

Note:One should not call XML_SetHashSalt with a +hash salt value of 0, as this value is used as sentinel value to indicate +that XML_SetHashSalt has not been called. Consequently +such a call will have no effect, even if it returns 1.


Modified: vendor/expat/dist/doc/xmlwf.1
==============================================================================
--- vendor/expat/dist/doc/xmlwf.1	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/doc/xmlwf.1	Wed Jun 29 06:24:30 2016	(r302260)
@@ -1,33 +1,40 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\"  
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng .
-.TH "XMLWF" "1" "24 January 2003" "" ""
+'\" -*- coding: us-ascii -*-
+.if \n(.g .ds T< \\FC
+.if \n(.g .ds T> \\F[\n[.fam]]
+.de URL
+\\$2 \(la\\$1\(ra\\$3
+..
+.if \n(.g .mso www.tmac
+.TH XMLWF 1 "March 11, 2016" "" ""
 .SH NAME
 xmlwf \- Determines if an XML document is well-formed
 .SH SYNOPSIS
-
-\fBxmlwf\fR [ \fB-s\fR]  [ \fB-n\fR]  [ \fB-p\fR]  [ \fB-x\fR]  [ \fB-e \fIencoding\fB\fR]  [ \fB-w\fR]  [ \fB-d \fIoutput-dir\fB\fR]  [ \fB-c\fR]  [ \fB-m\fR]  [ \fB-r\fR]  [ \fB-t\fR]  [ \fB-v\fR]  [ \fBfile ...\fR] 
-
-.SH "DESCRIPTION"
-.PP
+'nh
+.fi
+.ad l
+\fBxmlwf\fR \kx
+.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
+'in \n(.iu+\nxu
+[\fB-s\fR] [\fB-n\fR] [\fB-p\fR] [\fB-x\fR] [\fB-e \fIencoding\fB\fR] [\fB-w\fR] [\fB-d \fIoutput-dir\fB\fR] [\fB-c\fR] [\fB-m\fR] [\fB-r\fR] [\fB-t\fR] [\fB-v\fR] [file ...]
+'in \n(.iu-\nxu
+.ad b
+'hy
+.SH DESCRIPTION
 \fBxmlwf\fR uses the Expat library to
-determine if an XML document is well-formed.  It is
+determine if an XML document is well-formed. It is
 non-validating.
 .PP
 If you do not specify any files on the command-line, and you
 have a recent version of \fBxmlwf\fR, the
 input file will be read from standard input.
 .SH "WELL-FORMED DOCUMENTS"
-.PP
 A well-formed document must adhere to the
 following rules:
 .TP 0.2i
 \(bu
-The file begins with an XML declaration.  For instance,
-.
-\fBNOTE:\fR
+The file begins with an XML declaration. For instance,
+\*(T<\*(T>.
+\fINOTE:\fR
 \fBxmlwf\fR does not currently
 check for a valid XML declaration.
 .TP 0.2i
@@ -36,8 +43,8 @@ Every start tag is either empty ()
 or has a corresponding end tag.
 .TP 0.2i
 \(bu
-There is exactly one root element.  This element must contain
-all other elements in the document.  Only comments, white
+There is exactly one root element. This element must contain
+all other elements in the document. Only comments, white
 space, and processing instructions may come after the close
 of the root element.
 .TP 0.2i
@@ -49,39 +56,38 @@ All attribute values are enclosed in quo
 or double).
 .PP
 If the document has a DTD, and it strictly complies with that
-DTD, then the document is also considered \fBvalid\fR.
+DTD, then the document is also considered \fIvalid\fR.
 \fBxmlwf\fR is a non-validating parser --
-it does not check the DTD.  However, it does support
-external entities (see the \fB-x\fR option).
-.SH "OPTIONS"
-.PP
+it does not check the DTD. However, it does support
+external entities (see the \*(T<\fB\-x\fR\*(T> option).
+.SH OPTIONS
 When an option includes an argument, you may specify the argument either
-separately ("\fB-d\fR output") or concatenated with the
-option ("\fB-d\fRoutput").  \fBxmlwf\fR
+separately ("\*(T<\fB\-d\fR\*(T> output") or concatenated with the
+option ("\*(T<\fB\-d\fR\*(T>output"). \fBxmlwf\fR
 supports both.
-.TP
-\fB-c\fR
+.TP 
+\*(T<\fB\-c\fR\*(T>
 If the input file is well-formed and \fBxmlwf\fR
 doesn't encounter any errors, the input file is simply copied to
 the output directory unchanged.
-This implies no namespaces (turns off \fB-n\fR) and
-requires \fB-d\fR to specify an output file.
-.TP
-\fB-d output-dir\fR
+This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
+requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-d output\-dir\fR\*(T>
 Specifies a directory to contain transformed
 representations of the input files.
-By default, \fB-d\fR outputs a canonical representation
+By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
 (described below).
-You can select different output formats using \fB-c\fR
-and \fB-m\fR.
+You can select different output formats using \*(T<\fB\-c\fR\*(T>
+and \*(T<\fB\-m\fR\*(T>.
 
 The output filenames will
 be exactly the same as the input filenames or "STDIN" if the input is
-coming from standard input.  Therefore, you must be careful that the
+coming from standard input. Therefore, you must be careful that the
 output file does not go into the same directory as the input
-file.  Otherwise, \fBxmlwf\fR will delete the
+file. Otherwise, \fBxmlwf\fR will delete the
 input file before it generates the output file (just like running
-cat < file > file in most shells).
+\*(T file\*(T> in most shells).
 
 Two structurally equivalent XML documents have a byte-for-byte
 identical canonical XML representation.
@@ -89,39 +95,39 @@ Note that ignorable white space is consi
 is treated equivalently to data.
 More on canonical XML can be found at
 http://www.jclark.com/xml/canonxml.html .
-.TP
-\fB-e encoding\fR
+.TP 
+\*(T<\fB\-e encoding\fR\*(T>
 Specifies the character encoding for the document, overriding
-any document encoding declaration.  \fBxmlwf\fR
+any document encoding declaration. \fBxmlwf\fR
 supports four built-in encodings:
-US-ASCII,
-UTF-8,
-UTF-16, and
-ISO-8859-1.
-Also see the \fB-w\fR option.
-.TP
-\fB-m\fR
+\*(T,
+\*(T,
+\*(T, and
+\*(T.
+Also see the \*(T<\fB\-w\fR\*(T> option.
+.TP 
+\*(T<\fB\-m\fR\*(T>
 Outputs some strange sort of XML file that completely
 describes the input file, including character positions.
-Requires \fB-d\fR to specify an output file.
-.TP
-\fB-n\fR
-Turns on namespace processing.  (describe namespaces)
-\fB-c\fR disables namespaces.
-.TP
-\fB-p\fR
+Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-n\fR\*(T>
+Turns on namespace processing. (describe namespaces)
+\*(T<\fB\-c\fR\*(T> disables namespaces.
+.TP 
+\*(T<\fB\-p\fR\*(T>
 Tells xmlwf to process external DTDs and parameter
 entities.
 
 Normally \fBxmlwf\fR never parses parameter
-entities.  \fB-p\fR tells it to always parse them.
-\fB-p\fR implies \fB-x\fR.
-.TP
-\fB-r\fR
+entities. \*(T<\fB\-p\fR\*(T> tells it to always parse them.
+\*(T<\fB\-p\fR\*(T> implies \*(T<\fB\-x\fR\*(T>.
+.TP 
+\*(T<\fB\-r\fR\*(T>
 Normally \fBxmlwf\fR memory-maps the XML file
 before parsing; this can result in faster parsing on many
 platforms.
-\fB-r\fR turns off memory-mapping and uses normal file
+\*(T<\fB\-r\fR\*(T> turns off memory-mapping and uses normal file
 IO calls instead.
 Of course, memory-mapping is automatically turned off
 when reading from standard input.
@@ -131,34 +137,33 @@ substantially higher memory usage for
 \fBxmlwf\fR, but this appears to be a matter of
 the operating system reporting memory in a strange way; there is
 not a leak in \fBxmlwf\fR.
-.TP
-\fB-s\fR
+.TP 
+\*(T<\fB\-s\fR\*(T>
 Prints an error if the document is not standalone. 
 A document is standalone if it has no external subset and no
 references to parameter entities.
-.TP
-\fB-t\fR
-Turns on timings.  This tells Expat to parse the entire file,
+.TP 
+\*(T<\fB\-t\fR\*(T>
+Turns on timings. This tells Expat to parse the entire file,
 but not perform any processing.
 This gives a fairly accurate idea of the raw speed of Expat itself
 without client overhead.
-\fB-t\fR turns off most of the output options
-(\fB-d\fR, \fB-m\fR, \fB-c\fR,
-\&...).
-.TP
-\fB-v\fR
+\*(T<\fB\-t\fR\*(T> turns off most of the output options
+(\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-m\fR\*(T>, \*(T<\fB\-c\fR\*(T>, ...).
+.TP 
+\*(T<\fB\-v\fR\*(T>
 Prints the version of the Expat library being used, including some
 information on the compile-time configuration of the library, and
 then exits.
-.TP
-\fB-w\fR
+.TP 
+\*(T<\fB\-w\fR\*(T>
 Enables support for Windows code pages.
 Normally, \fBxmlwf\fR will throw an error if it
-runs across an encoding that it is not equipped to handle itself.  With
-\fB-w\fR, xmlwf will try to use a Windows code
-page.  See also \fB-e\fR.
-.TP
-\fB-x\fR
+runs across an encoding that it is not equipped to handle itself. With
+\*(T<\fB\-w\fR\*(T>, xmlwf will try to use a Windows code
+page. See also \*(T<\fB\-e\fR\*(T>.
+.TP 
+\*(T<\fB\-x\fR\*(T>
 Turns on parsing external entities.
 
 Non-validating parsers are not required to resolve external
@@ -172,80 +177,75 @@ data from outside the XML file currently
 This is an example of an internal entity:
 
 .nf
+
 
 .fi
 
 And here are some examples of external entities:
 
 .nf
-  (parsed)
+
+  (parsed)
          (unparsed)
 .fi
-.TP
-\fB--\fR
+.TP 
+\*(T<\fB\-\-\fR\*(T>
 (Two hyphens.)
-Terminates the list of options.  This is only needed if a filename
-starts with a hyphen.  For example:
+Terminates the list of options. This is only needed if a filename
+starts with a hyphen. For example:
 
 .nf
-xmlwf -- -myfile.xml
+
+xmlwf \-\- \-myfile.xml
 .fi
 
 will run \fBxmlwf\fR on the file
-\fI-myfile.xml\fR.
+\*(T<\fI\-myfile.xml\fR\*(T>.
 .PP
 Older versions of \fBxmlwf\fR do not support
 reading from standard input.
-.SH "OUTPUT"
-.PP
+.SH OUTPUT
 If an input file is not well-formed,
 \fBxmlwf\fR prints a single line describing
-the problem to standard output.  If a file is well formed,
+the problem to standard output. If a file is well formed,
 \fBxmlwf\fR outputs nothing.
-Note that the result code is \fBnot\fR set.
-.SH "BUGS"
-.PP
-According to the W3C standard, an XML file without a
-declaration at the beginning is not considered well-formed.
-However, \fBxmlwf\fR allows this to pass.
-.PP
+Note that the result code is \fInot\fR set.
+.SH BUGS
 \fBxmlwf\fR returns a 0 - noerr result,
-even if the file is not well-formed.  There is no good way for
+even if the file is not well-formed. There is no good way for
 a program to use \fBxmlwf\fR to quickly
 check a file -- it must parse \fBxmlwf\fR's
 standard output.
 .PP
 The errors should go to standard error, not standard output.
 .PP
-There should be a way to get \fB-d\fR to send its
+There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
 output to standard output rather than forcing the user to send
 it to a file.
 .PP
 I have no idea why anyone would want to use the
-\fB-d\fR, \fB-c\fR, and
-\fB-m\fR options.  If someone could explain it to
+\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
+\*(T<\fB\-m\fR\*(T> options. If someone could explain it to
 me, I'd like to add this information to this manpage.
-.SH "ALTERNATIVES"
-.PP
+.SH ALTERNATIVES
 Here are some XML validators on the web:
 
 .nf
-http://www.hcrc.ed.ac.uk/~richard/xml-check.html
+
+http://www.hcrc.ed.ac.uk/~richard/xml\-check.html
 http://www.stg.brown.edu/service/xmlvalid/
 http://www.scripting.com/frontier5/xml/code/xmlValidator.html
 http://www.xml.com/pub/a/tools/ruwf/check.html
 .fi
 .SH "SEE ALSO"
-.PP
-
 .nf
+
 The Expat home page:        http://www.libexpat.org/
-The W3 XML specification:   http://www.w3.org/TR/REC-xml
+The W3 XML specification:   http://www.w3.org/TR/REC\-xml
 .fi
-.SH "AUTHOR"
-.PP
-This manual page was written by Scott Bronson  for
-the Debian GNU/Linux system (but may be used by others).  Permission is
+.SH AUTHOR
+This manual page was written by Scott Bronson <\*(T> for
+the Debian GNU/Linux system (but may be used by others). Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU Free Documentation
 License, Version 1.1.

Copied and modified: vendor/expat/dist/doc/xmlwf.xml (from r302259, vendor/expat/dist/doc/xmlwf.sgml)
==============================================================================
--- vendor/expat/dist/doc/xmlwf.sgml	Wed Jun 29 06:04:45 2016	(r302259, copy source)
+++ vendor/expat/dist/doc/xmlwf.xml	Wed Jun 29 06:24:30 2016	(r302260)
@@ -1,19 +1,9 @@
- manpage.1'.  You may view
-     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
-     less'.  A typical entry in a Makefile or Makefile.am is:
-
-manpage.1: manpage.sgml
-	docbook-to-man $< > $@
-  -->
-
+
   Scott">
   Bronson">
   
-  December  5, 2001">
+  March 11, 2016">
   
   1">
@@ -213,7 +203,7 @@ supports both.
         
 		
   Outputs some strange sort of XML file that completely
-  describes the the input file, including character postitions.
+  describes the input file, including character positions.
   Requires  to specify an output file.
 	   
         
@@ -286,8 +276,7 @@ supports both.
   This gives a fairly accurate idea of the raw speed of Expat itself
   without client overhead.
    turns off most of the output options
-  (, , ,
-  ...).
+  (, , , ...).
 	   
         
       
@@ -449,20 +438,3 @@ The W3 XML specification:   http://www.w
 	
   
 
-
-

Modified: vendor/expat/dist/examples/elements.c
==============================================================================
--- vendor/expat/dist/examples/elements.c	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/examples/elements.c	Wed Jun 29 06:24:30 2016	(r302260)
@@ -27,6 +27,8 @@ startElement(void *userData, const char 
 {
   int i;
   int *depthPtr = (int *)userData;
+  (void)atts;
+
   for (i = 0; i < *depthPtr; i++)
     putchar('\t');
   puts(name);
@@ -37,6 +39,8 @@ static void XMLCALL
 endElement(void *userData, const char *name)
 {
   int *depthPtr = (int *)userData;
+  (void)name;
+
   *depthPtr -= 1;
 }
 
@@ -47,10 +51,13 @@ main(int argc, char *argv[])
   XML_Parser parser = XML_ParserCreate(NULL);
   int done;
   int depth = 0;
+  (void)argc;
+  (void)argv;
+
   XML_SetUserData(parser, &depth);
   XML_SetElementHandler(parser, startElement, endElement);
   do {
-    int len = (int)fread(buf, 1, sizeof(buf), stdin);
+    size_t len = fread(buf, 1, sizeof(buf), stdin);
     done = len < sizeof(buf);
     if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
       fprintf(stderr,

Modified: vendor/expat/dist/examples/outline.c
==============================================================================
--- vendor/expat/dist/examples/outline.c	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/examples/outline.c	Wed Jun 29 06:24:30 2016	(r302260)
@@ -49,6 +49,7 @@ static void XMLCALL
 start(void *data, const char *el, const char **attr)
 {
   int i;
+  (void)data;
 
   for (i = 0; i < Depth; i++)
     printf("  ");
@@ -66,6 +67,9 @@ start(void *data, const char *el, const 
 static void XMLCALL
 end(void *data, const char *el)
 {
+  (void)data;
+  (void)el;
+
   Depth--;
 }
 
@@ -73,6 +77,9 @@ int
 main(int argc, char *argv[])
 {
   XML_Parser p = XML_ParserCreate(NULL);
+  (void)argc;
+  (void)argv;
+
   if (! p) {
     fprintf(stderr, "Couldn't allocate memory for parser\n");
     exit(-1);

Modified: vendor/expat/dist/expat_config.h.in
==============================================================================
--- vendor/expat/dist/expat_config.h.in	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/expat_config.h.in	Wed Jun 29 06:24:30 2016	(r302260)
@@ -1,4 +1,4 @@
-/* expat_config.h.in.  Generated from configure.in by autoheader.  */
+/* expat_config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
 #undef BYTEORDER
@@ -51,8 +51,7 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Define to the address where bug reports for this package should be sent. */

Modified: vendor/expat/dist/lib/expat.h
==============================================================================
--- vendor/expat/dist/lib/expat.h	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/lib/expat.h	Wed Jun 29 06:24:30 2016	(r302260)
@@ -342,7 +342,7 @@ XML_SetEntityDeclHandler(XML_Parser pars
                          XML_EntityDeclHandler handler);
 
 /* OBSOLETE -- OBSOLETE -- OBSOLETE
-   This handler has been superceded by the EntityDeclHandler above.
+   This handler has been superseded by the EntityDeclHandler above.
    It is provided here for backward compatibility.
 
    This is called for a declaration of an unparsed (NDATA) entity.
@@ -973,9 +973,12 @@ XML_FreeContentModel(XML_Parser parser, 
 
 /* Exposing the memory handling functions used in Expat */
 XMLPARSEAPI(void *)
+XML_ATTR_MALLOC
+XML_ATTR_ALLOC_SIZE(2)
 XML_MemMalloc(XML_Parser parser, size_t size);
 
 XMLPARSEAPI(void *)
+XML_ATTR_ALLOC_SIZE(3)
 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
 
 XMLPARSEAPI(void)
@@ -1031,13 +1034,11 @@ XMLPARSEAPI(const XML_Feature *)
 XML_GetFeatureList(void);
 
 
-/* Expat follows the GNU/Linux convention of odd number minor version for
-   beta/development releases and even number minor version for stable
-   releases. Micro is bumped with each release, and set to 0 with each
-   change to major or minor version.
+/* Expat follows the semantic versioning convention.
+   See http://semver.org.
 */
 #define XML_MAJOR_VERSION 2
-#define XML_MINOR_VERSION 1
+#define XML_MINOR_VERSION 2
 #define XML_MICRO_VERSION 0
 
 #ifdef __cplusplus

Modified: vendor/expat/dist/lib/expat_external.h
==============================================================================
--- vendor/expat/dist/lib/expat_external.h	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/lib/expat_external.h	Wed Jun 29 06:24:30 2016	(r302260)
@@ -65,12 +65,26 @@
 #endif
 #endif  /* not defined XML_STATIC */
 
+#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
+#define XMLIMPORT __attribute__ ((visibility ("default")))
+#endif
 
 /* If we didn't define it above, define it away: */
 #ifndef XMLIMPORT
 #define XMLIMPORT
 #endif
 
+#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
+#define XML_ATTR_MALLOC __attribute__((__malloc__))
+#else
+#define XML_ATTR_MALLOC
+#endif
+
+#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+#define XML_ATTR_ALLOC_SIZE(x)  __attribute__((__alloc_size__(x)))
+#else
+#define XML_ATTR_ALLOC_SIZE(x)
+#endif
 
 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
 

Modified: vendor/expat/dist/lib/internal.h
==============================================================================
--- vendor/expat/dist/lib/internal.h	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/lib/internal.h	Wed Jun 29 06:24:30 2016	(r302260)
@@ -71,3 +71,25 @@
 #define inline
 #endif
 #endif
+
+#ifndef UNUSED_P
+# ifdef __GNUC__
+#  define UNUSED_P(p) UNUSED_ ## p __attribute__((__unused__))
+# else
+#  define UNUSED_P(p) UNUSED_ ## p
+# endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void
+align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef);
+
+
+#ifdef __cplusplus
+}
+#endif

Modified: vendor/expat/dist/lib/xmlparse.c
==============================================================================
--- vendor/expat/dist/lib/xmlparse.c	Wed Jun 29 06:04:45 2016	(r302259)
+++ vendor/expat/dist/lib/xmlparse.c	Wed Jun 29 06:24:30 2016	(r302260)
@@ -6,11 +6,18 @@
 #include                      /* memset(), memcpy() */
 #include 
 #include                      /* UINT_MAX */
-#include                        /* time() */
+
+#ifdef WIN32
+#define getpid GetCurrentProcessId
+#else
+#include                    /* gettimeofday() */
+#include                   /* getpid() */
+#include                      /* getpid() */
+#endif
 
 #define XML_BUILDING_EXPAT 1
 
-#ifdef COMPILED_FROM_DSP
+#ifdef WIN32
 #include "winconfig.h"
 #elif defined(MACOS_CLASSIC)
 #include "macconfig.h"
@@ -20,7 +27,7 @@

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-all@freebsd.org  Wed Jun 29 06:25:25 2016
Return-Path: 
Delivered-To: svn-src-all@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 290F9B8645C;
 Wed, 29 Jun 2016 06:25:25 +0000 (UTC)
 (envelope-from delphij@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 D4100262B;
 Wed, 29 Jun 2016 06:25:24 +0000 (UTC)
 (envelope-from delphij@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6POPf065583;
 Wed, 29 Jun 2016 06:25:24 GMT (envelope-from delphij@FreeBSD.org)
Received: (from delphij@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6POEC065582;
 Wed, 29 Jun 2016 06:25:24 GMT (envelope-from delphij@FreeBSD.org)
Message-Id: <201606290625.u5T6POEC065582@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: delphij set sender to
 delphij@FreeBSD.org using -f
From: Xin LI 
Date: Wed, 29 Jun 2016 06:25:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-vendor@freebsd.org
Subject: svn commit: r302261 - vendor/expat/2.2.0
X-SVN-Group: vendor
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.22
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: Wed, 29 Jun 2016 06:25:25 -0000

Author: delphij
Date: Wed Jun 29 06:25:23 2016
New Revision: 302261
URL: https://svnweb.freebsd.org/changeset/base/302261

Log:
  Tag expat 2.2.0.

Added:
  vendor/expat/2.2.0/
     - copied from r302260, vendor/expat/dist/

From owner-svn-src-all@freebsd.org  Wed Jun 29 06:42:21 2016
Return-Path: 
Delivered-To: svn-src-all@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 9BECFB868A3;
 Wed, 29 Jun 2016 06:42:21 +0000 (UTC) (envelope-from cem@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 6A63B2F07;
 Wed, 29 Jun 2016 06:42:21 +0000 (UTC) (envelope-from cem@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6gKwj072939;
 Wed, 29 Jun 2016 06:42:20 GMT (envelope-from cem@FreeBSD.org)
Received: (from cem@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6gKIF072935;
 Wed, 29 Jun 2016 06:42:20 GMT (envelope-from cem@FreeBSD.org)
Message-Id: <201606290642.u5T6gKIF072935@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org
 using -f
From: "Conrad E. Meyer" 
Date: Wed, 29 Jun 2016 06:42:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302262 - in head/sys/dev/usb: . quirk
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 06:42:21 -0000

Author: cem
Date: Wed Jun 29 06:42:20 2016
New Revision: 302262
URL: https://svnweb.freebsd.org/changeset/base/302262

Log:
  USB: Add Garmin FR230 device quirk (broken INQUIRY)
  
  PR:		210544
  Reviewed by:	hps
  Approved by:	re

Modified:
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- head/sys/dev/usb/quirk/usb_quirk.c	Wed Jun 29 06:25:23 2016	(r302261)
+++ head/sys/dev/usb/quirk/usb_quirk.c	Wed Jun 29 06:42:20 2016	(r302262)
@@ -200,6 +200,7 @@ static struct usb_quirk_entry usb_quirks
 	USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI),
 	USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I,
 	    UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE),
+	USB_QUIRK(GARMIN, FORERUNNER230, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY),
 	USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ,
 	    UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE),

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Wed Jun 29 06:25:23 2016	(r302261)
+++ head/sys/dev/usb/usbdevs	Wed Jun 29 06:42:20 2016	(r302262)
@@ -2151,6 +2151,7 @@ product FUJITSU AH_F401U	0x105b	AH-F401U
 product FUJITSUSIEMENS SCR	0x0009	Fujitsu-Siemens SCR USB Reader
 
 /* Garmin products */
+product GARMIN FORERUNNER230	0x086d	ForeRunner 230
 product GARMIN IQUE_3600	0x0004	iQue 3600
 
 /* Gemalto products */

From owner-svn-src-all@freebsd.org  Wed Jun 29 06:55:31 2016
Return-Path: 
Delivered-To: svn-src-all@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 9B560B86AC3;
 Wed, 29 Jun 2016 06:55:31 +0000 (UTC) (envelope-from np@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 5258726CB;
 Wed, 29 Jun 2016 06:55:31 +0000 (UTC) (envelope-from np@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T6tUM4076810;
 Wed, 29 Jun 2016 06:55:30 GMT (envelope-from np@FreeBSD.org)
Received: (from np@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T6tUEe076808;
 Wed, 29 Jun 2016 06:55:30 GMT (envelope-from np@FreeBSD.org)
Message-Id: <201606290655.u5T6tUEe076808@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org
 using -f
From: Navdeep Parhar 
Date: Wed, 29 Jun 2016 06:55:30 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302263 - in head/sys/dev/cxgbe: . tom
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 06:55:31 -0000

Author: np
Date: Wed Jun 29 06:55:30 2016
New Revision: 302263
URL: https://svnweb.freebsd.org/changeset/base/302263

Log:
  cxgbe(4):  Do not bring up an interface when IFCAP_TOE is enabled on it.
  The interface's queues are functional after VI_INIT_DONE (which is short
  of interface-up) and that's all that's needed for t4_tom to communicate
  with the chip.
  
  Approved by:	re@ (gjb@)
  Sponsored by:	Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/tom/t4_listen.c

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Wed Jun 29 06:42:20 2016	(r302262)
+++ head/sys/dev/cxgbe/t4_main.c	Wed Jun 29 06:55:30 2016	(r302263)
@@ -8981,12 +8981,12 @@ toe_capability(struct vi_info *vi, int e
 		 * port has never been UP'd administratively.
 		 */
 		if (!(vi->flags & VI_INIT_DONE)) {
-			rc = cxgbe_init_synchronized(vi);
+			rc = vi_full_init(vi);
 			if (rc)
 				return (rc);
 		}
 		if (!(pi->vi[0].flags & VI_INIT_DONE)) {
-			rc = cxgbe_init_synchronized(&pi->vi[0]);
+			rc = vi_full_init(&pi->vi[0]);
 			if (rc)
 				return (rc);
 		}

Modified: head/sys/dev/cxgbe/tom/t4_listen.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_listen.c	Wed Jun 29 06:42:20 2016	(r302262)
+++ head/sys/dev/cxgbe/tom/t4_listen.c	Wed Jun 29 06:55:30 2016	(r302263)
@@ -532,7 +532,7 @@ t4_listen_start(struct toedev *tod, stru
 #endif
 
 	/*
-	 * Find a running VI with IFCAP_TOE (4 or 6).  We'll use the first
+	 * Find an initialized VI with IFCAP_TOE (4 or 6).  We'll use the first
 	 * such VI's queues to send the passive open and receive the reply to
 	 * it.
 	 *
@@ -543,7 +543,7 @@ t4_listen_start(struct toedev *tod, stru
 	for_each_port(sc, i) {
 		pi = sc->port[i];
 		for_each_vi(pi, v, vi) {
-			if (vi->ifp->if_drv_flags & IFF_DRV_RUNNING &&
+			if (vi->flags & VI_INIT_DONE &&
 			    vi->ifp->if_capenable & IFCAP_TOE)
 				goto found;
 		}

From owner-svn-src-all@freebsd.org  Wed Jun 29 07:00:17 2016
Return-Path: 
Delivered-To: svn-src-all@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 0F13FB86BB8;
 Wed, 29 Jun 2016 07:00:17 +0000 (UTC) (envelope-from mm@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 DE93A2924;
 Wed, 29 Jun 2016 07:00:16 +0000 (UTC) (envelope-from mm@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T70G2P077050;
 Wed, 29 Jun 2016 07:00:16 GMT (envelope-from mm@FreeBSD.org)
Received: (from mm@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T70Fmf077042;
 Wed, 29 Jun 2016 07:00:15 GMT (envelope-from mm@FreeBSD.org)
Message-Id: <201606290700.u5T70Fmf077042@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org
 using -f
From: Martin Matuska 
Date: Wed, 29 Jun 2016 07:00:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-vendor@freebsd.org
Subject: svn commit: r302264 - in vendor/libarchive/dist: . build/cmake
 libarchive libarchive/test libarchive_fe
X-SVN-Group: vendor
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.22
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: Wed, 29 Jun 2016 07:00:17 -0000

Author: mm
Date: Wed Jun 29 07:00:15 2016
New Revision: 302264
URL: https://svnweb.freebsd.org/changeset/base/302264

Log:
  Update vendor/libarchive to git 084ef320b8fc62e3fd3acb762fe6175d48d7829c
  
  Vendor issues fixed:
  #686: Correctly grow buffer in archive_string_append_from_wcs_in_codepage()
  FreeBSD PR #204157: Fix test on filesystems without birthtime support
  
  PR:	204157

Deleted:
  vendor/libarchive/dist/build/cmake/CheckStructMember.cmake
Modified:
  vendor/libarchive/dist/CMakeLists.txt
  vendor/libarchive/dist/configure.ac
  vendor/libarchive/dist/libarchive/archive_read_disk_posix.c
  vendor/libarchive/dist/libarchive/archive_string.c
  vendor/libarchive/dist/libarchive/archive_write_disk_posix.c
  vendor/libarchive/dist/libarchive/test/main.c
  vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c
  vendor/libarchive/dist/libarchive_fe/passphrase.c

Modified: vendor/libarchive/dist/CMakeLists.txt
==============================================================================
--- vendor/libarchive/dist/CMakeLists.txt	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/CMakeLists.txt	Wed Jun 29 07:00:15 2016	(r302264)
@@ -274,7 +274,7 @@ INCLUDE(CheckHeaderDirent)
 INCLUDE(CheckIncludeFile)
 INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckLibraryExists)
-INCLUDE(CheckStructMember)
+INCLUDE(CheckStructHasMember)
 INCLUDE(CheckSymbolExists)
 INCLUDE(CheckTypeExists)
 INCLUDE(CheckTypeSize)
@@ -1332,47 +1332,47 @@ CHECK_SYMBOL_EXISTS(SSIZE_MAX        "li
 # Check struct members
 #
 # Check for tm_gmtoff in struct tm
-CHECK_STRUCT_MEMBER("struct tm" tm_gmtoff
+CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff
     "time.h" HAVE_STRUCT_TM_TM_GMTOFF)
-CHECK_STRUCT_MEMBER("struct tm" __tm_gmtoff
+CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff
     "time.h" HAVE_STRUCT_TM___TM_GMTOFF)
 
 # Check for f_namemax in struct statfs
-CHECK_STRUCT_MEMBER("struct statfs" f_namemax
+CHECK_STRUCT_HAS_MEMBER("struct statfs" f_namemax
     "sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_NAMEMAX)
 
 # Check for birthtime in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_birthtime
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtime
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIME)
 
 # Check for high-resolution timestamps in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_birthtimespec.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtimespec.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtimespec.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtim.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtime_n
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_n
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_N)
-CHECK_STRUCT_MEMBER("struct stat" st_umtime
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_umtime
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_UMTIME)
-CHECK_STRUCT_MEMBER("struct stat" st_mtime_usec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_usec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_USEC)
 # Check for block size support in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_blksize
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_blksize
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
 # Check for st_flags in struct stat (BSD fflags)
-CHECK_STRUCT_MEMBER("struct stat" st_flags
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_flags
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_FLAGS)
 
 IF(HAVE_SYS_STATVFS_H)
-  CHECK_STRUCT_MEMBER("struct statvfs" f_iosize
+  CHECK_STRUCT_HAS_MEMBER("struct statvfs" f_iosize
     "sys/types.h;sys/statvfs.h" HAVE_STRUCT_STATVFS_F_IOSIZE)
 ENDIF()
 
 #
 #
-CHECK_STRUCT_MEMBER("struct tm" tm_sec
+CHECK_STRUCT_HAS_MEMBER("struct tm" tm_sec
     "sys/types.h;sys/time.h;time.h" TIME_WITH_SYS_TIME)
 
 #

Modified: vendor/libarchive/dist/configure.ac
==============================================================================
--- vendor/libarchive/dist/configure.ac	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/configure.ac	Wed Jun 29 07:00:15 2016	(r302264)
@@ -374,8 +374,11 @@ if test "x$with_lzma" != "xno"; then
   AC_CACHE_CHECK(
     [whether we have multithread support in lzma],
     ac_cv_lzma_has_mt,
-    [AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[#include ]],
+    [AC_LINK_IFELSE([
+      AC_LANG_PROGRAM([[#include ]
+                       [#if LZMA_VERSION < 50020000]
+                       [#error unsupported]
+                       [#endif]],
                       [[lzma_stream_encoder_mt(0, 0);]])],
       [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
   if test "x$ac_cv_lzma_has_mt" != xno; then
@@ -613,6 +616,14 @@ AC_CHECK_FUNCS([_get_timezone _localtime
 # detects cygwin-1.7, as opposed to older versions
 AC_CHECK_FUNCS([cygwin_conv_path])
 
+# DragonFly uses vfsconf, FreeBSD xvfsconf.
+AC_CHECK_TYPES(struct vfsconf,,,
+	[#if HAVE_SYS_TYPES_H
+	#include 
+	#endif
+	#include 
+	])
+
 # There are several variants of readdir_r around; we only
 # accept the POSIX-compliant version.
 AC_COMPILE_IFELSE(

Modified: vendor/libarchive/dist/libarchive/archive_read_disk_posix.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read_disk_posix.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive/archive_read_disk_posix.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -1504,7 +1504,11 @@ setup_current_filesystem(struct archive_
 	struct tree *t = a->tree;
 	struct statfs sfs;
 #if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC)
+#  if defined(HAVE_STRUCT_VFSCONF)
+	struct vfsconf vfc;
+#  else
 	struct xvfsconf vfc;
+#  endif
 #endif
 	int r, xr = 0;
 #if !defined(HAVE_STRUCT_STATFS_F_NAMEMAX)

Modified: vendor/libarchive/dist/libarchive/archive_string.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_string.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive/archive_string.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -559,7 +559,8 @@ archive_wstring_append_from_mbs_in_codep
 			}
 			if (count == 0 && length != 0)
 				ret = -1;
-		} while (0);
+			break;
+		} while (1);
 	}
 	dest->length += count;
 	dest->s[dest->length] = L'\0';
@@ -3552,18 +3553,19 @@ win_strncat_from_utf16(struct archive_st
 		ll = WideCharToMultiByte(sc->to_cp, 0,
 		    (LPCWSTR)u16, (int)bytes>>1, mbs, (int)mbs_size,
 			NULL, &defchar);
-		if (ll == 0 &&
-		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-			/* Need more buffer for MBS. */
-			ll = WideCharToMultiByte(sc->to_cp, 0,
-			    (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
-			if (archive_string_ensure(as, ll +1) == NULL)
-				return (-1);
-			mbs = as->s + as->length;
-			mbs_size = as->buffer_length - as->length -1;
-			continue;
+		/* Exit loop if we succeeded */
+		if (ll != 0 ||
+		    GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+			break;
 		}
-	} while (0);
+		/* Else expand buffer and loop to try again. */
+		ll = WideCharToMultiByte(sc->to_cp, 0,
+		    (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
+		if (archive_string_ensure(as, ll +1) == NULL)
+			return (-1);
+		mbs = as->s + as->length;
+		mbs_size = as->buffer_length - as->length -1;
+	} while (1);
 	archive_string_free(&tmp);
 	as->length += ll;
 	as->s[as->length] = '\0';
@@ -3634,19 +3636,20 @@ win_strncat_to_utf16(struct archive_stri
 	do {
 		count = MultiByteToWideChar(sc->from_cp,
 		    MB_PRECOMPOSED, s, (int)length, (LPWSTR)u16, (int)avail>>1);
-		if (count == 0 &&
-		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-			/* Need more buffer for UTF-16 string */
-			count = MultiByteToWideChar(sc->from_cp,
-			    MB_PRECOMPOSED, s, (int)length, NULL, 0);
-			if (archive_string_ensure(as16, (count +1) * 2)
-			    == NULL)
-				return (-1);
-			u16 = as16->s + as16->length;
-			avail = as16->buffer_length - 2;
-			continue;
+		/* Exit loop if we succeeded */
+		if (count != 0 ||
+		    GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+			break;
 		}
-	} while (0);
+		/* Expand buffer and try again */
+		count = MultiByteToWideChar(sc->from_cp,
+		    MB_PRECOMPOSED, s, (int)length, NULL, 0);
+		if (archive_string_ensure(as16, (count +1) * 2)
+		    == NULL)
+			return (-1);
+		u16 = as16->s + as16->length;
+		avail = as16->buffer_length - 2;
+	} while (1);
 	as16->length += count * 2;
 	as16->s[as16->length] = 0;
 	as16->s[as16->length+1] = 0;

Modified: vendor/libarchive/dist/libarchive/archive_write_disk_posix.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_write_disk_posix.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive/archive_write_disk_posix.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -3487,6 +3487,9 @@ exit_xattr:
 static int
 copy_acls(struct archive_write_disk *a, int tmpfd, int dffd)
 {
+#ifndef HAVE_SYS_ACL_H
+	return 0;
+#else
 	acl_t acl, dfacl = NULL;
 	int acl_r, ret = ARCHIVE_OK;
 
@@ -3514,6 +3517,7 @@ exit_acl:
 	if (dfacl)
 		acl_free(dfacl);
 	return (ret);
+#endif
 }
 
 static int

Modified: vendor/libarchive/dist/libarchive/test/main.c
==============================================================================
--- vendor/libarchive/dist/libarchive/test/main.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive/test/main.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -1292,6 +1292,11 @@ assertion_file_time(const char *file, in
 	switch (type) {
 	case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
 	case 'b': filet = st.st_birthtime;
+		/* FreeBSD filesystems that don't support birthtime
+		 * (e.g., UFS1) always return -1 here. */
+		if (filet == -1) {
+			return (1);
+		}
 		filet_nsec = st.st_birthtimespec.tv_nsec; break;
 	case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
 	default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);

Modified: vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c
==============================================================================
--- vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -42,6 +42,7 @@ DEFINE_TEST(test_write_format_gnutar_fil
 	struct archive_entry *ae, *template;
 	struct archive *a;
 	size_t used;
+	int i;
 
 	buff = malloc(buffsize); /* million bytes of work area */
 	assert(buff != NULL);
@@ -55,7 +56,7 @@ DEFINE_TEST(test_write_format_gnutar_fil
 	archive_entry_set_mode(template, S_IFREG | 0755);
 	archive_entry_set_size(template, 8);
 
-	for (int i = 0; i < 2000; ++i) {
+	for (i = 0; i < 2000; ++i) {
 		filename[i] = 'a';
 		filename[i + 1] = '\0';
 		archive_entry_copy_pathname(template, filename);
@@ -97,6 +98,7 @@ DEFINE_TEST(test_write_format_gnutar_lin
 	struct archive_entry *ae, *template;
 	struct archive *a;
 	size_t used;
+	int i;
 
 	buff = malloc(buffsize); /* million bytes of work area */
 	assert(buff != NULL);
@@ -110,7 +112,7 @@ DEFINE_TEST(test_write_format_gnutar_lin
 	archive_entry_set_mode(template, S_IFLNK | 0755);
 	archive_entry_copy_pathname(template, "link");
 
-	for (int i = 0; i < 2000; ++i) {
+	for (i = 0; i < 2000; ++i) {
 		filename[i] = 'a';
 		filename[i + 1] = '\0';
 		archive_entry_copy_symlink(template, filename);

Modified: vendor/libarchive/dist/libarchive_fe/passphrase.c
==============================================================================
--- vendor/libarchive/dist/libarchive_fe/passphrase.c	Wed Jun 29 06:55:30 2016	(r302263)
+++ vendor/libarchive/dist/libarchive_fe/passphrase.c	Wed Jun 29 07:00:15 2016	(r302264)
@@ -132,6 +132,10 @@ readpassphrase(const char *prompt, char 
 #include 
 #include 
 
+#ifndef _PATH_TTY
+#define _PATH_TTY "/dev/tty"
+#endif
+
 #ifdef TCSASOFT
 # define _T_FLUSH	(TCSAFLUSH|TCSASOFT)
 #else

From owner-svn-src-all@freebsd.org  Wed Jun 29 07:55:46 2016
Return-Path: 
Delivered-To: svn-src-all@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 82CBDB86A1F;
 Wed, 29 Jun 2016 07:55:46 +0000 (UTC) (envelope-from smh@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 40A5527A7;
 Wed, 29 Jun 2016 07:55:46 +0000 (UTC) (envelope-from smh@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5T7tjoX099053;
 Wed, 29 Jun 2016 07:55:45 GMT (envelope-from smh@FreeBSD.org)
Received: (from smh@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5T7tjTs099051;
 Wed, 29 Jun 2016 07:55:45 GMT (envelope-from smh@FreeBSD.org)
Message-Id: <201606290755.u5T7tjTs099051@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org
 using -f
From: Steven Hartland 
Date: Wed, 29 Jun 2016 07:55:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302265 -
 head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 07:55:46 -0000

Author: smh
Date: Wed Jun 29 07:55:45 2016
New Revision: 302265
URL: https://svnweb.freebsd.org/changeset/base/302265

Log:
  Allow ZFS ARC min / max to be tuned at runtime
  
  Prior to this change ZFS ARC min / max could only be changed using
  boot time tunables, this allows the values to be tuned at runtime
  using the sysctls:
  * vfs.zfs.arc_max
  * vfs.zfs.arc_min
  
  When adjusting ZFS ARC minimum the memory used  will only reduce
  to the new minimum given memory pressure.
  
  Reviewed by:	allanjude
  Approved by:	re (gjb)
  MFC after:	2 weeks
  Relnotes:	yes
  Sponsored by:	Multiplay
  Differential Revision:	https://reviews.freebsd.org/D5907

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Wed Jun 29 07:00:15 2016	(r302264)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Wed Jun 29 07:55:45 2016	(r302265)
@@ -238,10 +238,15 @@ int zfs_disable_dup_eviction = 0;
 uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */
 u_int zfs_arc_free_target = 0;
 
+/* Absolute min for arc min / max is 16MB. */
+static uint64_t arc_abs_min = 16 << 20;
+
 static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS);
 static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS);
+static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS);
+static int sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_ARGS);
 
-#ifdef _KERNEL
+#if defined(__FreeBSD__) && defined(_KERNEL)
 static void
 arc_free_target_init(void *unused __unused)
 {
@@ -255,10 +260,10 @@ TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &
 TUNABLE_QUAD("vfs.zfs.arc_meta_min", &zfs_arc_meta_min);
 TUNABLE_INT("vfs.zfs.arc_shrink_shift", &zfs_arc_shrink_shift);
 SYSCTL_DECL(_vfs_zfs);
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0,
-    "Maximum ARC size");
-SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, &zfs_arc_min, 0,
-    "Minimum ARC size");
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, CTLTYPE_U64 | CTLFLAG_RWTUN,
+    0, sizeof(uint64_t), sysctl_vfs_zfs_arc_max, "QU", "Maximum ARC size");
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, CTLTYPE_U64 | CTLFLAG_RWTUN,
+    0, sizeof(uint64_t), sysctl_vfs_zfs_arc_min, "QU", "Minimum ARC size");
 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN,
     &zfs_arc_average_blocksize, 0,
     "ARC average blocksize");
@@ -884,7 +889,7 @@ struct arc_buf_hdr {
 	l1arc_buf_hdr_t		b_l1hdr;
 };
 
-#ifdef _KERNEL
+#if defined(__FreeBSD__) && defined(_KERNEL)
 static int
 sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS)
 {
@@ -902,6 +907,70 @@ sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HAN
 	arc_meta_limit = val;
 	return (0);
 }
+
+static int
+sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS)
+{
+	uint64_t val;
+	int err;
+
+	val = zfs_arc_max;
+	err = sysctl_handle_64(oidp, &val, 0, req);
+	if (err != 0 || req->newptr == NULL)
+		return (err);
+
+	if (val < arc_abs_min || val > kmem_size())
+		return (EINVAL);
+	if (val < arc_c_min)
+		return (EINVAL);
+	if (zfs_arc_meta_limit > 0 && val < zfs_arc_meta_limit)
+		return (EINVAL);
+
+	arc_c_max = val;
+
+	arc_c = arc_c_max;
+        arc_p = (arc_c >> 1);
+
+	if (zfs_arc_meta_limit == 0) {
+		/* limit meta-data to 1/4 of the arc capacity */
+		arc_meta_limit = arc_c_max / 4;
+	}
+
+	/* if kmem_flags are set, lets try to use less memory */
+	if (kmem_debugging())
+		arc_c = arc_c / 2;
+
+	zfs_arc_max = arc_c;
+
+	return (0);
+}
+
+static int
+sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_ARGS)
+{
+	uint64_t val;
+	int err;
+
+	val = zfs_arc_min;
+	err = sysctl_handle_64(oidp, &val, 0, req);
+	if (err != 0 || req->newptr == NULL)
+		return (err);
+
+	if (val < arc_abs_min || val > arc_c_max)
+		return (EINVAL);
+
+	arc_c_min = val;
+
+	if (zfs_arc_meta_min == 0)
+                arc_meta_min = arc_c_min / 2;
+
+	if (arc_c < arc_c_min)
+                arc_c = arc_c_min;
+
+	zfs_arc_min = arc_c_min;
+
+	return (0);
+}
 #endif
 
 static arc_buf_t *arc_eviction_list;
@@ -5385,8 +5454,8 @@ arc_init(void)
 	arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8);
 #endif
 #endif	/* illumos */
-	/* set min cache to 1/32 of all memory, or 16MB, whichever is more */
-	arc_c_min = MAX(arc_c / 4, 16 << 20);
+	/* set min cache to 1/32 of all memory, or arc_abs_min, whichever is more */
+	arc_c_min = MAX(arc_c / 4, arc_abs_min);
 	/* set max to 1/2 of all memory, or all but 1GB, whichever is more */
 	if (arc_c * 8 >= 1 << 30)
 		arc_c_max = (arc_c * 8) - (1 << 30);
@@ -5407,11 +5476,11 @@ arc_init(void)
 #ifdef _KERNEL
 	/*
 	 * Allow the tunables to override our calculations if they are
-	 * reasonable (ie. over 16MB)
+	 * reasonable.
 	 */
-	if (zfs_arc_max > 16 << 20 && zfs_arc_max < kmem_size())
+	if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size())
 		arc_c_max = zfs_arc_max;
-	if (zfs_arc_min > 16 << 20 && zfs_arc_min <= arc_c_max)
+	if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max)
 		arc_c_min = zfs_arc_min;
 #endif
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c	Wed Jun 29 07:00:15 2016	(r302264)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c	Wed Jun 29 07:55:45 2016	(r302265)
@@ -49,8 +49,8 @@
 #include 
 
 #if defined(__FreeBSD__) && defined(_KERNEL)
-#include 
 #include 
+#include 
 #endif
 
 /*

From owner-svn-src-all@freebsd.org  Wed Jun 29 07:58:18 2016
Return-Path: 
Delivered-To: svn-src-all@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 0F181B86B1E;
 Wed, 29 Jun 2016 07:58:18 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au
 [211.29.132.53])
 by mx1.freebsd.org (Postfix) with ESMTP id B2B8429E2;
 Wed, 29 Jun 2016 07:58:17 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au
 [110.21.100.149])
 by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 95BD5D4FC80;
 Wed, 29 Jun 2016 17:58:05 +1000 (AEST)
Date: Wed, 29 Jun 2016 17:58:05 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Konstantin Belousov 
cc: src-committers@freebsd.org, svn-src-all@freebsd.org, 
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302251 - head/sys/kern
In-Reply-To: <201606281642.u5SGge18061528@repo.freebsd.org>
Message-ID: <20160629154400.F968@besplex.bde.org>
References: <201606281642.u5SGge18061528@repo.freebsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Optus-CM-Score: 0
X-Optus-CM-Analysis: v=2.1 cv=OtmysHLt c=1 sm=1 tr=0
 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17
 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10
 a=RdlyHFHmpbaWVazvlCcA:9 a=CjuIK1q_8ugA:10
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 07:58:18 -0000

On Tue, 28 Jun 2016, Konstantin Belousov wrote:

> Log:
>  Do not use Giant to prevent parallel calls to CLOCK_SETTIME().  Use
>  private mtx in resettodr(), no implementation of CLOCK_SETTIME() is
>  allowed to sleep.

Thanks.

As you know, clock locking is still quite broken.  The most obvious
bugs near here are now:
- settime() still begins with splclock().  This gave fewer bugs in
   clock locking when it last worked in FreeBSD-4.  Now it is just
   a hint that the clock locking has still not been converted to use
   mutexes.
- bitrot near the end of settime() removed the splx() that should
   be paired with the splclock().
- the locking should be stronger than mutexes (or splclock()) to
   minimise the delay between deciding to set the time and actually
   setting it.  The delay between making the decision in userland
   and acquiring a lock in the kernel is hard to control, so this
   would be better handled by another API, and often is by using
   the adjtime(x) API to apply a small adjustment.

   The only safe way to set an absolute time with POSIX APIs seems
   to be sometime like:
   - clock_gettime(CLOCK_MONOTONIC, &start)
   - clock_settime(CLOCK_REALTIME, &now)
   - clock_gettime(CLOCK_MONOTONIC, &finish)
   - loop doing this while 'finish' is too much later than 'start'.

   My kernel code for reading (but not writing) does this, but without
   the loop (except it loops for an average of 0.5 seconds before
   starting to synchronize).  It just prints the difference finish -
   start.  Even though this is all at a low level, the difference is
   typically about 40 usec on a 2GHz i386 system (since reading the AT
   rtc registers is slow).

   A delay of 40 usec is too much using ntpd if you want closer to
   microseconds accuracy than milliseconds.  However, ntpd mostly
   uses adjtimex().

   The software part of setting the time can be much faster.  This
   requires ordering things carefully.  settime() now uses the
   reasonable order of tc_setclock() first.

   The AT rtc register only has a resolution and precision of 1 second,
   and sloppy programming gives it an accuracy of at most 1 second too.
   Uncontrolled delays in settime() don't matter compared with the
   larger sloppiness at lower levels.  My version fixes this for some
   cases, so that the rtc can be used to restore the software time to
   within ~40 microseconds after interrupts have been stopped by ddb.
   Similar methods would work for restoring the software time accurately
   enough to avoid steps in ntp after suspend/resume.

- settime() still does bogus Giant locking at the end (where it lost the
   splx()):

   X 	mtx_lock(&Giant);
   X 	tc_setclock(&ts);
   X 	resettodr();
   X 	mtx_unlock(&Giant);

   Giant locking for tc_setlock() is even less necessary and/or sufficient
   than it is for the resettodr().  Locking for tc_setclock() is more
   important than for the rtc, but it has no locking except for this
   Giant locking, and none of the variables accessed by it is locked by
   Giant.

- more below, with references to changes in this commit.

> Modified: head/sys/kern/subr_rtc.c
> ==============================================================================
> --- head/sys/kern/subr_rtc.c	Tue Jun 28 16:41:50 2016	(r302250)
> +++ head/sys/kern/subr_rtc.c	Tue Jun 28 16:42:40 2016	(r302251)
> @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$");
> #include 
> #include 
> #include 
> +#include 
> +#include 
> #include 
> #ifdef FFCLOCK
> #include 
> @@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$");
> static device_t clock_dev = NULL;
> static long clock_res;
> static struct timespec clock_adj;
> +static struct mtx resettodr_lock;
> +MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF);
>
> /* XXX: should be kern. now, it's no longer machdep.  */
> static int disable_rtc_set;
> @@ -168,11 +172,14 @@ resettodr(void)
> 	if (disable_rtc_set || clock_dev == NULL)
> 		return;
>
> +	mtx_lock(&resettodr_lock);

This could be later (only around the hardware parts) since we are sloppy
with the delays.

> 	getnanotime(&ts);

This doesn't even try to get nanoseconds accuracy.

> 	timespecadd(&ts, &clock_adj);
> 	ts.tv_sec -= utc_offset();

Who knows what utc_offset() is locked by?  Certainly not this new locking,
since it is set in another file but the new locking is only in this file.
It still seems to be most under Giant :-(.

The change in the other part of the diff is related to this, and doesn't
seem quite right.  utc_offset() uses the variables tz_minuteswest,
wall_cmos_clock and adjkerntz:
- tz_minuteswest is set with no locking in kern_settimeofday(), just
   after the settime() call.  This last had a chance of being correct
   when the kernel was UP and not preemptible.  But it is broken in
   a more fundamental way back to at least FreeBSD-1: resettodr() is
   called _before_ updating the timezone, so it uses an out-of-date
   tz_minuteswest.
- wall_cmos_clock is still under a simple (not MPSAFE) sysctl
- adjkerntz is under a PROC sysctl, and you just changed this sysctl to
   be MPSAFE.  The sysctl calls here, so we don't want all of it
   giant-locked.  But it now does unlocked accesses to the adjkerntz
   variable, and the access to the disable_rtc_set variable is unlocked
   because we do it before acquiring the lock in this function (this
   variable is still under a simple (not MPSAFE) sysctl.

Most of the variables are ints, so access to them are atomic, but without
locking the correct order only occurs accidentally and is hard to
understand.

> 	/* XXX: We should really set all registered RTCs */
> -	if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0)
> +	error = CLOCK_SETTIME(clock_dev, &ts);
> +	mtx_unlock(&resettodr_lock);
> +	if (error != 0)
> 		printf("warning: clock_settime failed (%d), time-of-day clock "
> 		    "not adjusted to system time\n", error);
> }

The lock needs to cover all high-level accesses to the rtc and related
variables to avoid races, and a bit more to minimise delays.  In particular,
inittodr() should be under this lock, and there is a problem with
"show rtc" in ddb.   ddb commands can't be under any lock since that gives
deadlock, but "show rtc" uses rtcin() which already uses RTC_LOCK.
RTC_LOCK locks the rtc at a lower level, but that is not enough for either
resettodr() or inittodr() or a combination.  This commit fixes the problem
for resettodr() only.  This is not a large problem in practice because it
is rare for these functions to be called concurrently, and it is only easy
to arrange for concurrent calls to resettodr(), but that takes root
privilege and in normal operation settime() is only called once from userland
(for initialization) since ntpd mostly uses adjtimex().

It might be useful to have an MI "show todr" ddb command.  This would be
easier to lock.  The MD "show rtc" command is still useful for showing
status registers.  BTW, subr_rtc.c is misnamed.  rtcs are MD things, and
subr_rtc mostly handles higher level things which have the even worse, but
historical name "todr".  Since the MD interfaces have the even worse still
name CLOCK_*TIME, the only rtc names in subr_rtc.c is just one due to
another namespace error -- disable_rtc_set.  The only other public function
in subr_rtc.c is another namespace error -- clock_register(), which might
belong in subr_clock.c.  The namespace error utc_offset() is in subr_clock.c.

"show rtc" now deadlocks when rtc clock is single stepped through.  To
fix this, use the usual kdb_active hack or mtx_trylock(), and make rtcin()
reentrant when it can't acquire the lock.  Then in resettodr() and
inittodr(), "show rtc" won't destroy the state.  Just stopping resettodr()
or inittodr() (or any time-related function) in ddb breaks the timing like
preemption does, but usually for longer.  If there is any error handling
for the preempted casse then it works for the ddb case too.

Bruce

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:08:17 2016
Return-Path: 
Delivered-To: svn-src-all@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 F0E4CB86F8C;
 Wed, 29 Jun 2016 10:08:17 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au
 [211.29.132.42])
 by mx1.freebsd.org (Postfix) with ESMTP id A0F532752;
 Wed, 29 Jun 2016 10:08:17 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au
 [110.21.100.149])
 by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id A08DC3D031F;
 Wed, 29 Jun 2016 19:39:45 +1000 (AEST)
Date: Wed, 29 Jun 2016 19:39:45 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Konstantin Belousov 
cc: src-committers@freebsd.org, svn-src-all@freebsd.org, 
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
In-Reply-To: <201606281643.u5SGhNsi061606@repo.freebsd.org>
Message-ID: <20160629175917.O968@besplex.bde.org>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Optus-CM-Score: 0
X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0
 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17
 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10
 a=YBTR0DOa03FoEZgt01gA:9 a=To-spq41Ae8Nz7We:21 a=wCAWHQOgn0QvNm88:21
 a=CjuIK1q_8ugA:10
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 10:08:18 -0000

On Tue, 28 Jun 2016, Konstantin Belousov wrote:

> Log:
>  Currently the ntptime code and resettodr() are Giant-locked. In
>  particular, the Giant is supposed to protect against parallel
>  ntp_adjtime(2) invocations.  But, for instance, sys_ntp_adjtime() does
>  copyout(9) under Giant and then examines time_status to return syscall
>  result.  Since copyout(9) could sleep, the syscall result might be
>  inconsistent.

Thanks.

As you know, there are still many errors near here.  This is more complicated
than for settime() vs resettodr() so I won't try to remember them all.
Some are:

- kern_ntptime.c still says that "all routines must run priority splclock
   or higher".  Since spls are null, this just points to missing locking.
   The pointers are quite weak since it only calls splclock() once
   internally and explicit splclock() calls have been removed from all
   callers.  There was only this one call in kern_ntptime.c as far back
   as FreeBSD-3.  Then the syscalls didn't have any locking, so I think
   there were lots of races even with UP non-preemptible kernels.

>  Another and more important issue is that if PPS is configured,
>  hardpps(9) is executed without any protection against the parallel
>  top-level code invocation. Potentially, this may result in the
>  inconsistent state of the ntptime state variables, but I cannot say
>  how serious such distortion is. The non-functional splclock() call in

It is surprising how unserious it is.

>  sys_ntp_adjtime() protected against clock interrupts calling hardpps()
>  in the pre-SMP era.
>
>  Modernize the locking. A mutex protects ntptime data.  Due to the
>  hardpps() KPI legitimately serving from the interrupt filters (and
>  e.g. uart(4) does call it from filter), the lock cannot be sleepable
>  mutex if PPS_SYNC is defined.  Otherwise, use normal sleepable mutex
>  to reduce interrupt latency.

The largest locking errors that I knew about were for pps and
ntp_update_second().  I still don't trust calling time code from fast
interrupt handlers (now misnamed filters) and don't allow it in my
version.  So my hardclock(), statclock() and profclock() interrupt handlers
are not fast, although this adds large overheads (nearly 1% at low hz and
np profileing).  I have a pps handler in the RTC interrupt handler.  I
didn't get around to fixing the pps locking, but since the handler is not
fast the fixes using sleep locks would be easier.  I have a pps handler
in sio.  sio normally uses fast interrupts, but I never use pps for it
so I didn't need to fix this.

> Modified: head/sys/kern/kern_ntptime.c
> ==============================================================================
> --- head/sys/kern/kern_ntptime.c	Tue Jun 28 16:42:40 2016	(r302251)
> +++ head/sys/kern/kern_ntptime.c	Tue Jun 28 16:43:23 2016	(r302252)
> @@ -162,6 +162,30 @@ static l_fp time_adj;			/* tick adjust (
>
> static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
>
> +static struct mtx ntpadj_lock;
> +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
> +#ifdef PPS_SYNC
> +    MTX_SPIN
> +#else
> +    MTX_DEF
> +#endif
> +);

This needs to be a spinlock in all cases, since ntp_update_second() needs
to be locked and ntp_update_second() is called from tc_windup() is usually
called from a fast interrupt handler.

ntp_update_second() is still unlocked.  It accesses lots of variables, so
it obviously needs locking.  E.g., its very first access is
time_maxerror += MAXFREQ / 1000.  This has the usual non-atomicity for
a read-modify write.  This obiously races with the locked access on the
28th linke of sys_ntp_adjtime().  Only the latter is locked now.

> +
> +/*
> + * When PPS_SYNC is defined, hardpps() function is provided which can
> + * be legitimately called from interrupt filters.  Due to this, use
> + * spinlock for ntptime state protection, otherwise sleepable mutex is
> + * adequate.
> + */
> +#ifdef PPS_SYNC
> +#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
> +#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
> +#else
> +#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
> +#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
> +#endif
> +#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)

*ADJ* and *adj* are not good names, since much more than ntp_adj*() needs
to be locked.

Probably the locking should be shared with kern_tc.c.  tc_windup() still
uses only fancy time-domaind/atomic-op locking.  This mostly works, but
is quite broken by calling tc_windup() from places other than hardclock().
The most problematic other place is from tc_setclock().  That is unlocked,
except accidentally by callers with only Giant locking, so it races with
the fast interrupt handler.

tc_windup() doesn't need the fancy locking for efficiency -- it only needs
it to be consistent with binuptime() and friends.  So it may as well use
the same lock as ntp.  Its lock must be around the whole function to
protect it from tc_setclock().  Then the same lock works for
ntp_update_second() and pps.  Any lock that is only acquired once per
second is not worth optimizing.  Hopefully the same for ntp's other locks.
ntp syscalls should only be frequent under unusual/malicious loads, so
they shouldn't cause much contention with the tc_windup() lock.

> @@ -203,11 +227,12 @@ static long pps_errcnt;			/* calibration
> static void ntp_init(void);
> static void hardupdate(long offset);
> static void ntp_gettime1(struct ntptimeval *ntvp);
> -static int ntp_is_time_error(void);
> +static bool ntp_is_time_error(int tsl);
>
> -static int
> -ntp_is_time_error(void)
> +static bool
> +ntp_is_time_error(int tsl)
> {
> +

Is it worth changing this to make a single variable less volatile?

bool shoudn't be used in old portable code.

> ...
> @@ -291,14 +315,17 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS)
> {
> 	struct ntptimeval ntv;	/* temporary structure */
>
> +	NTPADJ_LOCK();
> 	ntp_gettime1(&ntv);
> +	NTPADJ_UNLOCK();
>
> 	return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req));
> }

> #ifdef PPS_SYNC
> SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW,
> @@ -308,10 +335,12 @@ SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_
> SYSCTL_LONG(_kern_ntp_pll, OID_AUTO, time_monitor, CTLFLAG_RD,
>     &time_monitor, 0, "Last time offset scaled (ns)");
>
> -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD,
> -    &pps_freq, sizeof(pps_freq), "I", "Scaled frequency offset (ns/sec)");
> -SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD,
> -    &time_freq, sizeof(time_freq), "I", "Frequency offset (ns/sec)");
> +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, pps_freq, CTLFLAG_RD | CTLFLAG_MPSAFE,
> +    &pps_freq, 0,
> +    "Scaled frequency offset (ns/sec)");
> +SYSCTL_S64(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD | CTLFLAG_MPSAFE,
> +    &time_freq, 0,
> +    "Frequency offset (ns/sec)");
> #endif

These are not really MPSAFE, and OPAQUE was better than S64 since it
doesn't hard-code the size.  None of the simple sysctl handlers actually
gives atomic/coherent data.  They just attempt it, and have comments
ad nauseum saying this even for the int8_t case where the access is
surely (?) atomic.  For OPAQUE 64 bits and S64, the accesses are equally
non-atomic for 32-bit arches.

pps_freq and time_freq are volatile, so it is technically necessary to
use a SYSCTL_PROC() to copy them to a local variable with locking as above.

S64 does give better printing that OPAQUE.  My version adds sysctls for
some more variables (mainly time_offset and time_adj).  I still use
OPAQUE, and with this, at least i386 the variables are printed confusingly
as 2 decimal intergers.

Bruce

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:21:46 2016
Return-Path: 
Delivered-To: svn-src-all@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 DB4E9B84220;
 Wed, 29 Jun 2016 10:21:46 +0000 (UTC)
 (envelope-from hselasky@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 B692A2DF7;
 Wed, 29 Jun 2016 10:21:46 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TALjBL053060;
 Wed, 29 Jun 2016 10:21:45 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TALjnZ053056;
 Wed, 29 Jun 2016 10:21:45 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291021.u5TALjnZ053056@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:21:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302266 - stable/10/sys/dev/usb/controller
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:21:47 -0000

Author: hselasky
Date: Wed Jun 29 10:21:45 2016
New Revision: 302266
URL: https://svnweb.freebsd.org/changeset/base/302266

Log:
  MFC r302076:
  Update the definition for number of scratch pages to match the latest
  version of the XHCI specification. Make sure the code can handle the
  maximum number of allowed scratch pages.
  
  Submitted by:	Shichun_Ma@Dell.com

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
  stable/10/sys/dev/usb/controller/xhci.h
  stable/10/sys/dev/usb/controller/xhcireg.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==============================================================================
--- stable/10/sys/dev/usb/controller/xhci.c	Wed Jun 29 07:55:45 2016	(r302265)
+++ stable/10/sys/dev/usb/controller/xhci.c	Wed Jun 29 10:21:45 2016	(r302266)
@@ -215,7 +215,7 @@ static void
 xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 {
 	struct xhci_softc *sc = XHCI_BUS2SC(bus);
-	uint8_t i;
+	uint16_t i;
 
 	cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg,
 	   sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE);
@@ -223,7 +223,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu
 	cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg,
 	   sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE);
 
-	for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+	for (i = 0; i != sc->sc_noscratch; i++) {
 		cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i],
 		    XHCI_PAGE_SIZE, XHCI_PAGE_SIZE);
 	}

Modified: stable/10/sys/dev/usb/controller/xhci.h
==============================================================================
--- stable/10/sys/dev/usb/controller/xhci.h	Wed Jun 29 07:55:45 2016	(r302265)
+++ stable/10/sys/dev/usb/controller/xhci.h	Wed Jun 29 10:21:45 2016	(r302266)
@@ -30,7 +30,7 @@
 
 #define	XHCI_MAX_DEVICES	MIN(USB_MAX_DEVICES, 128)
 #define	XHCI_MAX_ENDPOINTS	32	/* hardcoded - do not change */
-#define	XHCI_MAX_SCRATCHPADS	32
+#define	XHCI_MAX_SCRATCHPADS	1024
 #define	XHCI_MAX_EVENTS		(16 * 13)
 #define	XHCI_MAX_COMMANDS	(16 * 1)
 #define	XHCI_MAX_RSEG		1
@@ -495,14 +495,15 @@ struct xhci_softc {
 	uint16_t		sc_command_idx;
 	uint16_t		sc_imod_default;
 
+	/* number of scratch pages */
+	uint16_t		sc_noscratch;
+
 	uint8_t			sc_event_ccs;
 	uint8_t			sc_command_ccs;
 	/* number of XHCI device slots */
 	uint8_t			sc_noslot;
 	/* number of ports on root HUB */
 	uint8_t			sc_noport;
-	/* number of scratch pages */
-	uint8_t			sc_noscratch;
 	/* root HUB device configuration */
 	uint8_t			sc_conf;
 	/* root HUB port event bitmap, max 256 ports */

Modified: stable/10/sys/dev/usb/controller/xhcireg.h
==============================================================================
--- stable/10/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 07:55:45 2016	(r302265)
+++ stable/10/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 10:21:45 2016	(r302266)
@@ -52,8 +52,8 @@
 #define	XHCI_HCSPARAMS2		0x08	/* RO structual parameters 2 */
 #define	XHCI_HCS2_IST(x)	((x) & 0xF)
 #define	XHCI_HCS2_ERST_MAX(x)	(((x) >> 4) & 0xF)
-#define	XHCI_HCS2_SPR(x)	(((x) >> 24) & 0x1)
-#define	XHCI_HCS2_SPB_MAX(x)	(((x) >> 27) & 0x7F)
+#define	XHCI_HCS2_SPR(x)	(((x) >> 26) & 0x1)
+#define	XHCI_HCS2_SPB_MAX(x)	((((x) >> 16) & 0x3E0) | (((x) >> 27) & 0x1F))
 #define	XHCI_HCSPARAMS3		0x0C	/* RO structual parameters 3 */
 #define	XHCI_HCS3_U1_DEL(x)	((x) & 0xFF)
 #define	XHCI_HCS3_U2_DEL(x)	(((x) >> 16) & 0xFFFF)

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:23:20 2016
Return-Path: 
Delivered-To: svn-src-all@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 E2DCEB8440F;
 Wed, 29 Jun 2016 10:23:20 +0000 (UTC)
 (envelope-from hselasky@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 BE9DD200D;
 Wed, 29 Jun 2016 10:23:20 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TANJK1053772;
 Wed, 29 Jun 2016 10:23:19 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TANJLX053769;
 Wed, 29 Jun 2016 10:23:19 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291023.u5TANJLX053769@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:23:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r302267 - stable/9/sys/dev/usb/controller
X-SVN-Group: stable-9
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.22
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: Wed, 29 Jun 2016 10:23:21 -0000

Author: hselasky
Date: Wed Jun 29 10:23:19 2016
New Revision: 302267
URL: https://svnweb.freebsd.org/changeset/base/302267

Log:
  MFC r302076:
  Update the definition for number of scratch pages to match the latest
  version of the XHCI specification. Make sure the code can handle the
  maximum number of allowed scratch pages.
  
  Submitted by:	Shichun_Ma@Dell.com

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
  stable/9/sys/dev/usb/controller/xhci.h
  stable/9/sys/dev/usb/controller/xhcireg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==============================================================================
--- stable/9/sys/dev/usb/controller/xhci.c	Wed Jun 29 10:21:45 2016	(r302266)
+++ stable/9/sys/dev/usb/controller/xhci.c	Wed Jun 29 10:23:19 2016	(r302267)
@@ -204,7 +204,7 @@ static void
 xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 {
 	struct xhci_softc *sc = XHCI_BUS2SC(bus);
-	uint8_t i;
+	uint16_t i;
 
 	cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg,
 	   sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE);
@@ -212,7 +212,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu
 	cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg,
 	   sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE);
 
-	for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+	for (i = 0; i != sc->sc_noscratch; i++) {
 		cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i],
 		    XHCI_PAGE_SIZE, XHCI_PAGE_SIZE);
 	}

Modified: stable/9/sys/dev/usb/controller/xhci.h
==============================================================================
--- stable/9/sys/dev/usb/controller/xhci.h	Wed Jun 29 10:21:45 2016	(r302266)
+++ stable/9/sys/dev/usb/controller/xhci.h	Wed Jun 29 10:23:19 2016	(r302267)
@@ -30,7 +30,7 @@
 
 #define	XHCI_MAX_DEVICES	MIN(USB_MAX_DEVICES, 128)
 #define	XHCI_MAX_ENDPOINTS	32	/* hardcoded - do not change */
-#define	XHCI_MAX_SCRATCHPADS	32
+#define	XHCI_MAX_SCRATCHPADS	1024
 #define	XHCI_MAX_EVENTS		(16 * 13)
 #define	XHCI_MAX_COMMANDS	(16 * 1)
 #define	XHCI_MAX_RSEG		1
@@ -486,14 +486,15 @@ struct xhci_softc {
 	uint16_t		sc_command_idx;
 	uint16_t		sc_imod_default;
 
+	/* number of scratch pages */
+	uint16_t		sc_noscratch;
+
 	uint8_t			sc_event_ccs;
 	uint8_t			sc_command_ccs;
 	/* number of XHCI device slots */
 	uint8_t			sc_noslot;
 	/* number of ports on root HUB */
 	uint8_t			sc_noport;
-	/* number of scratch pages */
-	uint8_t			sc_noscratch;
 	/* root HUB device configuration */
 	uint8_t			sc_conf;
 	/* root HUB port event bitmap, max 256 ports */

Modified: stable/9/sys/dev/usb/controller/xhcireg.h
==============================================================================
--- stable/9/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 10:21:45 2016	(r302266)
+++ stable/9/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 10:23:19 2016	(r302267)
@@ -52,8 +52,8 @@
 #define	XHCI_HCSPARAMS2		0x08	/* RO structual parameters 2 */
 #define	XHCI_HCS2_IST(x)	((x) & 0xF)
 #define	XHCI_HCS2_ERST_MAX(x)	(((x) >> 4) & 0xF)
-#define	XHCI_HCS2_SPR(x)	(((x) >> 24) & 0x1)
-#define	XHCI_HCS2_SPB_MAX(x)	(((x) >> 27) & 0x7F)
+#define	XHCI_HCS2_SPR(x)	(((x) >> 26) & 0x1)
+#define	XHCI_HCS2_SPB_MAX(x)	((((x) >> 16) & 0x3E0) | (((x) >> 27) & 0x1F))
 #define	XHCI_HCSPARAMS3		0x0C	/* RO structual parameters 3 */
 #define	XHCI_HCS3_U1_DEL(x)	((x) & 0xFF)
 #define	XHCI_HCS3_U2_DEL(x)	(((x) >> 16) & 0xFFFF)

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:25:34 2016
Return-Path: 
Delivered-To: svn-src-all@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 552DBB84493;
 Wed, 29 Jun 2016 10:25:34 +0000 (UTC)
 (envelope-from hselasky@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 2C6F221B7;
 Wed, 29 Jun 2016 10:25:34 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAPXv6053908;
 Wed, 29 Jun 2016 10:25:33 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAPXaT053905;
 Wed, 29 Jun 2016 10:25:33 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291025.u5TAPXaT053905@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:25:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject: svn commit: r302268 - stable/8/sys/dev/usb/controller
X-SVN-Group: stable-8
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.22
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: Wed, 29 Jun 2016 10:25:34 -0000

Author: hselasky
Date: Wed Jun 29 10:25:32 2016
New Revision: 302268
URL: https://svnweb.freebsd.org/changeset/base/302268

Log:
  MFC r302076:
  Update the definition for number of scratch pages to match the latest
  version of the XHCI specification. Make sure the code can handle the
  maximum number of allowed scratch pages.
  
  Submitted by:	Shichun_Ma@Dell.com

Modified:
  stable/8/sys/dev/usb/controller/xhci.c
  stable/8/sys/dev/usb/controller/xhci.h
  stable/8/sys/dev/usb/controller/xhcireg.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/usb/   (props changed)

Modified: stable/8/sys/dev/usb/controller/xhci.c
==============================================================================
--- stable/8/sys/dev/usb/controller/xhci.c	Wed Jun 29 10:23:19 2016	(r302267)
+++ stable/8/sys/dev/usb/controller/xhci.c	Wed Jun 29 10:25:32 2016	(r302268)
@@ -199,7 +199,7 @@ static void
 xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 {
 	struct xhci_softc *sc = XHCI_BUS2SC(bus);
-	uint8_t i;
+	uint16_t i;
 
 	cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg,
 	   sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE);
@@ -207,7 +207,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu
 	cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg,
 	   sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE);
 
-	for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+	for (i = 0; i != sc->sc_noscratch; i++) {
 		cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i],
 		    XHCI_PAGE_SIZE, XHCI_PAGE_SIZE);
 	}

Modified: stable/8/sys/dev/usb/controller/xhci.h
==============================================================================
--- stable/8/sys/dev/usb/controller/xhci.h	Wed Jun 29 10:23:19 2016	(r302267)
+++ stable/8/sys/dev/usb/controller/xhci.h	Wed Jun 29 10:25:32 2016	(r302268)
@@ -30,7 +30,7 @@
 
 #define	XHCI_MAX_DEVICES	MIN(USB_MAX_DEVICES, 128)
 #define	XHCI_MAX_ENDPOINTS	32	/* hardcoded - do not change */
-#define	XHCI_MAX_SCRATCHPADS	32
+#define	XHCI_MAX_SCRATCHPADS	1024
 #define	XHCI_MAX_EVENTS		(16 * 13)
 #define	XHCI_MAX_COMMANDS	(16 * 1)
 #define	XHCI_MAX_RSEG		1
@@ -486,14 +486,15 @@ struct xhci_softc {
 	uint16_t		sc_command_idx;
 	uint16_t		sc_imod_default;
 
+	/* number of scratch pages */
+	uint16_t		sc_noscratch;
+
 	uint8_t			sc_event_ccs;
 	uint8_t			sc_command_ccs;
 	/* number of XHCI device slots */
 	uint8_t			sc_noslot;
 	/* number of ports on root HUB */
 	uint8_t			sc_noport;
-	/* number of scratch pages */
-	uint8_t			sc_noscratch;
 	/* root HUB device configuration */
 	uint8_t			sc_conf;
 	/* root HUB port event bitmap, max 256 ports */

Modified: stable/8/sys/dev/usb/controller/xhcireg.h
==============================================================================
--- stable/8/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 10:23:19 2016	(r302267)
+++ stable/8/sys/dev/usb/controller/xhcireg.h	Wed Jun 29 10:25:32 2016	(r302268)
@@ -52,8 +52,8 @@
 #define	XHCI_HCSPARAMS2		0x08	/* RO structual parameters 2 */
 #define	XHCI_HCS2_IST(x)	((x) & 0xF)
 #define	XHCI_HCS2_ERST_MAX(x)	(((x) >> 4) & 0xF)
-#define	XHCI_HCS2_SPR(x)	(((x) >> 24) & 0x1)
-#define	XHCI_HCS2_SPB_MAX(x)	(((x) >> 27) & 0x7F)
+#define	XHCI_HCS2_SPR(x)	(((x) >> 26) & 0x1)
+#define	XHCI_HCS2_SPB_MAX(x)	((((x) >> 16) & 0x3E0) | (((x) >> 27) & 0x1F))
 #define	XHCI_HCSPARAMS3		0x0C	/* RO structual parameters 3 */
 #define	XHCI_HCS3_U1_DEL(x)	((x) & 0xFF)
 #define	XHCI_HCS3_U2_DEL(x)	(((x) >> 16) & 0xFFFF)

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:29:53 2016
Return-Path: 
Delivered-To: svn-src-all@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 5CA08B84517;
 Wed, 29 Jun 2016 10:29:53 +0000 (UTC)
 (envelope-from hselasky@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 1DBE52484;
 Wed, 29 Jun 2016 10:29:53 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TATq7T054092;
 Wed, 29 Jun 2016 10:29:52 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TATqvB054091;
 Wed, 29 Jun 2016 10:29:52 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291029.u5TATqvB054091@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:29:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302269 - stable/10/sys/dev/mlx5/mlx5_core
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:29:53 -0000

Author: hselasky
Date: Wed Jun 29 10:29:52 2016
New Revision: 302269
URL: https://svnweb.freebsd.org/changeset/base/302269

Log:
  MFC r302139:
  Use correct Q-counter output array.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Jun 29 10:25:32 2016	(r302268)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Jun 29 10:29:52 2016	(r302269)
@@ -71,7 +71,7 @@ static int mlx5_query_nic_vport_context(
 int mlx5_vport_alloc_q_counter(struct mlx5_core_dev *mdev, int *counter_set_id)
 {
 	u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)];
-	u32 out[MLX5_ST_SZ_DW(alloc_q_counter_in)];
+	u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)];
 	int err;
 
 	memset(in, 0, sizeof(in));

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:33:12 2016
Return-Path: 
Delivered-To: svn-src-all@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 81F81B84812;
 Wed, 29 Jun 2016 10:33:12 +0000 (UTC)
 (envelope-from hselasky@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 4DF0428F9;
 Wed, 29 Jun 2016 10:33:12 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAXBJA057524;
 Wed, 29 Jun 2016 10:33:11 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAXBYF057519;
 Wed, 29 Jun 2016 10:33:11 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291033.u5TAXBYF057519@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:33:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302270 - in stable/10/sys/dev/mlx5: . mlx5_core mlx5_en
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:33:12 -0000

Author: hselasky
Date: Wed Jun 29 10:33:11 2016
New Revision: 302270
URL: https://svnweb.freebsd.org/changeset/base/302270

Log:
  MFC r301545:
  Add SR-IOV guest support to the mlx5en driver.
  
  This patch adds the missing pieces needed for device setup using the
  mlx5en driver inside a virtual machine which is providing hardware
  access through SR-IOV.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/sys/dev/mlx5/driver.h
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
  stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  stable/10/sys/dev/mlx5/vport.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/driver.h
==============================================================================
--- stable/10/sys/dev/mlx5/driver.h	Wed Jun 29 10:29:52 2016	(r302269)
+++ stable/10/sys/dev/mlx5/driver.h	Wed Jun 29 10:33:11 2016	(r302270)
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Jun 29 10:29:52 2016	(r302269)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Jun 29 10:33:11 2016	(r302270)
@@ -471,6 +471,241 @@ int mlx5_set_nic_vport_promisc(struct ml
 	return mlx5_modify_nic_vport_context(mdev, in, sizeof(in));
 }
 EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_promisc);
+
+int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
+				  u32 vport,
+				  enum mlx5_list_type list_type,
+				  u8 addr_list[][ETH_ALEN],
+				  int *list_size)
+{
+	u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
+	void *nic_vport_ctx;
+	int max_list_size;
+	int req_list_size;
+	u8 *mac_addr;
+	int out_sz;
+	void *out;
+	int err;
+	int i;
+
+	req_list_size = *list_size;
+
+	max_list_size = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC) ?
+			1 << MLX5_CAP_GEN_MAX(dev, log_max_current_uc_list) :
+			1 << MLX5_CAP_GEN_MAX(dev, log_max_current_mc_list);
+
+	if (req_list_size > max_list_size) {
+		mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n",
+			       req_list_size, max_list_size);
+		req_list_size = max_list_size;
+	}
+
+	out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+		 req_list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+	memset(in, 0, sizeof(in));
+	out = kzalloc(out_sz, GFP_KERNEL);
+	if (!out)
+		return -ENOMEM;
+
+	MLX5_SET(query_nic_vport_context_in, in, opcode,
+		 MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
+	MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type);
+	MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
+
+	if (vport)
+		MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+
+	err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_sz);
+	if (err)
+		goto out;
+
+	nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out,
+				     nic_vport_context);
+	req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx,
+				 allowed_list_size);
+
+	*list_size = req_list_size;
+	for (i = 0; i < req_list_size; i++) {
+		mac_addr = MLX5_ADDR_OF(nic_vport_context,
+					nic_vport_ctx,
+					current_uc_mac_address[i]) + 2;
+		ether_addr_copy(addr_list[i], mac_addr);
+	}
+out:
+	kfree(out);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_list);
+
+int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
+				   enum mlx5_list_type list_type,
+				   u8 addr_list[][ETH_ALEN],
+				   int list_size)
+{
+	u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
+	void *nic_vport_ctx;
+	int max_list_size;
+	int in_sz;
+	void *in;
+	int err;
+	int i;
+
+	max_list_size = list_type == MLX5_NIC_VPORT_LIST_TYPE_UC ?
+		 1 << MLX5_CAP_GEN(dev, log_max_current_uc_list) :
+		 1 << MLX5_CAP_GEN(dev, log_max_current_mc_list);
+
+	if (list_size > max_list_size)
+		return -ENOSPC;
+
+	in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+		list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+	memset(out, 0, sizeof(out));
+	in = kzalloc(in_sz, GFP_KERNEL);
+	if (!in)
+		return -ENOMEM;
+
+	MLX5_SET(modify_nic_vport_context_in, in, opcode,
+		 MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 field_select.addresses_list, 1);
+
+	nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
+				     nic_vport_context);
+
+	MLX5_SET(nic_vport_context, nic_vport_ctx,
+		 allowed_list_type, list_type);
+	MLX5_SET(nic_vport_context, nic_vport_ctx,
+		 allowed_list_size, list_size);
+
+	for (i = 0; i < list_size; i++) {
+		u8 *curr_mac = MLX5_ADDR_OF(nic_vport_context,
+					    nic_vport_ctx,
+					    current_uc_mac_address[i]) + 2;
+		ether_addr_copy(curr_mac, addr_list[i]);
+	}
+
+	err = mlx5_cmd_exec_check_status(dev, in, in_sz, out, sizeof(out));
+	kfree(in);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mac_list);
+
+int mlx5_query_nic_vport_vlan_list(struct mlx5_core_dev *dev,
+				   u32 vport,
+				   u16 *vlan_list,
+				   int *list_size)
+{
+	u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
+	void *nic_vport_ctx;
+	int max_list_size;
+	int req_list_size;
+	int out_sz;
+	void *out;
+	void *vlan_addr;
+	int err;
+	int i;
+
+	req_list_size = *list_size;
+
+	max_list_size = 1 << MLX5_CAP_GEN_MAX(dev, log_max_vlan_list);
+
+	if (req_list_size > max_list_size) {
+		mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n",
+			       req_list_size, max_list_size);
+		req_list_size = max_list_size;
+	}
+
+	out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+		 req_list_size * MLX5_ST_SZ_BYTES(vlan_layout);
+
+	memset(in, 0, sizeof(in));
+	out = kzalloc(out_sz, GFP_KERNEL);
+	if (!out)
+		return -ENOMEM;
+
+	MLX5_SET(query_nic_vport_context_in, in, opcode,
+		 MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
+	MLX5_SET(query_nic_vport_context_in, in, allowed_list_type,
+		 MLX5_NIC_VPORT_CONTEXT_ALLOWED_LIST_TYPE_VLAN_LIST);
+	MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
+
+	if (vport)
+		MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+
+	err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_sz);
+	if (err)
+		goto out;
+
+	nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out,
+				     nic_vport_context);
+	req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx,
+				 allowed_list_size);
+
+	*list_size = req_list_size;
+	for (i = 0; i < req_list_size; i++) {
+		vlan_addr = MLX5_ADDR_OF(nic_vport_context, nic_vport_ctx,
+					 current_uc_mac_address[i]);
+		vlan_list[i] = MLX5_GET(vlan_layout, vlan_addr, vlan);
+	}
+out:
+	kfree(out);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_vlan_list);
+
+int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
+				u16 vlans[],
+				int list_size)
+{
+	u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
+	void *nic_vport_ctx;
+	int max_list_size;
+	int in_sz;
+	void *in;
+	int err;
+	int i;
+
+	max_list_size = 1 << MLX5_CAP_GEN(dev, log_max_vlan_list);
+
+	if (list_size > max_list_size)
+		return -ENOSPC;
+
+	in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+		list_size * MLX5_ST_SZ_BYTES(vlan_layout);
+
+	memset(out, 0, sizeof(out));
+	in = kzalloc(in_sz, GFP_KERNEL);
+	if (!in)
+		return -ENOMEM;
+
+	MLX5_SET(modify_nic_vport_context_in, in, opcode,
+		 MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 field_select.addresses_list, 1);
+
+	nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
+				     nic_vport_context);
+
+	MLX5_SET(nic_vport_context, nic_vport_ctx,
+		 allowed_list_type, MLX5_NIC_VPORT_LIST_TYPE_VLAN);
+	MLX5_SET(nic_vport_context, nic_vport_ctx,
+		 allowed_list_size, list_size);
+
+	for (i = 0; i < list_size; i++) {
+		void *vlan_addr = MLX5_ADDR_OF(nic_vport_context,
+					       nic_vport_ctx,
+					       current_uc_mac_address[i]);
+		MLX5_SET(vlan_layout, vlan_addr, vlan, vlans[i]);
+	}
+
+	err = mlx5_cmd_exec_check_status(dev, in, in_sz, out, sizeof(out));
+	kfree(in);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_vlans);
+
 int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
 				     u8 *addr)
 {
@@ -785,6 +1020,129 @@ int mlx5_set_eswitch_cvlan_info(struct m
 }
 EXPORT_SYMBOL_GPL(mlx5_set_eswitch_cvlan_info);
 
+int mlx5_arm_vport_context_events(struct mlx5_core_dev *mdev,
+				  u8 vport,
+				  u32 events_mask)
+{
+	u32 *in;
+	u32 inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+	void *nic_vport_ctx;
+	int err;
+
+	in = mlx5_vzalloc(inlen);
+	if (!in)
+		return -ENOMEM;
+
+	MLX5_SET(modify_nic_vport_context_in,
+		 in,
+		 opcode,
+		 MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+	MLX5_SET(modify_nic_vport_context_in,
+		 in,
+		 field_select.change_event,
+		 1);
+	MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+	if (vport)
+		MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
+	nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
+				     in,
+				     nic_vport_context);
+
+	MLX5_SET(nic_vport_context, nic_vport_ctx, arm_change_event, 1);
+
+	if (events_mask & MLX5_UC_ADDR_CHANGE)
+		MLX5_SET(nic_vport_context,
+			 nic_vport_ctx,
+			 event_on_uc_address_change,
+			 1);
+	if (events_mask & MLX5_MC_ADDR_CHANGE)
+		MLX5_SET(nic_vport_context,
+			 nic_vport_ctx,
+			 event_on_mc_address_change,
+			 1);
+	if (events_mask & MLX5_VLAN_CHANGE)
+		MLX5_SET(nic_vport_context,
+			 nic_vport_ctx,
+			 event_on_vlan_change,
+			 1);
+	if (events_mask & MLX5_PROMISC_CHANGE)
+		MLX5_SET(nic_vport_context,
+			 nic_vport_ctx,
+			 event_on_promisc_change,
+			 1);
+	if (events_mask & MLX5_MTU_CHANGE)
+		MLX5_SET(nic_vport_context,
+			 nic_vport_ctx,
+			 event_on_mtu,
+			 1);
+
+	err = mlx5_modify_nic_vport_context(mdev, in, inlen);
+
+	kvfree(in);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_arm_vport_context_events);
+
+int mlx5_query_vport_promisc(struct mlx5_core_dev *mdev,
+			     u32 vport,
+			     u8 *promisc_uc,
+			     u8 *promisc_mc,
+			     u8 *promisc_all)
+{
+	u32 *out;
+	int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
+	int err;
+
+	out = kzalloc(outlen, GFP_KERNEL);
+	if (!out)
+		return -ENOMEM;
+
+	err = mlx5_query_nic_vport_context(mdev, vport, out, outlen);
+	if (err)
+		goto out;
+
+	*promisc_uc = MLX5_GET(query_nic_vport_context_out, out,
+			       nic_vport_context.promisc_uc);
+	*promisc_mc = MLX5_GET(query_nic_vport_context_out, out,
+			       nic_vport_context.promisc_mc);
+	*promisc_all = MLX5_GET(query_nic_vport_context_out, out,
+				nic_vport_context.promisc_all);
+
+out:
+	kfree(out);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_promisc);
+
+int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
+				  int promisc_uc,
+				  int promisc_mc,
+				  int promisc_all)
+{
+	void *in;
+	int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+	int err;
+
+	in = mlx5_vzalloc(inlen);
+	if (!in) {
+		mlx5_core_err(mdev, "failed to allocate inbox\n");
+		return -ENOMEM;
+	}
+
+	MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 nic_vport_context.promisc_uc, promisc_uc);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 nic_vport_context.promisc_mc, promisc_mc);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 nic_vport_context.promisc_all, promisc_all);
+
+	err = mlx5_modify_nic_vport_context(mdev, in, inlen);
+	kvfree(in);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_promisc);
+
 int mlx5_query_vport_counter(struct mlx5_core_dev *dev,
 			     u8 port_num, u16 vport_num,
 			     void *out, int out_size)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c	Wed Jun 29 10:29:52 2016	(r302269)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c	Wed Jun 29 10:33:11 2016	(r302270)
@@ -390,6 +390,49 @@ add_eth_addr_rule_out:
 	return (err);
 }
 
+static int mlx5e_vport_context_update_vlans(struct mlx5e_priv *priv)
+{
+	struct ifnet *ifp = priv->ifp;
+	int max_list_size;
+	int list_size;
+	u16 *vlans;
+	int vlan;
+	int err;
+	int i;
+
+	list_size = 0;
+	for_each_set_bit(vlan, priv->vlan.active_vlans, VLAN_N_VID)
+		list_size++;
+
+	max_list_size = 1 << MLX5_CAP_GEN(priv->mdev, log_max_vlan_list);
+
+	if (list_size > max_list_size) {
+		if_printf(ifp,
+			    "ifnet vlans list size (%d) > (%d) max vport list size, some vlans will be dropped\n",
+			    list_size, max_list_size);
+		list_size = max_list_size;
+	}
+
+	vlans = kcalloc(list_size, sizeof(*vlans), GFP_KERNEL);
+	if (!vlans)
+		return -ENOMEM;
+
+	i = 0;
+	for_each_set_bit(vlan, priv->vlan.active_vlans, VLAN_N_VID) {
+		if (i >= list_size)
+			break;
+		vlans[i++] = vlan;
+	}
+
+	err = mlx5_modify_nic_vport_vlans(priv->mdev, vlans, list_size);
+	if (err)
+		if_printf(ifp, "Failed to modify vport vlans list err(%d)\n",
+			   err);
+
+	kfree(vlans);
+	return err;
+}
+
 enum mlx5e_vlan_rule_type {
 	MLX5E_VLAN_RULE_TYPE_UNTAGGED,
 	MLX5E_VLAN_RULE_TYPE_ANY_VID,
@@ -448,6 +491,7 @@ mlx5e_add_vlan_rule(struct mlx5e_priv *p
 		    outer_headers.first_vid);
 		MLX5_SET(fte_match_param, match_value, outer_headers.first_vid,
 		    vid);
+		mlx5e_vport_context_update_vlans(priv);
 		break;
 	}
 
@@ -478,6 +522,7 @@ mlx5e_del_vlan_rule(struct mlx5e_priv *p
 	case MLX5E_VLAN_RULE_TYPE_MATCH_VID:
 		mlx5_del_flow_table_entry(priv->ft.vlan,
 		    priv->vlan.active_vlans_ft_ix[vid]);
+		mlx5e_vport_context_update_vlans(priv);
 		break;
 	}
 }
@@ -628,6 +673,91 @@ mlx5e_sync_ifp_addr(struct mlx5e_priv *p
 	if_maddr_runlock(ifp);
 }
 
+static void mlx5e_fill_addr_array(struct mlx5e_priv *priv, int list_type,
+				  u8 addr_array[][ETH_ALEN], int size)
+{
+	bool is_uc = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC);
+	struct ifnet *ifp = priv->ifp;
+	struct mlx5e_eth_addr_hash_node *hn;
+	struct mlx5e_eth_addr_hash_head *addr_list;
+	struct mlx5e_eth_addr_hash_node *tmp;
+	int i = 0;
+	int hi;
+
+	addr_list = is_uc ? priv->eth_addr.if_uc : priv->eth_addr.if_mc;
+
+	if (is_uc) /* Make sure our own address is pushed first */
+		ether_addr_copy(addr_array[i++], IF_LLADDR(ifp));
+	else if (priv->eth_addr.broadcast_enabled)
+		ether_addr_copy(addr_array[i++], ifp->if_broadcastaddr);
+
+	mlx5e_for_each_hash_node(hn, tmp, addr_list, hi) {
+		if (ether_addr_equal(IF_LLADDR(ifp), hn->ai.addr))
+			continue;
+		if (i >= size)
+			break;
+		ether_addr_copy(addr_array[i++], hn->ai.addr);
+	}
+}
+
+static void mlx5e_vport_context_update_addr_list(struct mlx5e_priv *priv,
+						 int list_type)
+{
+	bool is_uc = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC);
+	struct mlx5e_eth_addr_hash_node *hn;
+	u8 (*addr_array)[ETH_ALEN] = NULL;
+	struct mlx5e_eth_addr_hash_head *addr_list;
+	struct mlx5e_eth_addr_hash_node *tmp;
+	int max_size;
+	int size;
+	int err;
+	int hi;
+
+	size = is_uc ? 0 : (priv->eth_addr.broadcast_enabled ? 1 : 0);
+	max_size = is_uc ?
+		1 << MLX5_CAP_GEN(priv->mdev, log_max_current_uc_list) :
+		1 << MLX5_CAP_GEN(priv->mdev, log_max_current_mc_list);
+
+	addr_list = is_uc ? priv->eth_addr.if_uc : priv->eth_addr.if_mc;
+	mlx5e_for_each_hash_node(hn, tmp, addr_list, hi)
+		size++;
+
+	if (size > max_size) {
+		if_printf(priv->ifp,
+			    "ifp %s list size (%d) > (%d) max vport list size, some addresses will be dropped\n",
+			    is_uc ? "UC" : "MC", size, max_size);
+		size = max_size;
+	}
+
+	if (size) {
+		addr_array = kcalloc(size, ETH_ALEN, GFP_KERNEL);
+		if (!addr_array) {
+			err = -ENOMEM;
+			goto out;
+		}
+		mlx5e_fill_addr_array(priv, list_type, addr_array, size);
+	}
+
+	err = mlx5_modify_nic_vport_mac_list(priv->mdev, list_type, addr_array, size);
+out:
+	if (err)
+		if_printf(priv->ifp,
+			   "Failed to modify vport %s list err(%d)\n",
+			   is_uc ? "UC" : "MC", err);
+	kfree(addr_array);
+}
+
+static void mlx5e_vport_context_update(struct mlx5e_priv *priv)
+{
+	struct mlx5e_eth_addr_db *ea = &priv->eth_addr;
+
+	mlx5e_vport_context_update_addr_list(priv, MLX5_NIC_VPORT_LIST_TYPE_UC);
+	mlx5e_vport_context_update_addr_list(priv, MLX5_NIC_VPORT_LIST_TYPE_MC);
+	mlx5_modify_nic_vport_promisc(priv->mdev, 0,
+				      ea->allmulti_enabled,
+				      ea->promisc_enabled);
+}
+
 static void
 mlx5e_apply_ifp_addr(struct mlx5e_priv *priv)
 {
@@ -701,6 +831,8 @@ mlx5e_set_rx_mode_core(struct mlx5e_priv
 	ea->promisc_enabled = promisc_enabled;
 	ea->allmulti_enabled = allmulti_enabled;
 	ea->broadcast_enabled = broadcast_enabled;
+
+	mlx5e_vport_context_update(priv);
 }
 
 void

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Wed Jun 29 10:29:52 2016	(r302269)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Wed Jun 29 10:33:11 2016	(r302270)
@@ -3001,6 +3001,13 @@ mlx5e_create_ifp(struct mlx5_core_dev *m
 	}
 	mlx5_query_nic_vport_mac_address(priv->mdev, 0, dev_addr);
 
+	/* check if we should generate a random MAC address */
+	if (MLX5_CAP_GEN(priv->mdev, vport_group_manager) == 0 &&
+	    is_zero_ether_addr(dev_addr)) {
+		random_ether_addr(dev_addr);
+		if_printf(ifp, "Assigned random MAC address\n");
+	}
+
 	/* set default MTU */
 	mlx5e_set_dev_port_mtu(ifp, ifp->if_mtu);
 

Modified: stable/10/sys/dev/mlx5/vport.h
==============================================================================
--- stable/10/sys/dev/mlx5/vport.h	Wed Jun 29 10:29:52 2016	(r302269)
+++ stable/10/sys/dev/mlx5/vport.h	Wed Jun 29 10:33:11 2016	(r302270)
@@ -38,6 +38,18 @@ int mlx5_vport_query_out_of_rx_buffer(st
 				      u32 *out_of_rx_buffer);
 
 u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod);
+int mlx5_arm_vport_context_events(struct mlx5_core_dev *mdev,
+				  u8 vport,
+				  u32 events_mask);
+int mlx5_query_vport_promisc(struct mlx5_core_dev *mdev,
+			     u32 vport,
+			     u8 *promisc_uc,
+			     u8 *promisc_mc,
+			     u8 *promisc_all);
+int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
+				  int promisc_uc,
+				  int promisc_mc,
+				  int promisc_all);
 int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
 				     u32 vport, u8 *addr);
 int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport,
@@ -49,6 +61,22 @@ int mlx5_set_nic_vport_mc_list(struct ml
 int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
 			       bool promisc_mc, bool promisc_uc,
 			       bool promisc_all);
+int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
+				  u32 vport,
+				  enum mlx5_list_type list_type,
+				  u8 addr_list[][ETH_ALEN],
+				  int *list_size);
+int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
+				   enum mlx5_list_type list_type,
+				   u8 addr_list[][ETH_ALEN],
+				   int list_size);
+int mlx5_query_nic_vport_vlan_list(struct mlx5_core_dev *dev,
+				   u32 vport,
+				   u16 *vlan_list,
+				   int *list_size);
+int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
+				u16 vlans[],
+				int list_size);
 int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
 				     u8 *addr);
 int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:40:36 2016
Return-Path: 
Delivered-To: svn-src-all@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 52CB2B84A50;
 Wed, 29 Jun 2016 10:40:36 +0000 (UTC)
 (envelope-from hselasky@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 09FC72B47;
 Wed, 29 Jun 2016 10:40:35 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAeZtk057866;
 Wed, 29 Jun 2016 10:40:35 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAeZPC057864;
 Wed, 29 Jun 2016 10:40:35 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291040.u5TAeZPC057864@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:40:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302271 - stable/10/sys/ofed/include/linux
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:40:36 -0000

Author: hselasky
Date: Wed Jun 29 10:40:34 2016
New Revision: 302271
URL: https://svnweb.freebsd.org/changeset/base/302271

Log:
  MFC r301544:
  Fallback to arc4rand() in the LinuxKPI when read_random() returns
  zero. This can happen for virtual machines.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/sys/ofed/include/linux/etherdevice.h
  stable/10/sys/ofed/include/linux/random.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/etherdevice.h
==============================================================================
--- stable/10/sys/ofed/include/linux/etherdevice.h	Wed Jun 29 10:33:11 2016	(r302270)
+++ stable/10/sys/ofed/include/linux/etherdevice.h	Wed Jun 29 10:40:34 2016	(r302271)
@@ -137,7 +137,8 @@ eth_broadcast_addr(u8 *pa)
 static inline void
 random_ether_addr(u8 * dst)
 {
-	read_random(dst, 6);
+	if (read_random(dst, 6) == 0)
+		arc4rand(dst, 6, 0);
 
 	dst[0] &= 0xfe;
 	dst[0] |= 0x02;

Modified: stable/10/sys/ofed/include/linux/random.h
==============================================================================
--- stable/10/sys/ofed/include/linux/random.h	Wed Jun 29 10:33:11 2016	(r302270)
+++ stable/10/sys/ofed/include/linux/random.h	Wed Jun 29 10:40:34 2016	(r302271)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,13 @@
 #define	_LINUX_RANDOM_H_
 
 #include 
+#include 
 
 static inline void
 get_random_bytes(void *buf, int nbytes)
 {
-	read_random(buf, nbytes);
+	if (read_random(buf, nbytes) == 0)
+		arc4rand(buf, nbytes, 0);
 }
 
 #endif	/* _LINUX_RANDOM_H_ */

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:43:32 2016
Return-Path: 
Delivered-To: svn-src-all@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 B3DE0B84AE6;
 Wed, 29 Jun 2016 10:43:32 +0000 (UTC)
 (envelope-from hselasky@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 841742EF9;
 Wed, 29 Jun 2016 10:43:32 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAhVtp061238;
 Wed, 29 Jun 2016 10:43:31 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAhVvL061237;
 Wed, 29 Jun 2016 10:43:31 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291043.u5TAhVvL061237@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:43:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302272 - stable/10/lib/libusb
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:43:32 -0000

Author: hselasky
Date: Wed Jun 29 10:43:31 2016
New Revision: 302272
URL: https://svnweb.freebsd.org/changeset/base/302272

Log:
  MFC r301842:
  Implement code to stop all USB endpoints before executing a USB device
  reset command, alternate setting command or set configuration
  command. Else LibUSB v1.0 will not re-open the endpoints which the
  kernel closes and the USB application might wait infinitely for
  transfers to complete.

Modified:
  stable/10/lib/libusb/libusb10.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10.c
==============================================================================
--- stable/10/lib/libusb/libusb10.c	Wed Jun 29 10:40:34 2016	(r302271)
+++ stable/10/lib/libusb/libusb10.c	Wed Jun 29 10:43:31 2016	(r302272)
@@ -51,6 +51,8 @@
 #include "libusb.h"
 #include "libusb10.h"
 
+#define	LIBUSB_NUM_SW_ENDPOINTS	(16 * 4)
+
 static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
 struct libusb_context *usbi_default_context = NULL;
 
@@ -442,7 +444,7 @@ libusb_open(libusb_device *dev, libusb_d
 	if (dev == NULL)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
-	err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+	err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
 	if (err) {
 		libusb_unref_device(dev);
 		return (LIBUSB_ERROR_NO_MEM);
@@ -1489,7 +1491,17 @@ libusb_cancel_transfer(struct libusb_tra
 UNEXPORTED void
 libusb10_cancel_all_transfer(libusb_device *dev)
 {
-	/* TODO */
+	struct libusb20_device *pdev = dev->os_priv;
+	unsigned x;
+
+	for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+		struct libusb20_transfer *xfer;
+
+		xfer = libusb20_tr_get_pointer(pdev, x);
+		if (xfer == NULL)
+			continue;
+		libusb20_tr_close(xfer);
+	}
 }
 
 uint16_t

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:46:12 2016
Return-Path: 
Delivered-To: svn-src-all@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 2C32BB84B67;
 Wed, 29 Jun 2016 10:46:12 +0000 (UTC)
 (envelope-from hselasky@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 E295620A4;
 Wed, 29 Jun 2016 10:46:11 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAkBBD061404;
 Wed, 29 Jun 2016 10:46:11 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAkBTs061403;
 Wed, 29 Jun 2016 10:46:11 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291046.u5TAkBTs061403@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:46:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r302273 - stable/9/lib/libusb
X-SVN-Group: stable-9
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.22
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: Wed, 29 Jun 2016 10:46:12 -0000

Author: hselasky
Date: Wed Jun 29 10:46:10 2016
New Revision: 302273
URL: https://svnweb.freebsd.org/changeset/base/302273

Log:
  MFC r301842:
  Implement code to stop all USB endpoints before executing a USB device
  reset command, alternate setting command or set configuration
  command. Else LibUSB v1.0 will not re-open the endpoints which the
  kernel closes and the USB application might wait infinitely for
  transfers to complete.

Modified:
  stable/9/lib/libusb/libusb10.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10.c
==============================================================================
--- stable/9/lib/libusb/libusb10.c	Wed Jun 29 10:43:31 2016	(r302272)
+++ stable/9/lib/libusb/libusb10.c	Wed Jun 29 10:46:10 2016	(r302273)
@@ -45,6 +45,8 @@
 #include "libusb.h"
 #include "libusb10.h"
 
+#define	LIBUSB_NUM_SW_ENDPOINTS	(16 * 4)
+
 static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
 struct libusb_context *usbi_default_context = NULL;
 
@@ -436,7 +438,7 @@ libusb_open(libusb_device *dev, libusb_d
 	if (dev == NULL)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
-	err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+	err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
 	if (err) {
 		libusb_unref_device(dev);
 		return (LIBUSB_ERROR_NO_MEM);
@@ -1489,7 +1491,17 @@ libusb_cancel_transfer(struct libusb_tra
 UNEXPORTED void
 libusb10_cancel_all_transfer(libusb_device *dev)
 {
-	/* TODO */
+	struct libusb20_device *pdev = dev->os_priv;
+	unsigned x;
+
+	for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+		struct libusb20_transfer *xfer;
+
+		xfer = libusb20_tr_get_pointer(pdev, x);
+		if (xfer == NULL)
+			continue;
+		libusb20_tr_close(xfer);
+	}
 }
 
 uint16_t

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:47:46 2016
Return-Path: 
Delivered-To: svn-src-all@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 28CECB84C1C;
 Wed, 29 Jun 2016 10:47:46 +0000 (UTC)
 (envelope-from hselasky@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 ED455221C;
 Wed, 29 Jun 2016 10:47:45 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAlj0N061516;
 Wed, 29 Jun 2016 10:47:45 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAlj5J061515;
 Wed, 29 Jun 2016 10:47:45 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291047.u5TAlj5J061515@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:47:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject: svn commit: r302274 - stable/8/lib/libusb
X-SVN-Group: stable-8
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.22
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: Wed, 29 Jun 2016 10:47:46 -0000

Author: hselasky
Date: Wed Jun 29 10:47:44 2016
New Revision: 302274
URL: https://svnweb.freebsd.org/changeset/base/302274

Log:
  MFC r301842:
  Implement code to stop all USB endpoints before executing a USB device
  reset command, alternate setting command or set configuration
  command. Else LibUSB v1.0 will not re-open the endpoints which the
  kernel closes and the USB application might wait infinitely for
  transfers to complete.

Modified:
  stable/8/lib/libusb/libusb10.c
Directory Properties:
  stable/8/lib/   (props changed)
  stable/8/lib/libusb/   (props changed)

Modified: stable/8/lib/libusb/libusb10.c
==============================================================================
--- stable/8/lib/libusb/libusb10.c	Wed Jun 29 10:46:10 2016	(r302273)
+++ stable/8/lib/libusb/libusb10.c	Wed Jun 29 10:47:44 2016	(r302274)
@@ -45,6 +45,8 @@
 #include "libusb.h"
 #include "libusb10.h"
 
+#define	LIBUSB_NUM_SW_ENDPOINTS	(16 * 4)
+
 static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
 struct libusb_context *usbi_default_context = NULL;
 
@@ -423,7 +425,7 @@ libusb_open(libusb_device *dev, libusb_d
 	if (dev == NULL)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
-	err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+	err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
 	if (err) {
 		libusb_unref_device(dev);
 		return (LIBUSB_ERROR_NO_MEM);
@@ -1476,7 +1478,17 @@ libusb_cancel_transfer(struct libusb_tra
 UNEXPORTED void
 libusb10_cancel_all_transfer(libusb_device *dev)
 {
-	/* TODO */
+	struct libusb20_device *pdev = dev->os_priv;
+	unsigned x;
+
+	for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+		struct libusb20_transfer *xfer;
+
+		xfer = libusb20_tr_get_pointer(pdev, x);
+		if (xfer == NULL)
+			continue;
+		libusb20_tr_close(xfer);
+	}
 }
 
 uint16_t

From owner-svn-src-all@freebsd.org  Wed Jun 29 10:58:38 2016
Return-Path: 
Delivered-To: svn-src-all@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 2BC3EB84E97;
 Wed, 29 Jun 2016 10:58:38 +0000 (UTC)
 (envelope-from hselasky@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 E9CF6287A;
 Wed, 29 Jun 2016 10:58:37 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAwbwm065275;
 Wed, 29 Jun 2016 10:58:37 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAwa08065267;
 Wed, 29 Jun 2016 10:58:36 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291058.u5TAwa08065267@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 10:58:36 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302275 - stable/10/lib/libusb
X-SVN-Group: stable-10
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.22
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: Wed, 29 Jun 2016 10:58:38 -0000

Author: hselasky
Date: Wed Jun 29 10:58:36 2016
New Revision: 302275
URL: https://svnweb.freebsd.org/changeset/base/302275

Log:
  MFC r301956, r301957, r301964, r301966, r301968, r301969, r302080,
      r302125 and r302171:
  
  Added multiple new LibUSB v1.0 API functions.
  Refer to the individual commits for more details.

Added:
  stable/10/lib/libusb/libusb10_hotplug.c
     - copied unchanged from r302080, head/lib/libusb/libusb10_hotplug.c
Modified:
  stable/10/lib/libusb/Makefile
  stable/10/lib/libusb/libusb.3
  stable/10/lib/libusb/libusb.h
  stable/10/lib/libusb/libusb10.c
  stable/10/lib/libusb/libusb10.h
  stable/10/lib/libusb/libusb10_desc.c
  stable/10/lib/libusb/libusb10_io.c
  stable/10/lib/libusb/libusb20.c
  stable/10/lib/libusb/libusb20_int.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/Makefile
==============================================================================
--- stable/10/lib/libusb/Makefile	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/Makefile	Wed Jun 29 10:58:36 2016	(r302275)
@@ -32,6 +32,7 @@ SRCS+=		libusb01.c
 INCS+=		libusb.h
 SRCS+=		libusb10.c
 SRCS+=		libusb10_desc.c
+SRCS+=		libusb10_hotplug.c
 SRCS+=		libusb10_io.c
 
 .if defined(COMPAT_32BIT)
@@ -67,6 +68,7 @@ CFLAGS+=	-I ../../sys
 .include 
 
 # LibUSB v1.0
+MLINKS += libusb.3 libusb_get_version.3
 MLINKS += libusb.3 libusb_init.3
 MLINKS += libusb.3 libusb_exit.3
 MLINKS += libusb.3 libusb_strerror.3
@@ -75,6 +77,7 @@ MLINKS += libusb.3 libusb_set_debug.3
 MLINKS += libusb.3 libusb_get_device_list.3
 MLINKS += libusb.3 libusb_free_device_list.3
 MLINKS += libusb.3 libusb_get_bus_number.3
+MLINKS += libusb.3 libusb_get_port_number.3
 MLINKS += libusb.3 libusb_get_device_address.3
 MLINKS += libusb.3 libusb_get_device_speed.3
 MLINKS += libusb.3 libusb_get_max_packet_size.3
@@ -99,6 +102,7 @@ MLINKS += libusb.3 libusb_get_driver_np.
 MLINKS += libusb.3 libusb_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_detach_kernel_driver_np.3
 MLINKS += libusb.3 libusb_attach_kernel_driver.3
+MLINKS += libusb.3 libusb_set_auto_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_get_device_descriptor.3
 MLINKS += libusb.3 libusb_get_active_config_descriptor.3
 MLINKS += libusb.3 libusb_get_config_descriptor.3
@@ -108,10 +112,22 @@ MLINKS += libusb.3 libusb_get_string_des
 MLINKS += libusb.3 libusb_get_string_descriptor_ascii.3
 MLINKS += libusb.3 libusb_parse_ss_endpoint_comp.3
 MLINKS += libusb.3 libusb_free_ss_endpoint_comp.3
+MLINKS += libusb.3 libusb_get_ss_endpoint_companion_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_endpoint_companion_descriptor.3
 MLINKS += libusb.3 libusb_parse_bos_descriptor.3
 MLINKS += libusb.3 libusb_free_bos_descriptor.3
+MLINKS += libusb.3 libusb_get_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_free_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_get_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_get_container_id_descriptor.3
+MLINKS += libusb.3 libusb_free_container_id_descriptor.3
+MLINKS += libusb.3 libusb_alloc_streams.3
+MLINKS += libusb.3 libusb_free_streams.3
 MLINKS += libusb.3 libusb_alloc_transfer.3
 MLINKS += libusb.3 libusb_free_transfer.3
+MLINKS += libusb.3 libusb_transfer_set_stream_id.3
+MLINKS += libusb.3 libusb_transfer_get_stream_id.3
 MLINKS += libusb.3 libusb_submit_transfer.3
 MLINKS += libusb.3 libusb_cancel_transfer.3
 MLINKS += libusb.3 libusb_control_transfer.3
@@ -133,6 +149,8 @@ MLINKS += libusb.3 libusb_handle_events_
 MLINKS += libusb.3 libusb_get_next_timeout.3
 MLINKS += libusb.3 libusb_set_pollfd_notifiers.3
 MLINKS += libusb.3 libusb_get_pollfds.3
+MLINKS += libusb.3 libusb_hotplug_register_callback.3
+MLINKS += libusb.3 libusb_hotplug_deregister_callback.3
 
 # LibUSB v0.1
 MLINKS += libusb.3 usb_open.3

Modified: stable/10/lib/libusb/libusb.3
==============================================================================
--- stable/10/lib/libusb/libusb.3	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/libusb.3	Wed Jun 29 10:58:36 2016	(r302275)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 5, 2014
+.Dd June 23, 2016
 .Dt LIBUSB 3
 .Os
 .Sh NAME
@@ -43,6 +43,10 @@ The
 library contains interfaces for directly managing a usb device.
 The current implementation supports v1.0 of the libusb API.
 .Sh LIBRARY INITIALISATION / DEINITIALISATION
+.Ft "const struct libusb_version *"
+.Fn libusb_get_version "void"
+This function returns version information about LibUSB.
+.Pp
 .Ft int
 .Fn libusb_init libusb_context **ctx
 This function initialises libusb.
@@ -102,6 +106,12 @@ counter decremented once.
 Returns the number of the bus contained by the device
 .Fa dev .
 .Pp
+.Ft uint8_t
+.Fn libusb_get_port_number "libusb_device *dev"
+Returns the port number which the device given by
+.Fa dev
+is attached to.
+.Pp
 .Ft int
 .Fn libusb_get_port_numbers "libusb_device *dev" "uint8_t *buf" "uint8_t bufsize"
 Stores, in the buffer
@@ -288,6 +298,18 @@ LIBUSB_ERROR_NO_DEVICE
 if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be
 attached because the interface is claimed by a program or driver and a
 LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_set_auto_detach_kernel_driver "libusb_device_handle *devh" "int enable"
+This function enables automatic kernel interface driver detach when an
+interface is claimed.
+When the interface is restored the kernel driver is allowed to be re-attached.
+If the
+.Fa enable
+argument is non-zero the feature is enabled.
+Else disabled.
+Returns 0 on success and a LIBUSB_ERROR code on
+failure.
 .Sh USB DESCRIPTORS
 .Ft int
 .Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc"
@@ -354,7 +376,31 @@ freed using the libusb_free_ss_endpoint_
 .Pp
 .Ft void
 .Fn libusb_free_ss_endpoint_comp "libusb_ss_endpoint_companion_descriptor *ep_comp"
-This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor.
+This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor given by
+.Fa ep_comp .
+.Pp
+.Ft int
+.Fn libusb_get_ss_endpoint_companion_descriptor "struct libusb_context *ctx" "const struct libusb_endpoint_descriptor *endpoint" "struct libusb_ss_endpoint_companion_descriptor **ep_comp"
+This function finds and parses the USB 3.0 endpoint companion descriptor given by
+.Fa endpoint .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed USB 3.0 endpoint companion descriptor must be
+freed using the libusb_free_ss_endpoint_companion_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_ss_endpoint_companion_descriptor "struct libusb_ss_endpoint_companion_descriptor *ep_comp"
+This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor given by
+.Fa ep_comp .
+.Pp
+.Ft int
+.Fn libusb_get_bos_descriptor "libusb_device_handle *handle" "struct libusb_bos_descriptor **bos"
+This function queries the USB device given by
+.Fa handle
+and stores a pointer to a parsed BOS descriptor into
+.Fa bos .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed BOS descriptor must be
+freed using the libusb_free_bos_descriptor function.
 .Pp
 .Ft int
 .Fn libusb_parse_bos_descriptor "const void *buf" "int len" "libusb_bos_descriptor **bos"
@@ -370,7 +416,53 @@ libusb_free_bos_descriptor function.
 .Pp
 .Ft void
 .Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos"
-This function is NULL safe and frees a parsed BOS descriptor.
+This function is NULL safe and frees a parsed BOS descriptor given by
+.Fa bos .
+.Pp
+.Ft int
+.Fn libusb_get_usb_2_0_extension_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension"
+This function parses the USB 2.0 extension descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa usb_2_0_extension .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed USB 2.0 extension descriptor must be freed using the
+libusb_free_usb_2_0_extension_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_usb_2_0_extension_descriptor "struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension"
+This function is NULL safe and frees a parsed USB 2.0 extension descriptor given by
+.Fa usb_2_0_extension .
+.Pp
+.Ft int
+.Fn libusb_get_ss_usb_device_capability_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability"
+This function parses the SuperSpeed device capability descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa ss_usb_device_capability .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed SuperSpeed device capability descriptor must be freed using the
+libusb_free_ss_usb_device_capability_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_ss_usb_device_capability_descriptor "struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability"
+This function is NULL safe and frees a parsed SuperSpeed device capability descriptor given by
+.Fa ss_usb_device_capability .
+.Pp
+.Ft int
+.Fn libusb_get_container_id_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_container_id_descriptor **container_id"
+This function parses the container ID descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa container_id .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed container ID descriptor must be freed using the
+libusb_free_container_id_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_container_id_descriptor "struct libusb_container_id_descriptor *container_id"
+This function is NULL safe and frees a parsed container ID descriptor given by
+.Fa container_id .
 .Sh USB ASYNCHRONOUS I/O
 .Ft struct libusb_transfer *
 .Fn libusb_alloc_transfer "int iso_packets"
@@ -429,6 +521,29 @@ if the transfer timed out, LIBUSB_ERROR_
 supported, LIBUSB_ERROR_OVERFLOW if the device offered more data,
 LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
 a LIBUSB_ERROR code on other failure.
+.Sh USB STREAMS SUPPORT
+.Ft int
+.Fn libusb_alloc_streams "libusb_device_handle *dev" "uint32_t num_streams" "unsigned char *endpoints" "int num_endpoints"
+This function verifies that the given number of streams using the
+given number of endpoints is allowed and allocates the resources
+needed to use so-called USB streams.
+Currently only a single stream per endpoint is supported to simplify
+the internals of LibUSB.
+This function returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_free_streams "libusb_device_handle *dev" "unsigned char *endpoints" "int num_endpoints"
+This function release resources needed for streams usage.
+Returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft void
+.Fn libusb_transfer_set_stream_id "struct libusb_transfer *transfer" "uint32_t stream_id"
+This function sets the stream ID for the given USB transfer.
+.Pp
+.Ft uint32_t
+.Fn libusb_transfer_get_stream_id "struct libusb_transfer *transfer"
+This function returns the stream ID for the given USB transfer.
+If no stream ID is used a value of zero is returned.
 .Sh USB EVENTS
 .Ft int
 .Fn libusb_try_lock_events "libusb_context *ctx"
@@ -550,6 +665,47 @@ that libusb uses as an event source.
 Retrive a list of file descriptors that should be polled by your main loop as
 libusb event sources.
 Returns a NULL-terminated list on success or NULL on failure.
+.Pp
+.Ft int
+.Fn libusb_hotplug_register_callback "libusb_context *ctx" "libusb_hotplug_event events" "libusb_hotplug_flag flags" "int vendor_id" "int product_id" "int dev_class" "libusb_hotplug_callback_fn cb_fn" "void *user_data" "libusb_hotplug_callback_handle *handle"
+This function registers a hotplug filter.
+The
+.Fa events
+argument select which events makes the hotplug filter trigger.
+Available event values are LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED and LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT.
+One or more events must be specified.
+The
+.Fa vendor_id ,
+.Fa product_id
+and
+.Fa dev_class
+arguments can be set to LIBUSB_HOTPLUG_MATCH_ANY to match any value in the USB device descriptor.
+Else the specified value is used for matching.
+If the
+.Fa flags
+argument is set to LIBUSB_HOTPLUG_ENUMERATE, all currently attached and matching USB devices will be passed to the hotplug filter, given by the
+.Fa cb_fn
+argument.
+Else the
+.Fa flags
+argument should be set to LIBUSB_HOTPLUG_NO_FLAGS.
+This function returns 0 upon success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_hotplug_callback_fn "libusb_context *ctx" "libusb_device *device" "libusb_hotplug_event event" "void *user_data"
+The hotplug filter function.
+If this function returns non-zero, the filter is removed.
+Else the filter is kept and can receive more events.
+The
+.Fa user_data
+argument is the same as given when the filter was registered.
+The
+.Fa event
+argument can be either of LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED or LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT.
+.Pp
+.Ft void
+.Fn libusb_hotplug_deregister_callback "libusb_context *ctx" "libusb_hotplug_callback_handle handle"
+This function unregisters a hotplug filter.
 .Sh LIBUSB VERSION 0.1 COMPATIBILITY
 The library is also compliant with LibUSB version 0.1.12.
 .Pp

Modified: stable/10/lib/libusb/libusb.h
==============================================================================
--- stable/10/lib/libusb/libusb.h	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/libusb.h	Wed Jun 29 10:58:36 2016	(r302275)
@@ -33,6 +33,8 @@
 #include 
 #endif
 
+#define	LIBUSB_API_VERSION 0x01000102
+
 #define	LIBUSB_CALL
 
 #ifdef __cplusplus
@@ -99,6 +101,10 @@ enum libusb_device_capability_type {
 #define	LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE	7
 #define	LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE	10
 
+#define	LIBUSB_BT_USB_2_0_EXTENSION_SIZE	7
+#define	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE	10
+#define	LIBUSB_BT_CONTAINER_ID_SIZE		20
+
 #define	LIBUSB_ENDPOINT_ADDRESS_MASK	0x0f
 #define	LIBUSB_ENDPOINT_DIR_MASK	0x80
 
@@ -163,6 +169,13 @@ enum libusb_iso_usage_type {
 	LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
 };
 
+enum libusb_bos_type {
+	LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
+	LIBUSB_BT_USB_2_0_EXTENSION = 2,
+	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
+	LIBUSB_BT_CONTAINER_ID = 4,
+};
+
 enum libusb_error {
 	LIBUSB_SUCCESS = 0,
 	LIBUSB_ERROR_IO = -1,
@@ -223,24 +236,47 @@ enum libusb_debug_level {
 	LIBUSB_DEBUG_TRANSFER=2,
 };
 
+#define	LIBUSB_HOTPLUG_MATCH_ANY -1
+
+typedef enum {
+	LIBUSB_HOTPLUG_NO_FLAGS = 0,
+	LIBUSB_HOTPLUG_ENUMERATE = 1 << 0,
+} libusb_hotplug_flag;
+
+typedef enum {
+	LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 1,
+	LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 2,
+} libusb_hotplug_event;
+
 /* libusb structures */
 
 struct libusb_context;
 struct libusb_device;
 struct libusb_transfer;
 struct libusb_device_handle;
+struct libusb_hotplug_callback_handle_struct;
 
 struct libusb_pollfd {
 	int	fd;
 	short	events;
 };
 
+struct libusb_version {
+	const uint16_t major;
+	const uint16_t minor;
+	const uint16_t micro;
+	const uint16_t nano;
+	const char *rc;
+	const char *describe;
+};
+
 typedef struct libusb_context libusb_context;
 typedef struct libusb_device libusb_device;
 typedef struct libusb_device_handle libusb_device_handle;
 typedef struct libusb_pollfd libusb_pollfd;
 typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data);
 typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data);
+typedef struct libusb_hotplug_callback_handle_struct *libusb_hotplug_callback_handle;
 
 typedef struct libusb_device_descriptor {
 	uint8_t	bLength;
@@ -338,6 +374,13 @@ typedef struct libusb_ss_usb_device_capa
 	uint16_t wU2DevExitLat;
 }	libusb_ss_usb_device_capability_descriptor __aligned(sizeof(void *));
 
+typedef struct libusb_bos_dev_capability_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint8_t dev_capability_data[0];
+}	libusb_bos_dev_capability_descriptor __aligned(sizeof(void *));
+
 typedef struct libusb_bos_descriptor {
 	uint8_t bLength;
 	uint8_t bDescriptorType;
@@ -347,6 +390,21 @@ typedef struct libusb_bos_descriptor {
 	struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap;
 }	libusb_bos_descriptor __aligned(sizeof(void *));
 
+typedef struct libusb_usb_2_0_extension_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint32_t bmAttributes;
+}	libusb_usb_2_0_extension_descriptor __aligned(sizeof(void *));
+
+typedef struct libusb_container_id_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint8_t	bReserved;
+	uint8_t ContainerID[16];
+}	libusb_container_id_descriptor __aligned(sizeof(void *));
+
 typedef struct libusb_control_setup {
 	uint8_t	bmRequestType;
 	uint8_t	bRequest;
@@ -384,6 +442,7 @@ typedef struct libusb_transfer {
 /* Library initialisation */
 
 void	libusb_set_debug(libusb_context * ctx, int level);
+const struct libusb_version *libusb_get_version(void);
 const char *libusb_strerror(int code);
 const char *libusb_error_name(int code);
 int	libusb_init(libusb_context ** context);
@@ -394,6 +453,7 @@ void	libusb_exit(struct libusb_context *
 ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list);
 void	libusb_free_device_list(libusb_device ** list, int unref_devices);
 uint8_t	libusb_get_bus_number(libusb_device * dev);
+uint8_t	libusb_get_port_number(libusb_device * dev);
 int	libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize);
 int	libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize);
 uint8_t	libusb_get_device_address(libusb_device * dev);
@@ -419,6 +479,7 @@ int	libusb_get_driver(libusb_device_hand
 int 	libusb_detach_kernel_driver_np(libusb_device_handle * devh, int interface);
 int 	libusb_detach_kernel_driver(libusb_device_handle * devh, int interface);
 int 	libusb_attach_kernel_driver(libusb_device_handle * devh, int interface);
+int	libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable);
 int	libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting);
 
 /* USB Descriptors */
@@ -428,6 +489,8 @@ int	libusb_get_active_config_descriptor(
 int	libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
 int	libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
 void	libusb_free_config_descriptor(struct libusb_config_descriptor *config);
+int	libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
+void	libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp);
 int	libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length);
 int	libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
 int	libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
@@ -435,6 +498,13 @@ int	libusb_parse_ss_endpoint_comp(const 
 void	libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp);
 int	libusb_parse_bos_descriptor(const void *buf, int len, struct libusb_bos_descriptor **bos);
 void	libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
+int	libusb_get_bos_descriptor(libusb_device_handle *handle, struct libusb_bos_descriptor **bos);
+int	libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
+void	libusb_free_usb_2_0_extension_descriptor(struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
+int	libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability);
+void	libusb_free_ss_usb_device_capability_descriptor(struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability);
+int	libusb_get_container_id_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id);
+void	libusb_free_container_id_descriptor(struct libusb_container_id_descriptor *container_id);
 
 /* Asynchronous device I/O */
 
@@ -483,6 +553,21 @@ int	libusb_interrupt_transfer(libusb_dev
 uint16_t libusb_cpu_to_le16(uint16_t x);
 uint16_t libusb_le16_to_cpu(uint16_t x);
 
+/* Hotplug support */
+
+typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx,
+    libusb_device *device, libusb_hotplug_event event, void *user_data);
+
+int	libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle);
+void	libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle);
+
+/* Streams support */
+
+int	libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
+int	libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints);
+void	libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id);
+uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer);
+
 #if 0
 {					/* indent fix */
 #endif

Modified: stable/10/lib/libusb/libusb10.c
==============================================================================
--- stable/10/lib/libusb/libusb10.c	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/libusb10.c	Wed Jun 29 10:58:36 2016	(r302275)
@@ -69,6 +69,22 @@ static void libusb10_submit_transfer_sub
 
 /*  Library initialisation / deinitialisation */
 
+static const struct libusb_version libusb_version = {
+	.major = 1,
+	.minor = 0,
+	.micro = 0,
+	.nano = 2016,
+	.rc = "",
+	.describe = "http://www.freebsd.org"
+};
+
+const struct libusb_version *
+libusb_get_version(void)
+{
+
+	return (&libusb_version);
+}
+
 void
 libusb_set_debug(libusb_context *ctx, int level)
 {
@@ -118,24 +134,34 @@ libusb_init(libusb_context **context)
 	}
 	TAILQ_INIT(&ctx->pollfds);
 	TAILQ_INIT(&ctx->tr_done);
+	TAILQ_INIT(&ctx->hotplug_cbh);
+	TAILQ_INIT(&ctx->hotplug_devs);
 
 	if (pthread_mutex_init(&ctx->ctx_lock, NULL) != 0) {
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
 	}
+	if (pthread_mutex_init(&ctx->hotplug_lock, NULL) != 0) {
+		pthread_mutex_destroy(&ctx->ctx_lock);
+		free(ctx);
+		return (LIBUSB_ERROR_NO_MEM);
+	}
 	if (pthread_condattr_init(&attr) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
 	}
 	if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_condattr_destroy(&attr);
 		free(ctx);
 		return (LIBUSB_ERROR_OTHER);
 	}
 	if (pthread_cond_init(&ctx->ctx_cond, &attr) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_condattr_destroy(&attr);
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
@@ -143,10 +169,12 @@ libusb_init(libusb_context **context)
 	pthread_condattr_destroy(&attr);
 
 	ctx->ctx_handler = NO_THREAD;
+	ctx->hotplug_handler = NO_THREAD;
 
 	ret = pipe(ctx->ctrl_pipe);
 	if (ret < 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_cond_destroy(&ctx->ctx_cond);
 		free(ctx);
 		return (LIBUSB_ERROR_OTHER);
@@ -179,12 +207,27 @@ libusb_exit(libusb_context *ctx)
 	if (ctx == NULL)
 		return;
 
+	/* stop hotplug thread, if any */
+
+	if (ctx->hotplug_handler != NO_THREAD) {
+		pthread_t td;
+		void *ptr;
+
+		HOTPLUG_LOCK(ctx);
+		td = ctx->hotplug_handler;
+		ctx->hotplug_handler = NO_THREAD;
+		HOTPLUG_UNLOCK(ctx);
+
+		pthread_join(td, &ptr);
+	}
+
 	/* XXX cleanup devices */
 
 	libusb10_remove_pollfd(ctx, &ctx->ctx_poll);
 	close(ctx->ctrl_pipe[0]);
 	close(ctx->ctrl_pipe[1]);
 	pthread_mutex_destroy(&ctx->ctx_lock);
+	pthread_mutex_destroy(&ctx->hotplug_lock);
 	pthread_cond_destroy(&ctx->ctx_cond);
 
 	pthread_mutex_lock(&default_context_lock);
@@ -292,6 +335,14 @@ libusb_get_bus_number(libusb_device *dev
 	return (libusb20_dev_get_bus_number(dev->os_priv));
 }
 
+uint8_t
+libusb_get_port_number(libusb_device *dev)
+{
+	if (dev == NULL)
+		return (0);		/* should not happen */
+	return (libusb20_dev_get_parent_port(dev->os_priv));
+}
+
 int
 libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize)
 {
@@ -613,6 +664,7 @@ int
 libusb_claim_interface(struct libusb20_device *pdev, int interface_number)
 {
 	libusb_device *dev;
+	int err = 0;
 
 	dev = libusb_get_device(pdev);
 	if (dev == NULL)
@@ -621,11 +673,17 @@ libusb_claim_interface(struct libusb20_d
 	if (interface_number < 0 || interface_number > 31)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
+	if (pdev->auto_detach != 0) {
+		err = libusb_detach_kernel_driver(pdev, interface_number);
+		if (err != 0)
+			goto done;
+	}
+
 	CTX_LOCK(dev->ctx);
 	dev->claimed_interfaces |= (1 << interface_number);
 	CTX_UNLOCK(dev->ctx);
-
-	return (0);
+done:
+	return (err);
 }
 
 int
@@ -641,13 +699,19 @@ libusb_release_interface(struct libusb20
 	if (interface_number < 0 || interface_number > 31)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
+	if (pdev->auto_detach != 0) {
+		err = libusb_attach_kernel_driver(pdev, interface_number);
+		if (err != 0)
+			goto done;
+	}
+
 	CTX_LOCK(dev->ctx);
 	if (!(dev->claimed_interfaces & (1 << interface_number)))
 		err = LIBUSB_ERROR_NOT_FOUND;
-
-	if (!err)
+	else
 		dev->claimed_interfaces &= ~(1 << interface_number);
 	CTX_UNLOCK(dev->ctx);
+done:
 	return (err);
 }
 
@@ -849,6 +913,13 @@ libusb_attach_kernel_driver(struct libus
 	return (0);
 }
 
+int
+libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable)
+{
+	dev->auto_detach = (enable ? 1 : 0);
+	return (0);
+}
+
 /* Asynchronous device I/O */
 
 struct libusb_transfer *
@@ -1339,7 +1410,8 @@ found:
 	maxframe = libusb10_get_maxframe(pdev, uxfer);
 
 	/* make sure the transfer is opened */
-	err = libusb20_tr_open(pxfer0, buffsize, maxframe, endpoint);
+	err = libusb20_tr_open_stream(pxfer0, buffsize, maxframe,
+	    endpoint, sxfer->stream_id);
 	if (err && (err != LIBUSB20_ERROR_BUSY)) {
 		goto failure;
 	}

Modified: stable/10/lib/libusb/libusb10.h
==============================================================================
--- stable/10/lib/libusb/libusb10.h	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/libusb10.h	Wed Jun 29 10:58:36 2016	(r302275)
@@ -36,6 +36,8 @@
 #define	CTX_LOCK(ctx) pthread_mutex_lock(&(ctx)->ctx_lock)
 #define	CTX_TRYLOCK(ctx) pthread_mutex_trylock(&(ctx)->ctx_lock)
 #define	CTX_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->ctx_lock)
+#define	HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
+#define	HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
 
 #define	DPRINTF(ctx, dbg, format, args...) do {	\
     if ((ctx)->debug == dbg) {			\
@@ -67,11 +69,22 @@ struct libusb_super_transfer {
 	uint8_t *curr_data;
 	uint32_t rem_len;
 	uint32_t last_len;
+	uint32_t stream_id;
 	uint8_t	state;
 #define	LIBUSB_SUPER_XFER_ST_NONE 0
 #define	LIBUSB_SUPER_XFER_ST_PEND 1
 };
 
+struct libusb_hotplug_callback_handle_struct {
+	TAILQ_ENTRY(libusb_hotplug_callback_handle_struct) entry;
+	int events;
+	int vendor;
+	int product;
+	int devclass;
+	libusb_hotplug_callback_fn fn;
+	void *user_data;
+};
+
 struct libusb_context {
 	int	debug;
 	int	debug_fixed;
@@ -80,12 +93,16 @@ struct libusb_context {
 	int	tr_done_gen;
 
 	pthread_mutex_t ctx_lock;
+  	pthread_mutex_t hotplug_lock;
 	pthread_cond_t ctx_cond;
+	pthread_t hotplug_handler;
 	pthread_t ctx_handler;
 #define	NO_THREAD ((pthread_t)-1)
 
 	TAILQ_HEAD(, libusb_super_pollfd) pollfds;
 	TAILQ_HEAD(, libusb_super_transfer) tr_done;
+	TAILQ_HEAD(, libusb_hotplug_callback_handle_struct) hotplug_cbh;
+  	TAILQ_HEAD(, libusb_device) hotplug_devs;
 
 	struct libusb_super_pollfd ctx_poll;
 
@@ -103,6 +120,8 @@ struct libusb_device {
 
 	struct libusb_context *ctx;
 
+	TAILQ_ENTRY(libusb_device) hotplug_entry;
+
 	TAILQ_HEAD(, libusb_super_transfer) tr_head;
 
 	struct libusb20_device *os_priv;

Modified: stable/10/lib/libusb/libusb10_desc.c
==============================================================================
--- stable/10/lib/libusb/libusb10_desc.c	Wed Jun 29 10:47:44 2016	(r302274)
+++ stable/10/lib/libusb/libusb10_desc.c	Wed Jun 29 10:58:36 2016	(r302275)
@@ -410,6 +410,23 @@ libusb_free_ss_endpoint_comp(struct libu
 }
 
 int
+libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx,
+    const struct libusb_endpoint_descriptor *endpoint,
+    struct libusb_ss_endpoint_companion_descriptor **ep_comp)
+{
+	if (endpoint == NULL)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	return (libusb_parse_ss_endpoint_comp(endpoint->extra, endpoint->extra_length, ep_comp));
+}
+
+void
+libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp)
+{
+
+	libusb_free_ss_endpoint_comp(ep_comp);
+}
+
+int
 libusb_parse_bos_descriptor(const void *buf, int len,
     struct libusb_bos_descriptor **bos)
 {
@@ -520,3 +537,154 @@ libusb_free_bos_descriptor(struct libusb
 
 	free(bos);
 }
+
+int
+libusb_get_bos_descriptor(libusb_device_handle *handle,
+    struct libusb_bos_descriptor **bos)
+{
+	uint8_t bos_header[LIBUSB_DT_BOS_SIZE] = {0};
+	uint16_t wTotalLength;
+	uint8_t *bos_data;
+	int err;
+
+	err = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0,
+	    bos_header, sizeof(bos_header));
+	if (err < 0)
+		return (err);
+
+	wTotalLength = bos_header[2] | (bos_header[3] << 8);
+	if (wTotalLength < LIBUSB_DT_BOS_SIZE)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
+	bos_data = calloc(wTotalLength, 1);
+	if (bos_data == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	err = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0,
+	    bos_data, wTotalLength);
+	if (err < 0)
+		goto done;
+
+	/* avoid descriptor length mismatches */
+	bos_data[2] = (wTotalLength & 0xFF);
+	bos_data[3] = (wTotalLength >> 8);
+
+	err = libusb_parse_bos_descriptor(bos_data, wTotalLength, bos);
+done:
+	free(bos_data);
+	return (err);
+}
+
+int
+libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
+{
+	struct libusb_usb_2_0_extension_descriptor *desc;
+
+	if (dev_cap == NULL || usb_2_0_extension == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_USB_2_0_EXTENSION)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_USB_2_0_EXTENSION_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bmAttributes =
+	    (dev_cap->dev_capability_data[0]) |
+	    (dev_cap->dev_capability_data[1] << 8) |
+	    (dev_cap->dev_capability_data[2] << 16) |
+	    (dev_cap->dev_capability_data[3] << 24);
+
+	*usb_2_0_extension = desc;
+	return (0);
+}
+
+void
+libusb_free_usb_2_0_extension_descriptor(
+    struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
+{
+
+	free(usb_2_0_extension);
+}
+
+int
+libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability)
+{
+	struct libusb_ss_usb_device_capability_descriptor *desc;
+
+	if (dev_cap == NULL || ss_usb_device_capability == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bmAttributes = dev_cap->dev_capability_data[0];
+	desc->wSpeedSupported = dev_cap->dev_capability_data[1] |
+	    (dev_cap->dev_capability_data[2] << 8);
+	desc->bFunctionalitySupport = dev_cap->dev_capability_data[3];
+	desc->bU1DevExitLat = dev_cap->dev_capability_data[4];
+	desc->wU2DevExitLat = dev_cap->dev_capability_data[5] |
+	    (dev_cap->dev_capability_data[6] << 8);
+
+	*ss_usb_device_capability = desc;
+	return (0);
+}
+
+void
+libusb_free_ss_usb_device_capability_descriptor(
+    struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability)
+{
+
+	free(ss_usb_device_capability);
+}
+
+int
+libusb_get_container_id_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_container_id_descriptor **container_id)
+{
+	struct libusb_container_id_descriptor *desc;
+
+	if (dev_cap == NULL || container_id == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_CONTAINER_ID_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bReserved = dev_cap->dev_capability_data[0];
+	memcpy(desc->ContainerID, dev_cap->dev_capability_data + 1,
+	    sizeof(desc->ContainerID));
+
+	*container_id = desc;
+	return (0);
+}
+
+void
+libusb_free_container_id_descriptor(
+    struct libusb_container_id_descriptor *container_id)
+{
+
+	free(container_id);
+}

Copied: stable/10/lib/libusb/libusb10_hotplug.c (from r302080, head/lib/libusb/libusb10_hotplug.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/lib/libusb/libusb10_hotplug.c	Wed Jun 29 10:58:36 2016	(r302275, copy of r302080, head/lib/libusb/libusb10_hotplug.c)
@@ -0,0 +1,237 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef LIBUSB_GLOBAL_INCLUDE_FILE
+#include LIBUSB_GLOBAL_INCLUDE_FILE
+#else
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
+#define	libusb_device_handle libusb20_device
+
+#include "libusb20.h"
+#include "libusb20_desc.h"
+#include "libusb20_int.h"
+#include "libusb.h"
+#include "libusb10.h"
+
+static int
+libusb_hotplug_equal(libusb_device *_adev, libusb_device *_bdev)
+{
+	struct libusb20_device *adev = _adev->os_priv;
+	struct libusb20_device *bdev = _bdev->os_priv;
+
+	if (adev->bus_number != bdev->bus_number)
+		return (0);
+	if (adev->device_address != bdev->device_address)
+		return (0);
+	if (memcmp(&adev->ddesc, &bdev->ddesc, sizeof(adev->ddesc)))
+		return (0);
+	if (memcmp(&adev->session_data, &bdev->session_data, sizeof(adev->session_data)))
+		return (0);
+	return (1);
+}
+
+static int
+libusb_hotplug_filter(libusb_context *ctx, libusb_hotplug_callback_handle pcbh,
+    libusb_device *dev, libusb_hotplug_event event)
+{
+	if (!(pcbh->events & event))
+		return (0);
+	if (pcbh->vendor != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->vendor != libusb20_dev_get_device_desc(dev->os_priv)->idVendor)
+		return (0);
+	if (pcbh->product != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->product != libusb20_dev_get_device_desc(dev->os_priv)->idProduct)
+		return (0);
+	if (pcbh->devclass != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->devclass != libusb20_dev_get_device_desc(dev->os_priv)->bDeviceClass)
+		return (0);
+	return (pcbh->fn(ctx, dev, event, pcbh->user_data));
+}
+
+static void *
+libusb_hotplug_scan(void *arg)
+{
+	TAILQ_HEAD(, libusb_device) hotplug_devs;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-all@freebsd.org  Wed Jun 29 11:06:15 2016
Return-Path: 
Delivered-To: svn-src-all@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 42733B8510B;
 Wed, 29 Jun 2016 11:06:15 +0000 (UTC)
 (envelope-from hselasky@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 0D6CD2CD1;
 Wed, 29 Jun 2016 11:06:14 +0000 (UTC)
 (envelope-from hselasky@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TB6E53068845;
 Wed, 29 Jun 2016 11:06:14 GMT (envelope-from hselasky@FreeBSD.org)
Received: (from hselasky@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TB6DIe068837;
 Wed, 29 Jun 2016 11:06:13 GMT (envelope-from hselasky@FreeBSD.org)
Message-Id: <201606291106.u5TB6DIe068837@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hselasky set sender to
 hselasky@FreeBSD.org using -f
From: Hans Petter Selasky 
Date: Wed, 29 Jun 2016 11:06:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject: svn commit: r302276 - stable/9/lib/libusb
X-SVN-Group: stable-9
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.22
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: Wed, 29 Jun 2016 11:06:15 -0000

Author: hselasky
Date: Wed Jun 29 11:06:13 2016
New Revision: 302276
URL: https://svnweb.freebsd.org/changeset/base/302276

Log:
  MFC r301956, r301957, r301964, r301966, r301968, r301969, r302080,
      r302125 and r302171:
  
  Added multiple new LibUSB v1.0 API functions.
  Streams support is only available in FreeBSD 10+.
  Refer to the individual commits for more details.

Added:
  stable/9/lib/libusb/libusb10_hotplug.c
     - copied unchanged from r302080, head/lib/libusb/libusb10_hotplug.c
Modified:
  stable/9/lib/libusb/Makefile
  stable/9/lib/libusb/libusb.3
  stable/9/lib/libusb/libusb.h
  stable/9/lib/libusb/libusb10.c
  stable/9/lib/libusb/libusb10.h
  stable/9/lib/libusb/libusb10_desc.c
  stable/9/lib/libusb/libusb10_io.c
  stable/9/lib/libusb/libusb20.c
  stable/9/lib/libusb/libusb20_int.h
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/Makefile
==============================================================================
--- stable/9/lib/libusb/Makefile	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/Makefile	Wed Jun 29 11:06:13 2016	(r302276)
@@ -31,6 +31,7 @@ SRCS+=		libusb01.c
 INCS+=		libusb.h
 SRCS+=		libusb10.c
 SRCS+=		libusb10_desc.c
+SRCS+=		libusb10_hotplug.c
 SRCS+=		libusb10_io.c
 
 .if defined(COMPAT_32BIT)
@@ -40,6 +41,7 @@ CFLAGS+=	-DCOMPAT_32BIT
 .include 
 
 # LibUSB v1.0
+MLINKS += libusb.3 libusb_get_version.3
 MLINKS += libusb.3 libusb_init.3
 MLINKS += libusb.3 libusb_exit.3
 MLINKS += libusb.3 libusb_strerror.3
@@ -48,6 +50,7 @@ MLINKS += libusb.3 libusb_set_debug.3
 MLINKS += libusb.3 libusb_get_device_list.3
 MLINKS += libusb.3 libusb_free_device_list.3
 MLINKS += libusb.3 libusb_get_bus_number.3
+MLINKS += libusb.3 libusb_get_port_number.3
 MLINKS += libusb.3 libusb_get_device_address.3
 MLINKS += libusb.3 libusb_get_device_speed.3
 MLINKS += libusb.3 libusb_get_max_packet_size.3
@@ -72,6 +75,7 @@ MLINKS += libusb.3 libusb_get_driver_np.
 MLINKS += libusb.3 libusb_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_detach_kernel_driver_np.3
 MLINKS += libusb.3 libusb_attach_kernel_driver.3
+MLINKS += libusb.3 libusb_set_auto_detach_kernel_driver.3
 MLINKS += libusb.3 libusb_get_device_descriptor.3
 MLINKS += libusb.3 libusb_get_active_config_descriptor.3
 MLINKS += libusb.3 libusb_get_config_descriptor.3
@@ -81,10 +85,22 @@ MLINKS += libusb.3 libusb_get_string_des
 MLINKS += libusb.3 libusb_get_string_descriptor_ascii.3
 MLINKS += libusb.3 libusb_parse_ss_endpoint_comp.3
 MLINKS += libusb.3 libusb_free_ss_endpoint_comp.3
+MLINKS += libusb.3 libusb_get_ss_endpoint_companion_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_endpoint_companion_descriptor.3
 MLINKS += libusb.3 libusb_parse_bos_descriptor.3
 MLINKS += libusb.3 libusb_free_bos_descriptor.3
+MLINKS += libusb.3 libusb_get_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_free_usb_2_0_extension_descriptor.3
+MLINKS += libusb.3 libusb_get_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_free_ss_usb_device_capability_descriptor.3
+MLINKS += libusb.3 libusb_get_container_id_descriptor.3
+MLINKS += libusb.3 libusb_free_container_id_descriptor.3
+MLINKS += libusb.3 libusb_alloc_streams.3
+MLINKS += libusb.3 libusb_free_streams.3
 MLINKS += libusb.3 libusb_alloc_transfer.3
 MLINKS += libusb.3 libusb_free_transfer.3
+MLINKS += libusb.3 libusb_transfer_set_stream_id.3
+MLINKS += libusb.3 libusb_transfer_get_stream_id.3
 MLINKS += libusb.3 libusb_submit_transfer.3
 MLINKS += libusb.3 libusb_cancel_transfer.3
 MLINKS += libusb.3 libusb_control_transfer.3
@@ -106,6 +122,8 @@ MLINKS += libusb.3 libusb_handle_events_
 MLINKS += libusb.3 libusb_get_next_timeout.3
 MLINKS += libusb.3 libusb_set_pollfd_notifiers.3
 MLINKS += libusb.3 libusb_get_pollfds.3
+MLINKS += libusb.3 libusb_hotplug_register_callback.3
+MLINKS += libusb.3 libusb_hotplug_deregister_callback.3
 
 # LibUSB v0.1
 MLINKS += libusb.3 usb_open.3

Modified: stable/9/lib/libusb/libusb.3
==============================================================================
--- stable/9/lib/libusb/libusb.3	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/libusb.3	Wed Jun 29 11:06:13 2016	(r302276)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 5, 2014
+.Dd June 23, 2016
 .Dt LIBUSB 3
 .Os
 .Sh NAME
@@ -43,6 +43,10 @@ The
 library contains interfaces for directly managing a usb device.
 The current implementation supports v1.0 of the libusb API.
 .Sh LIBRARY INITIALISATION / DEINITIALISATION
+.Ft "const struct libusb_version *"
+.Fn libusb_get_version "void"
+This function returns version information about LibUSB.
+.Pp
 .Ft int
 .Fn libusb_init libusb_context **ctx
 This function initialises libusb.
@@ -102,6 +106,12 @@ counter decremented once.
 Returns the number of the bus contained by the device
 .Fa dev .
 .Pp
+.Ft uint8_t
+.Fn libusb_get_port_number "libusb_device *dev"
+Returns the port number which the device given by
+.Fa dev
+is attached to.
+.Pp
 .Ft int
 .Fn libusb_get_port_numbers "libusb_device *dev" "uint8_t *buf" "uint8_t bufsize"
 Stores, in the buffer
@@ -288,6 +298,18 @@ LIBUSB_ERROR_NO_DEVICE
 if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be
 attached because the interface is claimed by a program or driver and a
 LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_set_auto_detach_kernel_driver "libusb_device_handle *devh" "int enable"
+This function enables automatic kernel interface driver detach when an
+interface is claimed.
+When the interface is restored the kernel driver is allowed to be re-attached.
+If the
+.Fa enable
+argument is non-zero the feature is enabled.
+Else disabled.
+Returns 0 on success and a LIBUSB_ERROR code on
+failure.
 .Sh USB DESCRIPTORS
 .Ft int
 .Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc"
@@ -354,7 +376,31 @@ freed using the libusb_free_ss_endpoint_
 .Pp
 .Ft void
 .Fn libusb_free_ss_endpoint_comp "libusb_ss_endpoint_companion_descriptor *ep_comp"
-This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor.
+This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor given by
+.Fa ep_comp .
+.Pp
+.Ft int
+.Fn libusb_get_ss_endpoint_companion_descriptor "struct libusb_context *ctx" "const struct libusb_endpoint_descriptor *endpoint" "struct libusb_ss_endpoint_companion_descriptor **ep_comp"
+This function finds and parses the USB 3.0 endpoint companion descriptor given by
+.Fa endpoint .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed USB 3.0 endpoint companion descriptor must be
+freed using the libusb_free_ss_endpoint_companion_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_ss_endpoint_companion_descriptor "struct libusb_ss_endpoint_companion_descriptor *ep_comp"
+This function is NULL safe and frees a parsed USB 3.0 endpoint companion descriptor given by
+.Fa ep_comp .
+.Pp
+.Ft int
+.Fn libusb_get_bos_descriptor "libusb_device_handle *handle" "struct libusb_bos_descriptor **bos"
+This function queries the USB device given by
+.Fa handle
+and stores a pointer to a parsed BOS descriptor into
+.Fa bos .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed BOS descriptor must be
+freed using the libusb_free_bos_descriptor function.
 .Pp
 .Ft int
 .Fn libusb_parse_bos_descriptor "const void *buf" "int len" "libusb_bos_descriptor **bos"
@@ -370,7 +416,53 @@ libusb_free_bos_descriptor function.
 .Pp
 .Ft void
 .Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos"
-This function is NULL safe and frees a parsed BOS descriptor.
+This function is NULL safe and frees a parsed BOS descriptor given by
+.Fa bos .
+.Pp
+.Ft int
+.Fn libusb_get_usb_2_0_extension_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension"
+This function parses the USB 2.0 extension descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa usb_2_0_extension .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed USB 2.0 extension descriptor must be freed using the
+libusb_free_usb_2_0_extension_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_usb_2_0_extension_descriptor "struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension"
+This function is NULL safe and frees a parsed USB 2.0 extension descriptor given by
+.Fa usb_2_0_extension .
+.Pp
+.Ft int
+.Fn libusb_get_ss_usb_device_capability_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability"
+This function parses the SuperSpeed device capability descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa ss_usb_device_capability .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed SuperSpeed device capability descriptor must be freed using the
+libusb_free_ss_usb_device_capability_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_ss_usb_device_capability_descriptor "struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability"
+This function is NULL safe and frees a parsed SuperSpeed device capability descriptor given by
+.Fa ss_usb_device_capability .
+.Pp
+.Ft int
+.Fn libusb_get_container_id_descriptor "struct libusb_context *ctx" "struct libusb_bos_dev_capability_descriptor *dev_cap" "struct libusb_container_id_descriptor **container_id"
+This function parses the container ID descriptor from the descriptor given by
+.Fa dev_cap
+and stores a pointer to the parsed descriptor into
+.Fa container_id .
+Returns zero on success and a LIBUSB_ERROR code on failure.
+On success the parsed container ID descriptor must be freed using the
+libusb_free_container_id_descriptor function.
+.Pp
+.Ft void
+.Fn libusb_free_container_id_descriptor "struct libusb_container_id_descriptor *container_id"
+This function is NULL safe and frees a parsed container ID descriptor given by
+.Fa container_id .
 .Sh USB ASYNCHRONOUS I/O
 .Ft struct libusb_transfer *
 .Fn libusb_alloc_transfer "int iso_packets"
@@ -429,6 +521,29 @@ if the transfer timed out, LIBUSB_ERROR_
 supported, LIBUSB_ERROR_OVERFLOW if the device offered more data,
 LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
 a LIBUSB_ERROR code on other failure.
+.Sh USB STREAMS SUPPORT
+.Ft int
+.Fn libusb_alloc_streams "libusb_device_handle *dev" "uint32_t num_streams" "unsigned char *endpoints" "int num_endpoints"
+This function verifies that the given number of streams using the
+given number of endpoints is allowed and allocates the resources
+needed to use so-called USB streams.
+Currently only a single stream per endpoint is supported to simplify
+the internals of LibUSB.
+This function returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_free_streams "libusb_device_handle *dev" "unsigned char *endpoints" "int num_endpoints"
+This function release resources needed for streams usage.
+Returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft void
+.Fn libusb_transfer_set_stream_id "struct libusb_transfer *transfer" "uint32_t stream_id"
+This function sets the stream ID for the given USB transfer.
+.Pp
+.Ft uint32_t
+.Fn libusb_transfer_get_stream_id "struct libusb_transfer *transfer"
+This function returns the stream ID for the given USB transfer.
+If no stream ID is used a value of zero is returned.
 .Sh USB EVENTS
 .Ft int
 .Fn libusb_try_lock_events "libusb_context *ctx"
@@ -550,6 +665,47 @@ that libusb uses as an event source.
 Retrive a list of file descriptors that should be polled by your main loop as
 libusb event sources.
 Returns a NULL-terminated list on success or NULL on failure.
+.Pp
+.Ft int
+.Fn libusb_hotplug_register_callback "libusb_context *ctx" "libusb_hotplug_event events" "libusb_hotplug_flag flags" "int vendor_id" "int product_id" "int dev_class" "libusb_hotplug_callback_fn cb_fn" "void *user_data" "libusb_hotplug_callback_handle *handle"
+This function registers a hotplug filter.
+The
+.Fa events
+argument select which events makes the hotplug filter trigger.
+Available event values are LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED and LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT.
+One or more events must be specified.
+The
+.Fa vendor_id ,
+.Fa product_id
+and
+.Fa dev_class
+arguments can be set to LIBUSB_HOTPLUG_MATCH_ANY to match any value in the USB device descriptor.
+Else the specified value is used for matching.
+If the
+.Fa flags
+argument is set to LIBUSB_HOTPLUG_ENUMERATE, all currently attached and matching USB devices will be passed to the hotplug filter, given by the
+.Fa cb_fn
+argument.
+Else the
+.Fa flags
+argument should be set to LIBUSB_HOTPLUG_NO_FLAGS.
+This function returns 0 upon success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_hotplug_callback_fn "libusb_context *ctx" "libusb_device *device" "libusb_hotplug_event event" "void *user_data"
+The hotplug filter function.
+If this function returns non-zero, the filter is removed.
+Else the filter is kept and can receive more events.
+The
+.Fa user_data
+argument is the same as given when the filter was registered.
+The
+.Fa event
+argument can be either of LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED or LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT.
+.Pp
+.Ft void
+.Fn libusb_hotplug_deregister_callback "libusb_context *ctx" "libusb_hotplug_callback_handle handle"
+This function unregisters a hotplug filter.
 .Sh LIBUSB VERSION 0.1 COMPATIBILITY
 The library is also compliant with LibUSB version 0.1.12.
 .Pp

Modified: stable/9/lib/libusb/libusb.h
==============================================================================
--- stable/9/lib/libusb/libusb.h	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/libusb.h	Wed Jun 29 11:06:13 2016	(r302276)
@@ -30,6 +30,8 @@
 #include 
 #include 
 
+#define	LIBUSB_API_VERSION 0x01000102
+
 #define	LIBUSB_CALL
 
 #ifdef __cplusplus
@@ -96,6 +98,10 @@ enum libusb_device_capability_type {
 #define	LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE	7
 #define	LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE	10
 
+#define	LIBUSB_BT_USB_2_0_EXTENSION_SIZE	7
+#define	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE	10
+#define	LIBUSB_BT_CONTAINER_ID_SIZE		20
+
 #define	LIBUSB_ENDPOINT_ADDRESS_MASK	0x0f
 #define	LIBUSB_ENDPOINT_DIR_MASK	0x80
 
@@ -160,6 +166,13 @@ enum libusb_iso_usage_type {
 	LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
 };
 
+enum libusb_bos_type {
+	LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
+	LIBUSB_BT_USB_2_0_EXTENSION = 2,
+	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
+	LIBUSB_BT_CONTAINER_ID = 4,
+};
+
 enum libusb_error {
 	LIBUSB_SUCCESS = 0,
 	LIBUSB_ERROR_IO = -1,
@@ -207,24 +220,47 @@ enum libusb_debug_level {
 	LIBUSB_DEBUG_TRANSFER=2,
 };
 
+#define	LIBUSB_HOTPLUG_MATCH_ANY -1
+
+typedef enum {
+	LIBUSB_HOTPLUG_NO_FLAGS = 0,
+	LIBUSB_HOTPLUG_ENUMERATE = 1 << 0,
+} libusb_hotplug_flag;
+
+typedef enum {
+	LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 1,
+	LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 2,
+} libusb_hotplug_event;
+
 /* libusb structures */
 
 struct libusb_context;
 struct libusb_device;
 struct libusb_transfer;
 struct libusb_device_handle;
+struct libusb_hotplug_callback_handle_struct;
 
 struct libusb_pollfd {
 	int	fd;
 	short	events;
 };
 
+struct libusb_version {
+	const uint16_t major;
+	const uint16_t minor;
+	const uint16_t micro;
+	const uint16_t nano;
+	const char *rc;
+	const char *describe;
+};
+
 typedef struct libusb_context libusb_context;
 typedef struct libusb_device libusb_device;
 typedef struct libusb_device_handle libusb_device_handle;
 typedef struct libusb_pollfd libusb_pollfd;
 typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data);
 typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data);
+typedef struct libusb_hotplug_callback_handle_struct *libusb_hotplug_callback_handle;
 
 typedef struct libusb_device_descriptor {
 	uint8_t	bLength;
@@ -322,6 +358,13 @@ typedef struct libusb_ss_usb_device_capa
 	uint16_t wU2DevExitLat;
 }	libusb_ss_usb_device_capability_descriptor __aligned(sizeof(void *));
 
+typedef struct libusb_bos_dev_capability_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint8_t dev_capability_data[0];
+}	libusb_bos_dev_capability_descriptor __aligned(sizeof(void *));
+
 typedef struct libusb_bos_descriptor {
 	uint8_t bLength;
 	uint8_t bDescriptorType;
@@ -331,6 +374,21 @@ typedef struct libusb_bos_descriptor {
 	struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap;
 }	libusb_bos_descriptor __aligned(sizeof(void *));
 
+typedef struct libusb_usb_2_0_extension_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint32_t bmAttributes;
+}	libusb_usb_2_0_extension_descriptor __aligned(sizeof(void *));
+
+typedef struct libusb_container_id_descriptor {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t bDevCapabilityType;
+	uint8_t	bReserved;
+	uint8_t ContainerID[16];
+}	libusb_container_id_descriptor __aligned(sizeof(void *));
+
 typedef struct libusb_control_setup {
 	uint8_t	bmRequestType;
 	uint8_t	bRequest;
@@ -369,6 +427,7 @@ typedef struct libusb_transfer {
 /* Library initialisation */
 
 void	libusb_set_debug(libusb_context * ctx, int level);
+const struct libusb_version *libusb_get_version(void);
 const char *libusb_strerror(int code);
 const char *libusb_error_name(int code);
 int	libusb_init(libusb_context ** context);
@@ -379,6 +438,7 @@ void	libusb_exit(struct libusb_context *
 ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list);
 void	libusb_free_device_list(libusb_device ** list, int unref_devices);
 uint8_t	libusb_get_bus_number(libusb_device * dev);
+uint8_t	libusb_get_port_number(libusb_device * dev);
 int	libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize);
 int	libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize);
 uint8_t	libusb_get_device_address(libusb_device * dev);
@@ -404,6 +464,7 @@ int	libusb_get_driver(libusb_device_hand
 int 	libusb_detach_kernel_driver_np(libusb_device_handle * devh, int interface);
 int 	libusb_detach_kernel_driver(libusb_device_handle * devh, int interface);
 int 	libusb_attach_kernel_driver(libusb_device_handle * devh, int interface);
+int	libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable);
 int	libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting);
 
 /* USB Descriptors */
@@ -413,6 +474,8 @@ int	libusb_get_active_config_descriptor(
 int	libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
 int	libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
 void	libusb_free_config_descriptor(struct libusb_config_descriptor *config);
+int	libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
+void	libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp);
 int	libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length);
 int	libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
 int	libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
@@ -420,6 +483,13 @@ int	libusb_parse_ss_endpoint_comp(const 
 void	libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp);
 int	libusb_parse_bos_descriptor(const void *buf, int len, struct libusb_bos_descriptor **bos);
 void	libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
+int	libusb_get_bos_descriptor(libusb_device_handle *handle, struct libusb_bos_descriptor **bos);
+int	libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
+void	libusb_free_usb_2_0_extension_descriptor(struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
+int	libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability);
+void	libusb_free_ss_usb_device_capability_descriptor(struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability);
+int	libusb_get_container_id_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id);
+void	libusb_free_container_id_descriptor(struct libusb_container_id_descriptor *container_id);
 
 /* Asynchronous device I/O */
 
@@ -468,6 +538,21 @@ int	libusb_interrupt_transfer(libusb_dev
 uint16_t libusb_cpu_to_le16(uint16_t x);
 uint16_t libusb_le16_to_cpu(uint16_t x);
 
+/* Hotplug support */
+
+typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx,
+    libusb_device *device, libusb_hotplug_event event, void *user_data);
+
+int	libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle);
+void	libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle);
+
+/* Streams support */
+
+int	libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
+int	libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints);
+void	libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id);
+uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer);
+
 #if 0
 {					/* indent fix */
 #endif

Modified: stable/9/lib/libusb/libusb10.c
==============================================================================
--- stable/9/lib/libusb/libusb10.c	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/libusb10.c	Wed Jun 29 11:06:13 2016	(r302276)
@@ -63,6 +63,22 @@ static void libusb10_submit_transfer_sub
 
 /*  Library initialisation / deinitialisation */
 
+static const struct libusb_version libusb_version = {
+	.major = 1,
+	.minor = 0,
+	.micro = 0,
+	.nano = 2016,
+	.rc = "",
+	.describe = "http://www.freebsd.org"
+};
+
+const struct libusb_version *
+libusb_get_version(void)
+{
+
+	return (&libusb_version);
+}
+
 void
 libusb_set_debug(libusb_context *ctx, int level)
 {
@@ -112,24 +128,34 @@ libusb_init(libusb_context **context)
 	}
 	TAILQ_INIT(&ctx->pollfds);
 	TAILQ_INIT(&ctx->tr_done);
+	TAILQ_INIT(&ctx->hotplug_cbh);
+	TAILQ_INIT(&ctx->hotplug_devs);
 
 	if (pthread_mutex_init(&ctx->ctx_lock, NULL) != 0) {
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
 	}
+	if (pthread_mutex_init(&ctx->hotplug_lock, NULL) != 0) {
+		pthread_mutex_destroy(&ctx->ctx_lock);
+		free(ctx);
+		return (LIBUSB_ERROR_NO_MEM);
+	}
 	if (pthread_condattr_init(&attr) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
 	}
 	if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_condattr_destroy(&attr);
 		free(ctx);
 		return (LIBUSB_ERROR_OTHER);
 	}
 	if (pthread_cond_init(&ctx->ctx_cond, &attr) != 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_condattr_destroy(&attr);
 		free(ctx);
 		return (LIBUSB_ERROR_NO_MEM);
@@ -137,10 +163,12 @@ libusb_init(libusb_context **context)
 	pthread_condattr_destroy(&attr);
 
 	ctx->ctx_handler = NO_THREAD;
+	ctx->hotplug_handler = NO_THREAD;
 
 	ret = pipe(ctx->ctrl_pipe);
 	if (ret < 0) {
 		pthread_mutex_destroy(&ctx->ctx_lock);
+		pthread_mutex_destroy(&ctx->hotplug_lock);
 		pthread_cond_destroy(&ctx->ctx_cond);
 		free(ctx);
 		return (LIBUSB_ERROR_OTHER);
@@ -173,12 +201,27 @@ libusb_exit(libusb_context *ctx)
 	if (ctx == NULL)
 		return;
 
+	/* stop hotplug thread, if any */
+
+	if (ctx->hotplug_handler != NO_THREAD) {
+		pthread_t td;
+		void *ptr;
+
+		HOTPLUG_LOCK(ctx);
+		td = ctx->hotplug_handler;
+		ctx->hotplug_handler = NO_THREAD;
+		HOTPLUG_UNLOCK(ctx);
+
+		pthread_join(td, &ptr);
+	}
+
 	/* XXX cleanup devices */
 
 	libusb10_remove_pollfd(ctx, &ctx->ctx_poll);
 	close(ctx->ctrl_pipe[0]);
 	close(ctx->ctrl_pipe[1]);
 	pthread_mutex_destroy(&ctx->ctx_lock);
+	pthread_mutex_destroy(&ctx->hotplug_lock);
 	pthread_cond_destroy(&ctx->ctx_cond);
 
 	pthread_mutex_lock(&default_context_lock);
@@ -286,6 +329,14 @@ libusb_get_bus_number(libusb_device *dev
 	return (libusb20_dev_get_bus_number(dev->os_priv));
 }
 
+uint8_t
+libusb_get_port_number(libusb_device *dev)
+{
+	if (dev == NULL)
+		return (0);		/* should not happen */
+	return (libusb20_dev_get_parent_port(dev->os_priv));
+}
+
 int
 libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize)
 {
@@ -607,6 +658,7 @@ int
 libusb_claim_interface(struct libusb20_device *pdev, int interface_number)
 {
 	libusb_device *dev;
+	int err = 0;
 
 	dev = libusb_get_device(pdev);
 	if (dev == NULL)
@@ -615,11 +667,17 @@ libusb_claim_interface(struct libusb20_d
 	if (interface_number < 0 || interface_number > 31)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
+	if (pdev->auto_detach != 0) {
+		err = libusb_detach_kernel_driver(pdev, interface_number);
+		if (err != 0)
+			goto done;
+	}
+
 	CTX_LOCK(dev->ctx);
 	dev->claimed_interfaces |= (1 << interface_number);
 	CTX_UNLOCK(dev->ctx);
-
-	return (0);
+done:
+	return (err);
 }
 
 int
@@ -635,13 +693,19 @@ libusb_release_interface(struct libusb20
 	if (interface_number < 0 || interface_number > 31)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
+	if (pdev->auto_detach != 0) {
+		err = libusb_attach_kernel_driver(pdev, interface_number);
+		if (err != 0)
+			goto done;
+	}
+
 	CTX_LOCK(dev->ctx);
 	if (!(dev->claimed_interfaces & (1 << interface_number)))
 		err = LIBUSB_ERROR_NOT_FOUND;
-
-	if (!err)
+	else
 		dev->claimed_interfaces &= ~(1 << interface_number);
 	CTX_UNLOCK(dev->ctx);
+done:
 	return (err);
 }
 
@@ -843,6 +907,13 @@ libusb_attach_kernel_driver(struct libus
 	return (0);
 }
 
+int
+libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable)
+{
+	dev->auto_detach = (enable ? 1 : 0);
+	return (0);
+}
+
 /* Asynchronous device I/O */
 
 struct libusb_transfer *

Modified: stable/9/lib/libusb/libusb10.h
==============================================================================
--- stable/9/lib/libusb/libusb10.h	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/libusb10.h	Wed Jun 29 11:06:13 2016	(r302276)
@@ -34,6 +34,8 @@
 #define	CTX_LOCK(ctx) pthread_mutex_lock(&(ctx)->ctx_lock)
 #define	CTX_TRYLOCK(ctx) pthread_mutex_trylock(&(ctx)->ctx_lock)
 #define	CTX_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->ctx_lock)
+#define	HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
+#define	HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
 
 #define	DPRINTF(ctx, dbg, format, args...) do {	\
     if ((ctx)->debug == dbg) {			\
@@ -65,11 +67,22 @@ struct libusb_super_transfer {
 	uint8_t *curr_data;
 	uint32_t rem_len;
 	uint32_t last_len;
+	uint32_t stream_id;
 	uint8_t	state;
 #define	LIBUSB_SUPER_XFER_ST_NONE 0
 #define	LIBUSB_SUPER_XFER_ST_PEND 1
 };
 
+struct libusb_hotplug_callback_handle_struct {
+	TAILQ_ENTRY(libusb_hotplug_callback_handle_struct) entry;
+	int events;
+	int vendor;
+	int product;
+	int devclass;
+	libusb_hotplug_callback_fn fn;
+	void *user_data;
+};
+
 struct libusb_context {
 	int	debug;
 	int	debug_fixed;
@@ -78,12 +91,16 @@ struct libusb_context {
 	int	tr_done_gen;
 
 	pthread_mutex_t ctx_lock;
+  	pthread_mutex_t hotplug_lock;
 	pthread_cond_t ctx_cond;
+	pthread_t hotplug_handler;
 	pthread_t ctx_handler;
 #define	NO_THREAD ((pthread_t)-1)
 
 	TAILQ_HEAD(, libusb_super_pollfd) pollfds;
 	TAILQ_HEAD(, libusb_super_transfer) tr_done;
+	TAILQ_HEAD(, libusb_hotplug_callback_handle_struct) hotplug_cbh;
+  	TAILQ_HEAD(, libusb_device) hotplug_devs;
 
 	struct libusb_super_pollfd ctx_poll;
 
@@ -101,6 +118,8 @@ struct libusb_device {
 
 	struct libusb_context *ctx;
 
+	TAILQ_ENTRY(libusb_device) hotplug_entry;
+
 	TAILQ_HEAD(, libusb_super_transfer) tr_head;
 
 	struct libusb20_device *os_priv;

Modified: stable/9/lib/libusb/libusb10_desc.c
==============================================================================
--- stable/9/lib/libusb/libusb10_desc.c	Wed Jun 29 10:58:36 2016	(r302275)
+++ stable/9/lib/libusb/libusb10_desc.c	Wed Jun 29 11:06:13 2016	(r302276)
@@ -405,6 +405,23 @@ libusb_free_ss_endpoint_comp(struct libu
 }
 
 int
+libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx,
+    const struct libusb_endpoint_descriptor *endpoint,
+    struct libusb_ss_endpoint_companion_descriptor **ep_comp)
+{
+	if (endpoint == NULL)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	return (libusb_parse_ss_endpoint_comp(endpoint->extra, endpoint->extra_length, ep_comp));
+}
+
+void
+libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp)
+{
+
+	libusb_free_ss_endpoint_comp(ep_comp);
+}
+
+int
 libusb_parse_bos_descriptor(const void *buf, int len,
     struct libusb_bos_descriptor **bos)
 {
@@ -515,3 +532,154 @@ libusb_free_bos_descriptor(struct libusb
 
 	free(bos);
 }
+
+int
+libusb_get_bos_descriptor(libusb_device_handle *handle,
+    struct libusb_bos_descriptor **bos)
+{
+	uint8_t bos_header[LIBUSB_DT_BOS_SIZE] = {0};
+	uint16_t wTotalLength;
+	uint8_t *bos_data;
+	int err;
+
+	err = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0,
+	    bos_header, sizeof(bos_header));
+	if (err < 0)
+		return (err);
+
+	wTotalLength = bos_header[2] | (bos_header[3] << 8);
+	if (wTotalLength < LIBUSB_DT_BOS_SIZE)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
+	bos_data = calloc(wTotalLength, 1);
+	if (bos_data == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	err = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0,
+	    bos_data, wTotalLength);
+	if (err < 0)
+		goto done;
+
+	/* avoid descriptor length mismatches */
+	bos_data[2] = (wTotalLength & 0xFF);
+	bos_data[3] = (wTotalLength >> 8);
+
+	err = libusb_parse_bos_descriptor(bos_data, wTotalLength, bos);
+done:
+	free(bos_data);
+	return (err);
+}
+
+int
+libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
+{
+	struct libusb_usb_2_0_extension_descriptor *desc;
+
+	if (dev_cap == NULL || usb_2_0_extension == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_USB_2_0_EXTENSION)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_USB_2_0_EXTENSION_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bmAttributes =
+	    (dev_cap->dev_capability_data[0]) |
+	    (dev_cap->dev_capability_data[1] << 8) |
+	    (dev_cap->dev_capability_data[2] << 16) |
+	    (dev_cap->dev_capability_data[3] << 24);
+
+	*usb_2_0_extension = desc;
+	return (0);
+}
+
+void
+libusb_free_usb_2_0_extension_descriptor(
+    struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
+{
+
+	free(usb_2_0_extension);
+}
+
+int
+libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability)
+{
+	struct libusb_ss_usb_device_capability_descriptor *desc;
+
+	if (dev_cap == NULL || ss_usb_device_capability == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bmAttributes = dev_cap->dev_capability_data[0];
+	desc->wSpeedSupported = dev_cap->dev_capability_data[1] |
+	    (dev_cap->dev_capability_data[2] << 8);
+	desc->bFunctionalitySupport = dev_cap->dev_capability_data[3];
+	desc->bU1DevExitLat = dev_cap->dev_capability_data[4];
+	desc->wU2DevExitLat = dev_cap->dev_capability_data[5] |
+	    (dev_cap->dev_capability_data[6] << 8);
+
+	*ss_usb_device_capability = desc;
+	return (0);
+}
+
+void
+libusb_free_ss_usb_device_capability_descriptor(
+    struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability)
+{
+
+	free(ss_usb_device_capability);
+}
+
+int
+libusb_get_container_id_descriptor(struct libusb_context *ctx,
+    struct libusb_bos_dev_capability_descriptor *dev_cap,
+    struct libusb_container_id_descriptor **container_id)
+{
+	struct libusb_container_id_descriptor *desc;
+
+	if (dev_cap == NULL || container_id == NULL ||
+	    dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+	if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE)
+		return (LIBUSB_ERROR_IO);
+
+	desc = malloc(sizeof(*desc));
+	if (desc == NULL)
+		return (LIBUSB_ERROR_NO_MEM);
+
+	desc->bLength = LIBUSB_BT_CONTAINER_ID_SIZE;
+	desc->bDescriptorType = dev_cap->bDescriptorType;
+	desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+	desc->bReserved = dev_cap->dev_capability_data[0];
+	memcpy(desc->ContainerID, dev_cap->dev_capability_data + 1,
+	    sizeof(desc->ContainerID));
+
+	*container_id = desc;
+	return (0);
+}
+
+void
+libusb_free_container_id_descriptor(
+    struct libusb_container_id_descriptor *container_id)
+{
+
+	free(container_id);
+}

Copied: stable/9/lib/libusb/libusb10_hotplug.c (from r302080, head/lib/libusb/libusb10_hotplug.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/lib/libusb/libusb10_hotplug.c	Wed Jun 29 11:06:13 2016	(r302276, copy of r302080, head/lib/libusb/libusb10_hotplug.c)
@@ -0,0 +1,237 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef LIBUSB_GLOBAL_INCLUDE_FILE
+#include LIBUSB_GLOBAL_INCLUDE_FILE
+#else
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
+#define	libusb_device_handle libusb20_device
+
+#include "libusb20.h"
+#include "libusb20_desc.h"
+#include "libusb20_int.h"
+#include "libusb.h"
+#include "libusb10.h"
+
+static int
+libusb_hotplug_equal(libusb_device *_adev, libusb_device *_bdev)
+{
+	struct libusb20_device *adev = _adev->os_priv;
+	struct libusb20_device *bdev = _bdev->os_priv;
+
+	if (adev->bus_number != bdev->bus_number)
+		return (0);
+	if (adev->device_address != bdev->device_address)
+		return (0);
+	if (memcmp(&adev->ddesc, &bdev->ddesc, sizeof(adev->ddesc)))
+		return (0);
+	if (memcmp(&adev->session_data, &bdev->session_data, sizeof(adev->session_data)))
+		return (0);
+	return (1);
+}
+
+static int
+libusb_hotplug_filter(libusb_context *ctx, libusb_hotplug_callback_handle pcbh,
+    libusb_device *dev, libusb_hotplug_event event)
+{
+	if (!(pcbh->events & event))
+		return (0);
+	if (pcbh->vendor != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->vendor != libusb20_dev_get_device_desc(dev->os_priv)->idVendor)
+		return (0);
+	if (pcbh->product != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->product != libusb20_dev_get_device_desc(dev->os_priv)->idProduct)
+		return (0);
+	if (pcbh->devclass != LIBUSB_HOTPLUG_MATCH_ANY &&
+	    pcbh->devclass != libusb20_dev_get_device_desc(dev->os_priv)->bDeviceClass)
+		return (0);
+	return (pcbh->fn(ctx, dev, event, pcbh->user_data));
+}
+
+static void *
+libusb_hotplug_scan(void *arg)
+{
+	TAILQ_HEAD(, libusb_device) hotplug_devs;
+	libusb_hotplug_callback_handle acbh;
+	libusb_hotplug_callback_handle bcbh;
+	libusb_context *ctx = arg;
+	libusb_device **ppdev;
+	libusb_device *temp;
+	libusb_device *adev;
+	libusb_device *bdev;
+	unsigned do_loop = 1;
+	ssize_t count;
+	ssize_t x;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-all@freebsd.org  Wed Jun 29 11:48:43 2016
Return-Path: 
Delivered-To: svn-src-all@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 80D47B86338;
 Wed, 29 Jun 2016 11:48:43 +0000 (UTC)
 (envelope-from emaste@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 3A7ED2991;
 Wed, 29 Jun 2016 11:48:43 +0000 (UTC)
 (envelope-from emaste@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TBmgKt083683;
 Wed, 29 Jun 2016 11:48:42 GMT (envelope-from emaste@FreeBSD.org)
Received: (from emaste@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TBmgUJ083682;
 Wed, 29 Jun 2016 11:48:42 GMT (envelope-from emaste@FreeBSD.org)
Message-Id: <201606291148.u5TBmgUJ083682@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: emaste set sender to
 emaste@FreeBSD.org using -f
From: Ed Maste 
Date: Wed, 29 Jun 2016 11:48:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302278 - head/lib/libcxxrt
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 11:48:43 -0000

Author: emaste
Date: Wed Jun 29 11:48:42 2016
New Revision: 302278
URL: https://svnweb.freebsd.org/changeset/base/302278

Log:
  libcxxrt: correct mangled "typeinfo name" symbols in Version.map
  
  r260553 added missing C++ typinfos to libcxxrt's version script.
  It appears that a number of duplicate mangled symbols were added due to
  a cut and paste error. Switch the second instances to _ZTS*,
  typeinfo name for *.
  
  Found by lld, which produces an error or warning for duplicate symbols.
  
  Reviewed by:	dim
  Approved by:	re (gjb)
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D7011

Modified:
  head/lib/libcxxrt/Version.map

Modified: head/lib/libcxxrt/Version.map
==============================================================================
--- head/lib/libcxxrt/Version.map	Wed Jun 29 11:39:37 2016	(r302277)
+++ head/lib/libcxxrt/Version.map	Wed Jun 29 11:48:42 2016	(r302278)
@@ -209,19 +209,19 @@ CXXABI_1.3 {
         "typeinfo name for void*";
         "typeinfo name for unsigned int*";
         "typeinfo name for float*";
-        # C++11 typeinfo not understood by our linker
+        # C++11 typeinfo name not understood by our linker
         # std::nullptr_t
-        _ZTSDn;_ZTIPDn;_ZTIPKDn;
+        _ZTSDn;_ZTSPDn;_ZTSPKDn;
         # char16_t
-        _ZTSDi;_ZTIPDi;_ZTIPKDi;
+        _ZTSDi;_ZTSPDi;_ZTSPKDi;
         # char32_t
-        _ZTSDs;_ZTIPDs;_ZTIPKDs;
+        _ZTSDs;_ZTSPDs;_ZTSPKDs;
         # IEEE 754r decimal floating point
-        _ZTSDd;_ZTIPDd;_ZTIPKDd;
-        _ZTSDe;_ZTIPDe;_ZTIPKDe;
-        _ZTSDf;_ZTIPDf;_ZTIPKDf;
+        _ZTSDd;_ZTSPDd;_ZTSPKDd;
+        _ZTSDe;_ZTSPDe;_ZTSPKDe;
+        _ZTSDf;_ZTSPDf;_ZTSPKDf;
         # IEEE 754r half-precision floating point
-        _ZTSDh;_ZTIPDh;_ZTIPKDh;
+        _ZTSDh;_ZTSPDh;_ZTSPKDh;
 
         "typeinfo name for __cxxabiv1::__array_type_info";
         "typeinfo name for __cxxabiv1::__class_type_info";

From owner-svn-src-all@freebsd.org  Wed Jun 29 14:40:45 2016
Return-Path: 
Delivered-To: svn-src-all@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 5A8E3B85805;
 Wed, 29 Jun 2016 14:40:45 +0000 (UTC)
 (envelope-from nwhitehorn@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 112122AF7;
 Wed, 29 Jun 2016 14:40:44 +0000 (UTC)
 (envelope-from nwhitehorn@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TEeinw047889;
 Wed, 29 Jun 2016 14:40:44 GMT (envelope-from nwhitehorn@FreeBSD.org)
Received: (from nwhitehorn@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TEeieA047887;
 Wed, 29 Jun 2016 14:40:44 GMT (envelope-from nwhitehorn@FreeBSD.org)
Message-Id: <201606291440.u5TEeieA047887@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to
 nwhitehorn@FreeBSD.org using -f
From: Nathan Whitehorn 
Date: Wed, 29 Jun 2016 14:40:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302279 - in head/sys/powerpc: aim powerpc
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 14:40:45 -0000

Author: nwhitehorn
Date: Wed Jun 29 14:40:43 2016
New Revision: 302279
URL: https://svnweb.freebsd.org/changeset/base/302279

Log:
  Do not rely on firmware having pre-enabled the MMU in a reasonable way for
  late boot: enable it explicitly after installing the page tables. If booting
  from an FDT, also make sure to escape the firmware's MMU context early
  before overwriting firmware page tables.
  
  Approved by:	re (gjb)

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea.c	Wed Jun 29 11:48:42 2016	(r302278)
+++ head/sys/powerpc/aim/mmu_oea.c	Wed Jun 29 14:40:43 2016	(r302279)
@@ -921,7 +921,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
 	Maxmem = powerpc_btop(phys_avail[i + 1]);
 
 	moea_cpu_bootstrap(mmup,0);
-
+	mtmsr(mfmsr() | PSL_DR | PSL_IR);
 	pmap_bootstrapped++;
 
 	/*

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c	Wed Jun 29 11:48:42 2016	(r302278)
+++ head/sys/powerpc/powerpc/machdep.c	Wed Jun 29 14:40:43 2016	(r302279)
@@ -251,6 +251,18 @@ powerpc_init(vm_offset_t fdt, vm_offset_
 	if (mdp == (void *)0x65504150)
 		mdp = NULL;
 
+#if AIM
+	/*
+	 * If running from an FDT, make sure we are in real mode to avoid
+	 * tromping on firmware page tables. Everything in the kernel assumes
+	 * 1:1 mappings out of firmware, so this won't break anything not
+	 * already broken. This doesn't work if there is live OF, since OF
+	 * may internally use non-1:1 mappings.
+	 */
+	if (ofentry == 0)
+		mtmsr(mfmsr() & ~(PSL_IR | PSL_DR));
+#endif
+
 	/*
 	 * Parse metadata if present and fetch parameters.  Must be done
 	 * before console is inited so cninit gets the right value of

From owner-svn-src-all@freebsd.org  Wed Jun 29 14:54:53 2016
Return-Path: 
Delivered-To: svn-src-all@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 61A5BB85C99;
 Wed, 29 Jun 2016 14:54:53 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id C590528CD;
 Wed, 29 Jun 2016 14:54:52 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TEsi9C062787
 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
 Wed, 29 Jun 2016 17:54:45 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TEsi9C062787
Received: (from kostik@localhost)
 by tom.home (8.15.2/8.15.2/Submit) id u5TEshO8062786;
 Wed, 29 Jun 2016 17:54:43 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Wed, 29 Jun 2016 17:54:43 +0300
From: Konstantin Belousov 
To: Bruce Evans 
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
Message-ID: <20160629145443.GG38613@kib.kiev.ua>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160629175917.O968@besplex.bde.org>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no
 autolearn_force=no version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 14:54:53 -0000

This is a reply to two mails in one, both for r302251 and r302252 threads.

On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote:
> On Tue, 28 Jun 2016, Konstantin Belousov wrote:
> 
> > Log:
> >  Do not use Giant to prevent parallel calls to CLOCK_SETTIME().  Use
> >  private mtx in resettodr(), no implementation of CLOCK_SETTIME() is
> >  allowed to sleep.
> 
> Thanks.
> 
> As you know, clock locking is still quite broken.  The most obvious
> bugs near here are now:
> - settime() still begins with splclock().  This gave fewer bugs in
>    clock locking when it last worked in FreeBSD-4.  Now it is just
>    a hint that the clock locking has still not been converted to use
>    mutexes.
> - bitrot near the end of settime() removed the splx() that should
>    be paired with the splclock().
Yes, I am aware of both splclock() and Giant braces in the setclock().
I did not wanted to even look at tc_setclock() at all, for that change.
See below.

> - the locking should be stronger than mutexes (or splclock()) to
>    minimise the delay between deciding to set the time and actually
>    setting it.
...
This is separate issue.  Might be a critical section around the code
is the right approximation for reducing delays there.

> > +	mtx_lock(&resettodr_lock);
> 
> This could be later (only around the hardware parts) since we are sloppy
> with the delays.
Done.

> 
> > 	getnanotime(&ts);
> 
> This doesn't even try to get nanoseconds accuracy.
> 
> > 	timespecadd(&ts, &clock_adj);
> > 	ts.tv_sec -= utc_offset();
> 
> Who knows what utc_offset() is locked by?  Certainly not this new locking,
> since it is set in another file but the new locking is only in this file.
> It still seems to be most under Giant :-(.
utc_offset() uses several variables, updates to each of the variable is
atomic.  There is no even an attempt to provide userspace with an interface
which would makes updates to the components used by utc_offset() consistent.
Thus I do not see a need in any locking there.

> 
> The change in the other part of the diff is related to this, and doesn't
> seem quite right.  utc_offset() uses the variables tz_minuteswest,
> wall_cmos_clock and adjkerntz:
> - tz_minuteswest is set with no locking in kern_settimeofday(), just
>    after the settime() call.  This last had a chance of being correct
>    when the kernel was UP and not preemptible.  But it is broken in
>    a more fundamental way back to at least FreeBSD-1: resettodr() is
>    called _before_ updating the timezone, so it uses an out-of-date
>    tz_minuteswest.
First, the man page is not correct, saying that 'this information is
kept outside the kernel'.

Second, why does settime(), logicall, need the updated timezone ?
I understand that resettodr() is called on successful update of
the wall clock.  But shouldn't the need to reset not-GMT RTC clock
in kern_settimeofday() satisfied by yet another call to resettodr()
if tzp != NULL, after the tz_* vars update ?

> - wall_cmos_clock is still under a simple (not MPSAFE) sysctl
> - adjkerntz is under a PROC sysctl, and you just changed this sysctl to
>    be MPSAFE.  The sysctl calls here, so we don't want all of it
>    giant-locked.  But it now does unlocked accesses to the adjkerntz
>    variable, and the access to the disable_rtc_set variable is unlocked
>    because we do it before acquiring the lock in this function (this
>    variable is still under a simple (not MPSAFE) sysctl.
> 
> Most of the variables are ints, so access to them are atomic, but without
> locking the correct order only occurs accidentally and is hard to
> understand.
I think there is no any global consistency, mostly caused by existence
of separate interfaces to control all of them.  IMO it is not worth to
try to ensure any.

> 
> > 	/* XXX: We should really set all registered RTCs */
> > -	if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0)
> > +	error = CLOCK_SETTIME(clock_dev, &ts);
> > +	mtx_unlock(&resettodr_lock);
> > +	if (error != 0)
> > 		printf("warning: clock_settime failed (%d), time-of-day clock "
> > 		    "not adjusted to system time\n", error);
> > }
> 
> The lock needs to cover all high-level accesses to the rtc and related
> variables to avoid races, and a bit more to minimise delays.  In particular,
> inittodr() should be under this lock, and there is a problem with
> "show rtc" in ddb.
I do not think that inittodr() actually needs that locking.  This code
is executed at the initialization stage, or at the resume stage.

Do you mean that CLOCK_GETTIME() hardware access should be made exclusive
with CLOCK_SETTIME() ?  Is there a hardware that rely on exclusivity and
not enforce that internally, how x86 rtc does ?

DDB access to rtc is separate problem.

On Wed, Jun 29, 2016 at 07:39:45PM +1000, Bruce Evans wrote:
> On Tue, 28 Jun 2016, Konstantin Belousov wrote:
> > static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
> >
> > +static struct mtx ntpadj_lock;
> > +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
> > +#ifdef PPS_SYNC
> > +    MTX_SPIN
> > +#else
> > +    MTX_DEF
> > +#endif
> > +);
> 
> This needs to be a spinlock in all cases, since ntp_update_second() needs
> to be locked and ntp_update_second() is called from tc_windup() is usually
> called from a fast interrupt handler.
Oh, I see.

> 
> ntp_update_second() is still unlocked.  It accesses lots of variables, so
> it obviously needs locking.  E.g., its very first access is
> time_maxerror += MAXFREQ / 1000.  This has the usual non-atomicity for
> a read-modify write.  This obiously races with the locked access on the
> 28th linke of sys_ntp_adjtime().  Only the latter is locked now.
> 
> > +
> > +/*
> > + * When PPS_SYNC is defined, hardpps() function is provided which can
> > + * be legitimately called from interrupt filters.  Due to this, use
> > + * spinlock for ntptime state protection, otherwise sleepable mutex is
> > + * adequate.
> > + */
> > +#ifdef PPS_SYNC
> > +#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
> > +#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
> > +#else
> > +#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
> > +#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
> > +#endif
> > +#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
> 
> *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs
> to be locked.
Do you have a suggestion for a better name ?

> 
> Probably the locking should be shared with kern_tc.c.  tc_windup() still
> uses only fancy time-domaind/atomic-op locking.  This mostly works, but
> is quite broken by calling tc_windup() from places other than hardclock().
> The most problematic other place is from tc_setclock().  That is unlocked,
> except accidentally by callers with only Giant locking, so it races with
> the fast interrupt handler.
> 
> tc_windup() doesn't need the fancy locking for efficiency -- it only needs
> it to be consistent with binuptime() and friends.  So it may as well use
> the same lock as ntp.  Its lock must be around the whole function to
> protect it from tc_setclock().  Then the same lock works for
> ntp_update_second() and pps.  Any lock that is only acquired once per
> second is not worth optimizing.  Hopefully the same for ntp's other locks.
> ntp syscalls should only be frequent under unusual/malicious loads, so
> they shouldn't cause much contention with the tc_windup() lock.
So I postponed looking at tc_windup(), and it seems that it was
useful. After you note above, it is mostly clear that we can skip some
tc_windup() calls which conflicts with currently active windup calls.
E.g., the hardclock update, which is done simultaneously with the
setclock(), could be just skipped.  But we must not skip the tc_windup()
call from setclock().

As an additional, but probably excessive measure, invocation of
tc_windup() from hardclock could ask the setclock() to re-execute
tc_windup() after its call is done.

> > -static int
> > -ntp_is_time_error(void)
> > +static bool
> > +ntp_is_time_error(int tsl)
> > {
> > +
> 
> Is it worth changing this to make a single variable less volatile?
Yes, to rely on single-variable read being atomic and avoiding locking
in callout.

[Skipped the S64/OPAQUE stuff]

Patch does the following:
- change the ntpadj_lock to spinlock.
- acquire the ntpadj_lock around ntp_update_second().
- prevent parallel tc_windup() invocations, while not allowing to
  skip calls coming from kernel top half.
- move resettodr_lock acquisition in resettodr() later.

diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index d352ee7..34b29d9 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -163,27 +163,10 @@ static l_fp time_adj;			/* tick adjust (ns/s) */
 static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
 
 static struct mtx ntpadj_lock;
-MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
-#ifdef PPS_SYNC
-    MTX_SPIN
-#else
-    MTX_DEF
-#endif
-);
+MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", MTX_SPIN);
 
-/*
- * When PPS_SYNC is defined, hardpps() function is provided which can
- * be legitimately called from interrupt filters.  Due to this, use
- * spinlock for ntptime state protection, otherwise sleepable mutex is
- * adequate.
- */
-#ifdef PPS_SYNC
 #define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
 #define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
-#else
-#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
-#endif
 #define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
 
 #ifdef PPS_SYNC
@@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	int tickrate;
 	l_fp ftemp;		/* 32/64-bit temporary */
 
+	NTPADJ_LOCK();
+
 	/*
 	 * On rollover of the second both the nanosecond and microsecond
 	 * clocks are updated and the state machine cranked as
@@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	else
 		time_status &= ~STA_PPSSIGNAL;
 #endif /* PPS_SYNC */
+
+	NTPADJ_UNLOCK();
 }
 
 /*
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 0f015b3..b738083 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
 
 static int tc_chosen;	/* Non-zero if a specific tc was chosen via sysctl. */
 
-static void tc_windup(void);
+static void tc_windup(bool top_call);
+static void tc_windup_locked(void);
 static void cpu_tick_calibrate(int);
 
 void dtrace_getnanotime(struct timespec *tsp);
@@ -1247,7 +1248,7 @@ tc_setclock(struct timespec *ts)
 	bintime2timeval(&bt, &boottime);
 
 	/* XXX fiddle all the little crinkly bits around the fiords... */
-	tc_windup();
+	tc_windup(true);
 	nanotime(&taft);
 	if (timestepwarnings) {
 		log(LOG_INFO,
@@ -1259,13 +1260,30 @@ tc_setclock(struct timespec *ts)
 	cpu_tick_calibrate(1);
 }
 
+static volatile int tc_windup_lock;
+static void
+tc_windup(bool top_call)
+{
+
+	for (;;) {
+		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
+			atomic_thread_fence_acq();
+			tc_windup_locked();
+			atomic_store_rel_int(&tc_windup_lock, 0);
+			break;
+		} else if (!top_call) {
+			break;
+		}
+	}
+}
+
 /*
  * Initialize the next struct timehands in the ring and make
  * it the active timehands.  Along the way we might switch to a different
  * timecounter and/or do seconds processing in NTP.  Slightly magic.
  */
 static void
-tc_windup(void)
+tc_windup_locked(void)
 {
 	struct bintime bt;
 	struct timehands *th, *tho;
@@ -1846,7 +1864,7 @@ tc_ticktock(int cnt)
 	if (count < tc_tick)
 		return;
 	count = 0;
-	tc_windup();
+	tc_windup(false);
 }
 
 static void __inline
@@ -1921,7 +1939,7 @@ inittimecounter(void *dummy)
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
 	(void)timecounter->tc_get_timecount(timecounter);
-	tc_windup();
+	tc_windup(true);
 }
 
 SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL);
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 148da2b..82710f7 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv)
 	struct timeval delta, tv1, tv2;
 	static struct timeval maxtime, laststep;
 	struct timespec ts;
-	int s;
 
-	s = splclock();
 	microtime(&tv1);
 	delta = *tv;
 	timevalsub(&delta, &tv1);
@@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv)
 				printf("Time adjustment clamped to -1 second\n");
 			}
 		} else {
-			if (tv1.tv_sec == laststep.tv_sec) {
-				splx(s);
+			if (tv1.tv_sec == laststep.tv_sec)
 				return (EPERM);
-			}
 			if (delta.tv_sec > 1) {
 				tv->tv_sec = tv1.tv_sec + 1;
 				printf("Time adjustment clamped to +1 second\n");
@@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv)
 
 	ts.tv_sec = tv->tv_sec;
 	ts.tv_nsec = tv->tv_usec * 1000;
-	mtx_lock(&Giant);
 	tc_setclock(&ts);
 	resettodr();
-	mtx_unlock(&Giant);
 	return (0);
 }
 
diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c
index dbad36d..4bac324 100644
--- a/sys/kern/subr_rtc.c
+++ b/sys/kern/subr_rtc.c
@@ -172,11 +172,11 @@ resettodr(void)
 	if (disable_rtc_set || clock_dev == NULL)
 		return;
 
-	mtx_lock(&resettodr_lock);
 	getnanotime(&ts);
 	timespecadd(&ts, &clock_adj);
 	ts.tv_sec -= utc_offset();
 	/* XXX: We should really set all registered RTCs */
+	mtx_lock(&resettodr_lock);
 	error = CLOCK_SETTIME(clock_dev, &ts);
 	mtx_unlock(&resettodr_lock);
 	if (error != 0)

From owner-svn-src-all@freebsd.org  Wed Jun 29 15:32:46 2016
Return-Path: 
Delivered-To: svn-src-all@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 028CEB866C2;
 Wed, 29 Jun 2016 15:32:46 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 4901C24C5;
 Wed, 29 Jun 2016 15:32:45 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TFWX28072367
 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
 Wed, 29 Jun 2016 18:32:33 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TFWX28072367
Received: (from kostik@localhost)
 by tom.home (8.15.2/8.15.2/Submit) id u5TFWXPM072366;
 Wed, 29 Jun 2016 18:32:33 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Wed, 29 Jun 2016 18:32:33 +0300
From: Konstantin Belousov 
To: Bruce Evans 
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
Message-ID: <20160629153233.GI38613@kib.kiev.ua>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org>
 <20160629145443.GG38613@kib.kiev.ua>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160629145443.GG38613@kib.kiev.ua>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no
 autolearn_force=no version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 15:32:46 -0000

On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote:
> This is a reply to two mails in one, both for r302251 and r302252 threads.
> 
> On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote:
> > On Tue, 28 Jun 2016, Konstantin Belousov wrote:
> > 
> > > Log:
> > >  Do not use Giant to prevent parallel calls to CLOCK_SETTIME().  Use
> > >  private mtx in resettodr(), no implementation of CLOCK_SETTIME() is
> > >  allowed to sleep.
> > 
> > Thanks.
> > 
> > As you know, clock locking is still quite broken.  The most obvious
> > bugs near here are now:
> > - settime() still begins with splclock().  This gave fewer bugs in
> >    clock locking when it last worked in FreeBSD-4.  Now it is just
> >    a hint that the clock locking has still not been converted to use
> >    mutexes.
> > - bitrot near the end of settime() removed the splx() that should
> >    be paired with the splclock().
> Yes, I am aware of both splclock() and Giant braces in the setclock().
> I did not wanted to even look at tc_setclock() at all, for that change.
> See below.
> 
> > - the locking should be stronger than mutexes (or splclock()) to
> >    minimise the delay between deciding to set the time and actually
> >    setting it.
> ...
> This is separate issue.  Might be a critical section around the code
> is the right approximation for reducing delays there.
> 
> > > +	mtx_lock(&resettodr_lock);
> > 
> > This could be later (only around the hardware parts) since we are sloppy
> > with the delays.
> Done.
> 
> > 
> > > 	getnanotime(&ts);
> > 
> > This doesn't even try to get nanoseconds accuracy.
> > 
> > > 	timespecadd(&ts, &clock_adj);
> > > 	ts.tv_sec -= utc_offset();
> > 
> > Who knows what utc_offset() is locked by?  Certainly not this new locking,
> > since it is set in another file but the new locking is only in this file.
> > It still seems to be most under Giant :-(.
> utc_offset() uses several variables, updates to each of the variable is
> atomic.  There is no even an attempt to provide userspace with an interface
> which would makes updates to the components used by utc_offset() consistent.
> Thus I do not see a need in any locking there.
> 
> > 
> > The change in the other part of the diff is related to this, and doesn't
> > seem quite right.  utc_offset() uses the variables tz_minuteswest,
> > wall_cmos_clock and adjkerntz:
> > - tz_minuteswest is set with no locking in kern_settimeofday(), just
> >    after the settime() call.  This last had a chance of being correct
> >    when the kernel was UP and not preemptible.  But it is broken in
> >    a more fundamental way back to at least FreeBSD-1: resettodr() is
> >    called _before_ updating the timezone, so it uses an out-of-date
> >    tz_minuteswest.
> First, the man page is not correct, saying that 'this information is
> kept outside the kernel'.
> 
> Second, why does settime(), logicall, need the updated timezone ?
> I understand that resettodr() is called on successful update of
> the wall clock.  But shouldn't the need to reset not-GMT RTC clock
> in kern_settimeofday() satisfied by yet another call to resettodr()
> if tzp != NULL, after the tz_* vars update ?
> 
> > - wall_cmos_clock is still under a simple (not MPSAFE) sysctl
> > - adjkerntz is under a PROC sysctl, and you just changed this sysctl to
> >    be MPSAFE.  The sysctl calls here, so we don't want all of it
> >    giant-locked.  But it now does unlocked accesses to the adjkerntz
> >    variable, and the access to the disable_rtc_set variable is unlocked
> >    because we do it before acquiring the lock in this function (this
> >    variable is still under a simple (not MPSAFE) sysctl.
> > 
> > Most of the variables are ints, so access to them are atomic, but without
> > locking the correct order only occurs accidentally and is hard to
> > understand.
> I think there is no any global consistency, mostly caused by existence
> of separate interfaces to control all of them.  IMO it is not worth to
> try to ensure any.
> 
> > 
> > > 	/* XXX: We should really set all registered RTCs */
> > > -	if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0)
> > > +	error = CLOCK_SETTIME(clock_dev, &ts);
> > > +	mtx_unlock(&resettodr_lock);
> > > +	if (error != 0)
> > > 		printf("warning: clock_settime failed (%d), time-of-day clock "
> > > 		    "not adjusted to system time\n", error);
> > > }
> > 
> > The lock needs to cover all high-level accesses to the rtc and related
> > variables to avoid races, and a bit more to minimise delays.  In particular,
> > inittodr() should be under this lock, and there is a problem with
> > "show rtc" in ddb.
> I do not think that inittodr() actually needs that locking.  This code
> is executed at the initialization stage, or at the resume stage.
> 
> Do you mean that CLOCK_GETTIME() hardware access should be made exclusive
> with CLOCK_SETTIME() ?  Is there a hardware that rely on exclusivity and
> not enforce that internally, how x86 rtc does ?
> 
> DDB access to rtc is separate problem.
> 
> On Wed, Jun 29, 2016 at 07:39:45PM +1000, Bruce Evans wrote:
> > On Tue, 28 Jun 2016, Konstantin Belousov wrote:
> > > static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
> > >
> > > +static struct mtx ntpadj_lock;
> > > +MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
> > > +#ifdef PPS_SYNC
> > > +    MTX_SPIN
> > > +#else
> > > +    MTX_DEF
> > > +#endif
> > > +);
> > 
> > This needs to be a spinlock in all cases, since ntp_update_second() needs
> > to be locked and ntp_update_second() is called from tc_windup() is usually
> > called from a fast interrupt handler.
> Oh, I see.
> 
> > 
> > ntp_update_second() is still unlocked.  It accesses lots of variables, so
> > it obviously needs locking.  E.g., its very first access is
> > time_maxerror += MAXFREQ / 1000.  This has the usual non-atomicity for
> > a read-modify write.  This obiously races with the locked access on the
> > 28th linke of sys_ntp_adjtime().  Only the latter is locked now.
> > 
> > > +
> > > +/*
> > > + * When PPS_SYNC is defined, hardpps() function is provided which can
> > > + * be legitimately called from interrupt filters.  Due to this, use
> > > + * spinlock for ntptime state protection, otherwise sleepable mutex is
> > > + * adequate.
> > > + */
> > > +#ifdef PPS_SYNC
> > > +#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
> > > +#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
> > > +#else
> > > +#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
> > > +#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
> > > +#endif
> > > +#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
> > 
> > *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs
> > to be locked.
> Do you have a suggestion for a better name ?
> 
> > 
> > Probably the locking should be shared with kern_tc.c.  tc_windup() still
> > uses only fancy time-domaind/atomic-op locking.  This mostly works, but
> > is quite broken by calling tc_windup() from places other than hardclock().
> > The most problematic other place is from tc_setclock().  That is unlocked,
> > except accidentally by callers with only Giant locking, so it races with
> > the fast interrupt handler.
> > 
> > tc_windup() doesn't need the fancy locking for efficiency -- it only needs
> > it to be consistent with binuptime() and friends.  So it may as well use
> > the same lock as ntp.  Its lock must be around the whole function to
> > protect it from tc_setclock().  Then the same lock works for
> > ntp_update_second() and pps.  Any lock that is only acquired once per
> > second is not worth optimizing.  Hopefully the same for ntp's other locks.
> > ntp syscalls should only be frequent under unusual/malicious loads, so
> > they shouldn't cause much contention with the tc_windup() lock.
> So I postponed looking at tc_windup(), and it seems that it was
> useful. After you note above, it is mostly clear that we can skip some
> tc_windup() calls which conflicts with currently active windup calls.
> E.g., the hardclock update, which is done simultaneously with the
> setclock(), could be just skipped.  But we must not skip the tc_windup()
> call from setclock().
> 
> As an additional, but probably excessive measure, invocation of
> tc_windup() from hardclock could ask the setclock() to re-execute
> tc_windup() after its call is done.
> 
> > > -static int
> > > -ntp_is_time_error(void)
> > > +static bool
> > > +ntp_is_time_error(int tsl)
> > > {
> > > +
> > 
> > Is it worth changing this to make a single variable less volatile?
> Yes, to rely on single-variable read being atomic and avoiding locking
> in callout.
> 
> [Skipped the S64/OPAQUE stuff]
> 
> Patch does the following:
> - change the ntpadj_lock to spinlock.
> - acquire the ntpadj_lock around ntp_update_second().
> - prevent parallel tc_windup() invocations, while not allowing to
>   skip calls coming from kernel top half.
> - move resettodr_lock acquisition in resettodr() later.

I now think that the lock around tc_windup() should have more flavor of
real spinlocks.  Ideally the spinlock_enter() should be taken around it,
but it might be too extreme.  Just a critical section in tc_setclock()
is good enough.

diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index d352ee7..34b29d9 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -163,27 +163,10 @@ static l_fp time_adj;			/* tick adjust (ns/s) */
 static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
 
 static struct mtx ntpadj_lock;
-MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
-#ifdef PPS_SYNC
-    MTX_SPIN
-#else
-    MTX_DEF
-#endif
-);
+MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", MTX_SPIN);
 
-/*
- * When PPS_SYNC is defined, hardpps() function is provided which can
- * be legitimately called from interrupt filters.  Due to this, use
- * spinlock for ntptime state protection, otherwise sleepable mutex is
- * adequate.
- */
-#ifdef PPS_SYNC
 #define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
 #define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
-#else
-#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
-#endif
 #define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
 
 #ifdef PPS_SYNC
@@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	int tickrate;
 	l_fp ftemp;		/* 32/64-bit temporary */
 
+	NTPADJ_LOCK();
+
 	/*
 	 * On rollover of the second both the nanosecond and microsecond
 	 * clocks are updated and the state machine cranked as
@@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	else
 		time_status &= ~STA_PPSSIGNAL;
 #endif /* PPS_SYNC */
+
+	NTPADJ_UNLOCK();
 }
 
 /*
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 0f015b3..a5776d2 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
 
 static int tc_chosen;	/* Non-zero if a specific tc was chosen via sysctl. */
 
-static void tc_windup(void);
+static void tc_windup(bool top_call);
+static void tc_windup_locked(void);
 static void cpu_tick_calibrate(int);
 
 void dtrace_getnanotime(struct timespec *tsp);
@@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts)
 	struct timespec tbef, taft;
 	struct bintime bt, bt2;
 
+	critical_enter();
 	cpu_tick_calibrate(1);
 	nanotime(&tbef);
 	timespec2bintime(ts, &bt);
@@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts)
 	bintime2timeval(&bt, &boottime);
 
 	/* XXX fiddle all the little crinkly bits around the fiords... */
-	tc_windup();
+	tc_windup(true);
 	nanotime(&taft);
+	cpu_tick_calibrate(1);
+	critical_exit();
 	if (timestepwarnings) {
 		log(LOG_INFO,
 		    "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n",
@@ -1256,7 +1260,23 @@ tc_setclock(struct timespec *ts)
 		    (intmax_t)taft.tv_sec, taft.tv_nsec,
 		    (intmax_t)ts->tv_sec, ts->tv_nsec);
 	}
-	cpu_tick_calibrate(1);
+}
+
+static volatile int tc_windup_lock;
+static void
+tc_windup(bool top_call)
+{
+
+	for (;;) {
+		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
+			atomic_thread_fence_acq();
+			tc_windup_locked();
+			atomic_store_rel_int(&tc_windup_lock, 0);
+			break;
+		} else if (!top_call) {
+			break;
+		}
+	}
 }
 
 /*
@@ -1265,7 +1285,7 @@ tc_setclock(struct timespec *ts)
  * timecounter and/or do seconds processing in NTP.  Slightly magic.
  */
 static void
-tc_windup(void)
+tc_windup_locked(void)
 {
 	struct bintime bt;
 	struct timehands *th, *tho;
@@ -1846,7 +1866,7 @@ tc_ticktock(int cnt)
 	if (count < tc_tick)
 		return;
 	count = 0;
-	tc_windup();
+	tc_windup(false);
 }
 
 static void __inline
@@ -1921,7 +1941,7 @@ inittimecounter(void *dummy)
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
 	(void)timecounter->tc_get_timecount(timecounter);
-	tc_windup();
+	tc_windup(true);
 }
 
 SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL);
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 148da2b..82710f7 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv)
 	struct timeval delta, tv1, tv2;
 	static struct timeval maxtime, laststep;
 	struct timespec ts;
-	int s;
 
-	s = splclock();
 	microtime(&tv1);
 	delta = *tv;
 	timevalsub(&delta, &tv1);
@@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv)
 				printf("Time adjustment clamped to -1 second\n");
 			}
 		} else {
-			if (tv1.tv_sec == laststep.tv_sec) {
-				splx(s);
+			if (tv1.tv_sec == laststep.tv_sec)
 				return (EPERM);
-			}
 			if (delta.tv_sec > 1) {
 				tv->tv_sec = tv1.tv_sec + 1;
 				printf("Time adjustment clamped to +1 second\n");
@@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv)
 
 	ts.tv_sec = tv->tv_sec;
 	ts.tv_nsec = tv->tv_usec * 1000;
-	mtx_lock(&Giant);
 	tc_setclock(&ts);
 	resettodr();
-	mtx_unlock(&Giant);
 	return (0);
 }
 
diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c
index dbad36d..4bac324 100644
--- a/sys/kern/subr_rtc.c
+++ b/sys/kern/subr_rtc.c
@@ -172,11 +172,11 @@ resettodr(void)
 	if (disable_rtc_set || clock_dev == NULL)
 		return;
 
-	mtx_lock(&resettodr_lock);
 	getnanotime(&ts);
 	timespecadd(&ts, &clock_adj);
 	ts.tv_sec -= utc_offset();
 	/* XXX: We should really set all registered RTCs */
+	mtx_lock(&resettodr_lock);
 	error = CLOCK_SETTIME(clock_dev, &ts);
 	mtx_unlock(&resettodr_lock);
 	if (error != 0)

From owner-svn-src-all@freebsd.org  Wed Jun 29 16:34:57 2016
Return-Path: 
Delivered-To: svn-src-all@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 B5AE4B861DF;
 Wed, 29 Jun 2016 16:34:57 +0000 (UTC)
 (envelope-from nwhitehorn@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 740AD2792;
 Wed, 29 Jun 2016 16:34:57 +0000 (UTC)
 (envelope-from nwhitehorn@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGYuD9092536;
 Wed, 29 Jun 2016 16:34:56 GMT (envelope-from nwhitehorn@FreeBSD.org)
Received: (from nwhitehorn@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGYu0M092535;
 Wed, 29 Jun 2016 16:34:56 GMT (envelope-from nwhitehorn@FreeBSD.org)
Message-Id: <201606291634.u5TGYu0M092535@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to
 nwhitehorn@FreeBSD.org using -f
From: Nathan Whitehorn 
Date: Wed, 29 Jun 2016 16:34:56 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302280 - head/sys/powerpc/powerpc
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 16:34:57 -0000

Author: nwhitehorn
Date: Wed Jun 29 16:34:56 2016
New Revision: 302280
URL: https://svnweb.freebsd.org/changeset/base/302280

Log:
  Fix fat-fingering: #if AIM should have been #ifdef AIM to avoid failures on
  Book-E kernels.
  
  Approved by:	re (gjb)
  Pointy hat to:	nwhitehorn

Modified:
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c	Wed Jun 29 14:40:43 2016	(r302279)
+++ head/sys/powerpc/powerpc/machdep.c	Wed Jun 29 16:34:56 2016	(r302280)
@@ -251,7 +251,7 @@ powerpc_init(vm_offset_t fdt, vm_offset_
 	if (mdp == (void *)0x65504150)
 		mdp = NULL;
 
-#if AIM
+#ifdef AIM
 	/*
 	 * If running from an FDT, make sure we are in real mode to avoid
 	 * tromping on firmware page tables. Everything in the kernel assumes

From owner-svn-src-all@freebsd.org  Wed Jun 29 16:41:38 2016
Return-Path: 
Delivered-To: svn-src-all@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 5C3A3B8637C;
 Wed, 29 Jun 2016 16:41:38 +0000 (UTC)
 (envelope-from sbruno@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 2AB342CD0;
 Wed, 29 Jun 2016 16:41:38 +0000 (UTC)
 (envelope-from sbruno@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGfbIM094263;
 Wed, 29 Jun 2016 16:41:37 GMT (envelope-from sbruno@FreeBSD.org)
Received: (from sbruno@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGfb42094262;
 Wed, 29 Jun 2016 16:41:37 GMT (envelope-from sbruno@FreeBSD.org)
Message-Id: <201606291641.u5TGfb42094262@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: sbruno set sender to
 sbruno@FreeBSD.org using -f
From: Sean Bruno 
Date: Wed, 29 Jun 2016 16:41:37 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302281 - head/sys/cam/scsi
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 16:41:38 -0000

Author: sbruno
Date: Wed Jun 29 16:41:37 2016
New Revision: 302281
URL: https://svnweb.freebsd.org/changeset/base/302281

Log:
  Correct PERSISTENT RESERVE OUT command and populate scsi_cmd->length.
  
  PR:	202625
  Submitted by:	niakrisn@gmail.com
  Reviewed by:	scottl kenm
  Approved by:	re (gjb)
  MFC after:	2 weeks

Modified:
  head/sys/cam/scsi/scsi_all.c

Modified: head/sys/cam/scsi/scsi_all.c
==============================================================================
--- head/sys/cam/scsi/scsi_all.c	Wed Jun 29 16:34:56 2016	(r302280)
+++ head/sys/cam/scsi/scsi_all.c	Wed Jun 29 16:41:37 2016	(r302281)
@@ -8788,6 +8788,7 @@ scsi_persistent_reserve_out(struct ccb_s
 	scsi_cmd->opcode = PERSISTENT_RES_OUT;
 	scsi_cmd->action = service_action;
 	scsi_cmd->scope_type = scope | res_type;
+	scsi_ulto4b(dxfer_len, scsi_cmd->length);
 
 	cam_fill_csio(csio,
 		      retries,

From owner-svn-src-all@freebsd.org  Wed Jun 29 16:45:03 2016
Return-Path: 
Delivered-To: svn-src-all@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 0AC0FB8652D;
 Wed, 29 Jun 2016 16:45:03 +0000 (UTC)
 (envelope-from bdrewery@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 CEDE92FBD;
 Wed, 29 Jun 2016 16:45:02 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TGj2iV096428;
 Wed, 29 Jun 2016 16:45:02 GMT (envelope-from bdrewery@FreeBSD.org)
Received: (from bdrewery@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TGj2eJ096427;
 Wed, 29 Jun 2016 16:45:02 GMT (envelope-from bdrewery@FreeBSD.org)
Message-Id: <201606291645.u5TGj2eJ096427@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to
 bdrewery@FreeBSD.org using -f
From: Bryan Drewery 
Date: Wed, 29 Jun 2016 16:45:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302282 - head/share/mk
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 16:45:03 -0000

Author: bdrewery
Date: Wed Jun 29 16:45:01 2016
New Revision: 302282
URL: https://svnweb.freebsd.org/changeset/base/302282

Log:
  Don't warn about needing filemon for makeman.
  
  r287879 wasn't quite enough here since Makefile.inc1 is running
  'make -C release -V VERSION' and hitting the warning.
  
  Reported by:	lattera
  Sponsored by:	EMC / Isilon Storage Division
  Approved by:	re (blanket, META_MODE)

Modified:
  head/share/mk/bsd.init.mk

Modified: head/share/mk/bsd.init.mk
==============================================================================
--- head/share/mk/bsd.init.mk	Wed Jun 29 16:41:37 2016	(r302281)
+++ head/share/mk/bsd.init.mk	Wed Jun 29 16:45:01 2016	(r302282)
@@ -31,7 +31,7 @@ _SKIP_BUILD = not building at level 0
 .if ${MK_META_MODE} == "yes"
 .if !exists(/dev/filemon) && \
     ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \
-    !make(showconfig)
+    !make(showconfig) && ${.MAKEFLAGS:M-V} == ""
 .warning The filemon module (/dev/filemon) is not loaded.
 .warning META_MODE is less useful for incremental builds without filemon.
 .warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning.

From owner-svn-src-all@freebsd.org  Wed Jun 29 17:25:48 2016
Return-Path: 
Delivered-To: svn-src-all@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 35A5BB86DB9;
 Wed, 29 Jun 2016 17:25:48 +0000 (UTC)
 (envelope-from avos@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 1152124F4;
 Wed, 29 Jun 2016 17:25:47 +0000 (UTC)
 (envelope-from avos@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5THPleF011752;
 Wed, 29 Jun 2016 17:25:47 GMT (envelope-from avos@FreeBSD.org)
Received: (from avos@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5THPk0Y011747;
 Wed, 29 Jun 2016 17:25:46 GMT (envelope-from avos@FreeBSD.org)
Message-Id: <201606291725.u5THPk0Y011747@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: avos set sender to
 avos@FreeBSD.org using -f
From: Andriy Voskoboinyk 
Date: Wed, 29 Jun 2016 17:25:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302283 - head/sys/net80211
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 17:25:48 -0000

Author: avos
Date: Wed Jun 29 17:25:46 2016
New Revision: 302283
URL: https://svnweb.freebsd.org/changeset/base/302283

Log:
  net80211: fix LOR/deadlock in ieee80211_ff_node_cleanup().
  
  Add new lock for stageq (part of ieee80211_superg structure) and
  ni_tx_superg (part of ieee80211_node structure);
  drop com_lock protection where it is used to protect them.
  
  While here, drop duplicate OPACKETS counter incrementation.
  
  ni_tx_ampdu is not protected with it (however, it is also used without
  locking in other places; probably, it requires some other solution
  to be thread-safe).
  
  Tested with RTL8188CUS (AP) and RTL8188EU (STA).
  
  NOTE: Since this change breaks KBI, all wireless drivers need to be
  recompiled.
  
  Reviewed by:	adrian
  Approved by:	re (gjb)
  Differential Revision:	https://reviews.freebsd.org/D6958

Modified:
  head/sys/net80211/ieee80211_ddb.c
  head/sys/net80211/ieee80211_freebsd.h
  head/sys/net80211/ieee80211_superg.c
  head/sys/net80211/ieee80211_superg.h
  head/sys/net80211/ieee80211_var.h

Modified: head/sys/net80211/ieee80211_ddb.c
==============================================================================
--- head/sys/net80211/ieee80211_ddb.c	Wed Jun 29 16:45:01 2016	(r302282)
+++ head/sys/net80211/ieee80211_ddb.c	Wed Jun 29 17:25:46 2016	(r302283)
@@ -506,6 +506,8 @@ _db_show_com(const struct ieee80211com *
 	db_printf("\tsoftc %p", ic->ic_softc);
 	db_printf("\tname %s", ic->ic_name);
 	db_printf(" comlock %p", &ic->ic_comlock);
+	db_printf(" txlock %p", &ic->ic_txlock);
+	db_printf(" fflock %p", &ic->ic_fflock);
 	db_printf("\n");
 	db_printf("\theadroom %d", ic->ic_headroom);
 	db_printf(" phytype %d", ic->ic_phytype);

Modified: head/sys/net80211/ieee80211_freebsd.h
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.h	Wed Jun 29 16:45:01 2016	(r302282)
+++ head/sys/net80211/ieee80211_freebsd.h	Wed Jun 29 17:25:46 2016	(r302283)
@@ -83,6 +83,25 @@ typedef struct {
 	mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED)
 
 /*
+ * Stageq / ni_tx_superg lock
+ */
+typedef struct {
+	char		name[16];		/* e.g. "ath0_ff_lock" */
+	struct mtx	mtx;
+} ieee80211_ff_lock_t;
+#define IEEE80211_FF_LOCK_INIT(_ic, _name) do {				\
+	ieee80211_ff_lock_t *fl = &(_ic)->ic_fflock;			\
+	snprintf(fl->name, sizeof(fl->name), "%s_ff_lock", _name);	\
+	mtx_init(&fl->mtx, fl->name, NULL, MTX_DEF);			\
+} while (0)
+#define IEEE80211_FF_LOCK_OBJ(_ic)	(&(_ic)->ic_fflock.mtx)
+#define IEEE80211_FF_LOCK_DESTROY(_ic)	mtx_destroy(IEEE80211_FF_LOCK_OBJ(_ic))
+#define IEEE80211_FF_LOCK(_ic)		mtx_lock(IEEE80211_FF_LOCK_OBJ(_ic))
+#define IEEE80211_FF_UNLOCK(_ic)	mtx_unlock(IEEE80211_FF_LOCK_OBJ(_ic))
+#define IEEE80211_FF_LOCK_ASSERT(_ic) \
+	mtx_assert(IEEE80211_FF_LOCK_OBJ(_ic), MA_OWNED)
+
+/*
  * Node locking definitions.
  */
 typedef struct {

Modified: head/sys/net80211/ieee80211_superg.c
==============================================================================
--- head/sys/net80211/ieee80211_superg.c	Wed Jun 29 16:45:01 2016	(r302282)
+++ head/sys/net80211/ieee80211_superg.c	Wed Jun 29 17:25:46 2016	(r302283)
@@ -99,6 +99,8 @@ ieee80211_superg_attach(struct ieee80211
 {
 	struct ieee80211_superg *sg;
 
+	IEEE80211_FF_LOCK_INIT(ic, ic->ic_name);
+
 	sg = (struct ieee80211_superg *) IEEE80211_MALLOC(
 	     sizeof(struct ieee80211_superg), M_80211_VAP,
 	     IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
@@ -120,6 +122,8 @@ ieee80211_superg_attach(struct ieee80211
 void
 ieee80211_superg_detach(struct ieee80211com *ic)
 {
+	IEEE80211_FF_LOCK_DESTROY(ic);
+
 	if (ic->ic_superg != NULL) {
 		IEEE80211_FREE(ic->ic_superg, M_80211_VAP);
 		ic->ic_superg = NULL;
@@ -575,19 +579,14 @@ ff_transmit(struct ieee80211_node *ni, s
 {
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211com *ic = ni->ni_ic;
-	int error;
 
-	IEEE80211_TX_LOCK_ASSERT(vap->iv_ic);
+	IEEE80211_TX_LOCK_ASSERT(ic);
 
 	/* encap and xmit */
 	m = ieee80211_encap(vap, ni, m);
-	if (m != NULL) {
-		struct ifnet *ifp = vap->iv_ifp;
-
-		error = ieee80211_parent_xmitpkt(ic, m);
-		if (!error)
-			if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
-	} else
+	if (m != NULL)
+		(void) ieee80211_parent_xmitpkt(ic, m);
+	else
 		ieee80211_free_node(ni);
 }
 
@@ -620,14 +619,6 @@ ff_flush(struct mbuf *head, struct mbuf 
 
 /*
  * Age frames on the staging queue.
- *
- * This is called without the comlock held, but it does all its work
- * behind the comlock.  Because of this, it's possible that the
- * staging queue will be serviced between the function which called
- * it and now; thus simply checking that the queue has work in it
- * may fail.
- *
- * See PR kern/174283 for more details.
  */
 void
 ieee80211_ff_age(struct ieee80211com *ic, struct ieee80211_stageq *sq,
@@ -636,11 +627,14 @@ ieee80211_ff_age(struct ieee80211com *ic
 	struct mbuf *m, *head;
 	struct ieee80211_node *ni;
 
-#if 0
+	IEEE80211_FF_LOCK(ic);
+	if (sq->depth == 0) {
+		IEEE80211_FF_UNLOCK(ic);
+		return;		/* nothing to do */
+	}
+
 	KASSERT(sq->head != NULL, ("stageq empty"));
-#endif
 
-	IEEE80211_LOCK(ic);
 	head = sq->head;
 	while ((m = sq->head) != NULL && M_AGE_GET(m) < quanta) {
 		int tid = WME_AC_TO_TID(M_WME_GETAC(m));
@@ -657,7 +651,7 @@ ieee80211_ff_age(struct ieee80211com *ic
 		sq->tail = NULL;
 	else
 		M_AGE_SUB(m, quanta);
-	IEEE80211_UNLOCK(ic);
+	IEEE80211_FF_UNLOCK(ic);
 
 	IEEE80211_TX_LOCK(ic);
 	ff_flush(head, m);
@@ -669,7 +663,7 @@ stageq_add(struct ieee80211com *ic, stru
 {
 	int age = ieee80211_ffagemax;
 
-	IEEE80211_LOCK_ASSERT(ic);
+	IEEE80211_FF_LOCK_ASSERT(ic);
 
 	if (sq->tail != NULL) {
 		sq->tail->m_nextpkt = m;
@@ -688,7 +682,7 @@ stageq_remove(struct ieee80211com *ic, s
 {
 	struct mbuf *m, *mprev;
 
-	IEEE80211_LOCK_ASSERT(ic);
+	IEEE80211_FF_LOCK_ASSERT(ic);
 
 	mprev = NULL;
 	for (m = sq->head; m != NULL; m = m->m_nextpkt) {
@@ -767,6 +761,11 @@ ieee80211_ff_check(struct ieee80211_node
 
 	IEEE80211_TX_UNLOCK_ASSERT(ic);
 
+	IEEE80211_LOCK(ic);
+	limit = IEEE80211_TXOP_TO_US(
+	    ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit);
+	IEEE80211_UNLOCK(ic);
+
 	/*
 	 * Check if the supplied frame can be aggregated.
 	 *
@@ -774,7 +773,7 @@ ieee80211_ff_check(struct ieee80211_node
 	 *     Do 802.1x EAPOL frames proceed in the clear? Then they couldn't
 	 *     be aggregated with other types of frames when encryption is on?
 	 */
-	IEEE80211_LOCK(ic);
+	IEEE80211_FF_LOCK(ic);
 	tap = &ni->ni_tx_ampdu[WME_AC_TO_TID(pri)];
 	mstaged = ni->ni_tx_superg[WME_AC_TO_TID(pri)];
 	/* XXX NOTE: reusing packet counter state from A-MPDU */
@@ -792,7 +791,7 @@ ieee80211_ff_check(struct ieee80211_node
 	if (vap->iv_opmode != IEEE80211_M_STA &&
 	    ETHER_IS_MULTICAST(mtod(m, struct ether_header *)->ether_dhost)) {
 		/* XXX flush staged frame? */
-		IEEE80211_UNLOCK(ic);
+		IEEE80211_FF_UNLOCK(ic);
 		return m;
 	}
 	/*
@@ -801,15 +800,13 @@ ieee80211_ff_check(struct ieee80211_node
 	 */
 	if (mstaged == NULL &&
 	    ieee80211_txampdu_getpps(tap) < ieee80211_ffppsmin) {
-		IEEE80211_UNLOCK(ic);
+		IEEE80211_FF_UNLOCK(ic);
 		return m;
 	}
 	sq = &sg->ff_stageq[pri];
 	/*
 	 * Check the txop limit to insure the aggregate fits.
 	 */
-	limit = IEEE80211_TXOP_TO_US(
-		ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit);
 	if (limit != 0 &&
 	    (txtime = ff_approx_txtime(ni, m, mstaged)) > limit) {
 		/*
@@ -824,7 +821,7 @@ ieee80211_ff_check(struct ieee80211_node
 		ni->ni_tx_superg[WME_AC_TO_TID(pri)] = NULL;
 		if (mstaged != NULL)
 			stageq_remove(ic, sq, mstaged);
-		IEEE80211_UNLOCK(ic);
+		IEEE80211_FF_UNLOCK(ic);
 
 		if (mstaged != NULL) {
 			IEEE80211_TX_LOCK(ic);
@@ -846,7 +843,7 @@ ieee80211_ff_check(struct ieee80211_node
 	if (mstaged != NULL) {
 		ni->ni_tx_superg[WME_AC_TO_TID(pri)] = NULL;
 		stageq_remove(ic, sq, mstaged);
-		IEEE80211_UNLOCK(ic);
+		IEEE80211_FF_UNLOCK(ic);
 
 		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
 		    "%s: aggregate fast-frame", __func__);
@@ -862,13 +859,13 @@ ieee80211_ff_check(struct ieee80211_node
 		mstaged->m_nextpkt = m;
 		mstaged->m_flags |= M_FF; /* NB: mark for encap work */
 	} else {
-		KASSERT(ni->ni_tx_superg[WME_AC_TO_TID(pri)]== NULL,
+		KASSERT(ni->ni_tx_superg[WME_AC_TO_TID(pri)] == NULL,
 		    ("ni_tx_superg[]: %p",
 		    ni->ni_tx_superg[WME_AC_TO_TID(pri)]));
 		ni->ni_tx_superg[WME_AC_TO_TID(pri)] = m;
 
 		stageq_add(ic, sq, m);
-		IEEE80211_UNLOCK(ic);
+		IEEE80211_FF_UNLOCK(ic);
 
 		IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
 		    "%s: stage frame, %u queued", __func__, sq->depth);
@@ -926,7 +923,7 @@ ieee80211_ff_node_cleanup(struct ieee802
 	struct mbuf *m, *next_m, *head;
 	int tid;
 
-	IEEE80211_LOCK(ic);
+	IEEE80211_FF_LOCK(ic);
 	head = NULL;
 	for (tid = 0; tid < WME_NUM_TID; tid++) {
 		int ac = TID_TO_WME_AC(tid);
@@ -945,7 +942,7 @@ ieee80211_ff_node_cleanup(struct ieee802
 			head = m;
 		}
 	}
-	IEEE80211_UNLOCK(ic);
+	IEEE80211_FF_UNLOCK(ic);
 
 	/*
 	 * Free mbufs, taking care to not dereference the mbuf after

Modified: head/sys/net80211/ieee80211_superg.h
==============================================================================
--- head/sys/net80211/ieee80211_superg.h	Wed Jun 29 16:45:01 2016	(r302282)
+++ head/sys/net80211/ieee80211_superg.h	Wed Jun 29 17:25:46 2016	(r302283)
@@ -107,38 +107,32 @@ struct mbuf *ieee80211_ff_check(struct i
 void	ieee80211_ff_age(struct ieee80211com *, struct ieee80211_stageq *,
 	     int quanta);
 
-/*
- * See ieee80211_ff_age() for a description of the locking
- * expectation here.
- */
 static __inline void
-ieee80211_ff_flush(struct ieee80211com *ic, int ac)
+ieee80211_ff_age_all(struct ieee80211com *ic, int quanta)
 {
 	struct ieee80211_superg *sg = ic->ic_superg;
 
-	if (sg != NULL && sg->ff_stageq[ac].depth)
-		ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff);
+	if (sg != NULL) {
+		ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta);
+		ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta);
+		ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta);
+		ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta);
+	}
 }
 
-/*
- * See ieee80211_ff_age() for a description of the locking
- * expectation here.
- */
 static __inline void
-ieee80211_ff_age_all(struct ieee80211com *ic, int quanta)
+ieee80211_ff_flush(struct ieee80211com *ic, int ac)
 {
 	struct ieee80211_superg *sg = ic->ic_superg;
 
-	if (sg != NULL) {
-		if (sg->ff_stageq[WME_AC_VO].depth)
-			ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta);
-		if (sg->ff_stageq[WME_AC_VI].depth)
-			ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta);
-		if (sg->ff_stageq[WME_AC_BE].depth)
-			ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta);
-		if (sg->ff_stageq[WME_AC_BK].depth)
-			ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta);
-	}
+	if (sg != NULL)
+		ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff);
+}
+
+static __inline void
+ieee80211_ff_flush_all(struct ieee80211com *ic)
+{
+	ieee80211_ff_age_all(ic, 0x7fffffff);
 }
 
 struct mbuf *ieee80211_ff_encap(struct ieee80211vap *, struct mbuf *,

Modified: head/sys/net80211/ieee80211_var.h
==============================================================================
--- head/sys/net80211/ieee80211_var.h	Wed Jun 29 16:45:01 2016	(r302282)
+++ head/sys/net80211/ieee80211_var.h	Wed Jun 29 17:25:46 2016	(r302283)
@@ -121,6 +121,7 @@ struct ieee80211com {
 	const char		*ic_name;	/* usually device name */
 	ieee80211_com_lock_t	ic_comlock;	/* state update lock */
 	ieee80211_tx_lock_t	ic_txlock;	/* ic/vap TX lock */
+	ieee80211_ff_lock_t	ic_fflock;	/* stageq/ni_tx_superg lock */
 	LIST_ENTRY(ieee80211com)   ic_next;	/* on global list */
 	TAILQ_HEAD(, ieee80211vap) ic_vaps;	/* list of vap instances */
 	int			ic_headroom;	/* driver tx headroom needs */

From owner-svn-src-all@freebsd.org  Wed Jun 29 17:36:29 2016
Return-Path: 
Delivered-To: svn-src-all@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 01463B860B7;
 Wed, 29 Jun 2016 17:36:28 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org
 [IPv6:2001:1900:2254:206c::16:87])
 by mx1.freebsd.org (Postfix) with ESMTP id D58412DBD;
 Wed, 29 Jun 2016 17:36:28 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from mail.xzibition.com (localhost [IPv6:::1])
 by freefall.freebsd.org (Postfix) with ESMTP id CA73D1A0C;
 Wed, 29 Jun 2016 17:36:28 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from mail.xzibition.com (localhost [172.31.3.2])
 by mail.xzibition.com (Postfix) with ESMTP id 7DB3621DBC;
 Wed, 29 Jun 2016 17:36:28 +0000 (UTC)
X-Virus-Scanned: amavisd-new at mail.xzibition.com
Received: from mail.xzibition.com ([172.31.3.2])
 by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new,
 port 10026)
 with LMTP id q--zsv3nNlu4; Wed, 29 Jun 2016 17:36:21 +0000 (UTC)
Subject: Re: svn commit: r302283 - head/sys/net80211
DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 37E3A21DB0
To: Andriy Voskoboinyk , src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
References: <201606291725.u5THPk0Y011747@repo.freebsd.org>
From: Bryan Drewery 
Organization: FreeBSD
Message-ID: 
Date: Wed, 29 Jun 2016 10:36:18 -0700
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0)
 Gecko/20100101 Thunderbird/45.1.1
MIME-Version: 1.0
In-Reply-To: <201606291725.u5THPk0Y011747@repo.freebsd.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 17:36:29 -0000

On 6/29/16 10:25 AM, Andriy Voskoboinyk wrote:
>   NOTE: Since this change breaks KBI, all wireless drivers need to be
>   recompiled.

__FreeBSD_version should probably be bumped in sys/sys/param.h

-- 
Regards,
Bryan Drewery

From owner-svn-src-all@freebsd.org  Wed Jun 29 18:19:07 2016
Return-Path: 
Delivered-To: svn-src-all@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 465C5B869C6;
 Wed, 29 Jun 2016 18:19:07 +0000 (UTC)
 (envelope-from sobomax@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 233B520D3;
 Wed, 29 Jun 2016 18:19:07 +0000 (UTC)
 (envelope-from sobomax@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TIJ6XI030915;
 Wed, 29 Jun 2016 18:19:06 GMT (envelope-from sobomax@FreeBSD.org)
Received: (from sobomax@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TIJ69s030911;
 Wed, 29 Jun 2016 18:19:06 GMT (envelope-from sobomax@FreeBSD.org)
Message-Id: <201606291819.u5TIJ69s030911@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: sobomax set sender to
 sobomax@FreeBSD.org using -f
From: Maxim Sobolev 
Date: Wed, 29 Jun 2016 18:19:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302284 - head/sys/geom/uzip
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 18:19:07 -0000

Author: sobomax
Date: Wed Jun 29 18:19:05 2016
New Revision: 302284
URL: https://svnweb.freebsd.org/changeset/base/302284

Log:
  1.Improve handling around last compressed block of the file, which is
    necessary because CLOOP format lacks explicit EOF or length, so that
    in the presence of padding or when the CLOOP is put onto a larger
    partition upper level provider size may be larger. Bound amount
    of extra data that we might touch to the max length of the compressed
    block and detect zero-padding in the last cluster, which when
    sector is all-zero might cause us to emit bogus I/O error after
    decompression of that fails. To not make code any more complicated
    that it needs to be deal with it in lazy-manner, i.e. when we
    first access that specific cluster.
  
    This change also fixes stupid mistake in the LZMA code, inherited
    from geom_lzma, which does not share length of the output buffer
    buffer with the decompression routine, so that in the presence
    of corrupted or purposedly tailored data may easily cause heap
    overflow and kernel memory corruption.
  
    Beef up validation of the CLOOP TOC by checking that lengths of
    all but the last compressed clusters match upper limit set by
    the decompressor and improve some error diagnostic output while
    I am here.
  
  2.Add kern.geom.uzip.attach_to tunable to artifically limit
    attaching uzip to certain devices in the dev tree only.
  
      For example the following only makes us attaching to the
      GPT labels:
  
      kern.geom.uzip.attach_to="gpt/*"
  
  3.Add kern.geom.uzip.noattach_to, which does opposite to the (2)
    above, i.e. prevents geom_uzip from tasting / attaching to
    providers matching some pattern. By default we don't attach
    to our own kind, i.e. kern.geom.uzip.noattach_to="*.uzip".
    It saves us quite some CPU cycles, esp on low-end embedded
    systems.
  
  Approved by:	re (gjb)
  Differential Revision:	https://reviews.freebsd.org/D7013

Modified:
  head/sys/geom/uzip/g_uzip.c
  head/sys/geom/uzip/g_uzip_dapi.h
  head/sys/geom/uzip/g_uzip_lzma.c
  head/sys/geom/uzip/g_uzip_zlib.c

Modified: head/sys/geom/uzip/g_uzip.c
==============================================================================
--- head/sys/geom/uzip/g_uzip.c	Wed Jun 29 17:25:46 2016	(r302283)
+++ head/sys/geom/uzip/g_uzip.c	Wed Jun 29 18:19:05 2016	(r302284)
@@ -60,6 +60,8 @@ FEATURE(geom_uzip, "GEOM read-only compr
 struct g_uzip_blk {
         uint64_t offset;
         uint32_t blen;
+        unsigned char last:1;
+        unsigned char padded:1;
 #define BLEN_UNDEF      UINT32_MAX
 };
 
@@ -84,6 +86,16 @@ struct g_uzip_blk {
 #define	GUZ_DBG_IO	3
 #define	GUZ_DBG_TOC	4
 
+#define	GUZ_DEV_SUFX	".uzip"
+#define	GUZ_DEV_NAME(p)	(p GUZ_DEV_SUFX)
+
+static char g_uzip_attach_to[MAXPATHLEN] = {"*"};
+static char g_uzip_noattach_to[MAXPATHLEN] = {GUZ_DEV_NAME("*")};
+TUNABLE_STR("kern.geom.uzip.attach_to", g_uzip_attach_to,
+    sizeof(g_uzip_attach_to));
+TUNABLE_STR("kern.geom.uzip.noattach_to", g_uzip_noattach_to,
+    sizeof(g_uzip_noattach_to));
+
 SYSCTL_DECL(_kern_geom);
 SYSCTL_NODE(_kern_geom, OID_AUTO, uzip, CTLFLAG_RW, 0, "GEOM_UZIP stuff");
 static u_int g_uzip_debug = GEOM_UZIP_DBG_DEFAULT;
@@ -258,8 +270,9 @@ g_uzip_request(struct g_geom *gp, struct
 	}
 
 	DPRINTF_BRNG(GUZ_DBG_IO, start_blk, end_blk, ("%s/%s: %p: "
-	    "start=%u (%ju), end=%u (%ju)\n", __func__, gp->name, bp,
+	    "start=%u (%ju[%jd]), end=%u (%ju)\n", __func__, gp->name, bp,
 	    (u_int)start_blk, (uintmax_t)sc->toc[start_blk].offset,
+	    (intmax_t)sc->toc[start_blk].blen,
 	    (u_int)end_blk, (uintmax_t)BLK_ENDS(sc, end_blk - 1)));
 
 	bp2 = g_clone_bio(bp);
@@ -272,16 +285,18 @@ g_uzip_request(struct g_geom *gp, struct
 	bp2->bio_offset = TOFF_2_BOFF(sc, pp, start_blk);
 	while (1) {
 		bp2->bio_length = TLEN_2_BLEN(sc, pp, bp2, end_blk - 1);
-		if (bp2->bio_length <= MAXPHYS)
+		if (bp2->bio_length <= MAXPHYS) {
 			break;
+		}
 		if (end_blk == (start_blk + 1)) {
 			break;
 		}
 		end_blk--;
 	}
 
-	DPRINTF(GUZ_DBG_IO, ("%s/%s: bp2->bio_length = %jd\n",
-	    __func__, gp->name, (intmax_t)bp2->bio_length));
+	DPRINTF(GUZ_DBG_IO, ("%s/%s: bp2->bio_length = %jd, "
+	    "bp2->bio_offset = %jd\n", __func__, gp->name,
+	    (intmax_t)bp2->bio_length, (intmax_t)bp2->bio_offset));
 
 	bp2->bio_data = malloc(bp2->bio_length, M_GEOM_UZIP, M_NOWAIT);
 	if (bp2->bio_data == NULL) {
@@ -315,6 +330,15 @@ g_uzip_read_done(struct bio *bp)
 	wakeup(sc);
 }
 
+static int
+g_uzip_memvcmp(const void *memory, unsigned char val, size_t size)
+{
+	const u_char *mm;
+
+	mm = (const u_char *)memory;
+	return (*mm == val) && memcmp(mm, mm + 1, size - 1) == 0;
+}
+
 static void
 g_uzip_do(struct g_uzip_softc *sc, struct bio *bp)
 {
@@ -362,18 +386,33 @@ g_uzip_do(struct g_uzip_softc *sc, struc
 		    bp->bio_completed, data2, (u_int)ulen, data, (u_int)len));
 		if (len == 0) {
 			/* All zero block: no cache update */
+zero_block:
 			bzero(data2, ulen);
 		} else if (len <= bp->bio_completed) {
 			mtx_lock(&sc->last_mtx);
 			err = sc->dcp->decompress(sc->dcp, gp->name, data,
 			    len, sc->last_buf);
+			if (err != 0 && sc->toc[blk].last != 0) {
+				/*
+				 * Last block decompression has failed, check
+				 * if it's just zero padding.
+				 */
+				if (g_uzip_memvcmp(data, '\0', len) == 0) {
+					sc->toc[blk].blen = 0;
+					sc->last_blk = -1;
+					mtx_unlock(&sc->last_mtx);
+					len = 0;
+					goto zero_block;
+				}
+			}
 			if (err != 0) {
 				sc->last_blk = -1;
 				mtx_unlock(&sc->last_mtx);
 				bp2->bio_error = EILSEQ;
 				DPRINTF(GUZ_DBG_ERR, ("%s/%s: decompress"
-				    "(%p) failed\n", __func__, gp->name,
-				    sc->dcp));
+				    "(%p, %ju, %ju) failed\n", __func__,
+				    gp->name, sc->dcp, (uintmax_t)blk,
+				    (uintmax_t)len));
 				goto done;
 			}
 			sc->last_blk = blk;
@@ -471,6 +510,7 @@ g_uzip_spoiled(struct g_consumer *cp)
 {
 	struct g_geom *gp;
 
+	G_VALID_CONSUMER(cp);
 	gp = cp->geom;
 	g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name);
 	g_topology_assert();
@@ -486,10 +526,12 @@ g_uzip_parse_toc(struct g_uzip_softc *sc
 {
 	uint32_t i, j, backref_to;
 	uint64_t max_offset, min_offset;
+	struct g_uzip_blk *last_blk;
 
 	min_offset = sizeof(struct cloop_header) +
 	    (sc->nblocks + 1) * sizeof(uint64_t);
 	max_offset = sc->toc[0].offset - 1;
+	last_blk = &sc->toc[0];
 	for (i = 0; i < sc->nblocks; i++) {
 		/* First do some bounds checking */
 		if ((sc->toc[i].offset < min_offset) ||
@@ -497,7 +539,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc
 			goto error_offset;
 		}
 		DPRINTF_BLK(GUZ_DBG_IO, i, ("%s: cluster #%u "
-		    "sc->toc[i].offset=%ju max_offset=%ju\n", gp->name,
+		    "offset=%ju max_offset=%ju\n", gp->name,
 		    (u_int)i, (uintmax_t)sc->toc[i].offset,
 		    (uintmax_t)max_offset));
 		backref_to = BLEN_UNDEF;
@@ -523,6 +565,7 @@ g_uzip_parse_toc(struct g_uzip_softc *sc
 			sc->toc[i].blen = sc->toc[j].blen;
 			backref_to = j;
 		} else {
+			last_blk = &sc->toc[i];
 			/*
 			 * For the "normal blocks" seek forward until we hit
 			 * block whose offset is larger than ours and assume
@@ -557,6 +600,25 @@ g_uzip_parse_toc(struct g_uzip_softc *sc
 		}
 		DPRINTF_BLK(GUZ_DBG_TOC, i, ("\n"));
 	}
+	last_blk->last = 1;
+	/* Do a second pass to validate block lengths */
+	for (i = 0; i < sc->nblocks; i++) {
+		if (sc->toc[i].blen > sc->dcp->max_blen) {
+			if (sc->toc[i].last == 0) {
+				DPRINTF(GUZ_DBG_ERR, ("%s: cluster #%u "
+				    "length (%ju) exceeds "
+				    "max_blen (%ju)\n", gp->name, i,
+				    (uintmax_t)sc->toc[i].blen,
+				    (uintmax_t)sc->dcp->max_blen));
+				return (-1);
+			}
+			DPRINTF(GUZ_DBG_INFO, ("%s: cluster #%u extra "
+			    "padding is detected, trimmed to %ju\n",
+			    gp->name, i, (uintmax_t)sc->dcp->max_blen));
+			    sc->toc[i].blen = sc->dcp->max_blen;
+			sc->toc[i].padded = 1;
+		}
+	}
 	return (0);
 
 error_offset:
@@ -589,12 +651,19 @@ g_uzip_taste(struct g_class *mp, struct 
 	if (pp->acw > 0)
 		return (NULL);
 
+	if ((fnmatch(g_uzip_attach_to, pp->name, 0) != 0) ||
+	    (fnmatch(g_uzip_noattach_to, pp->name, 0) == 0)) {
+		DPRINTF(GUZ_DBG_INFO, ("%s(%s,%s), ignoring\n", __func__,
+		    mp->name, pp->name));
+		return (NULL);
+	}
+
 	buf = NULL;
 
 	/*
 	 * Create geom instance.
 	 */
-	gp = g_new_geomf(mp, "%s.uzip", pp->name);
+	gp = g_new_geomf(mp, GUZ_DEV_NAME("%s"), pp->name);
 	cp = g_new_consumer(gp);
 	error = g_attach(cp, pp);
 	if (error == 0)
@@ -712,6 +781,16 @@ g_uzip_taste(struct g_class *mp, struct 
 		    sc->nblocks < offsets_read ? "more" : "less"));
 		goto e5;
 	}
+
+	if (type == G_UZIP) {
+		sc->dcp = g_uzip_zlib_ctor(sc->blksz);
+	} else {
+		sc->dcp = g_uzip_lzma_ctor(sc->blksz);
+	}
+	if (sc->dcp == NULL) {
+		goto e5;
+	}
+
 	/*
 	 * "Fake" last+1 block, to make it easier for the TOC parser to
 	 * iterate without making the last element a special case.
@@ -720,7 +799,7 @@ g_uzip_taste(struct g_class *mp, struct 
 	/* Massage TOC (table of contents), make sure it is sound */
 	if (g_uzip_parse_toc(sc, pp, gp) != 0) {
 		DPRINTF(GUZ_DBG_ERR, ("%s: TOC error\n", gp->name));
-		goto e5;
+		goto e6;
 	}
 	mtx_init(&sc->last_mtx, "geom_uzip cache", NULL, MTX_DEF);
 	mtx_init(&sc->queue_mtx, "geom_uzip wrkthread", NULL, MTX_DEF);
@@ -730,15 +809,6 @@ g_uzip_taste(struct g_class *mp, struct 
 	sc->req_total = 0;
 	sc->req_cached = 0;
 
-	if (type == G_UZIP) {
-		sc->dcp = g_uzip_zlib_ctor(sc->blksz);
-	} else {
-		sc->dcp = g_uzip_lzma_ctor(sc->blksz);
-	}
-	if (sc->dcp == NULL) {
-		goto e6;
-	}
-
 	sc->uzip_do = &g_uzip_do;
 
 	error = kproc_create(g_uzip_wrkthr, sc, &sc->procp, 0, 0, "%s",
@@ -764,11 +834,11 @@ g_uzip_taste(struct g_class *mp, struct 
 	return (gp);
 
 e7:
-	sc->dcp->free(sc->dcp);
-e6:
 	free(sc->last_buf, M_GEOM);
 	mtx_destroy(&sc->queue_mtx);
 	mtx_destroy(&sc->last_mtx);
+e6:
+	sc->dcp->free(sc->dcp);
 e5:
 	free(sc->toc, M_GEOM);
 e4:

Modified: head/sys/geom/uzip/g_uzip_dapi.h
==============================================================================
--- head/sys/geom/uzip/g_uzip_dapi.h	Wed Jun 29 17:25:46 2016	(r302283)
+++ head/sys/geom/uzip/g_uzip_dapi.h	Wed Jun 29 18:19:05 2016	(r302284)
@@ -38,4 +38,5 @@ struct g_uzip_dapi {
 	g_uzip_dapi_free_t free;
 	g_uzip_dapi_rewind_t rewind;
 	void *pvt;
+	int max_blen;
 };

Modified: head/sys/geom/uzip/g_uzip_lzma.c
==============================================================================
--- head/sys/geom/uzip/g_uzip_lzma.c	Wed Jun 29 17:25:46 2016	(r302283)
+++ head/sys/geom/uzip/g_uzip_lzma.c	Wed Jun 29 18:19:05 2016	(r302284)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -41,6 +42,7 @@ __FBSDID("$FreeBSD$");
 
 struct g_uzip_lzma {
 	struct g_uzip_dapi pub;
+	uint32_t blksz;
 	/* XZ decoder structs */
 	struct xz_buf b;
 	struct xz_dec *s;
@@ -75,13 +77,26 @@ g_uzip_lzma_decompress(struct g_uzip_dap
 	lzp->b.out = obp;
 	lzp->b.in_pos = lzp->b.out_pos = 0;
 	lzp->b.in_size = ilen;
-	lzp->b.out_size = (size_t)-1;
+	lzp->b.out_size = lzp->blksz;
 	err = (xz_dec_run(lzp->s, &lzp->b) != XZ_STREAM_END) ? 1 : 0;
 	/* TODO decoder recovery, if needed */
+	if (err != 0) {
+		printf("%s: ibp=%p, obp=%p, in_pos=%jd, out_pos=%jd, "
+		    "in_size=%jd, out_size=%jd\n", __func__, ibp, obp,
+		    (intmax_t)lzp->b.in_pos, (intmax_t)lzp->b.out_pos,
+		    (intmax_t)lzp->b.in_size, (intmax_t)lzp->b.out_size);
+	}
 
 	return (err);
 }
 
+static int
+LZ4_compressBound(int isize)
+{
+
+        return (isize + (isize / 255) + 16);
+}
+
 struct g_uzip_dapi *
 g_uzip_lzma_ctor(uint32_t blksz)
 {
@@ -93,6 +108,8 @@ g_uzip_lzma_ctor(uint32_t blksz)
 	if (lzp->s == NULL) {
 		goto e1;
 	}
+	lzp->blksz = blksz;
+	lzp->pub.max_blen = LZ4_compressBound(blksz);
 	lzp->pub.decompress = &g_uzip_lzma_decompress;
 	lzp->pub.free = &g_uzip_lzma_free;
 	lzp->pub.rewind = &g_uzip_lzma_nop;

Modified: head/sys/geom/uzip/g_uzip_zlib.c
==============================================================================
--- head/sys/geom/uzip/g_uzip_zlib.c	Wed Jun 29 17:25:46 2016	(r302283)
+++ head/sys/geom/uzip/g_uzip_zlib.c	Wed Jun 29 18:19:05 2016	(r302284)
@@ -97,6 +97,13 @@ g_uzip_zlib_rewind(struct g_uzip_dapi *z
 	return (err);
 }
 
+static int
+z_compressBound(int len)
+{
+
+	return (len + (len >> 12) + (len >> 14) + 11);
+}
+
 struct g_uzip_dapi *
 g_uzip_zlib_ctor(uint32_t blksz)
 {
@@ -109,6 +116,7 @@ g_uzip_zlib_ctor(uint32_t blksz)
 		goto e1;
 	}
 	zp->blksz = blksz;
+	zp->pub.max_blen = z_compressBound(blksz);
 	zp->pub.decompress = &g_uzip_zlib_decompress;
 	zp->pub.free = &g_uzip_zlib_free;
 	zp->pub.rewind = &g_uzip_zlib_rewind;

From owner-svn-src-all@freebsd.org  Wed Jun 29 19:47:45 2016
Return-Path: 
Delivered-To: svn-src-all@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 604C6B85196;
 Wed, 29 Jun 2016 19:47:45 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au
 [211.29.132.53])
 by mx1.freebsd.org (Postfix) with ESMTP id C707D25D7;
 Wed, 29 Jun 2016 19:47:44 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au
 [110.21.100.149])
 by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id F07FFD4563B;
 Thu, 30 Jun 2016 05:47:42 +1000 (AEST)
Date: Thu, 30 Jun 2016 05:47:39 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Konstantin Belousov 
cc: Bruce Evans , src-committers@freebsd.org, 
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
In-Reply-To: <20160629153233.GI38613@kib.kiev.ua>
Message-ID: <20160630040123.F791@besplex.bde.org>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua>
 <20160629153233.GI38613@kib.kiev.ua>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Optus-CM-Score: 0
X-Optus-CM-Analysis: v=2.1 cv=M8SwUHEs c=1 sm=1 tr=0
 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17
 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10
 a=g-2O5F1047fdS1yRY-EA:9 a=CjuIK1q_8ugA:10
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 19:47:45 -0000

On Wed, 29 Jun 2016, Konstantin Belousov wrote:

> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote:
>> This is a reply to two mails in one, both for r302251 and r302252 threads.

Reply to your second reply.

>> On Wed, Jun 29, 2016 at 05:58:05PM +1000, Bruce Evans wrote:
>>> On Tue, 28 Jun 2016, Konstantin Belousov wrote:

>> ...
>>> - the locking should be stronger than mutexes (or splclock()) to
>>>    minimise the delay between deciding to set the time and actually
>>>    setting it.
>> ...
>> This is separate issue.  Might be a critical section around the code
>> is the right approximation for reducing delays there.

Spinlocks give a critical section automatically, but we might not want
to put either around the whole clock_gettime() syscall and if we don't
do that then neither works for reducing delays (preemption is especially
likely when the critical region is left).

>>>...
>>>> 	timespecadd(&ts, &clock_adj);
>>>> 	ts.tv_sec -= utc_offset();
>>>
>>> Who knows what utc_offset() is locked by?  Certainly not this new locking,
>>> since it is set in another file but the new locking is only in this file.
>>> It still seems to be most under Giant :-(.
>> utc_offset() uses several variables, updates to each of the variable is
>> atomic.  There is no even an attempt to provide userspace with an interface
>> which would makes updates to the components used by utc_offset() consistent.
>> Thus I do not see a need in any locking there.

After removing the foot-shooting tz_minuteswest variable from utc_offset(),
all of the variables in it are ones set by adjkerntz sysctls.  The settings
are normally ordered by not running more than 1 instance of adjkerntz.
When adjkerntz starts, this instance shouldn't have any contention with
other initialization doing resettodr().  There is contention every 6
months if wall_cmos_clock when adjkerntz changes the offset for daylight
savings time.  The chances of this used to be tiny since resettodr() was
almost never called, but now there is the periodic resettodr() in
kern_ntptime.c.


>>> ...
>>> The change in the other part of the diff is related to this, and doesn't
>>> seem quite right.  utc_offset() uses the variables tz_minuteswest,
>>> wall_cmos_clock and adjkerntz:
>>> - tz_minuteswest is set with no locking in kern_settimeofday(), just
>>>    after the settime() call.  This last had a chance of being correct
>>>    when the kernel was UP and not preemptible.  But it is broken in
>>>    a more fundamental way back to at least FreeBSD-1: resettodr() is
>>>    called _before_ updating the timezone, so it uses an out-of-date
>>>    tz_minuteswest.
>> First, the man page is not correct, saying that 'this information is
>> kept outside the kernel'.

We deprecate the timezone support in settimeofday(), but use wrong wording
for this here.  The info set by this sysctl is of course kept in the kernel,
and I think the man page is trying to say that this info is never used
outside of the kernel.

The man page doesn't say enough about deprecation, or that we only use this
info for foot-shooting in the kernel, only (?) in utc_offset().  utc_offset()
does:

 	return (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0));

If !wall_cmos_clock, then the offset should be 0, so any setting of
tz_minutewest using the timezone info breaks the offset and this breaks
the rtc _not being on wall time.

If wall_cmos_clock, then adjkerntz(8) normally maintains the offset in
the adjkerntz variable, so again tz_minuteswest must be 0 to work and
any setting of it to nonzero using the timezone info breaks the offset.

>> Second, why does settime(), logicall, need the updated timezone ?
>> I understand that resettodr() is called on successful update of
>> the wall clock.  But shouldn't the need to reset not-GMT RTC clock
c

The timezone updates just give foot-shooting, but we need an up to
date adjkerntz variable initially and on every daylight saving change
in the wall_cmos_clock case.  This is the normal way to keep the rtc
on wall time after every daylight saving changes -- adjkerntz() runs,
and it should change the adjkerntz variable first and then call
settimeofday() with a "null" change to get the side effect of calling
resettodr() which does a large change of the rtc.  It is impossible
to make a really null change of the software clock using settimeofday(),
but I don't know of any better API to do this.  I think the locking that
you just added is enough -- adjkerntz() just has to arrange a call to
resettodr() strictly after it updates the variable, and that happens
almost automatically.

>>>> 	/* XXX: We should really set all registered RTCs */
>>>> -	if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0)
>>>> +	error = CLOCK_SETTIME(clock_dev, &ts);
>>>> +	mtx_unlock(&resettodr_lock);
>>>> +	if (error != 0)
>>>> 		printf("warning: clock_settime failed (%d), time-of-day clock "
>>>> 		    "not adjusted to system time\n", error);
>>>> }
>>>
>>> The lock needs to cover all high-level accesses to the rtc and related
>>> variables to avoid races, and a bit more to minimise delays.  In particular,
>>> inittodr() should be under this lock, and there is a problem with
>>> "show rtc" in ddb.
>> I do not think that inittodr() actually needs that locking.  This code
>> is executed at the initialization stage, or at the resume stage.

Perhaps, but resume runs more often than every 6 months for the daylight
savings time race, and it isn't clear if anything stops resettodr() running
concurrently then.

In my version, something like inittodr() runs 3 seconds after every exit
from ddb.  Stopping in ddb is a bit like a short suspend-resume -- it
stops or breaks some timers, and inittodr() is a way to fix up the
software real time using an unstopped timer.

>*...
>>>> +/*
>>>> + * When PPS_SYNC is defined, hardpps() function is provided which can
>>>> + * be legitimately called from interrupt filters.  Due to this, use
>>>> + * spinlock for ntptime state protection, otherwise sleepable mutex is
>>>> + * adequate.
>>>> + */
>>>> +#ifdef PPS_SYNC
>>>> +#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
>>>> +#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
>>>> +#else
>>>> +#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
>>>> +#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
>>>> +#endif
>>>> +#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
>>>
>>> *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs
>>> to be locked.
>> Do you have a suggestion for a better name ?

Just a general name like ntp_lock for ntp or t_lock if the same lock is
used for timecounters.  I also prefer not to use macros except for
development versions, and then name the lock as xxx_mtx, not xxx_lock.
We depend on special properties of (spin) mutexes.

>*...
>>> Probably the locking should be shared with kern_tc.c.  tc_windup() still
>>> uses only fancy time-domaind/atomic-op locking.  This mostly works, but
>>> is quite broken by calling tc_windup() from places other than hardclock().
>>> The most problematic other place is from tc_setclock().  That is unlocked,
>>> except accidentally by callers with only Giant locking, so it races with
>>> the fast interrupt handler.
>>>
>>> tc_windup() doesn't need the fancy locking for efficiency -- it only needs
>>> it to be consistent with binuptime() and friends.  So it may as well use
>>> the same lock as ntp.  Its lock must be around the whole function to
>>> protect it from tc_setclock().  Then the same lock works for
>>> ntp_update_second() and pps.  Any lock that is only acquired once per
>>> second is not worth optimizing.  Hopefully the same for ntp's other locks.
>>> ntp syscalls should only be frequent under unusual/malicious loads, so
>>> they shouldn't cause much contention with the tc_windup() lock.
>> So I postponed looking at tc_windup(), and it seems that it was
>> useful. After you note above, it is mostly clear that we can skip some
>> tc_windup() calls which conflicts with currently active windup calls.
>> E.g., the hardclock update, which is done simultaneously with the
>> setclock(), could be just skipped.  But we must not skip the tc_windup()
>> call from setclock().

Several things could be deferred, but I think that would just be more
complicated.

>> As an additional, but probably excessive measure, invocation of
>> tc_windup() from hardclock could ask the setclock() to re-execute
>> tc_windup() after its call is done.

I don't quite understand this.  hardclock -> tc_windup() normally doesn't
have interference from tc_setclock().


>> ...
>> Patch does the following:
>> - change the ntpadj_lock to spinlock.
>> - acquire the ntpadj_lock around ntp_update_second().
>> - prevent parallel tc_windup() invocations, while not allowing to
>>   skip calls coming from kernel top half.

tc_setclock() needs locking even more than tc_windup().

>> - move resettodr_lock acquisition in resettodr() later.
>
> I now think that the lock around tc_windup() should have more flavor of
> real spinlocks.  Ideally the spinlock_enter() should be taken around it,
> but it might be too extreme.  Just a critical section in tc_setclock()
> is good enough.

No, it must have a full lock since it does read-write-modify on critical
variables.

> ...
> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> index 0f015b3..a5776d2 100644
> --- a/sys/kern/kern_tc.c
> +++ b/sys/kern/kern_tc.c
> ...
> @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts)
> 	struct timespec tbef, taft;
> 	struct bintime bt, bt2;
>
> +	critical_enter();
> 	cpu_tick_calibrate(1);
> 	nanotime(&tbef);
> 	timespec2bintime(ts, &bt);
> @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts)
> 	bintime2timeval(&bt, &boottime);

boottime is one of the critical variables.  Before this, there are 2
accesses to boottimebin.  The Giant locking that you just removed gave
only some protection here.  It prevented concurrent acccess by
malicious/stress-testing code doing settime().  It didn't prevent
nanotime() and friends seeing boottime in an in-between state.  Oops, 
mutex locking won't fix that either.  I think the update of these
variables needs to be moved into tc_windup() where it will hopefully
automatically be protected by the generation count, like the timehands
offsets already are.

bootime is also accessed with no locking in the kern.boottime sysctl.

There is also ffclock_boottime.  I don't like the duplication for
ffclock, but it doesn't have much duplication for initializing
ffsclock_boottime.

>
> 	/* XXX fiddle all the little crinkly bits around the fiords... */
> -	tc_windup();
> +	tc_windup(true);
> 	nanotime(&taft);
> +	cpu_tick_calibrate(1);

The 2 calls to cpu_tick_calibrate() in this function are excessive.  These
calls are just a hack to recalibrate after suspend/resume as a side effect
of calling here.  The first call suffices, since cpu ticks have nothing to
do with any time variable that is set here.

> +	critical_exit();
> 	if (timestepwarnings) {
> 		log(LOG_INFO,
> 		    "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n",
> @@ -1256,7 +1260,23 @@ tc_setclock(struct timespec *ts)
> 		    (intmax_t)taft.tv_sec, taft.tv_nsec,
> 		    (intmax_t)ts->tv_sec, ts->tv_nsec);
> 	}
> -	cpu_tick_calibrate(1);
> +}
> +
> +static volatile int tc_windup_lock;
> +static void
> +tc_windup(bool top_call)
> +{
> +
> +	for (;;) {
> +		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
> +			atomic_thread_fence_acq();
> +			tc_windup_locked();
> +			atomic_store_rel_int(&tc_windup_lock, 0);
> +			break;
> +		} else if (!top_call) {
> +			break;
> +		}
> +	}
> }

I like to write optimized locking like that, but don't see why you
want it here.

Also, how does WITNESS work for almost any new lock that we don't add
to the witness list?  WITNESS of course doesn't work for special locking
like this.  MTX_NOWITNESS gives mutexes that are almost as efficient as
the above, but with with no witnessing of course.  I prefer to witness
almost everything so that it can be debugged.

Bruce

From owner-svn-src-all@freebsd.org  Wed Jun 29 21:20:08 2016
Return-Path: 
Delivered-To: svn-src-all@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 69E0AB86951;
 Wed, 29 Jun 2016 21:20:08 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id DE147269B;
 Wed, 29 Jun 2016 21:20:07 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5TLJr9l054159
 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
 Thu, 30 Jun 2016 00:19:54 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5TLJr9l054159
Received: (from kostik@localhost)
 by tom.home (8.15.2/8.15.2/Submit) id u5TLJrUw054158;
 Thu, 30 Jun 2016 00:19:53 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Thu, 30 Jun 2016 00:19:53 +0300
From: Konstantin Belousov 
To: Bruce Evans 
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
Message-ID: <20160629211953.GK38613@kib.kiev.ua>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org>
 <20160629145443.GG38613@kib.kiev.ua>
 <20160629153233.GI38613@kib.kiev.ua>
 <20160630040123.F791@besplex.bde.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160630040123.F791@besplex.bde.org>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no
 autolearn_force=no version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Wed, 29 Jun 2016 21:20:08 -0000

On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote:
> On Wed, 29 Jun 2016, Konstantin Belousov wrote:
> 
> > On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote:
> >> This is a reply to two mails in one, both for r302251 and r302252 threads.
> 

> After removing the foot-shooting tz_minuteswest variable from utc_offset(),
> all of the variables in it are ones set by adjkerntz sysctls.  The settings
> are normally ordered by not running more than 1 instance of adjkerntz.
> When adjkerntz starts, this instance shouldn't have any contention with
> other initialization doing resettodr().  There is contention every 6
> months if wall_cmos_clock when adjkerntz changes the offset for daylight
> savings time.  The chances of this used to be tiny since resettodr() was
> almost never called, but now there is the periodic resettodr() in
> kern_ntptime.c.
I do not see how your text above changes anything I said about consistency.
Each sysctl sets or fetches integer variable, so individually it is atomic.
Inter-dependencies between wall_cmos_clock and adjkerntz settings are
completely up to user, no locking can change it while keeping separate
sysctls to set and fetch each var individually.

The only side-effects in resettodr() are possible in CLOCK_SETTIME(),
which is protected against parallel invocation by resettodr_lock.

> 
> 
> >>> ...
> >>> The change in the other part of the diff is related to this, and doesn't
> >>> seem quite right.  utc_offset() uses the variables tz_minuteswest,
> >>> wall_cmos_clock and adjkerntz:
> >>> - tz_minuteswest is set with no locking in kern_settimeofday(), just
> >>>    after the settime() call.  This last had a chance of being correct
> >>>    when the kernel was UP and not preemptible.  But it is broken in
> >>>    a more fundamental way back to at least FreeBSD-1: resettodr() is
> >>>    called _before_ updating the timezone, so it uses an out-of-date
> >>>    tz_minuteswest.
> >> First, the man page is not correct, saying that 'this information is
> >> kept outside the kernel'.
> 
> We deprecate the timezone support in settimeofday(), but use wrong wording
> for this here.  The info set by this sysctl is of course kept in the kernel,
> and I think the man page is trying to say that this info is never used
> outside of the kernel.
How the later statement could be true, since that information is
returned by gettimeofday(), and we do not control what programs a user
might run on his machine.

> 
> The man page doesn't say enough about deprecation, or that we only use this
> info for foot-shooting in the kernel, only (?) in utc_offset().  utc_offset()
> does:
> 
>  	return (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0));
> 
> If !wall_cmos_clock, then the offset should be 0, so any setting of
> tz_minutewest using the timezone info breaks the offset and this breaks
> the rtc _not being on wall time.
> 
> If wall_cmos_clock, then adjkerntz(8) normally maintains the offset in
> the adjkerntz variable, so again tz_minuteswest must be 0 to work and
> any setting of it to nonzero using the timezone info breaks the offset.
> 
> >> Second, why does settime(), logicall, need the updated timezone ?
> >> I understand that resettodr() is called on successful update of
> >> the wall clock.  But shouldn't the need to reset not-GMT RTC clock
> c
> 
> The timezone updates just give foot-shooting, but we need an up to
> date adjkerntz variable initially and on every daylight saving change
> in the wall_cmos_clock case.  This is the normal way to keep the rtc
> on wall time after every daylight saving changes -- adjkerntz() runs,
> and it should change the adjkerntz variable first and then call
> settimeofday() with a "null" change to get the side effect of calling
> resettodr() which does a large change of the rtc.  It is impossible
> to make a really null change of the software clock using settimeofday(),
> but I don't know of any better API to do this.  I think the locking that
> you just added is enough -- adjkerntz() just has to arrange a call to
> resettodr() strictly after it updates the variable, and that happens
> almost automatically.
I think that the way it is done is just by doing sysctl machdep.adjkerntz,
which calls resettodr().  Old wisdom to re-sync RTC to kernel-maintained
time was to run the sysctl from cron, but Andrey added the callout
several years ago.

> >> I do not think that inittodr() actually needs that locking.  This code
> >> is executed at the initialization stage, or at the resume stage.
> 
> Perhaps, but resume runs more often than every 6 months for the daylight
> savings time race, and it isn't clear if anything stops resettodr() running
> concurrently then.
> 
> In my version, something like inittodr() runs 3 seconds after every exit
> from ddb.  Stopping in ddb is a bit like a short suspend-resume -- it
> stops or breaks some timers, and inittodr() is a way to fix up the
> software real time using an unstopped timer.
Lets postpone this.  Might be, a resettodr_lock can be applied to
inittodr() as a whole, and additionally merged with some other lock.
BUt I think inittodr() is not very important right now.

> >>> *ADJ* and *adj* are not good names, since much more than ntp_adj*() needs
> >>> to be locked.
> >> Do you have a suggestion for a better name ?
> 
> Just a general name like ntp_lock for ntp or t_lock if the same lock is
> used for timecounters.  I also prefer not to use macros except for
> development versions, and then name the lock as xxx_mtx, not xxx_lock.
> We depend on special properties of (spin) mutexes.
I want to keep this macroized.  Yes, it is at development stage right now.

> >> So I postponed looking at tc_windup(), and it seems that it was
> >> useful. After you note above, it is mostly clear that we can skip some
> >> tc_windup() calls which conflicts with currently active windup calls.
> >> E.g., the hardclock update, which is done simultaneously with the
> >> setclock(), could be just skipped.  But we must not skip the tc_windup()
> >> call from setclock().
> 
> Several things could be deferred, but I think that would just be more
> complicated.
> 
> >> As an additional, but probably excessive measure, invocation of
> >> tc_windup() from hardclock could ask the setclock() to re-execute
> >> tc_windup() after its call is done.
> 
> I don't quite understand this.  hardclock -> tc_windup() normally doesn't
> have interference from tc_setclock().
In what sense it does not have interference ?  tc_windup() may be executed
from hardclock/hardclock_cnt (low half) and concurrently from setclock()
(top half).  And this is exactly what we want to avoid, isn't it ?

> tc_setclock() needs locking even more than tc_windup().
...
> > I now think that the lock around tc_windup() should have more flavor of
> > real spinlocks.  Ideally the spinlock_enter() should be taken around it,
> > but it might be too extreme.  Just a critical section in tc_setclock()
> > is good enough.
> 
> No, it must have a full lock since it does read-write-modify on critical
> variables.
I talked only about tc_windup(). Parallel invocations of tc_setclock()
should be guarded, indeed. I added a private mutex for it.

> 
> > ...
> > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> > index 0f015b3..a5776d2 100644
> > --- a/sys/kern/kern_tc.c
> > +++ b/sys/kern/kern_tc.c
> > ...
> > @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts)
> > 	struct timespec tbef, taft;
> > 	struct bintime bt, bt2;
> >
> > +	critical_enter();
> > 	cpu_tick_calibrate(1);
> > 	nanotime(&tbef);
> > 	timespec2bintime(ts, &bt);
> > @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts)
> > 	bintime2timeval(&bt, &boottime);
> 
> boottime is one of the critical variables.  Before this, there are 2
> accesses to boottimebin.  The Giant locking that you just removed gave
> only some protection here.  It prevented concurrent acccess by
> malicious/stress-testing code doing settime().  It didn't prevent
> nanotime() and friends seeing boottime in an in-between state.  Oops, 
> mutex locking won't fix that either.  I think the update of these
> variables needs to be moved into tc_windup() where it will hopefully
> automatically be protected by the generation count, like the timehands
> offsets already are.
I do not understand how that would help.  Do you mean to move the vars
into current timehands ?

> 
> bootime is also accessed with no locking in the kern.boottime sysctl.
> 
> There is also ffclock_boottime.  I don't like the duplication for
> ffclock, but it doesn't have much duplication for initializing
> ffsclock_boottime.
> 
> >
> > 	/* XXX fiddle all the little crinkly bits around the fiords... */
> > -	tc_windup();
> > +	tc_windup(true);
> > 	nanotime(&taft);
> > +	cpu_tick_calibrate(1);
> 
> The 2 calls to cpu_tick_calibrate() in this function are excessive.  These
> calls are just a hack to recalibrate after suspend/resume as a side effect
> of calling here.  The first call suffices, since cpu ticks have nothing to
> do with any time variable that is set here.
Ok.

> > +static volatile int tc_windup_lock;
> > +static void
> > +tc_windup(bool top_call)
> > +{
> > +
> > +	for (;;) {
> > +		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
> > +			atomic_thread_fence_acq();
> > +			tc_windup_locked();
> > +			atomic_store_rel_int(&tc_windup_lock, 0);
> > +			break;
> > +		} else if (!top_call) {
> > +			break;
> > +		}
> > +	}
> > }
> 
> I like to write optimized locking like that, but don't see why you
> want it here.
Because I do not want the fast clock interrupt handler to wait on lock,
which neccessary becomes spinlock.  The ntp_lock is bad enough already.
What I coded above is not real lock.  In contention case it bails out,
so there is no blocking.  In particular, witness is not relevant to it.

diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index d352ee7..efc3713 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -162,29 +162,12 @@ static l_fp time_adj;			/* tick adjust (ns/s) */
 
 static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
 
-static struct mtx ntpadj_lock;
-MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
-#ifdef PPS_SYNC
-    MTX_SPIN
-#else
-    MTX_DEF
-#endif
-);
+static struct mtx ntp_lock;
+MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN);
 
-/*
- * When PPS_SYNC is defined, hardpps() function is provided which can
- * be legitimately called from interrupt filters.  Due to this, use
- * spinlock for ntptime state protection, otherwise sleepable mutex is
- * adequate.
- */
-#ifdef PPS_SYNC
-#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
-#else
-#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
-#endif
-#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
+#define	NTP_LOCK()		mtx_lock_spin(&ntp_lock)
+#define	NTP_UNLOCK()		mtx_unlock_spin(&ntp_lock)
+#define	NTP_ASSERT_LOCKED()	mtx_assert(&ntp_lock, MA_OWNED)
 
 #ifdef PPS_SYNC
 /*
@@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp)
 {
 	struct timespec atv;	/* nanosecond time */
 
-	NTPADJ_ASSERT_LOCKED();
+	NTP_ASSERT_LOCKED();
 
 	nanotime(&atv);
 	ntvp->time.tv_sec = atv.tv_sec;
@@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap)
 {	
 	struct ntptimeval ntv;
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ntp_gettime1(&ntv);
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	td->td_retval[0] = ntv.time_state;
 	return (copyout(&ntv, uap->ntvp, sizeof(ntv)));
@@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS)
 {
 	struct ntptimeval ntv;	/* temporary structure */
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ntp_gettime1(&ntv);
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req));
 }
@@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 		error = priv_check(td, PRIV_NTP_ADJTIME);
 	if (error != 0)
 		return (error);
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	if (modes & MOD_MAXERROR)
 		time_maxerror = ntv.maxerror;
 	if (modes & MOD_ESTERROR)
@@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 	ntv.stbcnt = pps_stbcnt;
 #endif /* PPS_SYNC */
 	retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state;
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv));
 	if (error == 0)
@@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	int tickrate;
 	l_fp ftemp;		/* 32/64-bit temporary */
 
+	NTP_LOCK();
+
 	/*
 	 * On rollover of the second both the nanosecond and microsecond
 	 * clocks are updated and the state machine cranked as
@@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	else
 		time_status &= ~STA_PPSSIGNAL;
 #endif /* PPS_SYNC */
+
+	NTP_UNLOCK();
 }
 
 /*
@@ -690,7 +677,7 @@ hardupdate(offset)
 	long mtemp;
 	l_fp ftemp;
 
-	NTPADJ_ASSERT_LOCKED();
+	NTP_ASSERT_LOCKED();
 
 	/*
 	 * Select how the phase is to be controlled and from which
@@ -772,7 +759,7 @@ hardpps(tsp, nsec)
 	long u_sec, u_nsec, v_nsec; /* temps */
 	l_fp ftemp;
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 
 	/*
 	 * The signal is first processed by a range gate and frequency
@@ -956,7 +943,7 @@ hardpps(tsp, nsec)
 		time_freq = pps_freq;
 
 out:
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 }
 #endif /* PPS_SYNC */
 
@@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta)
 			return (error);
 		ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec;
 	}
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ltr = time_adjtime;
 	if (delta != NULL)
 		time_adjtime = ltw;
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 	if (olddelta != NULL) {
 		atv.tv_sec = ltr / 1000000;
 		atv.tv_usec = ltr % 1000000;
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 0f015b3..7bb767c 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -135,7 +135,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
 
 static int tc_chosen;	/* Non-zero if a specific tc was chosen via sysctl. */
 
-static void tc_windup(void);
+static void tc_windup(bool top_call);
+static void tc_windup_locked(void);
 static void cpu_tick_calibrate(int);
 
 void dtrace_getnanotime(struct timespec *tsp);
@@ -1226,10 +1227,12 @@ tc_getfrequency(void)
 	return (timehands->th_counter->tc_frequency);
 }
 
+static struct mtx tc_setclock_mtx;
+MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF);
+
 /*
  * Step our concept of UTC.  This is done by modifying our estimate of
  * when we booted.
- * XXX: not locked.
  */
 void
 tc_setclock(struct timespec *ts)
@@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts)
 	struct timespec tbef, taft;
 	struct bintime bt, bt2;
 
+	mtx_lock(&tc_setclock_mtx);
+	critical_enter();
 	cpu_tick_calibrate(1);
 	nanotime(&tbef);
 	timespec2bintime(ts, &bt);
@@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts)
 	bintime2timeval(&bt, &boottime);
 
 	/* XXX fiddle all the little crinkly bits around the fiords... */
-	tc_windup();
+	tc_windup(true);
 	nanotime(&taft);
+	critical_exit();
+	mtx_unlock(&tc_setclock_mtx);
 	if (timestepwarnings) {
 		log(LOG_INFO,
 		    "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n",
@@ -1256,7 +1263,23 @@ tc_setclock(struct timespec *ts)
 		    (intmax_t)taft.tv_sec, taft.tv_nsec,
 		    (intmax_t)ts->tv_sec, ts->tv_nsec);
 	}
-	cpu_tick_calibrate(1);
+}
+
+static volatile int tc_windup_lock;
+static void
+tc_windup(bool top_call)
+{
+
+	for (;;) {
+		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
+			atomic_thread_fence_acq();
+			tc_windup_locked();
+			atomic_store_rel_int(&tc_windup_lock, 0);
+			break;
+		} else if (!top_call) {
+			break;
+		}
+	}
 }
 
 /*
@@ -1265,7 +1288,7 @@ tc_setclock(struct timespec *ts)
  * timecounter and/or do seconds processing in NTP.  Slightly magic.
  */
 static void
-tc_windup(void)
+tc_windup_locked(void)
 {
 	struct bintime bt;
 	struct timehands *th, *tho;
@@ -1846,7 +1869,7 @@ tc_ticktock(int cnt)
 	if (count < tc_tick)
 		return;
 	count = 0;
-	tc_windup();
+	tc_windup(false);
 }
 
 static void __inline
@@ -1921,7 +1944,7 @@ inittimecounter(void *dummy)
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
 	(void)timecounter->tc_get_timecount(timecounter);
-	tc_windup();
+	tc_windup(true);
 }
 
 SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL);
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 148da2b..82710f7 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv)
 	struct timeval delta, tv1, tv2;
 	static struct timeval maxtime, laststep;
 	struct timespec ts;
-	int s;
 
-	s = splclock();
 	microtime(&tv1);
 	delta = *tv;
 	timevalsub(&delta, &tv1);
@@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv)
 				printf("Time adjustment clamped to -1 second\n");
 			}
 		} else {
-			if (tv1.tv_sec == laststep.tv_sec) {
-				splx(s);
+			if (tv1.tv_sec == laststep.tv_sec)
 				return (EPERM);
-			}
 			if (delta.tv_sec > 1) {
 				tv->tv_sec = tv1.tv_sec + 1;
 				printf("Time adjustment clamped to +1 second\n");
@@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv)
 
 	ts.tv_sec = tv->tv_sec;
 	ts.tv_nsec = tv->tv_usec * 1000;
-	mtx_lock(&Giant);
 	tc_setclock(&ts);
 	resettodr();
-	mtx_unlock(&Giant);
 	return (0);
 }
 
diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c
index dbad36d..4bac324 100644
--- a/sys/kern/subr_rtc.c
+++ b/sys/kern/subr_rtc.c
@@ -172,11 +172,11 @@ resettodr(void)
 	if (disable_rtc_set || clock_dev == NULL)
 		return;
 
-	mtx_lock(&resettodr_lock);
 	getnanotime(&ts);
 	timespecadd(&ts, &clock_adj);
 	ts.tv_sec -= utc_offset();
 	/* XXX: We should really set all registered RTCs */
+	mtx_lock(&resettodr_lock);
 	error = CLOCK_SETTIME(clock_dev, &ts);
 	mtx_unlock(&resettodr_lock);
 	if (error != 0)

From owner-svn-src-all@freebsd.org  Wed Jun 29 22:39:23 2016
Return-Path: 
Delivered-To: svn-src-all@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 59562B86F36;
 Wed, 29 Jun 2016 22:39:23 +0000 (UTC)
 (envelope-from bdrewery@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 1E71F2BAD;
 Wed, 29 Jun 2016 22:39:23 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TMdM9t027674;
 Wed, 29 Jun 2016 22:39:22 GMT (envelope-from bdrewery@FreeBSD.org)
Received: (from bdrewery@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TMdMom027673;
 Wed, 29 Jun 2016 22:39:22 GMT (envelope-from bdrewery@FreeBSD.org)
Message-Id: <201606292239.u5TMdMom027673@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to
 bdrewery@FreeBSD.org using -f
From: Bryan Drewery 
Date: Wed, 29 Jun 2016 22:39:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302285 - head/sys/modules/aic7xxx/ahd
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 22:39:23 -0000

Author: bdrewery
Date: Wed Jun 29 22:39:22 2016
New Revision: 302285
URL: https://svnweb.freebsd.org/changeset/base/302285

Log:
  WITH_META_MODE: Avoid false-positive error due to missing .meta with build commands.
  
  Sponsored by:	EMC / Isilon Storage Division
  Approved by:	re (blanket, META_MODE)

Modified:
  head/sys/modules/aic7xxx/ahd/Makefile

Modified: head/sys/modules/aic7xxx/ahd/Makefile
==============================================================================
--- head/sys/modules/aic7xxx/ahd/Makefile	Wed Jun 29 18:19:05 2016	(r302284)
+++ head/sys/modules/aic7xxx/ahd/Makefile	Wed Jun 29 22:39:22 2016	(r302285)
@@ -26,7 +26,7 @@ ${GENSRCS}:								 \
 			-i ${.CURDIR}/../../../dev/aic7xxx/aic79xx_osm.h \
 			${.CURDIR}/../../../dev/aic7xxx/aic79xx.seq
 .else
-${GENSRCS}:
+${GENSRCS}: .NOMETA
 	@echo "Error: ${.TARGET} is missing.  Run 'make ahdfirmware'."
 .endif
 

From owner-svn-src-all@freebsd.org  Wed Jun 29 22:54:03 2016
Return-Path: 
Delivered-To: svn-src-all@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 2D15EB86453;
 Wed, 29 Jun 2016 22:54:03 +0000 (UTC)
 (envelope-from bdrewery@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 F1FC2241C;
 Wed, 29 Jun 2016 22:54:02 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TMs2pt034865;
 Wed, 29 Jun 2016 22:54:02 GMT (envelope-from bdrewery@FreeBSD.org)
Received: (from bdrewery@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TMs2Pg034864;
 Wed, 29 Jun 2016 22:54:02 GMT (envelope-from bdrewery@FreeBSD.org)
Message-Id: <201606292254.u5TMs2Pg034864@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to
 bdrewery@FreeBSD.org using -f
From: Bryan Drewery 
Date: Wed, 29 Jun 2016 22:54:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302286 - head/contrib/bmake
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 22:54:03 -0000

Author: bdrewery
Date: Wed Jun 29 22:54:01 2016
New Revision: 302286
URL: https://svnweb.freebsd.org/changeset/base/302286

Log:
  Flush every line when using meta mode and no -j or with -B.
  
  Otherwise the output is buffered and it appears that make is stuck on something
  long-running.  This problem is not present with -j as it uses different
  code that was already flushing.
  
  Discussed with:	sjg
  Approved by:	re (blanket, META_MODE)
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/contrib/bmake/meta.c

Modified: head/contrib/bmake/meta.c
==============================================================================
--- head/contrib/bmake/meta.c	Wed Jun 29 22:39:22 2016	(r302285)
+++ head/contrib/bmake/meta.c	Wed Jun 29 22:54:01 2016	(r302286)
@@ -1547,6 +1547,7 @@ meta_compat_parent(void)
     while (fgets(buf, sizeof(buf), fp)) {
 	meta_job_output(NULL, buf, "");
 	printf("%s", buf);
+	(void)fflush(stdout);
     }
     fclose(fp);
 }

From owner-svn-src-all@freebsd.org  Wed Jun 29 23:33:45 2016
Return-Path: 
Delivered-To: svn-src-all@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 6B28FB86D0C;
 Wed, 29 Jun 2016 23:33:45 +0000 (UTC)
 (envelope-from gonzo@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 1BE9221F4;
 Wed, 29 Jun 2016 23:33:45 +0000 (UTC)
 (envelope-from gonzo@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TNXiQQ049470;
 Wed, 29 Jun 2016 23:33:44 GMT (envelope-from gonzo@FreeBSD.org)
Received: (from gonzo@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TNXiqF049469;
 Wed, 29 Jun 2016 23:33:44 GMT (envelope-from gonzo@FreeBSD.org)
Message-Id: <201606292333.u5TNXiqF049469@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: gonzo set sender to
 gonzo@FreeBSD.org using -f
From: Oleksandr Tymoshenko 
Date: Wed, 29 Jun 2016 23:33:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302287 - head/sys/mips/malta
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 23:33:45 -0000

Author: gonzo
Date: Wed Jun 29 23:33:44 2016
New Revision: 302287
URL: https://svnweb.freebsd.org/changeset/base/302287

Log:
  Fixed FreeBSD/mips MALTA support for QEMU
  
  Recource management functions in GT PCI controller driver
  treated memory/IO resources as KSEG1 addresses, later during
  activation these values would be increased by KSEG1 base again
  rendering the address invalid and causing "bus error" trap.
  
  Actual logic was converted to use real physical addresses,
  so mapping takes place only during activation.
  
  Submitted by:	Aleksandr Rybalko 
  Approved by:	re (gjb)

Modified:
  head/sys/mips/malta/gt_pci.c

Modified: head/sys/mips/malta/gt_pci.c
==============================================================================
--- head/sys/mips/malta/gt_pci.c	Wed Jun 29 22:54:01 2016	(r302286)
+++ head/sys/mips/malta/gt_pci.c	Wed Jun 29 23:33:44 2016	(r302287)
@@ -272,7 +272,7 @@ gt_pci_attach(device_t dev)
 	sc->sc_st = mips_bus_space_generic;
 
 	/* Use KSEG1 to access IO ports for it is uncached */
-	sc->sc_io = MIPS_PHYS_TO_KSEG1(MALTA_PCI0_IO_BASE);
+	sc->sc_io = MALTA_PCI0_IO_BASE;
 	sc->sc_io_rman.rm_type = RMAN_ARRAY;
 	sc->sc_io_rman.rm_descr = "GT64120 PCI I/O Ports";
 	/* 
@@ -285,7 +285,7 @@ gt_pci_attach(device_t dev)
 	}
 
 	/* Use KSEG1 to access PCI memory for it is uncached */
-	sc->sc_mem = MIPS_PHYS_TO_KSEG1(MALTA_PCIMEM1_BASE);
+	sc->sc_mem = MALTA_PCIMEM1_BASE;
 	sc->sc_mem_rman.rm_type = RMAN_ARRAY;
 	sc->sc_mem_rman.rm_descr = "GT64120 PCI Memory";
 	if (rman_init(&sc->sc_mem_rman) != 0 ||
@@ -310,9 +310,9 @@ gt_pci_attach(device_t dev)
 	if (bus_space_map(sc->sc_st, IO_ICU2, 2, 0, &sc->sc_ioh_icu2) != 0)
 		device_printf(dev, "unable to map ICU2 registers\n");
 #else
-	sc->sc_ioh_elcr = sc->sc_io + 0x4d0;
-	sc->sc_ioh_icu1 = sc->sc_io + IO_ICU1;
-	sc->sc_ioh_icu2 = sc->sc_io + IO_ICU2;
+	sc->sc_ioh_elcr = MIPS_PHYS_TO_KSEG1(sc->sc_io + 0x4d0);
+	sc->sc_ioh_icu1 = MIPS_PHYS_TO_KSEG1(sc->sc_io + IO_ICU1);
+	sc->sc_ioh_icu2 = MIPS_PHYS_TO_KSEG1(sc->sc_io + IO_ICU2);
 #endif	
 
 

From owner-svn-src-all@freebsd.org  Wed Jun 29 23:56:25 2016
Return-Path: 
Delivered-To: svn-src-all@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 B705EB8715D;
 Wed, 29 Jun 2016 23:56:25 +0000 (UTC)
 (envelope-from cperciva@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 79BCA2B92;
 Wed, 29 Jun 2016 23:56:25 +0000 (UTC)
 (envelope-from cperciva@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TNuOl3057122;
 Wed, 29 Jun 2016 23:56:24 GMT (envelope-from cperciva@FreeBSD.org)
Received: (from cperciva@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TNuODh057121;
 Wed, 29 Jun 2016 23:56:24 GMT (envelope-from cperciva@FreeBSD.org)
Message-Id: <201606292356.u5TNuODh057121@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: cperciva set sender to
 cperciva@FreeBSD.org using -f
From: Colin Percival 
Date: Wed, 29 Jun 2016 23:56:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302288 - head/release/tools
X-SVN-Group: head
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.22
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: Wed, 29 Jun 2016 23:56:25 -0000

Author: cperciva
Date: Wed Jun 29 23:56:24 2016
New Revision: 302288
URL: https://svnweb.freebsd.org/changeset/base/302288

Log:
  Enable indirect segment I/Os by default in the Xen blkfront driver when
  running on EC2.  Due to improvements in EC2, the performance penalty which
  was present on some EC2 instances no longer exists, and enabling this
  feature now consistently yields ~20% higher throughput with equal or lower
  latency.
  
  Reverts:	r286063
  Approved by:	re (gjb)
  MFC after:	2 weeks
  Relnotes:	Improved disk throughput on EC2

Modified:
  head/release/tools/ec2.conf

Modified: head/release/tools/ec2.conf
==============================================================================
--- head/release/tools/ec2.conf	Wed Jun 29 23:33:44 2016	(r302287)
+++ head/release/tools/ec2.conf	Wed Jun 29 23:56:24 2016	(r302288)
@@ -72,11 +72,6 @@ vm_extra_pre_umount() {
 	# nodes, but apply the workaround just in case.
 	echo 'hw.broken_txfifo="1"' >> ${DESTDIR}/boot/loader.conf
 
-	# Some EC2 instances suffer a significant (~40%) reduction in
-	# throughput when using blkif indirect segment I/Os.  Disable this
-	# by default for now.
-	echo 'hw.xbd.xbd_enable_indirect="0"' >> ${DESTDIR}/boot/loader.conf
-
 	# Some EC2 instances run on a version of Xen which has a bug relating
 	# to the migration of MSI-X interrupts; this is visible as SR-IOV
 	# networking (aka. "EC2 Enhanced Networking") not being able to pass

From owner-svn-src-all@freebsd.org  Thu Jun 30 00:01:32 2016
Return-Path: 
Delivered-To: svn-src-all@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 8BA52B8745E;
 Thu, 30 Jun 2016 00:01:32 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org
 [IPv6:2001:1900:2254:206c::16:87])
 by mx1.freebsd.org (Postfix) with ESMTP id 6E9302E6B;
 Thu, 30 Jun 2016 00:01:32 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from mail.xzibition.com (localhost [IPv6:::1])
 by freefall.freebsd.org (Postfix) with ESMTP id 67B1A1D0E;
 Thu, 30 Jun 2016 00:01:32 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from mail.xzibition.com (localhost [172.31.3.2])
 by mail.xzibition.com (Postfix) with ESMTP id 1B09D233F2;
 Thu, 30 Jun 2016 00:01:32 +0000 (UTC)
X-Virus-Scanned: amavisd-new at mail.xzibition.com
Received: from mail.xzibition.com ([172.31.3.2])
 by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new,
 port 10026)
 with LMTP id UGwrLVY-YFKU; Thu, 30 Jun 2016 00:01:29 +0000 (UTC)
Subject: Re: svn commit: r302288 - head/release/tools
DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com BB3F1233ED
To: Colin Percival , src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
References: <201606292356.u5TNuODh057121@repo.freebsd.org>
From: Bryan Drewery 
Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF;
 url=http://www.shatow.net/bryan/bryan2.asc
Organization: FreeBSD
Message-ID: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org>
Date: Wed, 29 Jun 2016 17:01:28 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.1
MIME-Version: 1.0
In-Reply-To: <201606292356.u5TNuODh057121@repo.freebsd.org>
Content-Type: multipart/signed; micalg=pgp-sha1;
 protocol="application/pgp-signature";
 boundary="kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24"
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Thu, 30 Jun 2016 00:01:32 -0000

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24
Content-Type: multipart/mixed; boundary="tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk"
From: Bryan Drewery 
To: Colin Percival , src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
Message-ID: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org>
Subject: Re: svn commit: r302288 - head/release/tools
References: <201606292356.u5TNuODh057121@repo.freebsd.org>
In-Reply-To: <201606292356.u5TNuODh057121@repo.freebsd.org>

--tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 6/29/2016 4:56 PM, Colin Percival wrote:
> Author: cperciva
> Date: Wed Jun 29 23:56:24 2016
> New Revision: 302288
> URL: https://svnweb.freebsd.org/changeset/base/302288
>=20
> Log:
>   Enable indirect segment I/Os by default in the Xen blkfront driver wh=
en
>   running on EC2.  Due to improvements in EC2, the performance penalty =
which
>   was present on some EC2 instances no longer exists, and enabling this=

>   feature now consistently yields ~20% higher throughput with equal or =
lower
>   latency.

Does this rely on any driver updates / is it safe to make the same
change on my existing 10.2 system?

>  =20
>   Reverts:	r286063
>   Approved by:	re (gjb)
>   MFC after:	2 weeks
>   Relnotes:	Improved disk throughput on EC2
>=20
> Modified:
>   head/release/tools/ec2.conf
>=20
> Modified: head/release/tools/ec2.conf
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/release/tools/ec2.conf	Wed Jun 29 23:33:44 2016	(r302287)
> +++ head/release/tools/ec2.conf	Wed Jun 29 23:56:24 2016	(r302288)
> @@ -72,11 +72,6 @@ vm_extra_pre_umount() {
>  	# nodes, but apply the workaround just in case.
>  	echo 'hw.broken_txfifo=3D"1"' >> ${DESTDIR}/boot/loader.conf
> =20
> -	# Some EC2 instances suffer a significant (~40%) reduction in
> -	# throughput when using blkif indirect segment I/Os.  Disable this
> -	# by default for now.
> -	echo 'hw.xbd.xbd_enable_indirect=3D"0"' >> ${DESTDIR}/boot/loader.con=
f
> -
>  	# Some EC2 instances run on a version of Xen which has a bug relating=

>  	# to the migration of MSI-X interrupts; this is visible as SR-IOV
>  	# networking (aka. "EC2 Enhanced Networking") not being able to pass
>=20


--=20
Regards,
Bryan Drewery


--tUvFVvcWuusfVLbU95PubWgdOKgVx7iNk--

--kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBAgAGBQJXdGFYAAoJEDXXcbtuRpfPhOQIANnWpgD14s0bbiapmsAXohGL
Aw4ZpTz0SNKF4z7bBFdFDWFuUoFdqXDsmz8CLDQCFFqWL3Okph+49A52jWvKLC+B
ovnGP9M+qook/a8J7QM75yrJUxOgK6Q1JmFaO5H8D7WYVKGnNvKTL10mzzsJ6unI
Wu7en3JbEAhSnRygmDybSSneVlQorCntQg0JCLYM4blclX2bHASE0TvvQjBVksP7
FkAmN1/qWe+/wz98n7RR6rRgZQGMRTJ+0UsZrk2uW3CjscVIiAK0UygXcur9DKJC
K0ADT8iVo28hY8QSoQ/3iXu/1bGP9G2TymFgqGrGSffV37bVOIQS8mkAjoc+19I=
=oAHN
-----END PGP SIGNATURE-----

--kFAJlTvqXbleNAlEF6hDkXpRO6RcgDN24--

From owner-svn-src-all@freebsd.org  Thu Jun 30 01:08:53 2016
Return-Path: 
Delivered-To: svn-src-all@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 C3182B85541
 for ;
 Thu, 30 Jun 2016 01:08:53 +0000 (UTC)
 (envelope-from bounces+73574-8822-svn-src-all=freebsd.org@sendgrid.net)
Received: from o1.l99.sendgrid.net (o1.l99.sendgrid.net [198.37.153.74])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 538E028F4
 for ; Thu, 30 Jun 2016 01:08:53 +0000 (UTC)
 (envelope-from bounces+73574-8822-svn-src-all=freebsd.org@sendgrid.net)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; 
 h=subject:to:references:from:mime-version:in-reply-to:content-type:content-transfer-encoding;
 s=smtpapi; bh=te6roGlD8rlrivdNIUEW3nFkS3A=; b=fCWci/y7zX7tmsu2o9
 E1PDJNmW/syL12USwrZ3NrB1cdvdCt+OTtpLe0NclwJzkKOnbEE85TjIkWIlbLiR
 O8rbQp9MdoDCq9RqKfXDiCUWLMWLzY0V6tfMpNnpxACidwXnUvrwcGWk8ugD2rse
 Ne2bMg/Wccitl2Ihonk3IatvY=
Received: by filter0465p1mdw1.sendgrid.net with SMTP id
 filter0465p1mdw1.27772.577470FC43
 2016-06-30 01:08:12.636547761 +0000 UTC
Received: from mail.tarsnap.com (ec2-54-86-246-204.compute-1.amazonaws.com
 [54.86.246.204])
 by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id A8H9byljT_SZ4sNV8gwDvQ
 for ; Thu, 30 Jun 2016 01:08:12.701 +0000 (UTC)
Received: (qmail 13813 invoked from network); 30 Jun 2016 01:07:25 -0000
Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1)
 by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP;
 30 Jun 2016 01:07:25 -0000
Received: (qmail 97416 invoked from network); 30 Jun 2016 01:08:11 -0000
Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1)
 by clamshell.daemonology.net with SMTP; 30 Jun 2016 01:08:11 -0000
Subject: Re: svn commit: r302288 - head/release/tools
To: Bryan Drewery , src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
References: <201606292356.u5TNuODh057121@repo.freebsd.org>
 <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org>
From: Colin Percival 
Message-ID: 
Date: Wed, 29 Jun 2016 18:08:11 -0700
User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.0
MIME-Version: 1.0
In-Reply-To: <7a41dac2-87b8-c255-391d-fce3d57e835a@FreeBSD.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-SG-EID: A6W2xSVPHetogaU8rnzccWwgBYtN+QvIzXyjfe/10PFsO+zhKUVjcuaWIUgL4Af2XzWQqGIfkpRA/s
 XPe0ngMYuev4tE6b3DKTITCUVaupB7csr5BLYPbyep1JoVk01sfRsNZVvWB4Ksueo00EbXJho/plgP
 Y4shnHCcYTl9/+FjmHGksJAlGGUoOb9kdcH2p5e1hd4I4AJ+++ke+MZhZ3M5Qtkf8CTuZgkIiu2i4m
 A=
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Thu, 30 Jun 2016 01:08:53 -0000

On 06/29/16 17:01, Bryan Drewery wrote:
> On 6/29/2016 4:56 PM, Colin Percival wrote:
>> Author: cperciva
>> Date: Wed Jun 29 23:56:24 2016
>> New Revision: 302288
>> URL: https://svnweb.freebsd.org/changeset/base/302288
>>
>> Log:
>>   Enable indirect segment I/Os by default in the Xen blkfront driver when
>>   running on EC2.  Due to improvements in EC2, the performance penalty which
>>   was present on some EC2 instances no longer exists, and enabling this
>>   feature now consistently yields ~20% higher throughput with equal or lower
>>   latency.
> 
> Does this rely on any driver updates / is it safe to make the same
> change on my existing 10.2 system?

The relevant driver code is only in 10.3 and later.  I'm not absolutely
certain if already-running EC2 instances have the EC2 performance fix,
either; you might need to launch a new instance in order to be guaranteed
of the performance benefits.

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid

From owner-svn-src-all@freebsd.org  Thu Jun 30 01:32:14 2016
Return-Path: 
Delivered-To: svn-src-all@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 25C76B85EB3;
 Thu, 30 Jun 2016 01:32:14 +0000 (UTC) (envelope-from bz@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 F1C1A29D3;
 Thu, 30 Jun 2016 01:32:13 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U1WDkr093380;
 Thu, 30 Jun 2016 01:32:13 GMT (envelope-from bz@FreeBSD.org)
Received: (from bz@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U1WCUa093377;
 Thu, 30 Jun 2016 01:32:12 GMT (envelope-from bz@FreeBSD.org)
Message-Id: <201606300132.u5U1WCUa093377@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org
 using -f
From: "Bjoern A. Zeeb" 
Date: Thu, 30 Jun 2016 01:32:12 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302289 - head/sys/contrib/ipfilter/netinet
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 01:32:14 -0000

Author: bz
Date: Thu Jun 30 01:32:12 2016
New Revision: 302289
URL: https://svnweb.freebsd.org/changeset/base/302289

Log:
  Remove unused global variables as well as unused memory
  allocations from ipfilter in preparation for VNET support.
  
  Suggested by:		cy (see D7000)
  Sponsored by:		The FreeBSD Foundation
  MFC after:		2 weeks
  Approved by:		re (gjb)

Modified:
  head/sys/contrib/ipfilter/netinet/ip_fil.h
  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
  head/sys/contrib/ipfilter/netinet/ip_nat.c

Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil.h	Wed Jun 29 23:56:24 2016	(r302288)
+++ head/sys/contrib/ipfilter/netinet/ip_fil.h	Thu Jun 30 01:32:12 2016	(r302289)
@@ -1710,7 +1710,6 @@ typedef struct ipf_main_softc_s {
 
 #ifndef	_KERNEL
 extern	int	ipf_check __P((void *, struct ip *, int, void *, int, mb_t **));
-extern	int	(*ipf_checkp) __P((ip_t *, int, void *, int, mb_t **));
 extern	struct	ifnet *get_unit __P((char *, int));
 extern	char	*get_ifname __P((struct ifnet *));
 extern	int	ipfioctl __P((ipf_main_softc_t *, int, ioctlcmd_t,

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Wed Jun 29 23:56:24 2016	(r302288)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Thu Jun 30 01:32:12 2016	(r302289)
@@ -99,10 +99,8 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I
 # endif
 
 
-static	int	(*ipf_savep) __P((void *, ip_t *, int, void *, int, struct mbuf **));
 static	int	ipf_send_ip __P((fr_info_t *, mb_t *));
 static void	ipf_timer_func __P((void *arg));
-int		ipf_locks_done = 0;
 
 ipf_main_softc_t ipfmain;
 
@@ -110,10 +108,6 @@ ipf_main_softc_t ipfmain;
 # if defined(NETBSD_PF)
 #  include 
 # endif /* NETBSD_PF */
-/*
- * We provide the ipf_checkp name just to minimize changes later.
- */
-int (*ipf_checkp) __P((void *, ip_t *ip, int hlen, void *ifp, int out, mb_t **mp));
 
 
 static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag;
@@ -221,11 +215,6 @@ ipfattach(softc)
 	}
 
 
-	if (ipf_checkp != ipf_check) {
-		ipf_savep = ipf_checkp;
-		ipf_checkp = ipf_check;
-	}
-
 	bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait));
 	softc->ipf_running = 1;
 
@@ -268,12 +257,6 @@ ipfdetach(softc)
 #endif
 	callout_drain(&softc->ipf_slow_ch);
 
-#ifndef NETBSD_PF
-	if (ipf_checkp != NULL)
-		ipf_checkp = ipf_savep;
-	ipf_savep = NULL;
-#endif
-
 	ipf_fini_all(softc);
 
 	softc->ipf_running = -2;

Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_nat.c	Wed Jun 29 23:56:24 2016	(r302288)
+++ head/sys/contrib/ipfilter/netinet/ip_nat.c	Thu Jun 30 01:32:12 2016	(r302289)
@@ -133,8 +133,6 @@ static const char rcsid[] = "@(#)$FreeBS
 #define	NBUMPSIDEDF(y,x)do { softn->ipf_nat_stats.ns_side[y].x++; \
 			     DT1(x, fr_info_t *, fin); } while (0)
 
-frentry_t	ipfnatblock;
-
 static ipftuneable_t ipf_nat_tuneables[] = {
 	/* nat */
 	{ { (void *)offsetof(ipf_nat_softc_t, ipf_nat_lock) },
@@ -275,9 +273,6 @@ static	void	ipf_nat_tabmove __P((ipf_nat
 int
 ipf_nat_main_load()
 {
-	bzero((char *)&ipfnatblock, sizeof(ipfnatblock));
-	ipfnatblock.fr_flags = FR_BLOCK|FR_QUICK;
-	ipfnatblock.fr_ref = 1;
 
 	return 0;
 }

From owner-svn-src-all@freebsd.org  Thu Jun 30 01:33:15 2016
Return-Path: 
Delivered-To: svn-src-all@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 522F8B85F3F;
 Thu, 30 Jun 2016 01:33:15 +0000 (UTC) (envelope-from bz@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 2FF4B2B88;
 Thu, 30 Jun 2016 01:33:15 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U1XE2K094059;
 Thu, 30 Jun 2016 01:33:14 GMT (envelope-from bz@FreeBSD.org)
Received: (from bz@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U1XErn094057;
 Thu, 30 Jun 2016 01:33:14 GMT (envelope-from bz@FreeBSD.org)
Message-Id: <201606300133.u5U1XErn094057@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org
 using -f
From: "Bjoern A. Zeeb" 
Date: Thu, 30 Jun 2016 01:33:14 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302290 - head/sys/netpfil/ipfw
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 01:33:15 -0000

Author: bz
Date: Thu Jun 30 01:33:14 2016
New Revision: 302290
URL: https://svnweb.freebsd.org/changeset/base/302290

Log:
  Move the ipfw_log_bpf() calls from global module initialisation to
  per-VNET initialisation and virtualise the interface cloning to
  allow a dedicated ipfw log interface per VNET.
  
  Approved by:		re (gjb)
  MFC after:		2 weeks
  Sponsored by:		The FreeBSD Foundation

Modified:
  head/sys/netpfil/ipfw/ip_fw2.c
  head/sys/netpfil/ipfw/ip_fw_log.c

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_fw2.c	Thu Jun 30 01:32:12 2016	(r302289)
+++ head/sys/netpfil/ipfw/ip_fw2.c	Thu Jun 30 01:33:14 2016	(r302290)
@@ -2691,7 +2691,6 @@ ipfw_init(void)
 	  default_fw_tables = IPFW_TABLES_MAX;
 
 	ipfw_init_sopt_handler();
-	ipfw_log_bpf(1); /* init */
 	ipfw_iface_init();
 	return (error);
 }
@@ -2704,7 +2703,6 @@ ipfw_destroy(void)
 {
 
 	ipfw_iface_destroy();
-	ipfw_log_bpf(0); /* uninit */
 	ipfw_destroy_sopt_handler();
 	printf("IP firewall unloaded\n");
 }
@@ -2793,6 +2791,7 @@ vnet_ipfw_init(const void *unused)
 	 * is checked on each packet because there are no pfil hooks.
 	 */
 	V_ip_fw_ctl_ptr = ipfw_ctl3;
+	ipfw_log_bpf(1); /* init */
 	error = ipfw_attach_hooks(1);
 	return (error);
 }
@@ -2816,6 +2815,8 @@ vnet_ipfw_uninit(const void *unused)
 	(void)ipfw_attach_hooks(0 /* detach */);
 	V_ip_fw_ctl_ptr = NULL;
 
+	ipfw_log_bpf(0); /* uninit */
+
 	last = IS_DEFAULT_VNET(curvnet) ? 1 : 0;
 
 	IPFW_UH_WLOCK(chain);

Modified: head/sys/netpfil/ipfw/ip_fw_log.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_fw_log.c	Thu Jun 30 01:32:12 2016	(r302289)
+++ head/sys/netpfil/ipfw/ip_fw_log.c	Thu Jun 30 01:33:14 2016	(r302290)
@@ -102,7 +102,8 @@ ipfw_log_bpf(int onoff)
 {
 }
 #else /* !WITHOUT_BPF */
-static struct ifnet *log_if;	/* hook to attach to bpf */
+static VNET_DEFINE(struct ifnet *, log_if);	/* hook to attach to bpf */
+#define	V_log_if		VNET(log_if)
 static struct rwlock log_if_lock;
 #define	LOGIF_LOCK_INIT(x)	rw_init(&log_if_lock, "ipfw log_if lock")
 #define	LOGIF_LOCK_DESTROY(x)	rw_destroy(&log_if_lock)
@@ -182,8 +183,8 @@ ipfw_log_clone_create(struct if_clone *i
 	ifp->if_baudrate = IF_Mbps(10);
 
 	LOGIF_WLOCK();
-	if (log_if == NULL)
-		log_if = ifp;
+	if (V_log_if == NULL)
+		V_log_if = ifp;
 	else {
 		LOGIF_WUNLOCK();
 		if_free(ifp);
@@ -206,8 +207,8 @@ ipfw_log_clone_destroy(struct if_clone *
 		return (0);
 
 	LOGIF_WLOCK();
-	if (log_if != NULL && ifp == log_if)
-		log_if = NULL;
+	if (V_log_if != NULL && ifp == V_log_if)
+		V_log_if = NULL;
 	else {
 		LOGIF_WUNLOCK();
 		return (EINVAL);
@@ -223,20 +224,23 @@ ipfw_log_clone_destroy(struct if_clone *
 	return (0);
 }
 
-static struct if_clone *ipfw_log_cloner;
+static VNET_DEFINE(struct if_clone *, ipfw_log_cloner);
+#define	V_ipfw_log_cloner		VNET(ipfw_log_cloner)
 
 void
 ipfw_log_bpf(int onoff)
 {
 
 	if (onoff) {
-		LOGIF_LOCK_INIT();
-		ipfw_log_cloner = if_clone_advanced(ipfwname, 0,
+		if (IS_DEFAULT_VNET(curvnet))
+			LOGIF_LOCK_INIT();
+		V_ipfw_log_cloner = if_clone_advanced(ipfwname, 0,
 		    ipfw_log_clone_match, ipfw_log_clone_create,
 		    ipfw_log_clone_destroy);
 	} else {
-		if_clone_detach(ipfw_log_cloner);
-		LOGIF_LOCK_DESTROY();
+		if_clone_detach(V_ipfw_log_cloner);
+		if (IS_DEFAULT_VNET(curvnet))
+			LOGIF_LOCK_DESTROY();
 	}
 }
 #endif /* !WITHOUT_BPF */
@@ -258,24 +262,24 @@ ipfw_log(struct ip_fw_chain *chain, stru
 	if (V_fw_verbose == 0) {
 #ifndef WITHOUT_BPF
 		LOGIF_RLOCK();
-		if (log_if == NULL || log_if->if_bpf == NULL) {
+		if (V_log_if == NULL || V_log_if->if_bpf == NULL) {
 			LOGIF_RUNLOCK();
 			return;
 		}
 
 		if (args->eh) /* layer2, use orig hdr */
-			BPF_MTAP2(log_if, args->eh, ETHER_HDR_LEN, m);
+			BPF_MTAP2(V_log_if, args->eh, ETHER_HDR_LEN, m);
 		else {
 			/* Add fake header. Later we will store
 			 * more info in the header.
 			 */
 			if (ip->ip_v == 4)
-				BPF_MTAP2(log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m);
+				BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m);
 			else if  (ip->ip_v == 6)
-				BPF_MTAP2(log_if, "DDDDDDSSSSSS\x86\xdd", ETHER_HDR_LEN, m);
+				BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\x86\xdd", ETHER_HDR_LEN, m);
 			else
 				/* Obviously bogus EtherType. */
-				BPF_MTAP2(log_if, "DDDDDDSSSSSS\xff\xff", ETHER_HDR_LEN, m);
+				BPF_MTAP2(V_log_if, "DDDDDDSSSSSS\xff\xff", ETHER_HDR_LEN, m);
 		}
 		LOGIF_RUNLOCK();
 #endif /* !WITHOUT_BPF */

From owner-svn-src-all@freebsd.org  Thu Jun 30 03:03:08 2016
Return-Path: 
Delivered-To: svn-src-all@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 41E45B867C2;
 Thu, 30 Jun 2016 03:03:08 +0000 (UTC)
 (envelope-from cy.schubert@komquats.com)
Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "Client", Issuer "CA" (not verified))
 by mx1.freebsd.org (Postfix) with ESMTPS id B132821C5;
 Thu, 30 Jun 2016 03:03:07 +0000 (UTC)
 (envelope-from cy.schubert@komquats.com)
Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP
 id ISFpbR3ldBLFmISFqbsbeu; Wed, 29 Jun 2016 21:03:05 -0600
X-Authority-Analysis: v=2.2 cv=W5d6blek c=1 sm=1 tr=0
 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17
 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10
 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=HQEh2bmjY8YPF31ghtgA:9
 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22
Received: from slippy.cwsent.com (slippy [10.1.1.91])
 by spqr.komquats.com (Postfix) with ESMTPS id A1B4B13752;
 Wed, 29 Jun 2016 20:03:01 -0700 (PDT)
Received: from slippy (localhost [127.0.0.1])
 by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id u5U331J9003137;
 Wed, 29 Jun 2016 20:03:01 -0700 (PDT)
 (envelope-from Cy.Schubert@cschubert.com)
Message-Id: <201606300303.u5U331J9003137@slippy.cwsent.com>
X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6
Reply-to: Cy Schubert 
From: Cy Schubert 
X-os: FreeBSD
X-Sender: cy@cwsent.com
X-URL: http://www.cschubert.com/
To: "Bjoern A. Zeeb" 
cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302289 - head/sys/contrib/ipfilter/netinet
In-Reply-To: Message from "Bjoern A. Zeeb"  of "Thu,
 30 Jun 2016 01:32:12 -0000." <201606300132.u5U1WCUa093377@repo.freebsd.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Date: Wed, 29 Jun 2016 20:03:01 -0700
X-CMAE-Envelope: MS4wfC55ZjDQ4p416sKVDKps0ICyW4clbr7rN0nviFT5FGxAziqbdBOuP/yz2e4T0rge+f8rZ8EQRCkuILMv+0s6z/hKDe6J0iql6qg1xxfb/dpaTjLH+Btg
 RMWMIECoyYCt/51RKpBI92UO1oRGtc5/9Pv72XeU8ooP1VIU0lhLg+2unwWZDIO++8qCdWC163cHD7mcF9kta/HmOE0JIpAjHnTOC2gCU2Te3KmEExHAD1Qk
 3ilN9QCOPv85EiRTKwskHIpvuNMfndllOBgytX2gJOWOHeqaOSRBnxSwo1wxvZ2F
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Thu, 30 Jun 2016 03:03:08 -0000

In message <201606300132.u5U1WCUa093377@repo.freebsd.org>, "Bjoern A. Zeeb" 
wri
tes:
> Author: bz
> Date: Thu Jun 30 01:32:12 2016
> New Revision: 302289
> URL: https://svnweb.freebsd.org/changeset/base/302289
> 
> Log:
>   Remove unused global variables as well as unused memory
>   allocations from ipfilter in preparation for VNET support.
>   
>   Suggested by:		cy (see D7000)
>   Sponsored by:		The FreeBSD Foundation
>   MFC after:		2 weeks
>   Approved by:		re (gjb)
> 
> Modified:
>   head/sys/contrib/ipfilter/netinet/ip_fil.h
>   head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
>   head/sys/contrib/ipfilter/netinet/ip_nat.c
> 
> Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h
> =============================================================================
> =
> --- head/sys/contrib/ipfilter/netinet/ip_fil.h	Wed Jun 29 23:56:24 201
> 6	(r302288)
> +++ head/sys/contrib/ipfilter/netinet/ip_fil.h	Thu Jun 30 01:32:12 201
> 6	(r302289)
> @@ -1710,7 +1710,6 @@ typedef struct ipf_main_softc_s {
>  
>  #ifndef	_KERNEL
>  extern	int	ipf_check __P((void *, struct ip *, int, void *, int, m
> b_t **));
> -extern	int	(*ipf_checkp) __P((ip_t *, int, void *, int, mb_t **));
>  extern	struct	ifnet *get_unit __P((char *, int));
>  extern	char	*get_ifname __P((struct ifnet *));
>  extern	int	ipfioctl __P((ipf_main_softc_t *, int, ioctlcmd_t,
> 
> Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
> =============================================================================
> =
> --- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Wed Jun 29 23:5
> 6:24 2016	(r302288)
> +++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Thu Jun 30 01:3
> 2:12 2016	(r302289)
> @@ -99,10 +99,8 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I
>  # endif
>  
>  
> -static	int	(*ipf_savep) __P((void *, ip_t *, int, void *, int, str
> uct mbuf **));
>  static	int	ipf_send_ip __P((fr_info_t *, mb_t *));
>  static void	ipf_timer_func __P((void *arg));
> -int		ipf_locks_done = 0;
>  
>  ipf_main_softc_t ipfmain;
>  
> @@ -110,10 +108,6 @@ ipf_main_softc_t ipfmain;
>  # if defined(NETBSD_PF)
>  #  include 
>  # endif /* NETBSD_PF */
> -/*
> - * We provide the ipf_checkp name just to minimize changes later.
> - */
> -int (*ipf_checkp) __P((void *, ip_t *ip, int hlen, void *ifp, int out, mb_t 
> **mp));
>  
>  
>  static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag;
> @@ -221,11 +215,6 @@ ipfattach(softc)
>  	}
>  
>  
> -	if (ipf_checkp != ipf_check) {
> -		ipf_savep = ipf_checkp;
> -		ipf_checkp = ipf_check;
> -	}
> -
>  	bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait));
>  	softc->ipf_running = 1;
>  
> @@ -268,12 +257,6 @@ ipfdetach(softc)
>  #endif
>  	callout_drain(&softc->ipf_slow_ch);
>  
> -#ifndef NETBSD_PF
> -	if (ipf_checkp != NULL)
> -		ipf_checkp = ipf_savep;
> -	ipf_savep = NULL;
> -#endif
> -
>  	ipf_fini_all(softc);
>  
>  	softc->ipf_running = -2;
> 
> Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c
> =============================================================================
> =
> --- head/sys/contrib/ipfilter/netinet/ip_nat.c	Wed Jun 29 23:56:24 201
> 6	(r302288)
> +++ head/sys/contrib/ipfilter/netinet/ip_nat.c	Thu Jun 30 01:32:12 201
> 6	(r302289)
> @@ -133,8 +133,6 @@ static const char rcsid[] = "@(#)$FreeBS
>  #define	NBUMPSIDEDF(y,x)do { softn->ipf_nat_stats.ns_side[y].x++; \
>  			     DT1(x, fr_info_t *, fin); } while (0)
>  
> -frentry_t	ipfnatblock;
> -
>  static ipftuneable_t ipf_nat_tuneables[] = {
>  	/* nat */
>  	{ { (void *)offsetof(ipf_nat_softc_t, ipf_nat_lock) },
> @@ -275,9 +273,6 @@ static	void	ipf_nat_tabmove __P((ipf_nat
>  int
>  ipf_nat_main_load()
>  {
> -	bzero((char *)&ipfnatblock, sizeof(ipfnatblock));
> -	ipfnatblock.fr_flags = FR_BLOCK|FR_QUICK;
> -	ipfnatblock.fr_ref = 1;
>  
>  	return 0;
>  }
> 
> 

Thank you Bjoern.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

	The need of the many outweighs the greed of the few.





From owner-svn-src-all@freebsd.org  Thu Jun 30 04:58:21 2016
Return-Path: 
Delivered-To: svn-src-all@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 02379B863DA;
 Thu, 30 Jun 2016 04:58:20 +0000 (UTC) (envelope-from wma@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 B909A20BA;
 Thu, 30 Jun 2016 04:58:20 +0000 (UTC) (envelope-from wma@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U4wJw3068419;
 Thu, 30 Jun 2016 04:58:19 GMT (envelope-from wma@FreeBSD.org)
Received: (from wma@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U4wJS9068418;
 Thu, 30 Jun 2016 04:58:19 GMT (envelope-from wma@FreeBSD.org)
Message-Id: <201606300458.u5U4wJS9068418@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org
 using -f
From: Wojciech Macek 
Date: Thu, 30 Jun 2016 04:58:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302291 - head/sys/arm64/include
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 04:58:21 -0000

Author: wma
Date: Thu Jun 30 04:58:19 2016
New Revision: 302291
URL: https://svnweb.freebsd.org/changeset/base/302291

Log:
  ARM64: fix DMAP calculation
  
      Use arithmetic operators instead of logical. This fixes
      DMAP ranges calculation for ThunderX Dual Socket.
  
      Obtained from:         Semihalf
      Sponsored by:          Cavium
      Reviewed by:           zbb
      Differential Revision: https://reviews.freebsd.org/D7023
      Approved by:           re (gjb)

Modified:
  head/sys/arm64/include/vmparam.h

Modified: head/sys/arm64/include/vmparam.h
==============================================================================
--- head/sys/arm64/include/vmparam.h	Thu Jun 30 01:33:14 2016	(r302290)
+++ head/sys/arm64/include/vmparam.h	Thu Jun 30 04:58:19 2016	(r302291)
@@ -181,7 +181,7 @@
 	KASSERT(PHYS_IN_DMAP(pa),					\
 	    ("%s: PA out of range, PA: 0x%lx", __func__,		\
 	    (vm_paddr_t)(pa)));						\
-	((pa) - dmap_phys_base) | DMAP_MIN_ADDRESS;			\
+	((pa) - dmap_phys_base) + DMAP_MIN_ADDRESS;			\
 })
 
 #define	DMAP_TO_PHYS(va)						\
@@ -189,7 +189,7 @@
 	KASSERT(VIRT_IN_DMAP(va),					\
 	    ("%s: VA out of range, VA: 0x%lx", __func__,		\
 	    (vm_offset_t)(va)));					\
-	((va) & ~DMAP_MIN_ADDRESS) + dmap_phys_base;			\
+	((va) - DMAP_MIN_ADDRESS) + dmap_phys_base;			\
 })
 
 #define	VM_MIN_USER_ADDRESS	(0x0000000000000000UL)

From owner-svn-src-all@freebsd.org  Thu Jun 30 05:18:38 2016
Return-Path: 
Delivered-To: svn-src-all@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 7BF62B8683B;
 Thu, 30 Jun 2016 05:18:38 +0000 (UTC) (envelope-from wma@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 22C4E2950;
 Thu, 30 Jun 2016 05:18:38 +0000 (UTC) (envelope-from wma@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U5IbDN075642;
 Thu, 30 Jun 2016 05:18:37 GMT (envelope-from wma@FreeBSD.org)
Received: (from wma@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U5IbT5075641;
 Thu, 30 Jun 2016 05:18:37 GMT (envelope-from wma@FreeBSD.org)
Message-Id: <201606300518.u5U5IbT5075641@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org
 using -f
From: Wojciech Macek 
Date: Thu, 30 Jun 2016 05:18:37 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302292 - head/sys/sys
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 05:18:38 -0000

Author: wma
Date: Thu Jun 30 05:18:37 2016
New Revision: 302292
URL: https://svnweb.freebsd.org/changeset/base/302292

Log:
  ARM, ARM64: Workaround for buf_ring reordering
  
      This patch offers a workaround to buf_ring reordering
      visible on armv7 and armv8. This is supposed to be
      removed once new buf_ring implementation is integrated
      into the tree.
  
      Obtained from:         Semihalf
      Reviewed by:           alc,emaste
      Differential Revision: https://reviews.freebsd.org/D6986
      Approved by:           re (gjb)

Modified:
  head/sys/sys/buf_ring.h

Modified: head/sys/sys/buf_ring.h
==============================================================================
--- head/sys/sys/buf_ring.h	Thu Jun 30 04:58:19 2016	(r302291)
+++ head/sys/sys/buf_ring.h	Thu Jun 30 05:18:37 2016	(r302292)
@@ -161,9 +161,38 @@ buf_ring_dequeue_sc(struct buf_ring *br)
 #endif
 	uint32_t prod_tail;
 	void *buf;
-	
+
+	/*
+	 * This is a workaround to allow using buf_ring on ARM and ARM64.
+	 * ARM64TODO: Fix buf_ring in a generic way.
+	 * REMARKS: It is suspected that br_cons_head does not require
+	 *   load_acq operation, but this change was extensively tested
+	 *   and confirmed it's working. To be reviewed once again in
+	 *   FreeBSD-12.
+	 *
+	 * Preventing following situation:
+
+	 * Core(0) - buf_ring_enqueue()                                       Core(1) - buf_ring_dequeue_sc()
+	 * -----------------------------------------                                       ----------------------------------------------
+	 *
+	 *                                                                                cons_head = br->br_cons_head;
+	 * atomic_cmpset_acq_32(&br->br_prod_head, ...));
+	 *                                                                                buf = br->br_ring[cons_head];     >
+	 * br->br_ring[prod_head] = buf;
+	 * atomic_store_rel_32(&br->br_prod_tail, ...);
+	 *                                                                                prod_tail = br->br_prod_tail;
+	 *                                                                                if (cons_head == prod_tail) 
+	 *                                                                                        return (NULL);
+	 *                                                                                `	
+	 *
+	 * <1> Load (on core 1) from br->br_ring[cons_head] can be reordered (speculative readed) by CPU.
+	 */	
+#if defined(__arm__) || defined(__aarch64__)
+	cons_head = atomic_load_acq_32(&br->br_cons_head);
+#else
 	cons_head = br->br_cons_head;
-	prod_tail = br->br_prod_tail;
+#endif
+	prod_tail = atomic_load_acq_32(&br->br_prod_tail);
 	
 	cons_next = (cons_head + 1) & br->br_cons_mask;
 #ifdef PREFETCH_DEFINED

From owner-svn-src-all@freebsd.org  Thu Jun 30 06:06:36 2016
Return-Path: 
Delivered-To: svn-src-all@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 654F2B87529;
 Thu, 30 Jun 2016 06:06:36 +0000 (UTC)
 (envelope-from tuexen@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 1E0682FC6;
 Thu, 30 Jun 2016 06:06:36 +0000 (UTC)
 (envelope-from tuexen@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U66ZDt094403;
 Thu, 30 Jun 2016 06:06:35 GMT (envelope-from tuexen@FreeBSD.org)
Received: (from tuexen@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U66ZUw094402;
 Thu, 30 Jun 2016 06:06:35 GMT (envelope-from tuexen@FreeBSD.org)
Message-Id: <201606300606.u5U66ZUw094402@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: tuexen set sender to
 tuexen@FreeBSD.org using -f
From: Michael Tuexen 
Date: Thu, 30 Jun 2016 06:06:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302293 - head/sys/netinet
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 06:06:36 -0000

Author: tuexen
Date: Thu Jun 30 06:06:35 2016
New Revision: 302293
URL: https://svnweb.freebsd.org/changeset/base/302293

Log:
  This patch fixes two bugs related to the setting of the I-Bit
  for SCTP DATA and I-DATA chunks.
  * For fragmented user messages, set the I-Bit only on the last
    fragment.
  * When using explicit EOR mode, set the I-Bit on the last
    fragment, whenever SCTP_SACK_IMMEDIATELY was set in snd_flags
    for any of the send() calls.
  
  Approved by:	re (hrs)
  MFC after:	1 week

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c	Thu Jun 30 05:18:37 2016	(r302292)
+++ head/sys/netinet/sctp_output.c	Thu Jun 30 06:06:35 2016	(r302293)
@@ -7325,10 +7325,12 @@ re_look:
 			/* All of it fits in the MTU */
 			if (sp->some_taken) {
 				rcv_flags |= SCTP_DATA_LAST_FRAG;
-				sp->put_last_out = 1;
 			} else {
 				rcv_flags |= SCTP_DATA_NOT_FRAG;
-				sp->put_last_out = 1;
+			}
+			sp->put_last_out = 1;
+			if (sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) {
+				rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY;
 			}
 		} else {
 			/* Not all of it fits, we fragment */
@@ -7396,8 +7398,8 @@ re_look:
 	if (sp->sinfo_flags & SCTP_UNORDERED) {
 		rcv_flags |= SCTP_DATA_UNORDERED;
 	}
-	if ((SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && ((sp->sinfo_flags & SCTP_EOF) == SCTP_EOF)) ||
-	    ((sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) == SCTP_SACK_IMMEDIATELY)) {
+	if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) &&
+	    (sp->sinfo_flags & SCTP_EOF) == SCTP_EOF) {
 		rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY;
 	}
 	/* clear out the chunk before setting up */
@@ -13280,7 +13282,9 @@ skip_preblock:
 				sctp_snd_sb_alloc(stcb, sndout);
 				atomic_add_int(&sp->length, sndout);
 				len += sndout;
-
+				if (srcv->sinfo_flags & SCTP_SACK_IMMEDIATELY) {
+					sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY;
+				}
 				/* Did we reach EOR? */
 				if ((uio->uio_resid == 0) &&
 				    ((user_marks_eor == 0) ||

From owner-svn-src-all@freebsd.org  Thu Jun 30 08:51:52 2016
Return-Path: 
Delivered-To: svn-src-all@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 9209DB87CA6;
 Thu, 30 Jun 2016 08:51:52 +0000 (UTC) (envelope-from mm@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 558CB2A58;
 Thu, 30 Jun 2016 08:51:52 +0000 (UTC) (envelope-from mm@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5U8ppiE055750;
 Thu, 30 Jun 2016 08:51:51 GMT (envelope-from mm@FreeBSD.org)
Received: (from mm@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5U8ppCM055743;
 Thu, 30 Jun 2016 08:51:51 GMT (envelope-from mm@FreeBSD.org)
Message-Id: <201606300851.u5U8ppCM055743@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org
 using -f
From: Martin Matuska 
Date: Thu, 30 Jun 2016 08:51:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302294 - in head/contrib/libarchive: libarchive
 libarchive/test libarchive_fe
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 08:51:52 -0000

Author: mm
Date: Thu Jun 30 08:51:50 2016
New Revision: 302294
URL: https://svnweb.freebsd.org/changeset/base/302294

Log:
  MFV r302264:
  
  Sync libarchive with vendor, bugfixes for tests:
  - fix tests on filesystems without birthtime support, e.g. UFS1 (1)
  - vendor issue #729: avoid use of C99 for-scope declarations in
    test_write_format_gnutar_filenames.c
  
  MFC after:	1 week
  PR:		204157 (1)
  Approved by:	re (hrs)

Modified:
  head/contrib/libarchive/libarchive/archive_read_disk_posix.c
  head/contrib/libarchive/libarchive/archive_string.c
  head/contrib/libarchive/libarchive/archive_write_disk_posix.c
  head/contrib/libarchive/libarchive/test/main.c
  head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
  head/contrib/libarchive/libarchive_fe/passphrase.c
Directory Properties:
  head/contrib/libarchive/   (props changed)
  head/contrib/libarchive/libarchive/   (props changed)
  head/contrib/libarchive/libarchive_fe/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_read_disk_posix.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_read_disk_posix.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive/archive_read_disk_posix.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -1504,7 +1504,11 @@ setup_current_filesystem(struct archive_
 	struct tree *t = a->tree;
 	struct statfs sfs;
 #if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC)
+#  if defined(HAVE_STRUCT_VFSCONF)
+	struct vfsconf vfc;
+#  else
 	struct xvfsconf vfc;
+#  endif
 #endif
 	int r, xr = 0;
 #if !defined(HAVE_STRUCT_STATFS_F_NAMEMAX)

Modified: head/contrib/libarchive/libarchive/archive_string.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_string.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive/archive_string.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -559,7 +559,8 @@ archive_wstring_append_from_mbs_in_codep
 			}
 			if (count == 0 && length != 0)
 				ret = -1;
-		} while (0);
+			break;
+		} while (1);
 	}
 	dest->length += count;
 	dest->s[dest->length] = L'\0';
@@ -3552,18 +3553,19 @@ win_strncat_from_utf16(struct archive_st
 		ll = WideCharToMultiByte(sc->to_cp, 0,
 		    (LPCWSTR)u16, (int)bytes>>1, mbs, (int)mbs_size,
 			NULL, &defchar);
-		if (ll == 0 &&
-		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-			/* Need more buffer for MBS. */
-			ll = WideCharToMultiByte(sc->to_cp, 0,
-			    (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
-			if (archive_string_ensure(as, ll +1) == NULL)
-				return (-1);
-			mbs = as->s + as->length;
-			mbs_size = as->buffer_length - as->length -1;
-			continue;
+		/* Exit loop if we succeeded */
+		if (ll != 0 ||
+		    GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+			break;
 		}
-	} while (0);
+		/* Else expand buffer and loop to try again. */
+		ll = WideCharToMultiByte(sc->to_cp, 0,
+		    (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
+		if (archive_string_ensure(as, ll +1) == NULL)
+			return (-1);
+		mbs = as->s + as->length;
+		mbs_size = as->buffer_length - as->length -1;
+	} while (1);
 	archive_string_free(&tmp);
 	as->length += ll;
 	as->s[as->length] = '\0';
@@ -3634,19 +3636,20 @@ win_strncat_to_utf16(struct archive_stri
 	do {
 		count = MultiByteToWideChar(sc->from_cp,
 		    MB_PRECOMPOSED, s, (int)length, (LPWSTR)u16, (int)avail>>1);
-		if (count == 0 &&
-		    GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-			/* Need more buffer for UTF-16 string */
-			count = MultiByteToWideChar(sc->from_cp,
-			    MB_PRECOMPOSED, s, (int)length, NULL, 0);
-			if (archive_string_ensure(as16, (count +1) * 2)
-			    == NULL)
-				return (-1);
-			u16 = as16->s + as16->length;
-			avail = as16->buffer_length - 2;
-			continue;
+		/* Exit loop if we succeeded */
+		if (count != 0 ||
+		    GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+			break;
 		}
-	} while (0);
+		/* Expand buffer and try again */
+		count = MultiByteToWideChar(sc->from_cp,
+		    MB_PRECOMPOSED, s, (int)length, NULL, 0);
+		if (archive_string_ensure(as16, (count +1) * 2)
+		    == NULL)
+			return (-1);
+		u16 = as16->s + as16->length;
+		avail = as16->buffer_length - 2;
+	} while (1);
 	as16->length += count * 2;
 	as16->s[as16->length] = 0;
 	as16->s[as16->length+1] = 0;

Modified: head/contrib/libarchive/libarchive/archive_write_disk_posix.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_write_disk_posix.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive/archive_write_disk_posix.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -3487,6 +3487,9 @@ exit_xattr:
 static int
 copy_acls(struct archive_write_disk *a, int tmpfd, int dffd)
 {
+#ifndef HAVE_SYS_ACL_H
+	return 0;
+#else
 	acl_t acl, dfacl = NULL;
 	int acl_r, ret = ARCHIVE_OK;
 
@@ -3514,6 +3517,7 @@ exit_acl:
 	if (dfacl)
 		acl_free(dfacl);
 	return (ret);
+#endif
 }
 
 static int

Modified: head/contrib/libarchive/libarchive/test/main.c
==============================================================================
--- head/contrib/libarchive/libarchive/test/main.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive/test/main.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -1292,6 +1292,11 @@ assertion_file_time(const char *file, in
 	switch (type) {
 	case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
 	case 'b': filet = st.st_birthtime;
+		/* FreeBSD filesystems that don't support birthtime
+		 * (e.g., UFS1) always return -1 here. */
+		if (filet == -1) {
+			return (1);
+		}
 		filet_nsec = st.st_birthtimespec.tv_nsec; break;
 	case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
 	default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);

Modified: head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
==============================================================================
--- head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -42,6 +42,7 @@ DEFINE_TEST(test_write_format_gnutar_fil
 	struct archive_entry *ae, *template;
 	struct archive *a;
 	size_t used;
+	int i;
 
 	buff = malloc(buffsize); /* million bytes of work area */
 	assert(buff != NULL);
@@ -55,7 +56,7 @@ DEFINE_TEST(test_write_format_gnutar_fil
 	archive_entry_set_mode(template, S_IFREG | 0755);
 	archive_entry_set_size(template, 8);
 
-	for (int i = 0; i < 2000; ++i) {
+	for (i = 0; i < 2000; ++i) {
 		filename[i] = 'a';
 		filename[i + 1] = '\0';
 		archive_entry_copy_pathname(template, filename);
@@ -97,6 +98,7 @@ DEFINE_TEST(test_write_format_gnutar_lin
 	struct archive_entry *ae, *template;
 	struct archive *a;
 	size_t used;
+	int i;
 
 	buff = malloc(buffsize); /* million bytes of work area */
 	assert(buff != NULL);
@@ -110,7 +112,7 @@ DEFINE_TEST(test_write_format_gnutar_lin
 	archive_entry_set_mode(template, S_IFLNK | 0755);
 	archive_entry_copy_pathname(template, "link");
 
-	for (int i = 0; i < 2000; ++i) {
+	for (i = 0; i < 2000; ++i) {
 		filename[i] = 'a';
 		filename[i + 1] = '\0';
 		archive_entry_copy_symlink(template, filename);

Modified: head/contrib/libarchive/libarchive_fe/passphrase.c
==============================================================================
--- head/contrib/libarchive/libarchive_fe/passphrase.c	Thu Jun 30 06:06:35 2016	(r302293)
+++ head/contrib/libarchive/libarchive_fe/passphrase.c	Thu Jun 30 08:51:50 2016	(r302294)
@@ -132,6 +132,10 @@ readpassphrase(const char *prompt, char 
 #include 
 #include 
 
+#ifndef _PATH_TTY
+#define _PATH_TTY "/dev/tty"
+#endif
+
 #ifdef TCSASOFT
 # define _T_FLUSH	(TCSAFLUSH|TCSASOFT)
 #else

From owner-svn-src-all@freebsd.org  Thu Jun 30 12:44:19 2016
Return-Path: 
Delivered-To: svn-src-all@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 7B268B874BA;
 Thu, 30 Jun 2016 12:44:19 +0000 (UTC) (envelope-from mm@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 218C42F4B;
 Thu, 30 Jun 2016 12:44:19 +0000 (UTC) (envelope-from mm@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UCiIP5042344;
 Thu, 30 Jun 2016 12:44:18 GMT (envelope-from mm@FreeBSD.org)
Received: (from mm@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UCiFk5042314;
 Thu, 30 Jun 2016 12:44:15 GMT (envelope-from mm@FreeBSD.org)
Message-Id: <201606301244.u5UCiFk5042314@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org
 using -f
From: Martin Matuska 
Date: Thu, 30 Jun 2016 12:44:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r302295 - in stable/10: contrib/libarchive
 contrib/libarchive/cat/test contrib/libarchive/cpio
 contrib/libarchive/cpio/test contrib/libarchive/libarchive
 contrib/libarchive/libarchive/t...
X-SVN-Group: stable-10
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.22
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: Thu, 30 Jun 2016 12:44:19 -0000

Author: mm
Date: Thu Jun 30 12:44:15 2016
New Revision: 302295
URL: https://svnweb.freebsd.org/changeset/base/302295

Log:
  MFC r302075:
  
  Update libarchive to 3.2.1 (bugfix and security fix release)
  
  List of vendor fixes:
  - fix exploitable heap overflow vulnerability in Rar decompression
    (vendor issue 719, CVE-2016-4302, TALOS-2016-0154)
  - fix exploitable stack based buffer overflow vulnebarility in mtree
    parse_device functionality (vendor PR 715, CVE-2016-4301, TALOS-2016-0153)
  - fix exploitable heap overflow vulnerability in 7-zip read_SubStreamsInfo
    (vendor issue 718, CVE-2016-4300, TALOS-2016-152)
  - fix integer overflow when computing location of volume descriptor
    (vendor issue 717)
  - fix buffer overflow when reading a crafred rar archive (vendor issue 521)
  - fix possible buffer overflow when reading ISO9660 archives on machines
    where sizeof(int) < sizeof(size_t) (vendor issue 711)
  - tar and cpio should fail if an input file named on the command line is
    missing (vendor issue 708)
  - fix incorrect writing of gnutar filenames that are exactly 512 bytes
    long (vendor issue 682)
  - allow tests to be run from paths that are equal or longer than 128
    characters (vendor issue 657)
  - add memory allocation errors in archive_entry_xattr.c (vendor PR 603)
  - remove dead code in archive_entry_xattr_add_entry() (vendor PR 716)
  - fix broken decryption of ZIP files (vendor issue 553)
  - manpage style, typo and description fixes
  
  Post-3.2.1 vendor fixes:
  - fix typo in cpio version reporting (Vendor PR 725, 726)
  - fix argument range of ctype functions in libarchive_fe/passphrase.c
  - fix ctype use and avoid empty loop bodies in WARC reader
  
  Security:	CVE-2016-4300, CVE-2016-4301, CVE-2016-4302

Added:
  stable/10/contrib/libarchive/cpio/test/test_missing_file.c
     - copied unchanged from r302075, head/contrib/libarchive/cpio/test/test_missing_file.c
  stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c
     - copied unchanged from r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c
  stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu
     - copied unchanged from r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu
  stable/10/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
     - copied unchanged from r302075, head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
  stable/10/contrib/libarchive/tar/test/test_missing_file.c
     - copied unchanged from r302075, head/contrib/libarchive/tar/test/test_missing_file.c
Modified:
  stable/10/contrib/libarchive/NEWS
  stable/10/contrib/libarchive/cat/test/main.c
  stable/10/contrib/libarchive/cpio/cpio.c
  stable/10/contrib/libarchive/cpio/test/main.c
  stable/10/contrib/libarchive/cpio/test/test_option_version.c
  stable/10/contrib/libarchive/libarchive/archive.h
  stable/10/contrib/libarchive/libarchive/archive_entry.h
  stable/10/contrib/libarchive/libarchive/archive_entry_xattr.c
  stable/10/contrib/libarchive/libarchive/archive_ppmd7.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_lha.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c
  stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c
  stable/10/contrib/libarchive/libarchive/archive_write_filter.3
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
  stable/10/contrib/libarchive/libarchive/archive_write_set_options.3
  stable/10/contrib/libarchive/libarchive/libarchive-formats.5
  stable/10/contrib/libarchive/libarchive/libarchive_changes.3
  stable/10/contrib/libarchive/libarchive/test/main.c
  stable/10/contrib/libarchive/libarchive_fe/passphrase.c
  stable/10/contrib/libarchive/tar/test/main.c
  stable/10/contrib/libarchive/tar/write.c
  stable/10/lib/libarchive/tests/Makefile
  stable/10/usr.bin/bsdcat/Makefile
  stable/10/usr.bin/cpio/Makefile
  stable/10/usr.bin/cpio/tests/Makefile
  stable/10/usr.bin/tar/Makefile
  stable/10/usr.bin/tar/tests/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/libarchive/NEWS
==============================================================================
--- stable/10/contrib/libarchive/NEWS	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/NEWS	Thu Jun 30 12:44:15 2016	(r302295)
@@ -1,3 +1,8 @@
+Jun 20, 2016: libarchive 3.2.1 released
+    This fixes a handful of security and other critical issues with 3.2.0
+
+May 01, 2016: libarchive 3.2.0 released
+
 Apr 09, 2016: libarchive 3.1.901a released
     Another test release in preparation for 3.2.0
 

Modified: stable/10/contrib/libarchive/cat/test/main.c
==============================================================================
--- stable/10/contrib/libarchive/cat/test/main.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/cat/test/main.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -2534,18 +2534,36 @@ usage(const char *program)
 static char *
 get_refdir(const char *d)
 {
-	char tried[512] = { '\0' };
-	char buff[128];
-	char *pwd, *p;
+	size_t tried_size, buff_size;
+	char *buff, *tried, *pwd = NULL, *p = NULL;
+
+#ifdef PATH_MAX
+	buff_size = PATH_MAX;
+#else
+	buff_size = 8192;
+#endif
+	buff = calloc(buff_size, 1);
+	if (buff == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
+
+	/* Allocate a buffer to hold the various directories we checked. */
+	tried_size = buff_size * 2;
+	tried = calloc(tried_size, 1);
+	if (tried == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
 
 	/* If a dir was specified, try that */
 	if (d != NULL) {
 		pwd = NULL;
-		snprintf(buff, sizeof(buff), "%s", d);
+		snprintf(buff, buff_size, "%s", d);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 		goto failure;
 	}
 
@@ -2559,48 +2577,48 @@ get_refdir(const char *d)
 		pwd[strlen(pwd) - 1] = '\0';
 
 	/* Look for a known file. */
-	snprintf(buff, sizeof(buff), "%s", pwd);
+	snprintf(buff, buff_size, "%s", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-	snprintf(buff, sizeof(buff), "%s/test", pwd);
+	snprintf(buff, buff_size, "%s/test", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(LIBRARY)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, LIBRARY);
 #else
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM);
 #endif
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(PROGRAM_ALIAS)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM_ALIAS);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 #endif
 
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
-		snprintf(buff, sizeof(buff), "%s", pwd + 8);
+		snprintf(buff, buff_size, "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-		snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+		snprintf(buff, buff_size, "%s/test", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 	}
 
 failure:
@@ -2615,7 +2633,12 @@ failure:
 success:
 	free(p);
 	free(pwd);
-	return strdup(buff);
+	free(tried);
+
+	/* Copy result into a fresh buffer to reduce memory usage. */
+	p = strdup(buff);
+	free(buff);
+	return p;
 }
 
 int

Modified: stable/10/contrib/libarchive/cpio/cpio.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/cpio.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/cpio/cpio.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -498,7 +498,7 @@ long_help(void)
 static void
 version(void)
 {
-	fprintf(stdout,"bsdcpio %s -- %s\n",
+	fprintf(stdout,"bsdcpio %s - %s\n",
 	    BSDCPIO_VERSION_STRING,
 	    archive_version_details());
 	exit(0);

Modified: stable/10/contrib/libarchive/cpio/test/main.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/test/main.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/cpio/test/main.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -2535,18 +2535,36 @@ usage(const char *program)
 static char *
 get_refdir(const char *d)
 {
-	char tried[512] = { '\0' };
-	char buff[128];
-	char *pwd, *p;
+	size_t tried_size, buff_size;
+	char *buff, *tried, *pwd = NULL, *p = NULL;
+
+#ifdef PATH_MAX
+	buff_size = PATH_MAX;
+#else
+	buff_size = 8192;
+#endif
+	buff = calloc(buff_size, 1);
+	if (buff == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
+
+	/* Allocate a buffer to hold the various directories we checked. */
+	tried_size = buff_size * 2;
+	tried = calloc(tried_size, 1);
+	if (tried == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
 
 	/* If a dir was specified, try that */
 	if (d != NULL) {
 		pwd = NULL;
-		snprintf(buff, sizeof(buff), "%s", d);
+		snprintf(buff, buff_size, "%s", d);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 		goto failure;
 	}
 
@@ -2560,48 +2578,48 @@ get_refdir(const char *d)
 		pwd[strlen(pwd) - 1] = '\0';
 
 	/* Look for a known file. */
-	snprintf(buff, sizeof(buff), "%s", pwd);
+	snprintf(buff, buff_size, "%s", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-	snprintf(buff, sizeof(buff), "%s/test", pwd);
+	snprintf(buff, buff_size, "%s/test", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(LIBRARY)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, LIBRARY);
 #else
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM);
 #endif
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(PROGRAM_ALIAS)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM_ALIAS);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 #endif
 
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
-		snprintf(buff, sizeof(buff), "%s", pwd + 8);
+		snprintf(buff, buff_size, "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-		snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+		snprintf(buff, buff_size, "%s/test", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 	}
 
 failure:
@@ -2616,7 +2634,12 @@ failure:
 success:
 	free(p);
 	free(pwd);
-	return strdup(buff);
+	free(tried);
+
+	/* Copy result into a fresh buffer to reduce memory usage. */
+	p = strdup(buff);
+	free(buff);
+	return p;
 }
 
 int

Copied: stable/10/contrib/libarchive/cpio/test/test_missing_file.c (from r302075, head/contrib/libarchive/cpio/test/test_missing_file.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/libarchive/cpio/test/test_missing_file.c	Thu Jun 30 12:44:15 2016	(r302295, copy of r302075, head/contrib/libarchive/cpio/test/test_missing_file.c)
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_missing_file)
+{
+	int r;
+
+	assertMakeFile("file1", 0644, "file1");
+	assertMakeFile("file2", 0644, "file2");
+
+	assertMakeFile("filelist1", 0644, "file1\nfile2\n");
+	r = systemf("%s -o stdout1 2>stderr1", testprog);
+	assertEqualInt(r, 0);
+	assertTextFileContents("1 block\n", "stderr1");
+
+	assertMakeFile("filelist2", 0644, "file1\nfile2\nfile3\n");
+	r = systemf("%s -o stdout2 2>stderr2", testprog);
+	assert(r != 0);
+
+	assertMakeFile("filelist3", 0644, "");
+	r = systemf("%s -o stdout3 2>stderr3", testprog);
+	assertEqualInt(r, 0);
+	assertTextFileContents("1 block\n", "stderr3");
+
+	assertMakeFile("filelist4", 0644, "file3\n");
+	r = systemf("%s -o stdout4 2>stderr4", testprog);
+	assert(r != 0);
+}

Modified: stable/10/contrib/libarchive/cpio/test/test_option_version.c
==============================================================================
--- stable/10/contrib/libarchive/cpio/test/test_option_version.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/cpio/test/test_option_version.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -59,8 +59,8 @@ verify(const char *p, size_t s)
 	++q; --s;
 	/* Separator. */
 	failure("Version: %s", p);
-	assertEqualMem(q, "-- ", 3);
-	q += 3; s -= 3;
+	assertEqualMem(q, "- ", 2);
+	q += 2; s -= 2;
 	/* libarchive name and version number */
 	assert(s > 11);
 	failure("Version: %s", p);

Modified: stable/10/contrib/libarchive/libarchive/archive.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive.h	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive.h	Thu Jun 30 12:44:15 2016	(r302295)
@@ -36,7 +36,7 @@
  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
 /* Note: Compiler will complain if this does not match archive_entry.h! */
-#define	ARCHIVE_VERSION_NUMBER 3002000
+#define	ARCHIVE_VERSION_NUMBER 3002001
 
 #include 
 #include   /* for wchar_t */
@@ -155,7 +155,7 @@ __LA_DECL int		archive_version_number(vo
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define	ARCHIVE_VERSION_ONLY_STRING "3.2.0"
+#define	ARCHIVE_VERSION_ONLY_STRING "3.2.1"
 #define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
 __LA_DECL const char *	archive_version_string(void);
 

Modified: stable/10/contrib/libarchive/libarchive/archive_entry.h
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_entry.h	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_entry.h	Thu Jun 30 12:44:15 2016	(r302295)
@@ -29,7 +29,7 @@
 #define	ARCHIVE_ENTRY_H_INCLUDED
 
 /* Note: Compiler will complain if this does not match archive.h! */
-#define	ARCHIVE_VERSION_NUMBER 3002000
+#define	ARCHIVE_VERSION_NUMBER 3002001
 
 /*
  * Note: archive_entry.h is for use outside of libarchive; the

Modified: stable/10/contrib/libarchive/libarchive/archive_entry_xattr.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_entry_xattr.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_entry_xattr.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -91,16 +91,11 @@ archive_entry_xattr_add_entry(struct arc
 {
 	struct ae_xattr	*xp;
 
-	for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
-		;
-
 	if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
-		/* XXX Error XXX */
-		return;
+		__archive_errx(1, "Out of memory");
 
 	if ((xp->name = strdup(name)) == NULL)
-		/* XXX Error XXX */
-		return;
+		__archive_errx(1, "Out of memory");
 
 	if ((xp->value = malloc(size)) != NULL) {
 		memcpy(xp->value, value, size);

Modified: stable/10/contrib/libarchive/libarchive/archive_ppmd7.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_ppmd7.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_ppmd7.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -126,6 +126,11 @@ static Bool Ppmd7_Alloc(CPpmd7 *p, UInt3
 {
   if (p->Base == 0 || p->Size != size)
   {
+    /* RestartModel() below assumes that p->Size >= UNIT_SIZE
+       (see the calculation of m->MinContext). */
+    if (size < UNIT_SIZE) {
+      return False;
+    }
     Ppmd7_Free(p, alloc);
     p->AlignOffset =
       #ifdef PPMD_32BIT

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -2153,6 +2153,9 @@ read_SubStreamsInfo(struct archive_read 
 				return (-1);
 			if (UMAX_ENTRY < f[i].numUnpackStreams)
 				return (-1);
+			if (unpack_streams > SIZE_MAX - UMAX_ENTRY) {
+				return (-1);
+			}
 			unpack_streams += (size_t)f[i].numUnpackStreams;
 		}
 		if ((p = header_bytes(a, 1)) == NULL)

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -1091,7 +1091,7 @@ choose_volume(struct archive_read *a, st
 		/* This condition is unlikely; by way of caution. */
 		vd = &(iso9660->joliet);
 
-	skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+	skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
 	skipsize = __archive_read_consume(a, skipsize);
 	if (skipsize < 0)
 		return ((int)skipsize);
@@ -1129,7 +1129,7 @@ choose_volume(struct archive_read *a, st
 	    && iso9660->seenJoliet) {
 		/* Switch reading data from primary to joliet. */
 		vd = &(iso9660->joliet);
-		skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+		skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
 		skipsize -= iso9660->current_position;
 		skipsize = __archive_read_consume(a, skipsize);
 		if (skipsize < 0)

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_lha.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_lha.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_lha.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -1712,6 +1712,7 @@ lha_crc16(uint16_t crc, const void *pp, 
 	for (;len >= 8; len -= 8) {
 		/* This if statement expects compiler optimization will
 		 * remove the stament which will not be executed. */
+#undef bswap16
 #if defined(_MSC_VER) && _MSC_VER >= 1400  /* Visual Studio */
 #  define bswap16(x) _byteswap_ushort(x)
 #elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -1385,12 +1385,12 @@ parse_device(dev_t *pdev, struct archive
 				    "Missing number");
 				return ARCHIVE_WARN;
 			}
-			numbers[argc++] = (unsigned long)mtree_atol(&p);
-			if (argc > MAX_PACK_ARGS) {
+			if (argc >= MAX_PACK_ARGS) {
 				archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
 				    "Too many arguments");
 				return ARCHIVE_WARN;
 			}
+			numbers[argc++] = (unsigned long)mtree_atol(&p);
 		}
 		if (argc < 2) {
 			archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -2127,6 +2127,12 @@ parse_codes(struct archive_read *a)
       rar->range_dec.Stream = &rar->bytein;
       __archive_ppmd7_functions.Ppmd7_Construct(&rar->ppmd7_context);
 
+      if (rar->dictionary_size == 0) {
+	      archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                          "Invalid zero dictionary size");
+	      return (ARCHIVE_FATAL);
+      }
+
       if (!__archive_ppmd7_functions.Ppmd7_Alloc(&rar->ppmd7_context,
         rar->dictionary_size, &g_szalloc))
       {
@@ -2884,11 +2890,10 @@ copy_from_lzss_window(struct archive_rea
   }
 
   windowoffs = lzss_offset_for_position(&rar->lzss, startpos);
-  if(windowoffs + length <= lzss_size(&rar->lzss))
+  if(windowoffs + length <= lzss_size(&rar->lzss)) {
     memcpy(&rar->unp_buffer[rar->unp_offset], &rar->lzss.window[windowoffs],
            length);
-  else
-  {
+  } else if (length <= lzss_size(&rar->lzss)) {
     firstpart = lzss_size(&rar->lzss) - windowoffs;
     if (firstpart < 0) {
       archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -2900,9 +2905,14 @@ copy_from_lzss_window(struct archive_rea
              &rar->lzss.window[windowoffs], firstpart);
       memcpy(&rar->unp_buffer[rar->unp_offset + firstpart],
              &rar->lzss.window[0], length - firstpart);
-    } else
+    } else {
       memcpy(&rar->unp_buffer[rar->unp_offset],
              &rar->lzss.window[windowoffs], length);
+    }
+  } else {
+      archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                        "Bad RAR file data");
+      return (ARCHIVE_FATAL);
   }
   rar->unp_offset += length;
   if (rar->unp_offset >= rar->unp_buffer_size)

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -535,7 +535,8 @@ xstrpisotime(const char *s, char **endpt
 
 	/* as a courtesy to our callers, and since this is a non-standard
 	 * routine, we skip leading whitespace */
-	for (; isspace(*s); s++);
+	while (isspace((unsigned char)*s))
+		++s;
 
 	/* read year */
 	if ((tm.tm_year = strtoi_lim(s, &s, 1583, 4095)) < 0 || *s++ != '-') {
@@ -639,7 +640,9 @@ _warc_rdtyp(const char *buf, size_t bsz)
 		return WT_NONE;
 	}
 	/* overread whitespace */
-	for (val += sizeof(_key) - 1U; val < eob && isspace(*val); val++);
+	val += sizeof(_key) - 1U;
+	while (val < eob && isspace((unsigned char)*val))
+		++val;
 
 	if (val + 8U > eob) {
 		;
@@ -676,7 +679,9 @@ _warc_rduri(const char *buf, size_t bsz)
 		return res;
 	}
 	/* overread whitespace */
-	for (val += sizeof(_key) - 1U; val < eob && isspace(*val); val++);
+	val += sizeof(_key) - 1U;
+	while (val < eob && isspace((unsigned char)*val))
+		++val;
 
 	/* overread URL designators */
 	if ((uri = xmemmem(val, eob - val, "://", 3U)) == NULL) {
@@ -692,7 +697,8 @@ _warc_rduri(const char *buf, size_t bsz)
 	/* also massage eol to point to the first whitespace
 	 * after the last non-whitespace character before
 	 * the end of the line */
-	for (; eol > uri && isspace(eol[-1]); eol--);
+	while (eol > uri && isspace((unsigned char)eol[-1]))
+		--eol;
 
 	/* now then, inspect the URI */
 	if (memcmp(val, "file", 4U) == 0) {
@@ -727,7 +733,7 @@ _warc_rdlen(const char *buf, size_t bsz)
 	/* strtol kindly overreads whitespace for us, so use that */
 	val += sizeof(_key) - 1U;
 	len = strtol(val, &on, 10);
-	if (on == NULL || !isspace(*on)) {
+	if (on == NULL || !isspace((unsigned char)*on)) {
 		/* hm, can we trust that number?  Best not. */
 		return -1;
 	}
@@ -750,7 +756,7 @@ _warc_rdrtm(const char *buf, size_t bsz)
 	/* xstrpisotime() kindly overreads whitespace for us, so use that */
 	val += sizeof(_key) - 1U;
 	res = xstrpisotime(val, &on);
-	if (on == NULL || !isspace(*on)) {
+	if (on == NULL || !isspace((unsigned char)*on)) {
 		/* hm, can we trust that number?  Best not. */
 		return (time_t)-1;
 	}
@@ -773,7 +779,7 @@ _warc_rdmtm(const char *buf, size_t bsz)
 	/* xstrpisotime() kindly overreads whitespace for us, so use that */
 	val += sizeof(_key) - 1U;
 	res = xstrpisotime(val, &on);
-	if (on == NULL || !isspace(*on)) {
+	if (on == NULL || !isspace((unsigned char)*on)) {
 		/* hm, can we trust that number?  Best not. */
 		return (time_t)-1;
 	}

Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -181,6 +181,14 @@ struct zip {
 	char			init_decryption;
 
 	/* Decryption buffer. */
+	/*
+	 * The decrypted data starts at decrypted_ptr and
+	 * extends for decrypted_bytes_remaining.  Decryption
+	 * adds new data to the end of this block, data is returned
+	 * to clients from the beginning.  When the block hits the
+	 * end of decrypted_buffer, it has to be shuffled back to
+	 * the beginning of the buffer.
+	 */
 	unsigned char 		*decrypted_buffer;
 	unsigned char 		*decrypted_ptr;
 	size_t 			decrypted_buffer_size;
@@ -1293,8 +1301,9 @@ zip_read_data_deflate(struct archive_rea
 
 	if (zip->tctx_valid || zip->cctx_valid) {
 		if (zip->decrypted_bytes_remaining < (size_t)bytes_avail) {
-			size_t buff_remaining = zip->decrypted_buffer_size
-			    - (zip->decrypted_ptr - zip->decrypted_buffer);
+			size_t buff_remaining =
+			    (zip->decrypted_buffer + zip->decrypted_buffer_size)
+			    - (zip->decrypted_ptr + zip->decrypted_bytes_remaining);
 
 			if (buff_remaining > (size_t)bytes_avail)
 				buff_remaining = (size_t)bytes_avail;

Modified: stable/10/contrib/libarchive/libarchive/archive_write_filter.3
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_write_filter.3	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_write_filter.3	Thu Jun 30 12:44:15 2016	(r302295)
@@ -43,6 +43,7 @@
 .Nm archive_write_add_filter_program ,
 .Nm archive_write_add_filter_uuencode ,
 .Nm archive_write_add_filter_xz
+.Nd functions enabling output filters
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
 .Sh SYNOPSIS

Modified: stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -467,7 +467,7 @@ archive_write_gnutar_header(struct archi
 		}
 	}
 	if (gnutar->linkname_length > GNUTAR_linkname_size) {
-		size_t todo = gnutar->linkname_length;
+		size_t length = gnutar->linkname_length + 1;
 		struct archive_entry *temp = archive_entry_new2(&a->archive);
 
 		/* Uname/gname here don't really matter since no one reads them;
@@ -476,7 +476,7 @@ archive_write_gnutar_header(struct archi
 		archive_entry_set_gname(temp, "wheel");
 
 		archive_entry_set_pathname(temp, "././@LongLink");
-		archive_entry_set_size(temp, gnutar->linkname_length + 1);
+		archive_entry_set_size(temp, length);
 		ret = archive_format_gnutar_header(a, buff, temp, 'K');
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
@@ -484,11 +484,12 @@ archive_write_gnutar_header(struct archi
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
 		archive_entry_free(temp);
-		/* Write as many 512 bytes blocks as needed to write full name. */
-		ret = __archive_write_output(a, gnutar->linkname, todo);
+		/* Write name and trailing null byte. */
+		ret = __archive_write_output(a, gnutar->linkname, length);
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
-		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)todo));
+		/* Pad to 512 bytes */
+		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length));
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
 	}
@@ -496,7 +497,7 @@ archive_write_gnutar_header(struct archi
 	/* If pathname is longer than 100 chars we need to add an 'L' header. */
 	if (gnutar->pathname_length > GNUTAR_name_size) {
 		const char *pathname = gnutar->pathname;
-		size_t todo = gnutar->pathname_length;
+		size_t length = gnutar->pathname_length + 1;
 		struct archive_entry *temp = archive_entry_new2(&a->archive);
 
 		/* Uname/gname here don't really matter since no one reads them;
@@ -505,7 +506,7 @@ archive_write_gnutar_header(struct archi
 		archive_entry_set_gname(temp, "wheel");
 
 		archive_entry_set_pathname(temp, "././@LongLink");
-		archive_entry_set_size(temp, gnutar->pathname_length + 1);
+		archive_entry_set_size(temp, length);
 		ret = archive_format_gnutar_header(a, buff, temp, 'L');
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
@@ -513,11 +514,12 @@ archive_write_gnutar_header(struct archi
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
 		archive_entry_free(temp);
-		/* Write as many 512 bytes blocks as needed to write full name. */
-		ret = __archive_write_output(a, pathname, todo);
+		/* Write pathname + trailing null byte. */
+		ret = __archive_write_output(a, pathname, length);
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
-		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)todo));
+		/* Pad to multiple of 512 bytes. */
+		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length));
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
 	}

Modified: stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -6225,7 +6225,7 @@ isoent_gen_joliet_identifier(struct arch
 	unsigned char *p;
 	size_t l;
 	int r;
-	int ffmax, parent_len;
+	size_t ffmax, parent_len;
 	static const struct archive_rb_tree_ops rb_ops = {
 		isoent_cmp_node_joliet, isoent_cmp_key_joliet
 	};
@@ -6239,7 +6239,7 @@ isoent_gen_joliet_identifier(struct arch
 	else
 		ffmax = 128;
 
-	r = idr_start(a, idr, isoent->children.cnt, ffmax, 6, 2, &rb_ops);
+	r = idr_start(a, idr, isoent->children.cnt, (int)ffmax, 6, 2, &rb_ops);
 	if (r < 0)
 		return (r);
 
@@ -6252,7 +6252,7 @@ isoent_gen_joliet_identifier(struct arch
 		int ext_off, noff, weight;
 		size_t lt;
 
-		if ((int)(l = np->file->basename_utf16.length) > ffmax)
+		if ((l = np->file->basename_utf16.length) > ffmax)
 			l = ffmax;
 
 		p = malloc((l+1)*2);
@@ -6285,7 +6285,7 @@ isoent_gen_joliet_identifier(struct arch
 		/*
 		 * Get a length of MBS of a full-pathname.
 		 */
-		if ((int)np->file->basename_utf16.length > ffmax) {
+		if (np->file->basename_utf16.length > ffmax) {
 			if (archive_strncpy_l(&iso9660->mbs,
 			    (const char *)np->identifier, l,
 				iso9660->sconv_from_utf16be) != 0 &&
@@ -6302,7 +6302,9 @@ isoent_gen_joliet_identifier(struct arch
 
 		/* If a length of full-pathname is longer than 240 bytes,
 		 * it violates Joliet extensions regulation. */
-		if (parent_len + np->mb_len > 240) {
+		if (parent_len > 240
+		    || np->mb_len > 240
+		    || parent_len + np->mb_len > 240) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "The regulation of Joliet extensions;"
 			    " A length of a full-pathname of `%s' is "
@@ -6314,11 +6316,11 @@ isoent_gen_joliet_identifier(struct arch
 
 		/* Make an offset of the number which is used to be set
 		 * hexadecimal number to avoid duplicate identifier. */
-		if ((int)l == ffmax)
+		if (l == ffmax)
 			noff = ext_off - 6;
-		else if ((int)l == ffmax-2)
+		else if (l == ffmax-2)
 			noff = ext_off - 4;
-		else if ((int)l == ffmax-4)
+		else if (l == ffmax-4)
 			noff = ext_off - 2;
 		else
 			noff = ext_off;

Modified: stable/10/contrib/libarchive/libarchive/archive_write_set_options.3
==============================================================================
--- stable/10/contrib/libarchive/libarchive/archive_write_set_options.3	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/archive_write_set_options.3	Thu Jun 30 12:44:15 2016	(r302295)
@@ -32,7 +32,7 @@
 .Nm archive_write_set_format_option ,
 .Nm archive_write_set_option ,
 .Nm archive_write_set_options
-.Nd functions controlling options for reading archives
+.Nd functions controlling options for writing archives
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
 .Sh SYNOPSIS

Modified: stable/10/contrib/libarchive/libarchive/libarchive-formats.5
==============================================================================
--- stable/10/contrib/libarchive/libarchive/libarchive-formats.5	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/libarchive-formats.5	Thu Jun 30 12:44:15 2016	(r302295)
@@ -65,7 +65,6 @@ Later variants have extended this by eit
 areas of the header record, extending the header to multiple records,
 or by storing special entries that modify the interpretation of
 subsequent entries.
-.Pp
 .Bl -tag -width indent
 .It Cm gnutar
 The

Modified: stable/10/contrib/libarchive/libarchive/libarchive_changes.3
==============================================================================
--- stable/10/contrib/libarchive/libarchive/libarchive_changes.3	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/libarchive_changes.3	Thu Jun 30 12:44:15 2016	(r302295)
@@ -28,7 +28,7 @@
 .Dt LIBARCHIVE_CHANGES 3
 .Os
 .Sh NAME
-.Nm changes in libarchive interface
+.Nd changes in libarchive interface
 .\"
 .Sh CHANGES IN LIBARCHIVE 3
 This page describes user-visible changes in libarchive3, and lists

Modified: stable/10/contrib/libarchive/libarchive/test/main.c
==============================================================================
--- stable/10/contrib/libarchive/libarchive/test/main.c	Thu Jun 30 08:51:50 2016	(r302294)
+++ stable/10/contrib/libarchive/libarchive/test/main.c	Thu Jun 30 12:44:15 2016	(r302295)
@@ -2533,18 +2533,36 @@ usage(const char *program)
 static char *
 get_refdir(const char *d)
 {
-	char tried[512] = { '\0' };
-	char buff[128];
-	char *pwd, *p;
+	size_t tried_size, buff_size;
+	char *buff, *tried, *pwd = NULL, *p = NULL;
+
+#ifdef PATH_MAX
+	buff_size = PATH_MAX;
+#else
+	buff_size = 8192;
+#endif
+	buff = calloc(buff_size, 1);
+	if (buff == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
+
+	/* Allocate a buffer to hold the various directories we checked. */
+	tried_size = buff_size * 2;
+	tried = calloc(tried_size, 1);
+	if (tried == NULL) {
+		fprintf(stderr, "Unable to allocate memory\n");
+		exit(1);
+	}
 
 	/* If a dir was specified, try that */
 	if (d != NULL) {
 		pwd = NULL;
-		snprintf(buff, sizeof(buff), "%s", d);
+		snprintf(buff, buff_size, "%s", d);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 		goto failure;
 	}
 
@@ -2558,48 +2576,48 @@ get_refdir(const char *d)
 		pwd[strlen(pwd) - 1] = '\0';
 
 	/* Look for a known file. */
-	snprintf(buff, sizeof(buff), "%s", pwd);
+	snprintf(buff, buff_size, "%s", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-	snprintf(buff, sizeof(buff), "%s/test", pwd);
+	snprintf(buff, buff_size, "%s/test", pwd);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(LIBRARY)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, LIBRARY);
 #else
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM);
 #endif
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
 #if defined(PROGRAM_ALIAS)
-	snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+	snprintf(buff, buff_size, "%s/%s/test", pwd, PROGRAM_ALIAS);
 	p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 	if (p != NULL) goto success;
-	strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-	strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+	strncat(tried, buff, tried_size - strlen(tried) - 1);
+	strncat(tried, "\n", tried_size - strlen(tried) - 1);
 #endif
 
 	if (memcmp(pwd, "/usr/obj", 8) == 0) {
-		snprintf(buff, sizeof(buff), "%s", pwd + 8);
+		snprintf(buff, buff_size, "%s", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 
-		snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+		snprintf(buff, buff_size, "%s/test", pwd + 8);
 		p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
 		if (p != NULL) goto success;
-		strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
-		strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+		strncat(tried, buff, tried_size - strlen(tried) - 1);
+		strncat(tried, "\n", tried_size - strlen(tried) - 1);
 	}
 
 failure:
@@ -2614,7 +2632,12 @@ failure:
 success:
 	free(p);
 	free(pwd);
-	return strdup(buff);
+	free(tried);
+
+	/* Copy result into a fresh buffer to reduce memory usage. */
+	p = strdup(buff);
+	free(buff);
+	return p;
 }
 
 int

Copied: stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c (from r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c	Thu Jun 30 12:44:15 2016	(r302295, copy of r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.c)
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2003-2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_rar_invalid1)
+{
+	const char *refname = "test_read_format_rar_invalid1.rar";
+	struct archive *a;
+	struct archive_entry *ae;
+	char *buff[100];
+
+	extract_reference_file(refname);
+	assert((a = archive_read_new()) != NULL);
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+	assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, buff, 99));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}

Copied: stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu (from r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu	Thu Jun 30 12:44:15 2016	(r302295, copy of r302075, head/contrib/libarchive/libarchive/test/test_read_format_rar_invalid1.rar.uu)
@@ -0,0 +1,5 @@
+begin 644 test_read_format_rar_invalid1.rar
+M4F%R(1H'`,^0B$4=
+2,P0`I($``'1E
Delivered-To: svn-src-all@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 82A7CB873EB;
 Thu, 30 Jun 2016 14:53:47 +0000 (UTC) (envelope-from cy@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 5372B2004;
 Thu, 30 Jun 2016 14:53:47 +0000 (UTC) (envelope-from cy@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UErk2x090521;
 Thu, 30 Jun 2016 14:53:46 GMT (envelope-from cy@FreeBSD.org)
Received: (from cy@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UErkRj090520;
 Thu, 30 Jun 2016 14:53:46 GMT (envelope-from cy@FreeBSD.org)
Message-Id: <201606301453.u5UErkRj090520@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org
 using -f
From: Cy Schubert 
Date: Thu, 30 Jun 2016 14:53:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302296 - head/contrib/ipfilter/tools
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 14:53:47 -0000

Author: cy
Date: Thu Jun 30 14:53:46 2016
New Revision: 302296
URL: https://svnweb.freebsd.org/changeset/base/302296

Log:
  Remove dead code.
  
  Approved by:	re@ (hrs@)
  MFC after:	1 week

Modified:
  head/contrib/ipfilter/tools/ipf.c

Modified: head/contrib/ipfilter/tools/ipf.c
==============================================================================
--- head/contrib/ipfilter/tools/ipf.c	Thu Jun 30 12:44:15 2016	(r302295)
+++ head/contrib/ipfilter/tools/ipf.c	Thu Jun 30 14:53:46 2016	(r302296)
@@ -410,23 +410,6 @@ static void flushfilter(arg, filter)
 		return;
 	}
 
-#ifdef	SIOCIPFFA
-	if (!strcmp(arg, "u")) {
-		closedevice();
-		/*
-		 * Flush auth rules and packets
-		 */
-		if (opendevice(IPL_AUTH, 1) == -1)
-			perror("open(IPL_AUTH)");
-		else {
-			if (ioctl(fd, SIOCIPFFA, &fl) == -1)
-				ipferror(fd, "ioctl(SIOCIPFFA)");
-		}
-		closedevice();
-		return;
-	}
-#endif
-
 	if (strchr(arg, 'i') || strchr(arg, 'I'))
 		fl = FR_INQUE;
 	if (strchr(arg, 'o') || strchr(arg, 'O'))

From owner-svn-src-all@freebsd.org  Thu Jun 30 14:55:50 2016
Return-Path: 
Delivered-To: svn-src-all@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 B23D9B874C4;
 Thu, 30 Jun 2016 14:55:50 +0000 (UTC) (envelope-from mav@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 7AF2321A8;
 Thu, 30 Jun 2016 14:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UEtnqk090651;
 Thu, 30 Jun 2016 14:55:49 GMT (envelope-from mav@FreeBSD.org)
Received: (from mav@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UEtnLs090648;
 Thu, 30 Jun 2016 14:55:49 GMT (envelope-from mav@FreeBSD.org)
Message-Id: <201606301455.u5UEtnLs090648@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org
 using -f
From: Alexander Motin 
Date: Thu, 30 Jun 2016 14:55:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302297 - in head/sys/cddl/contrib/opensolaris:
 common/acl uts/common/fs/zfs uts/common/sys
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 14:55:50 -0000

Author: mav
Date: Thu Jun 30 14:55:49 2016
New Revision: 302297
URL: https://svnweb.freebsd.org/changeset/base/302297

Log:
  Revert r299454 and r299448.
  
  Those changes were found confusing FreeBSD libc ACL code, that doesn't
  differentiate ACL for directories and files, and report ACLs for all
  directories created after those patches as non-trivial.  On the other
  side these changes were considered wrong from POSIX and NFSv4 points of
  view.  Until further investigation done upstream, revert those changes
  locally in preparation for FreeBSD 11.0 release.
  
  Approved by:	re (hrs)

Modified:
  head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h

Modified: head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c	Thu Jun 30 14:53:46 2016	(r302296)
+++ head/sys/cddl/contrib/opensolaris/common/acl/acl_common.c	Thu Jun 30 14:55:49 2016	(r302297)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include 
@@ -1580,8 +1580,7 @@ acl_trivial_access_masks(mode_t mode, bo
 	uint32_t write_mask = ACE_WRITE_DATA|ACE_APPEND_DATA;
 	uint32_t execute_mask = ACE_EXECUTE;
 
-	if (isdir)
-		write_mask |= ACE_DELETE_CHILD;
+	(void) isdir;	/* will need this later */
 
 	masks->deny1 = 0;
 	if (!(mode & S_IRUSR) && (mode & (S_IRGRP|S_IROTH)))
@@ -1725,17 +1724,10 @@ ace_trivial_common(void *acep, int aclcn
 			return (1);
 
 		/*
-		 * Delete permission is never set by default
-		 */
-		if (mask & ACE_DELETE)
-			return (1);
-
-		/*
-		 * Child delete permission should be accompanied by write
+		 * Delete permissions are never set by default
 		 */
-		if ((mask & ACE_DELETE_CHILD) && !(mask & ACE_WRITE_DATA))
+		if (mask & (ACE_DELETE|ACE_DELETE_CHILD))
 			return (1);
-
 		/*
 		 * only allow owner@ to have
 		 * write_acl/write_owner/write_attributes/write_xattr/

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c	Thu Jun 30 14:53:46 2016	(r302296)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c	Thu Jun 30 14:55:49 2016	(r302297)
@@ -20,8 +20,8 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2013 by Delphix. All rights reserved.
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include 
@@ -2085,7 +2085,7 @@ zfs_zaccess_dataset_check(znode_t *zp, u
  * placed into the working_mode, giving the caller a mask of denied
  * accesses.  Returns:
  *	0		if all AoI granted
- *	EACCES		if the denied mask is non-zero
+ *	EACCESS 	if the denied mask is non-zero
  *	other error	if abnormal failure (e.g., IO error)
  *
  * A secondary usage of the function is to determine if any of the
@@ -2532,32 +2532,46 @@ zfs_zaccess_unix(znode_t *zp, mode_t mod
 	return (zfs_zaccess(zp, v4_mode, 0, B_FALSE, cr));
 }
 
-/* See zfs_zaccess_delete() */
-int zfs_write_implies_delete_child = 1;
+static int
+zfs_delete_final_check(znode_t *zp, znode_t *dzp,
+    mode_t available_perms, cred_t *cr)
+{
+	int error;
+	uid_t downer;
+
+	downer = zfs_fuid_map_id(dzp->z_zfsvfs, dzp->z_uid, cr, ZFS_OWNER);
+
+	error = secpolicy_vnode_access2(cr, ZTOV(dzp),
+	    downer, available_perms, VWRITE|VEXEC);
+
+	if (error == 0)
+		error = zfs_sticky_remove_access(dzp, zp, cr);
+
+	return (error);
+}
 
 /*
- * Determine whether delete access should be granted.
+ * Determine whether Access should be granted/deny, without
+ * consulting least priv subsystem.
  *
- * The following chart outlines how we handle delete permissions which is
- * how recent versions of windows (Windows 2008) handles it.  The efficiency
- * comes from not having to check the parent ACL where the object itself grants
- * delete:
+ * The following chart is the recommended NFSv4 enforcement for
+ * ability to delete an object.
  *
  *      -------------------------------------------------------
- *      |   Parent Dir  |      Target Object Permissions      |
+ *      |   Parent Dir  |           Target Object Permissions |
  *      |  permissions  |                                     |
  *      -------------------------------------------------------
  *      |               | ACL Allows | ACL Denies| Delete     |
  *      |               |  Delete    |  Delete   | unspecified|
  *      -------------------------------------------------------
- *      | ACL Allows    | Permit     | Deny *    | Permit     |
- *      | DELETE_CHILD  |            |           |            |
+ *      |  ACL Allows   | Permit     | Permit    | Permit     |
+ *      |  DELETE_CHILD |                                     |
  *      -------------------------------------------------------
- *      | ACL Denies    | Permit     | Deny      | Deny       |
- *      | DELETE_CHILD  |            |           |            |
+ *      |  ACL Denies   | Permit     | Deny      | Deny       |
+ *      |  DELETE_CHILD |            |           |            |
  *      -------------------------------------------------------
  *      | ACL specifies |            |           |            |
- *      | only allow    | Permit     | Deny *    | Permit     |
+ *      | only allow    | Permit     | Permit    | Permit     |
  *      | write and     |            |           |            |
  *      | execute       |            |           |            |
  *      -------------------------------------------------------
@@ -2567,171 +2581,91 @@ int zfs_write_implies_delete_child = 1;
  *      -------------------------------------------------------
  *         ^
  *         |
- *         Re. execute permission on the directory:  if that's missing,
- *	   the vnode lookup of the target will fail before we get here.
- *
- * Re [*] in the table above:  NFSv4 would normally Permit delete for
- * these two cells of the matrix.
- * See acl.h for notes on which ACE_... flags should be checked for which
- * operations.  Specifically, the NFSv4 committee recommendation is in
- * conflict with the Windows interpretation of DENY ACEs, where DENY ACEs
- * should take precedence ahead of ALLOW ACEs.
- *
- * This implementation always consults the target object's ACL first.
- * If a DENY ACE is present on the target object that specifies ACE_DELETE,
- * delete access is denied.  If an ALLOW ACE with ACE_DELETE is present on
- * the target object, access is allowed.  If and only if no entries with
- * ACE_DELETE are present in the object's ACL, check the container's ACL
- * for entries with ACE_DELETE_CHILD.
- *
- * A summary of the logic implemented from the table above is as follows:
+ *         No search privilege, can't even look up file?
  *
- * First check for DENY ACEs that apply.
- * If either target or container has a deny, EACCES.
- *
- * Delete access can then be summarized as follows:
- * 1: The object to be deleted grants ACE_DELETE, or
- * 2: The containing directory grants ACE_DELETE_CHILD.
- * In a Windows system, that would be the end of the story.
- * In this system, (2) has some complications...
- * 2a: "sticky" bit on a directory adds restrictions, and
- * 2b: existing ACEs from previous versions of ZFS may
- * not carry ACE_DELETE_CHILD where they should, so we
- * also allow delete when ACE_WRITE_DATA is granted.
- *
- * Note: 2b is technically a work-around for a prior bug,
- * which hopefully can go away some day.  For those who
- * no longer need the work around, and for testing, this
- * work-around is made conditional via the tunable:
- * zfs_write_implies_delete_child
  */
 int
 zfs_zaccess_delete(znode_t *dzp, znode_t *zp, cred_t *cr)
 {
-	uint32_t wanted_dirperms;
 	uint32_t dzp_working_mode = 0;
 	uint32_t zp_working_mode = 0;
 	int dzp_error, zp_error;
-	boolean_t dzpcheck_privs;
-	boolean_t zpcheck_privs;
+	mode_t available_perms;
+	boolean_t dzpcheck_privs = B_TRUE;
+	boolean_t zpcheck_privs = B_TRUE;
+
+	/*
+	 * We want specific DELETE permissions to
+	 * take precedence over WRITE/EXECUTE.  We don't
+	 * want an ACL such as this to mess us up.
+	 * user:joe:write_data:deny,user:joe:delete:allow
+	 *
+	 * However, deny permissions may ultimately be overridden
+	 * by secpolicy_vnode_access().
+	 *
+	 * We will ask for all of the necessary permissions and then
+	 * look at the working modes from the directory and target object
+	 * to determine what was found.
+	 */
 
 	if (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_NOUNLINK))
 		return (SET_ERROR(EPERM));
 
 	/*
-	 * Case 1:
-	 * If target object grants ACE_DELETE then we are done.  This is
-	 * indicated by a return value of 0.  For this case we don't worry
-	 * about the sticky bit because sticky only applies to the parent
-	 * directory and this is the child access result.
-	 *
-	 * If we encounter a DENY ACE here, we're also done (EACCES).
-	 * Note that if we hit a DENY ACE here (on the target) it should
-	 * take precedence over a DENY ACE on the container, so that when
-	 * we have more complete auditing support we will be able to
-	 * report an access failure against the specific target.
-	 * (This is part of why we're checking the target first.)
-	 */
-	zp_error = zfs_zaccess_common(zp, ACE_DELETE, &zp_working_mode,
-	    &zpcheck_privs, B_FALSE, cr);
-	if (zp_error == EACCES) {
-		/* We hit a DENY ACE. */
-		if (!zpcheck_privs)
-			return (SET_ERROR(zp_error));
-		return (secpolicy_vnode_remove(ZTOV(dzp), cr)); /* XXXPJD: s/dzp/zp/ ? */
-
-	}
-	if (zp_error == 0)
+	 * First row
+	 * If the directory permissions allow the delete, we are done.
+	 */
+	if ((dzp_error = zfs_zaccess_common(dzp, ACE_DELETE_CHILD,
+	    &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr)) == 0)
 		return (0);
 
 	/*
-	 * Case 2:
-	 * If the containing directory grants ACE_DELETE_CHILD,
-	 * or we're in backward compatibility mode and the
-	 * containing directory has ACE_WRITE_DATA, allow.
-	 * Case 2b is handled with wanted_dirperms.
-	 */
-	wanted_dirperms = ACE_DELETE_CHILD;
-	if (zfs_write_implies_delete_child)
-		wanted_dirperms |= ACE_WRITE_DATA;
-	dzp_error = zfs_zaccess_common(dzp, wanted_dirperms,
-	    &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr);
-	if (dzp_error == EACCES) {
-		/* We hit a DENY ACE. */
-		if (!dzpcheck_privs)
-			return (SET_ERROR(dzp_error));
-		return (secpolicy_vnode_remove(ZTOV(dzp), cr));  /* XXXPJD: s/dzp/zp/ ? */
-	}
+	 * If target object has delete permission then we are done
+	 */
+	if ((zp_error = zfs_zaccess_common(zp, ACE_DELETE, &zp_working_mode,
+	    &zpcheck_privs, B_FALSE, cr)) == 0)
+		return (0);
 
-	/*
-	 * Cases 2a, 2b (continued)
-	 *
-	 * Note: dzp_working_mode now contains any permissions
-	 * that were NOT granted.  Therefore, if any of the
-	 * wanted_dirperms WERE granted, we will have:
-	 *   dzp_working_mode != wanted_dirperms
-	 * We're really asking if ANY of those permissions
-	 * were granted, and if so, grant delete access.
-	 */
-	if (dzp_working_mode != wanted_dirperms)
-		dzp_error = 0;
+	ASSERT(dzp_error && zp_error);
+
+	if (!dzpcheck_privs)
+		return (dzp_error);
+	if (!zpcheck_privs)
+		return (zp_error);
 
 	/*
-	 * dzp_error is 0 if the container granted us permissions to "modify".
-	 * If we do not have permission via one or more ACEs, our current
-	 * privileges may still permit us to modify the container.
+	 * Second row
 	 *
-	 * dzpcheck_privs is false when i.e. the FS is read-only.
-	 * Otherwise, do privilege checks for the container.
+	 * If directory returns EACCES then delete_child was denied
+	 * due to deny delete_child.  In this case send the request through
+	 * secpolicy_vnode_remove().  We don't use zfs_delete_final_check()
+	 * since that *could* allow the delete based on write/execute permission
+	 * and we want delete permissions to override write/execute.
 	 */
-	if (dzp_error != 0 && dzpcheck_privs) {
-		uid_t owner;
 
-		/*
-		 * The secpolicy call needs the requested access and
-		 * the current access mode of the container, but it
-		 * only knows about Unix-style modes (VEXEC, VWRITE),
-		 * so this must condense the fine-grained ACE bits into
-		 * Unix modes.
-		 *
-		 * The VEXEC flag is easy, because we know that has
-		 * always been checked before we get here (during the
-		 * lookup of the target vnode).  The container has not
-		 * granted us permissions to "modify", so we do not set
-		 * the VWRITE flag in the current access mode.
-		 */
-		owner = zfs_fuid_map_id(dzp->z_zfsvfs, dzp->z_uid, cr,
-		    ZFS_OWNER);
-		dzp_error = secpolicy_vnode_access2(cr, ZTOV(dzp),
-		    owner, VEXEC, VWRITE|VEXEC);
-	}
-	if (dzp_error != 0) {
-		/*
-		 * Note: We may have dzp_error = -1 here (from
-		 * zfs_zacess_common).  Don't return that.
-		 */
-		return (SET_ERROR(EACCES));
-	}
+	if (dzp_error == EACCES)
+		return (secpolicy_vnode_remove(ZTOV(dzp), cr));	/* XXXPJD: s/dzp/zp/ ? */
 
 	/*
-	 * At this point, we know that the directory permissions allow
-	 * us to modify, but we still need to check for the additional
-	 * restrictions that apply when the "sticky bit" is set.
-	 *
-	 * Yes, zfs_sticky_remove_access() also checks this bit, but
-	 * checking it here and skipping the call below is nice when
-	 * you're watching all of this with dtrace.
+	 * Third Row
+	 * only need to see if we have write/execute on directory.
 	 */
-	if ((dzp->z_mode & S_ISVTX) == 0)
-		return (0);
+
+	dzp_error = zfs_zaccess_common(dzp, ACE_EXECUTE|ACE_WRITE_DATA,
+	    &dzp_working_mode, &dzpcheck_privs, B_FALSE, cr);
+
+	if (dzp_error != 0 && !dzpcheck_privs)
+		return (dzp_error);
 
 	/*
-	 * zfs_sticky_remove_access will succeed if:
-	 * 1. The sticky bit is absent.
-	 * 2. We pass the sticky bit restrictions.
-	 * 3. We have privileges that always allow file removal.
+	 * Fourth row
 	 */
-	return (zfs_sticky_remove_access(dzp, zp, cr));
+
+	available_perms = (dzp_working_mode & ACE_WRITE_DATA) ? 0 : VWRITE;
+	available_perms |= (dzp_working_mode & ACE_EXECUTE) ? 0 : VEXEC;
+
+	return (zfs_delete_final_check(zp, dzp, available_perms, cr));
+
 }
 
 int

Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h	Thu Jun 30 14:53:46 2016	(r302296)
+++ head/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h	Thu Jun 30 14:55:49 2016	(r302297)
@@ -23,8 +23,6 @@
  *
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- *
- * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _SYS_ACL_H
@@ -90,55 +88,37 @@ typedef struct acl_info acl_t;
 
 /*
  * The following are defined for ace_t.
- *
- * Note, these are intentionally the same as the Windows
- * "File Access Rights Constants" you can find on MSDN.
- * (See also: "Standard Access Rights" on MSDN).
- *
- * The equivalent Windows names for these are just like
- * those show below, with FILE_ in place of ACE_, except
- * as noted below.  Also note that Windows uses a special
- * privilege: BYPASS_TRAVERSE_CHECKING, normally granted
- * to everyone, that causes the absence of ACE_TRAVERSE
- * to be ignored.
- */
-#define	ACE_READ_DATA		0x00000001	/* file: read data */
-#define	ACE_LIST_DIRECTORY	0x00000001	/* dir: list files */
-#define	ACE_WRITE_DATA		0x00000002	/* file: write data */
-#define	ACE_ADD_FILE		0x00000002	/* dir: create file */
-#define	ACE_APPEND_DATA		0x00000004	/* file: append data */
-#define	ACE_ADD_SUBDIRECTORY	0x00000004	/* dir: create subdir */
-#define	ACE_READ_NAMED_ATTRS	0x00000008	/* FILE_READ_EA */
-#define	ACE_WRITE_NAMED_ATTRS	0x00000010	/* FILE_WRITE_EA */
-#define	ACE_EXECUTE		0x00000020	/* file: execute */
-#define	ACE_TRAVERSE		0x00000020	/* dir: lookup name */
-#define	ACE_DELETE_CHILD	0x00000040	/* dir: unlink child */
-#define	ACE_READ_ATTRIBUTES	0x00000080	/* (all) stat, etc. */
-#define	ACE_WRITE_ATTRIBUTES	0x00000100	/* (all) utimes, etc. */
-#define	ACE_DELETE		0x00010000	/* (all) unlink self */
-#define	ACE_READ_ACL		0x00020000	/* (all) getsecattr */
-#define	ACE_WRITE_ACL		0x00040000	/* (all) setsecattr */
-#define	ACE_WRITE_OWNER		0x00080000	/* (all) chown */
-#define	ACE_SYNCHRONIZE		0x00100000	/* (all) see MSDN */
-
-/*
- * Some of the following are the same as Windows uses. (but NOT ALL!)
- * See the "ACE_HEADER" structure description on MSDN for details.
- * Comments show relations to the MSDN names.
  */
-#define	ACE_FILE_INHERIT_ACE		0x0001	/* = OBJECT_INHERIT_ACE */
-#define	ACE_DIRECTORY_INHERIT_ACE	0x0002	/* = CONTAINER_INHERIT_ACE */
-#define	ACE_NO_PROPAGATE_INHERIT_ACE	0x0004	/* = NO_PROPAGATE_INHERIT_ACE */
-#define	ACE_INHERIT_ONLY_ACE		0x0008	/* = INHERIT_ONLY_ACE */
+#define	ACE_READ_DATA		0x00000001
+#define	ACE_LIST_DIRECTORY	0x00000001
+#define	ACE_WRITE_DATA		0x00000002
+#define	ACE_ADD_FILE		0x00000002
+#define	ACE_APPEND_DATA		0x00000004
+#define	ACE_ADD_SUBDIRECTORY	0x00000004
+#define	ACE_READ_NAMED_ATTRS	0x00000008
+#define	ACE_WRITE_NAMED_ATTRS	0x00000010
+#define	ACE_EXECUTE		0x00000020
+#define	ACE_DELETE_CHILD	0x00000040
+#define	ACE_READ_ATTRIBUTES	0x00000080
+#define	ACE_WRITE_ATTRIBUTES	0x00000100
+#define	ACE_DELETE		0x00010000
+#define	ACE_READ_ACL		0x00020000
+#define	ACE_WRITE_ACL		0x00040000
+#define	ACE_WRITE_OWNER		0x00080000
+#define	ACE_SYNCHRONIZE		0x00100000
+
+#define	ACE_FILE_INHERIT_ACE		0x0001
+#define	ACE_DIRECTORY_INHERIT_ACE	0x0002
+#define	ACE_NO_PROPAGATE_INHERIT_ACE	0x0004
+#define	ACE_INHERIT_ONLY_ACE		0x0008
 #define	ACE_SUCCESSFUL_ACCESS_ACE_FLAG	0x0010
 #define	ACE_FAILED_ACCESS_ACE_FLAG	0x0020
 #define	ACE_IDENTIFIER_GROUP		0x0040
-#define	ACE_INHERITED_ACE		0x0080	/* INHERITED_ACE, 0x10 on NT */
+#define	ACE_INHERITED_ACE		0x0080
 #define	ACE_OWNER			0x1000
 #define	ACE_GROUP			0x2000
 #define	ACE_EVERYONE			0x4000
 
-/* These four are the same as Windows, but with an ACE_ prefix added. */
 #define	ACE_ACCESS_ALLOWED_ACE_TYPE	0x0000
 #define	ACE_ACCESS_DENIED_ACE_TYPE	0x0001
 #define	ACE_SYSTEM_AUDIT_ACE_TYPE	0x0002
@@ -154,7 +134,6 @@ typedef struct acl_info acl_t;
 
 /*
  * These are only applicable in a CIFS context.
- * Here again, same as Windows, but with an ACE_ prefix added.
  */
 #define	ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE		0x04
 #define	ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE		0x05

From owner-svn-src-all@freebsd.org  Thu Jun 30 15:01:09 2016
Return-Path: 
Delivered-To: svn-src-all@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 3D64CB87789;
 Thu, 30 Jun 2016 15:01:09 +0000 (UTC) (envelope-from bz@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 069A82674;
 Thu, 30 Jun 2016 15:01:08 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UF1819091560;
 Thu, 30 Jun 2016 15:01:08 GMT (envelope-from bz@FreeBSD.org)
Received: (from bz@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UF17WV091555;
 Thu, 30 Jun 2016 15:01:07 GMT (envelope-from bz@FreeBSD.org)
Message-Id: <201606301501.u5UF17WV091555@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org
 using -f
From: "Bjoern A. Zeeb" 
Date: Thu, 30 Jun 2016 15:01:07 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302298 - head/sys/contrib/ipfilter/netinet
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 15:01:09 -0000

Author: bz
Date: Thu Jun 30 15:01:07 2016
New Revision: 302298
URL: https://svnweb.freebsd.org/changeset/base/302298

Log:
  Virtualise ipfilter.
  Split initializzation an teardown into module (global state) and VNET
  (per virtual network stack) parts.  Virtualise global state, which is
  not "const".
  
  Cleanup eventhandlers, so that we can make use of the passed in argument
  to get the vnet state from the ifp;  disable the "cloner" event as it is
  too early, has no state, and can fire before initialisation (see comment
  in the source).
  
  Handle the dynamic sysctls specially.  The problem is that "ipmain"
  is the virtualized struct, but the fields used for the sysctls are
  hanging off memory allocated and attached to the virtualized "ipmain"
  thus standard VNET macros and sysctl handling do not work.
  We still say it is VNET sysctls to get the proper protection checks
  in the VIMAGE case;  to solve the problem of accessing the right bit
  of memory hanging of each per-VNET ipmain, we use a dedicated handler
  function wrapping around sysctl_ipf_int() undoing the base calculation
  from kern_sysctl.c and then adding the passed-in offset into the right
  struct depending on handler.  A bit of a mess exposing VNET-internals
  this way but the only way to keep the code without having to massively
  restructure ipf internals.
  
  Approved by:		re (hrs)
  Sponsored by:		The FreeBSD Foundation
  Obtained from:		projects/vnet
  MFC after:		2 weeks
  Reviewed by:		cy
  Differential Revision:	https://reviews.freebsd.org/D7000

Modified:
  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
  head/sys/contrib/ipfilter/netinet/ip_proxy.c
  head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
  head/sys/contrib/ipfilter/netinet/ip_rules.c
  head/sys/contrib/ipfilter/netinet/mlfk_ipl.c

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Thu Jun 30 14:55:49 2016	(r302297)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Thu Jun 30 15:01:07 2016	(r302298)
@@ -62,6 +62,9 @@ static const char rcsid[] = "@(#)$Id$";
 #else
 #define CURVNET_SET(arg)
 #define CURVNET_RESTORE()
+#define	VNET_DEFINE(_t, _v)	_t _v
+#define	VNET_DECLARE(_t, _v)	extern _t _v
+#define	VNET(arg)	arg
 #endif
 #if defined(__osf__)
 # include 
@@ -102,22 +105,40 @@ MALLOC_DEFINE(M_IPFILTER, "ipfilter", "I
 static	int	ipf_send_ip __P((fr_info_t *, mb_t *));
 static void	ipf_timer_func __P((void *arg));
 
-ipf_main_softc_t ipfmain;
+VNET_DEFINE(ipf_main_softc_t, ipfmain) = {
+	.ipf_running		= -2,
+};
+#define	V_ipfmain		VNET(ipfmain)
 
 # include 
 # if defined(NETBSD_PF)
 #  include 
 # endif /* NETBSD_PF */
 
+static eventhandler_tag ipf_arrivetag, ipf_departtag;
+#if 0
+/*
+ * Disable the "cloner" event handler;  we are getting interface
+ * events before the firewall is fully initiallized and also no vnet
+ * information thus leading to uninitialised memory accesses.
+ * In addition it is unclear why we need it in first place.
+ * If it turns out to be needed, well need a dedicated event handler
+ * for it to deal with the ifc and the correct vnet.
+ */
+static eventhandler_tag ipf_clonetag;
+#endif
 
-static eventhandler_tag ipf_arrivetag, ipf_departtag, ipf_clonetag;
-
-static void ipf_ifevent(void *arg);
+static void ipf_ifevent(void *arg, struct ifnet *ifp);
 
-static void ipf_ifevent(arg)
+static void ipf_ifevent(arg, ifp)
 	void *arg;
+	struct ifnet *ifp;
 {
-        ipf_sync(arg, NULL);
+
+	CURVNET_SET(ifp->if_vnet);
+	if (V_ipfmain.ipf_running > 0)
+		ipf_sync(&V_ipfmain, NULL);
+	CURVNET_RESTORE();
 }
 
 
@@ -135,8 +156,10 @@ ipf_check_wrapper(void *arg, struct mbuf
 	ip->ip_len = htons(ip->ip_len);
 	ip->ip_off = htons(ip->ip_off);
 #endif
-	rv = ipf_check(&ipfmain, ip, ip->ip_hl << 2, ifp, (dir == PFIL_OUT),
+	CURVNET_SET(ifp->if_vnet);
+	rv = ipf_check(&V_ipfmain, ip, ip->ip_hl << 2, ifp, (dir == PFIL_OUT),
 		       mp);
+	CURVNET_RESTORE();
 #if (__FreeBSD_version < 1000019)
 	if ((rv == 0) && (*mp != NULL)) {
 		ip = mtod(*mp, struct ip *);
@@ -153,8 +176,13 @@ ipf_check_wrapper(void *arg, struct mbuf
 static int
 ipf_check_wrapper6(void *arg, struct mbuf **mp, struct ifnet *ifp, int dir)
 {
-	return (ipf_check(&ipfmain, mtod(*mp, struct ip *),
-			  sizeof(struct ip6_hdr), ifp, (dir == PFIL_OUT), mp));
+	int error;
+
+	CURVNET_SET(ifp->if_vnet);
+	error = ipf_check(&V_ipfmain, mtod(*mp, struct ip *),
+			  sizeof(struct ip6_hdr), ifp, (dir == PFIL_OUT), mp);
+	CURVNET_RESTORE();
+	return (error);
 }
 # endif
 #if	defined(IPFILTER_LKM)
@@ -215,7 +243,7 @@ ipfattach(softc)
 	}
 
 
-	bzero((char *)ipfmain.ipf_selwait, sizeof(ipfmain.ipf_selwait));
+	bzero((char *)V_ipfmain.ipf_selwait, sizeof(V_ipfmain.ipf_selwait));
 	softc->ipf_running = 1;
 
 	if (softc->ipf_control_forwarding & 1)
@@ -284,38 +312,42 @@ ipfioctl(dev, cmd, data, mode
 	int error = 0, unit = 0;
 	SPL_INT(s);
 
+	CURVNET_SET(TD_TO_VNET(p));
 #if (BSD >= 199306)
         if (securelevel_ge(p->p_cred, 3) && (mode & FWRITE))
 	{
-		ipfmain.ipf_interror = 130001;
+		V_ipfmain.ipf_interror = 130001;
+		CURVNET_RESTORE();
 		return EPERM;
 	}
 #endif
 
 	unit = GET_MINOR(dev);
 	if ((IPL_LOGMAX < unit) || (unit < 0)) {
-		ipfmain.ipf_interror = 130002;
+		V_ipfmain.ipf_interror = 130002;
+		CURVNET_RESTORE();
 		return ENXIO;
 	}
 
-	if (ipfmain.ipf_running <= 0) {
+	if (V_ipfmain.ipf_running <= 0) {
 		if (unit != IPL_LOGIPF && cmd != SIOCIPFINTERROR) {
-			ipfmain.ipf_interror = 130003;
+			V_ipfmain.ipf_interror = 130003;
+			CURVNET_RESTORE();
 			return EIO;
 		}
 		if (cmd != SIOCIPFGETNEXT && cmd != SIOCIPFGET &&
 		    cmd != SIOCIPFSET && cmd != SIOCFRENB &&
 		    cmd != SIOCGETFS && cmd != SIOCGETFF &&
 		    cmd != SIOCIPFINTERROR) {
-			ipfmain.ipf_interror = 130004;
+			V_ipfmain.ipf_interror = 130004;
+			CURVNET_RESTORE();
 			return EIO;
 		}
 	}
 
 	SPL_NET(s);
 
-	CURVNET_SET(TD_TO_VNET(p));
-	error = ipf_ioctlswitch(&ipfmain, unit, data, cmd, mode, p->p_uid, p);
+	error = ipf_ioctlswitch(&V_ipfmain, unit, data, cmd, mode, p->p_uid, p);
 	CURVNET_RESTORE();
 	if (error != -1) {
 		SPL_X(s);
@@ -563,7 +595,7 @@ ipf_send_icmp_err(type, fin, dst)
 			}
 
 		if (dst == 0) {
-			if (ipf_ifpaddr(&ipfmain, 4, FRI_NORMAL, ifp,
+			if (ipf_ifpaddr(&V_ipfmain, 4, FRI_NORMAL, ifp,
 					&dst6, NULL) == -1) {
 				FREE_MB_T(m);
 				return -1;
@@ -600,7 +632,7 @@ ipf_send_icmp_err(type, fin, dst)
 		xtra = MIN(fin->fin_plen, avail - iclen - max_linkhdr);
 		xtra = MIN(xtra, IPV6_MMTU - iclen);
 		if (dst == 0) {
-			if (ipf_ifpaddr(&ipfmain, 6, FRI_NORMAL, ifp,
+			if (ipf_ifpaddr(&V_ipfmain, 6, FRI_NORMAL, ifp,
 					&dst6, NULL) == -1) {
 				FREE_MB_T(m);
 				return -1;
@@ -924,9 +956,9 @@ sendorfree:
     }
 done:
 	if (!error)
-		ipfmain.ipf_frouteok[0]++;
+		V_ipfmain.ipf_frouteok[0]++;
 	else
-		ipfmain.ipf_frouteok[1]++;
+		V_ipfmain.ipf_frouteok[1]++;
 
 	if (has_nhop)
 		fib4_free_nh_ext(fibnum, &nh4);
@@ -1388,13 +1420,15 @@ void
 ipf_event_reg(void)
 {
 	ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \
-					       ipf_ifevent, &ipfmain, \
+					       ipf_ifevent, NULL, \
 					       EVENTHANDLER_PRI_ANY);
 	ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \
-					       ipf_ifevent, &ipfmain, \
+					       ipf_ifevent, NULL, \
 					       EVENTHANDLER_PRI_ANY);
+#if 0
 	ipf_clonetag  = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \
-					       &ipfmain, EVENTHANDLER_PRI_ANY);
+					       NULL, EVENTHANDLER_PRI_ANY);
+#endif
 }
 
 void
@@ -1406,9 +1440,11 @@ ipf_event_dereg(void)
 	if (ipf_departtag != NULL) {
 		EVENTHANDLER_DEREGISTER(ifnet_departure_event, ipf_departtag);
 	}
+#if 0
 	if (ipf_clonetag != NULL) {
 		EVENTHANDLER_DEREGISTER(if_clone_event, ipf_clonetag);
 	}
+#endif
 }
 
 

Modified: head/sys/contrib/ipfilter/netinet/ip_proxy.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_proxy.c	Thu Jun 30 14:55:49 2016	(r302297)
+++ head/sys/contrib/ipfilter/netinet/ip_proxy.c	Thu Jun 30 15:01:07 2016	(r302298)
@@ -64,6 +64,15 @@ struct file;
 # include 
 #endif
 #include 
+#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL)
+#include 
+#else
+#define CURVNET_SET(arg)
+#define CURVNET_RESTORE()
+#define	VNET_DEFINE(_t, _v)	_t _v
+#define	VNET_DECLARE(_t, _v)	extern _t _v
+#define	VNET(arg)	arg
+#endif
 #ifdef sun
 # include 
 #endif

Modified: head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c	Thu Jun 30 14:55:49 2016	(r302297)
+++ head/sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c	Thu Jun 30 15:01:07 2016	(r302298)
@@ -80,7 +80,9 @@ static void     ipf_p_rpcb_fixlen __P((f
  */
 static	frentry_t	rpcbfr;	/* Skeleton rule for reference by entities
 				   this proxy creates. */
-static	int	rpcbcnt;	/* Upper bound of allocated RPCB sessions. */
+static	VNET_DEFINE(int,	rpcbcnt);
+#define	V_rpcbcnt		VNET(rpcbcnt)
+				/* Upper bound of allocated RPCB sessions. */
 				/* XXX rpcbcnt still requires locking. */
 
 static	int	rpcb_proxy_init = 0;
@@ -107,7 +109,7 @@ static	int	rpcb_proxy_init = 0;
 void
 ipf_p_rpcb_main_load()
 {
-	rpcbcnt = 0;
+	V_rpcbcnt = 0;
 
 	bzero((char *)&rpcbfr, sizeof(rpcbfr));
 	rpcbfr.fr_ref = 1;
@@ -581,7 +583,7 @@ ipf_p_rpcb_insert(rs, rx)
 		return(0);
         }
 
-	if (rpcbcnt == RPCB_MAXREQS)
+	if (V_rpcbcnt == RPCB_MAXREQS)
 		return(-1);
 
 	KMALLOC(rxp, rpcb_xact_t *);
@@ -599,7 +601,7 @@ ipf_p_rpcb_insert(rs, rx)
 
 	rxp->rx_ref = 1;
 
-	++rpcbcnt;
+	++V_rpcbcnt;
 
 	return(0);
 }
@@ -1084,7 +1086,7 @@ ipf_p_rpcb_deref(rs, rx)
 
 	KFREE(rx);
 
-	--rpcbcnt;
+	--V_rpcbcnt;
 }
 
 /* --------------------------------------------------------------------	*/

Modified: head/sys/contrib/ipfilter/netinet/ip_rules.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_rules.c	Thu Jun 30 14:55:49 2016	(r302297)
+++ head/sys/contrib/ipfilter/netinet/ip_rules.c	Thu Jun 30 15:01:07 2016	(r302298)
@@ -32,6 +32,15 @@
 #endif
 #if defined(__FreeBSD__) && (__FreeBSD_version > 220000)
 # include 
+#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL)
+#include 
+#else
+#define CURVNET_SET(arg)
+#define CURVNET_RESTORE()
+#define	VNET_DEFINE(_t, _v)	_t _v
+#define	VNET_DECLARE(_t, _v)	extern _t _v
+#define	VNET(arg)	arg
+#endif
 #else
 # include 
 #endif /* FreeBSD */
@@ -51,7 +60,8 @@
 
 #ifdef IPFILTER_COMPILED
 
-extern ipf_main_softc_t ipfmain;
+VNET_DECLARE(ipf_main_softc_t, ipfmain);
+#define	V_ipfmain		VNET(ipfmain)
 
 
 static u_long in_rule__0[] = {
@@ -129,8 +139,8 @@ int ipfrule_add_out_()
 	fp->fr_dsize = sizeof(ipf_rules_out_[0]);
 	fp->fr_family = AF_INET;
 	fp->fr_func = (ipfunc_t)ipfrule_match_out_;
-	err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
-			ipfmain.ipf_active, 0);
+	err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
+			V_ipfmain.ipf_active, 0);
 	return err;
 }
 
@@ -156,9 +166,9 @@ int ipfrule_remove_out_()
 		}
 	}
 	if (err == 0)
-		err = frrequest(&ipfmain, IPL_LOGIPF, SIOCDELFR,
+		err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCDELFR,
 				(caddr_t)&ipfrule_out_,
-				ipfmain.ipf_active, 0);
+				V_ipfmain.ipf_active, 0);
 	if (err)
 		return err;
 
@@ -198,8 +208,8 @@ int ipfrule_add_in_()
 	fp->fr_dsize = sizeof(ipf_rules_in_[0]);
 	fp->fr_family = AF_INET;
 	fp->fr_func = (ipfunc_t)ipfrule_match_in_;
-	err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
-			ipfmain.ipf_active, 0);
+	err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
+			V_ipfmain.ipf_active, 0);
 	return err;
 }
 
@@ -225,9 +235,9 @@ int ipfrule_remove_in_()
 		}
 	}
 	if (err == 0)
-		err = frrequest(&ipfmain, IPL_LOGIPF, SIOCDELFR,
+		err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCDELFR,
 				(caddr_t)&ipfrule_in_,
-				ipfmain.ipf_active, 0);
+				V_ipfmain.ipf_active, 0);
 	if (err)
 		return err;
 

Modified: head/sys/contrib/ipfilter/netinet/mlfk_ipl.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/mlfk_ipl.c	Thu Jun 30 14:55:49 2016	(r302297)
+++ head/sys/contrib/ipfilter/netinet/mlfk_ipl.c	Thu Jun 30 15:01:07 2016	(r302298)
@@ -7,6 +7,12 @@
  * See the IPFILTER.LICENCE file for details on licencing.
  */
 
+#if defined(KERNEL) || defined(_KERNEL)
+# undef KERNEL
+# undef _KERNEL
+# define	KERNEL  1
+# define	_KERNEL 1
+#endif
 
 #include 
 #include 
@@ -18,6 +24,16 @@
 #include 
 #if __FreeBSD_version >= 500000
 # include 
+# include 
+#endif
+#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL)
+#include 
+#else
+#define CURVNET_SET(arg)
+#define CURVNET_RESTORE()
+#define	VNET_DEFINE(_t, _v)	_t _v
+#define	VNET_DECLARE(_t, _v)	extern _t _v
+#define	VNET(arg)	arg
 #endif
 #include 
 #include 
@@ -33,7 +49,8 @@
 #include "netinet/ip_frag.h"
 #include "netinet/ip_sync.h"
 
-extern ipf_main_softc_t ipfmain;
+VNET_DECLARE(ipf_main_softc_t, ipfmain);
+#define	V_ipfmain		VNET(ipfmain)
 
 #if __FreeBSD_version >= 502116
 static struct cdev *ipf_devs[IPL_LOGSIZE];
@@ -42,10 +59,14 @@ static dev_t ipf_devs[IPL_LOGSIZE];
 #endif
 
 static int sysctl_ipf_int ( SYSCTL_HANDLER_ARGS );
+static int sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS );
+static int sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS );
+static int sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS );
+static int sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS );
 static int ipf_modload(void);
 static int ipf_modunload(void);
-static int ipf_fbsd_sysctl_create(ipf_main_softc_t*);
-static int ipf_fbsd_sysctl_destroy(ipf_main_softc_t*);
+static int ipf_fbsd_sysctl_create(void);
+static int ipf_fbsd_sysctl_destroy(void);
 
 #if (__FreeBSD_version >= 500024)
 # if (__FreeBSD_version >= 502116)
@@ -70,40 +91,49 @@ static	int	ipfwrite __P((dev_t, struct u
 
 SYSCTL_DECL(_net_inet);
 #define SYSCTL_IPF(parent, nbr, name, access, ptr, val, descr) \
-	SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
-		   ptr, val, sysctl_ipf_int, "I", descr);
-#define SYSCTL_DYN_IPF(parent, nbr, name, access,ptr, val, descr) \
+	SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_VNET|access, \
+		   ptr, val, sysctl_ipf_int, "I", descr)
+#define SYSCTL_DYN_IPF_NAT(parent, nbr, name, access,ptr, val, descr) \
+	SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
+	CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_nat, "I", descr)
+#define SYSCTL_DYN_IPF_STATE(parent, nbr, name, access,ptr, val, descr) \
 	SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
-	CTLFLAG_DYN|CTLTYPE_INT|access, ptr, val, sysctl_ipf_int, "I", descr)
+	CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_state, "I", descr)
+#define SYSCTL_DYN_IPF_FRAG(parent, nbr, name, access,ptr, val, descr) \
+	SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
+	CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_frag, "I", descr)
+#define SYSCTL_DYN_IPF_AUTH(parent, nbr, name, access,ptr, val, descr) \
+	SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
+	CTLFLAG_DYN|CTLTYPE_INT|CTLFLAG_VNET|access, ptr, val, sysctl_ipf_int_auth, "I", descr)
 static struct sysctl_ctx_list ipf_clist;
 #define	CTLFLAG_OFF	0x00800000	/* IPFilter must be disabled */
 #define	CTLFLAG_RWO	(CTLFLAG_RW|CTLFLAG_OFF)
 SYSCTL_NODE(_net_inet, OID_AUTO, ipf, CTLFLAG_RW, 0, "IPF");
-SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_flags, CTLFLAG_RW, &ipfmain.ipf_flags, 0, "IPF flags");
-SYSCTL_IPF(_net_inet_ipf, OID_AUTO, ipf_pass, CTLFLAG_RW, &ipfmain.ipf_pass, 0, "default pass/block");
-SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_active, CTLFLAG_RD, &ipfmain.ipf_active, 0, "IPF is active");
+SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_flags, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_flags), 0, "IPF flags");
+SYSCTL_IPF(_net_inet_ipf, OID_AUTO, ipf_pass, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_pass), 0, "default pass/block");
+SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_active, CTLFLAG_RD, &VNET_NAME(ipfmain.ipf_active), 0, "IPF is active");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpidletimeout, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcpidletimeout, 0, "TCP idle timeout in seconds");
+	   &VNET_NAME(ipfmain.ipf_tcpidletimeout), 0, "TCP idle timeout in seconds");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcphalfclosed, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcphalfclosed, 0, "timeout for half closed TCP sessions");
+	   &VNET_NAME(ipfmain.ipf_tcphalfclosed), 0, "timeout for half closed TCP sessions");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpclosewait, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcpclosewait, 0, "timeout for TCP sessions in closewait status");
+	   &VNET_NAME(ipfmain.ipf_tcpclosewait), 0, "timeout for TCP sessions in closewait status");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcplastack, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcplastack, 0, "timeout for TCP sessions in last ack status");
+	   &VNET_NAME(ipfmain.ipf_tcplastack), 0, "timeout for TCP sessions in last ack status");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcptimeout, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcptimeout, 0, "");
+	   &VNET_NAME(ipfmain.ipf_tcptimeout), 0, "");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_tcpclosed, CTLFLAG_RWO,
-	   &ipfmain.ipf_tcpclosed, 0, "");
+	   &VNET_NAME(ipfmain.ipf_tcpclosed), 0, "");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_udptimeout, CTLFLAG_RWO,
-	   &ipfmain.ipf_udptimeout, 0, "UDP timeout");
+	   &VNET_NAME(ipfmain.ipf_udptimeout), 0, "UDP timeout");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_udpacktimeout, CTLFLAG_RWO,
-	   &ipfmain.ipf_udpacktimeout, 0, "");
+	   &VNET_NAME(ipfmain.ipf_udpacktimeout), 0, "");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_icmptimeout, CTLFLAG_RWO,
-	   &ipfmain.ipf_icmptimeout, 0, "ICMP timeout");
+	   &VNET_NAME(ipfmain.ipf_icmptimeout), 0, "ICMP timeout");
 SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_running, CTLFLAG_RD,
-	   &ipfmain.ipf_running, 0, "IPF is running");
-SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_chksrc, CTLFLAG_RW, &ipfmain.ipf_chksrc, 0, "");
-SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG_RW, &ipfmain.ipf_minttl, 0, "");
+	   &VNET_NAME(ipfmain.ipf_running), 0, "IPF is running");
+SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_chksrc, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_chksrc), 0, "");
+SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG_RW, &VNET_NAME(ipfmain.ipf_minttl), 0, "");
 
 #define CDEV_MAJOR 79
 #include 
@@ -178,28 +208,61 @@ ipfilter_modevent(module_t mod, int type
 }
 
 
+static void
+vnet_ipf_init(void)
+{
+	char *defpass;
+	int error;
+
+	if (ipf_create_all(&V_ipfmain) == NULL)
+		return;
+
+	error = ipfattach(&V_ipfmain);
+	if (error) {
+		ipf_destroy_all(&V_ipfmain);
+		return;
+	}
+
+	if (FR_ISPASS(V_ipfmain.ipf_pass))
+		defpass = "pass";
+	else if (FR_ISBLOCK(V_ipfmain.ipf_pass))
+		defpass = "block";
+	else
+		defpass = "no-match -> block";
+
+	if (IS_DEFAULT_VNET(curvnet))
+	    printf("%s initialized.  Default = %s all, Logging = %s%s\n",
+		ipfilter_version, defpass,
+#ifdef IPFILTER_LOG
+		"enabled",
+#else
+		"disabled",
+#endif
+#ifdef IPFILTER_COMPILED
+		" (COMPILED)"
+#else
+		""
+#endif
+		);
+}
+VNET_SYSINIT(vnet_ipf_init, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD,
+    vnet_ipf_init, NULL);
+
 static int
 ipf_modload()
 {
-	char *defpass, *c, *str;
+	char *c, *str;
 	int i, j, error;
 
 	if (ipf_load_all() != 0)
 		return EIO;
 
-	if (ipf_create_all(&ipfmain) == NULL)
-		return EIO;
-
-	if (ipf_fbsd_sysctl_create(&ipfmain) != 0)
+	if (ipf_fbsd_sysctl_create() != 0) {
 		return EIO;
-
-	error = ipfattach(&ipfmain);
-	if (error)
-		return error;
+	}
 
 	for (i = 0; i < IPL_LOGSIZE; i++)
 		ipf_devs[i] = NULL;
-
 	for (i = 0; (str = ipf_devfiles[i]); i++) {
 		c = NULL;
 		for(j = strlen(str); j > 0; j--)
@@ -217,63 +280,48 @@ ipf_modload()
 		return error;
 	ipf_event_reg();
 
-	if (FR_ISPASS(ipfmain.ipf_pass))
-		defpass = "pass";
-	else if (FR_ISBLOCK(ipfmain.ipf_pass))
-		defpass = "block";
-	else
-		defpass = "no-match -> block";
-
-	printf("%s initialized.  Default = %s all, Logging = %s%s\n",
-		ipfilter_version, defpass,
-#ifdef IPFILTER_LOG
-		"enabled",
-#else
-		"disabled",
-#endif
-#ifdef IPFILTER_COMPILED
-		" (COMPILED)"
-#else
-		""
-#endif
-		);
 	return 0;
 }
 
+static void
+vnet_ipf_uninit(void)
+{
+
+	if (V_ipfmain.ipf_refcnt)
+		return;
+
+	if (V_ipfmain.ipf_running >= 0) {
+		if (ipfdetach(&V_ipfmain) != 0)
+			return;
+
+		ipf_destroy_all(&V_ipfmain);
+	}
+
+	V_ipfmain.ipf_running = -2;
+}
+VNET_SYSUNINIT(vnet_ipf_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD,
+    vnet_ipf_uninit, NULL);
 
 static int
 ipf_modunload()
 {
 	int error, i;
 
-	if (ipfmain.ipf_refcnt)
-		return EBUSY;
+	ipf_event_dereg();
 
-	if (ipf_fbsd_sysctl_destroy(&ipfmain) != 0)
-		return EIO;
+	ipf_fbsd_sysctl_destroy();
 
 	error = ipf_pfil_unhook();
 	if (error != 0)
 		return error;
 
-	if (ipfmain.ipf_running >= 0) {
-		error = ipfdetach(&ipfmain);
-		if (error != 0)
-			return error;
-
-		ipf_fbsd_sysctl_destroy(&ipfmain);
-		ipf_destroy_all(&ipfmain);
-		ipf_unload_all();
-	} else
-		error = 0;
-
-	ipfmain.ipf_running = -2;
-
 	for (i = 0; ipf_devfiles[i]; i++) {
 		if (ipf_devs[i] != NULL)
 			destroy_dev(ipf_devs[i]);
 	}
 
+	ipf_unload_all();
+
 	printf("%s unloaded\n", ipfilter_version);
 
 	return error;
@@ -287,7 +335,7 @@ static moduledata_t ipfiltermod = {
 };
 
 
-DECLARE_MODULE(ipfilter, ipfiltermod, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY);
+DECLARE_MODULE(ipfilter, ipfiltermod, SI_SUB_PROTO_FIREWALL, SI_ORDER_SECOND);
 #ifdef	MODULE_VERSION
 MODULE_VERSION(ipfilter, 1);
 #endif
@@ -310,13 +358,87 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS )
 	if (!arg1)
 		error = EPERM;
 	else {
-		if ((oidp->oid_kind & CTLFLAG_OFF) && (ipfmain.ipf_running > 0))
+		if ((oidp->oid_kind & CTLFLAG_OFF) && (V_ipfmain.ipf_running > 0))
 			error = EBUSY;
 		else
 			error = SYSCTL_IN(req, arg1, sizeof(int));
 	}
 	return (error);
 }
+
+/*
+ * In the VIMAGE case kern_sysctl.c already adds the vnet base address given
+ * we set CTLFLAG_VNET to get proper access checks.  Have to undo this.
+ * Then we add the given offset to the specific malloced struct hanging off
+ * virtualized ipmain struct.
+ */
+static int
+sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS )
+{
+
+	if (arg1) {
+		ipf_nat_softc_t *nat_softc;
+
+		nat_softc = V_ipfmain.ipf_nat_soft;
+#ifdef VIMAGE
+		arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base);
+#endif
+		arg1 = (void *)((uintptr_t)nat_softc + (uintptr_t)arg1);
+	}
+
+	return (sysctl_ipf_int(oidp, arg1, arg2, req));
+}
+
+static int
+sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS )
+{
+
+	if (arg1) {
+		ipf_state_softc_t *state_softc;
+
+		state_softc = V_ipfmain.ipf_state_soft;
+#ifdef VIMAGE
+		arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base);
+#endif
+		arg1 = (void *)((uintptr_t)state_softc + (uintptr_t)arg1);
+	}
+
+	return (sysctl_ipf_int(oidp, arg1, arg2, req));
+}
+
+static int
+sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS )
+{
+
+	if (arg1) {
+		ipf_auth_softc_t *auth_softc;
+
+		auth_softc = V_ipfmain.ipf_auth_soft;
+#ifdef VIMAGE
+		arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base);
+#endif
+		arg1 = (void *)((uintptr_t)auth_softc + (uintptr_t)arg1);
+	}
+
+	return (sysctl_ipf_int(oidp, arg1, arg2, req));
+}
+
+static int
+sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS )
+{
+
+	if (arg1) {
+		ipf_frag_softc_t *frag_softc;
+
+		frag_softc = V_ipfmain.ipf_frag_soft;
+#ifdef VIMAGE
+		arg1 = (void *)((uintptr_t)arg1 - curvnet->vnet_data_base);
+#endif
+		arg1 = (void *)((uintptr_t)frag_softc + (uintptr_t)arg1);
+	}
+
+	return (sysctl_ipf_int(oidp, arg1, arg2, req));
+}
 #endif
 
 
@@ -335,24 +457,25 @@ ipfpoll(dev_t dev, int events, struct pr
 
 	revents = 0;
 
+	CURVNET_SET(TD_TO_VNET(td));
 	switch (unit)
 	{
 	case IPL_LOGIPF :
 	case IPL_LOGNAT :
 	case IPL_LOGSTATE :
 #ifdef IPFILTER_LOG
-		if ((events & (POLLIN | POLLRDNORM)) && ipf_log_canread(&ipfmain, unit))
+		if ((events & (POLLIN | POLLRDNORM)) && ipf_log_canread(&V_ipfmain, unit))
 			revents |= events & (POLLIN | POLLRDNORM);
 #endif
 		break;
 	case IPL_LOGAUTH :
-		if ((events & (POLLIN | POLLRDNORM)) && ipf_auth_waiting(&ipfmain))
+		if ((events & (POLLIN | POLLRDNORM)) && ipf_auth_waiting(&V_ipfmain))
 			revents |= events & (POLLIN | POLLRDNORM);
 		break;
 	case IPL_LOGSYNC :
-		if ((events & (POLLIN | POLLRDNORM)) && ipf_sync_canread(&ipfmain))
+		if ((events & (POLLIN | POLLRDNORM)) && ipf_sync_canread(&V_ipfmain))
 			revents |= events & (POLLIN | POLLRDNORM);
-		if ((events & (POLLOUT | POLLWRNORM)) && ipf_sync_canwrite(&ipfmain))
+		if ((events & (POLLOUT | POLLWRNORM)) && ipf_sync_canwrite(&V_ipfmain))
 			revents |= events & (POLLOUT | POLLWRNORM);
 		break;
 	case IPL_LOGSCAN :
@@ -362,7 +485,8 @@ ipfpoll(dev_t dev, int events, struct pr
 	}
 
 	if ((revents == 0) && ((events & (POLLIN|POLLRDNORM)) != 0))
-		selrecord(td, &ipfmain.ipf_selwait[unit]);
+		selrecord(td, &V_ipfmain.ipf_selwait[unit]);
+	CURVNET_RESTORE();
 
 	return revents;
 }
@@ -465,22 +589,31 @@ static int ipfread(dev, uio)
 #endif
 	struct uio *uio;
 {
+	int error;
 	int	unit = GET_MINOR(dev);
 
 	if (unit < 0)
 		return ENXIO;
 
-	if (ipfmain.ipf_running < 1)
+	CURVNET_SET(TD_TO_VNET(curthread));
+	if (V_ipfmain.ipf_running < 1) {
+		CURVNET_RESTORE();
 		return EIO;
+	}
 
-	if (unit == IPL_LOGSYNC)
-		return ipf_sync_read(&ipfmain, uio);
+	if (unit == IPL_LOGSYNC) {
+		error = ipf_sync_read(&V_ipfmain, uio);
+		CURVNET_RESTORE();
+		return error;
+	}
 
 #ifdef IPFILTER_LOG
-	return ipf_log_read(&ipfmain, unit, uio);
+	error = ipf_log_read(&V_ipfmain, unit, uio);
 #else
-	return ENXIO;
+	error = ENXIO;
 #endif
+	CURVNET_RESTORE();
+	return error;
 }
 
 
@@ -503,61 +636,57 @@ static int ipfwrite(dev, uio)
 #endif
 	struct uio *uio;
 {
+	int error;
 
-	if (ipfmain.ipf_running < 1)
+	CURVNET_SET(TD_TO_VNET(curthread));
+	if (V_ipfmain.ipf_running < 1) {
+		CURVNET_RESTORE();
 		return EIO;
+	}
 
-	if (GET_MINOR(dev) == IPL_LOGSYNC)
-		return ipf_sync_write(&ipfmain, uio);
+	if (GET_MINOR(dev) == IPL_LOGSYNC) {
+		error = ipf_sync_write(&V_ipfmain, uio);
+		CURVNET_RESTORE();
+		return error;
+	}
 	return ENXIO;
 }
 
 static int
-ipf_fbsd_sysctl_create(main_softc)
-	ipf_main_softc_t *main_softc;
+ipf_fbsd_sysctl_create(void)
 {
-	ipf_nat_softc_t	*nat_softc;
-	ipf_state_softc_t *state_softc;
-	ipf_auth_softc_t *auth_softc;
-	ipf_frag_softc_t *frag_softc;
-
-	nat_softc = main_softc->ipf_nat_soft;
-	state_softc = main_softc->ipf_state_soft;
-	auth_softc = main_softc->ipf_auth_soft;
-	frag_softc = main_softc->ipf_frag_soft;
 
 	sysctl_ctx_init(&ipf_clist);
 
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_defnatage", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_defage, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_statesize", CTLFLAG_RWO,
-	    &state_softc->ipf_state_size, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_statemax", CTLFLAG_RWO,
-	    &state_softc->ipf_state_max, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_nattable_max", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_table_max, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_nattable_sz", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_table_sz, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_natrules_sz", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_maprules_sz, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_rdrrules_sz", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_rdrrules_sz, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "ipf_hostmap_sz", CTLFLAG_RWO,
-	    &nat_softc->ipf_nat_hostmap_sz, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_authsize", CTLFLAG_RWO,
-	   &auth_softc->ipf_auth_size, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_authused", CTLFLAG_RD,
-	   &auth_softc->ipf_auth_used, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_defaultauthage", CTLFLAG_RW,
-	   &auth_softc->ipf_auth_defaultage, 0, "");
-	SYSCTL_DYN_IPF(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW,
-	   &frag_softc->ipfr_ttl, 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "fr_defnatage", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_defage), 0, "");
+	SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statesize", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_state_softc_t, ipf_state_size), 0, "");
+	SYSCTL_DYN_IPF_STATE(_net_inet_ipf, OID_AUTO, "fr_statemax", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_state_softc_t, ipf_state_max), 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_max", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_max), 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_nattable_sz", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_table_sz), 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_natrules_sz", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_maprules_sz), 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_rdrrules_sz", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_rdrrules_sz), 0, "");
+	SYSCTL_DYN_IPF_NAT(_net_inet_ipf, OID_AUTO, "ipf_hostmap_sz", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_nat_softc_t, ipf_nat_hostmap_sz), 0, "");
+	SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authsize", CTLFLAG_RWO,
+	    (void *)offsetof(ipf_auth_softc_t, ipf_auth_size), 0, "");
+	SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_authused", CTLFLAG_RD,
+	    (void *)offsetof(ipf_auth_softc_t, ipf_auth_used), 0, "");
+	SYSCTL_DYN_IPF_AUTH(_net_inet_ipf, OID_AUTO, "fr_defaultauthage", CTLFLAG_RW,
+	    (void *)offsetof(ipf_auth_softc_t, ipf_auth_defaultage), 0, "");
+	SYSCTL_DYN_IPF_FRAG(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW,
+	    (void *)offsetof(ipf_frag_softc_t, ipfr_ttl), 0, "");
 	return 0;
 }
 
 static int
-ipf_fbsd_sysctl_destroy(main_softc)
-	ipf_main_softc_t *main_softc;
+ipf_fbsd_sysctl_destroy(void)
 {
 	if (sysctl_ctx_free(&ipf_clist)) {
 		printf("sysctl_ctx_free failed");

From owner-svn-src-all@freebsd.org  Thu Jun 30 18:01:16 2016
Return-Path: 
Delivered-To: svn-src-all@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 CA5C6B873B8;
 Thu, 30 Jun 2016 18:01:16 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 74DF82CE4;
 Thu, 30 Jun 2016 18:01:16 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5UI17dX094765
 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
 Thu, 30 Jun 2016 21:01:07 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5UI17dX094765
Received: (from kostik@localhost)
 by tom.home (8.15.2/8.15.2/Submit) id u5UI16RM094736;
 Thu, 30 Jun 2016 21:01:06 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Thu, 30 Jun 2016 21:01:06 +0300
From: Konstantin Belousov 
To: Bruce Evans 
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
Message-ID: <20160630180106.GU38613@kib.kiev.ua>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org>
 <20160629145443.GG38613@kib.kiev.ua>
 <20160629153233.GI38613@kib.kiev.ua>
 <20160630040123.F791@besplex.bde.org>
 <20160629211953.GK38613@kib.kiev.ua>
 <20160701005401.Q1084@besplex.bde.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160701005401.Q1084@besplex.bde.org>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no
 autolearn_force=no version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Thu, 30 Jun 2016 18:01:16 -0000

On Fri, Jul 01, 2016 at 03:30:41AM +1000, Bruce Evans wrote:
> On Thu, 30 Jun 2016, Konstantin Belousov wrote:
> 
> > On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote:
> >> On Wed, 29 Jun 2016, Konstantin Belousov wrote:
> >>
> >>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote:
> >>>> As an additional, but probably excessive measure, invocation of
> >>>> tc_windup() from hardclock could ask the setclock() to re-execute
> >>>> tc_windup() after its call is done.
> >>
> >> I don't quite understand this.  hardclock -> tc_windup() normally doesn't
> >> have interference from tc_setclock().
> > In what sense it does not have interference ?  tc_windup() may be executed
> > from hardclock/hardclock_cnt (low half) and concurrently from setclock()
> > (top half).  And this is exactly what we want to avoid, isn't it ?
> 
> Ues, but you seemed to be saying that hardclock should schedule or call
> tc_setclock().  That makes no sense.  So I thought that you meant
> tc_setclock() calling or scheduling tc_windup() in a different way than
> it does now (it just calls it now).
More precisely, I mean that hardclock, when not able to execute tc_windup()
due to the top-half currently executing tc_windup(), may ask top-half to
re-execute tc_windup() (and not tc_setclock()) once the current invocation
finishes.

> 
> >>> ...
> >>> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> >>> index 0f015b3..a5776d2 100644
> >>> --- a/sys/kern/kern_tc.c
> >>> +++ b/sys/kern/kern_tc.c
> >>> ...
> >>> @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts)
> >>> 	struct timespec tbef, taft;
> >>> 	struct bintime bt, bt2;
> >>>
> >>> +	critical_enter();
> >>> 	cpu_tick_calibrate(1);
> >>> 	nanotime(&tbef);
> >>> 	timespec2bintime(ts, &bt);
> >>> @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts)
> >>> 	bintime2timeval(&bt, &boottime);
> >>
> >> boottime is one of the critical variables.  Before this, there are 2
> >> accesses to boottimebin.  The Giant locking that you just removed gave
> >> only some protection here.  It prevented concurrent acccess by
> >> malicious/stress-testing code doing settime().  It didn't prevent
> >> nanotime() and friends seeing boottime in an in-between state.  Oops,
> >> mutex locking won't fix that either.  I think the update of these
> >> variables needs to be moved into tc_windup() where it will hopefully
> >> automatically be protected by the generation count, like the timehands
> >> offsets already are.
> > I do not understand how that would help.  Do you mean to move the vars
> > into current timehands ?
> 
> I hoped that it would just work without putting it in timehands, but
> now I don't see a better way that putting it in timehands.  The space
> wastage is not too bad, and we might need it in timehands for other
> reasons.  One is that the actual boot time is invariant, but FreeBSD
> varies it; a global is needed for the actual boot time and then it is
> natural to put the fudged boot time in timehands (it is not a boot
> time, but an offset which is sometimes close to the boot time).
> 
> Note that boottimebin is also updated in tc_windup() (for leap seconds).
> The new mutex doesn't protect it there.  This is the next of other
> reasons to put it in timehands.
Yes.

> 
> >*...
> >>> +	for (;;) {
> >>> +		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
> >>> +			atomic_thread_fence_acq();
> >>> +			tc_windup_locked();
> >>> +			atomic_store_rel_int(&tc_windup_lock, 0);
> >>> +			break;
> >>> +		} else if (!top_call) {
> >>> +			break;
> >>> +		}
> >>> +	}
> >>> }
> >>
> >> I like to write optimized locking like that, but don't see why you
> >> want it here.
> > Because I do not want the fast clock interrupt handler to wait on lock,
> > which neccessary becomes spinlock.  The ntp_lock is bad enough already.
> > What I coded above is not real lock.  In contention case it bails out,
> > so there is no blocking.  In particular, witness is not relevant to it.
> 
> I think this is too complicated.  Spinlocks aren't very expensive, and
> hardclock() already has some.  I think it has several.  It has at least
> one silly one -- in hardclock_cpu(), a thread locking to lock a single
> flags update.  hardclock() and tc_windup() just aren't called enough
> for the locking overhead or contention to matter, even at too-large hz.
Spinlocks are quite expensive.  They delay interrupt delivery.
I do not want the fast interrupt handler to be delayed due to the top-half
of the kernel executing settimeofday(2) in loop.

> 
> > ...
> > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> > index 0f015b3..7bb767c 100644
> > --- a/sys/kern/kern_tc.c
> > +++ b/sys/kern/kern_tc.c
> >...
> > +static struct mtx tc_setclock_mtx;
> > +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF);
> 
> I thought it would be a spinlock.  The sleep lock is better if you can
> make ot work, but this is complicated.
For mutual exclusion of invocation of tc_setclock(), I do not see why
sleepable lock would not suffice.

> 
> > +
> > /*
> >  * Step our concept of UTC.  This is done by modifying our estimate of
> >  * when we booted.
> > - * XXX: not locked.
> >  */
> 
> Now "not properly locked" -).
> 
> > void
> > tc_setclock(struct timespec *ts)
> > @@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts)
> > 	struct timespec tbef, taft;
> > 	struct bintime bt, bt2;
> >
> > +	mtx_lock(&tc_setclock_mtx);
> > +	critical_enter();
> 
> I thought at first that this critical section was redundant, since a
> spinlock would already have it.
It is not spinlock.

> 
> > 	cpu_tick_calibrate(1);
> > 	nanotime(&tbef);
> > 	timespec2bintime(ts, &bt);
> > @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts)
> > 	bintime2timeval(&bt, &boottime);
> 
> The leap second update to boottimebin in tc_windup() races with the
> update to boottimebin here.  This can be fixed partially by using the
> same locking there.  Then the locking would have to be a spin mutex
> (or special).  This still doesn't fix non-atomic accesses to boottimebin
> in nanotime() and friends.  Putting it in timehands seems to be best for
> fixing that.
Yes, timehands for bootimebin should be the solution, but
not in the scope of this patch.  I will work on this right after the
current changeset lands in svn.

> boottime is easier to fix (and doesn't need to be in timehands).  It
> is only used to copy it out in a historical sysctl.  The locking for
> that is buggy.  We convert boottimebin to boottime here (now with locking)
> but in the sysctl we copy out boottime non-atomically.
Do we need boottime at all ?  Can't it be calculated from boottimebin
on the sysctl invocation ?

From owner-svn-src-all@freebsd.org  Thu Jun 30 18:02:38 2016
Return-Path: 
Delivered-To: svn-src-all@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 48F22B87527;
 Thu, 30 Jun 2016 18:02:38 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au
 [211.29.132.59])
 by mx1.freebsd.org (Postfix) with ESMTP id AFD352F16;
 Thu, 30 Jun 2016 18:02:37 +0000 (UTC)
 (envelope-from brde@optusnet.com.au)
Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au
 [110.21.100.149])
 by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id AC7D71A21F0;
 Fri,  1 Jul 2016 03:30:41 +1000 (AEST)
Date: Fri, 1 Jul 2016 03:30:41 +1000 (EST)
From: Bruce Evans 
X-X-Sender: bde@besplex.bde.org
To: Konstantin Belousov 
cc: src-committers@freebsd.org, svn-src-all@freebsd.org, 
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
In-Reply-To: <20160629211953.GK38613@kib.kiev.ua>
Message-ID: <20160701005401.Q1084@besplex.bde.org>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua>
 <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org>
 <20160629211953.GK38613@kib.kiev.ua>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Optus-CM-Score: 0
X-Optus-CM-Analysis: v=2.1 cv=OtmysHLt c=1 sm=1 tr=0
 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17
 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10
 a=rSq5_t48hvnpDHZ03tAA:9 a=YlvRzp75ULENEib-:21 a=7WTdreb3hoYc-uwb:21
 a=CjuIK1q_8ugA:10
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Thu, 30 Jun 2016 18:02:38 -0000

On Thu, 30 Jun 2016, Konstantin Belousov wrote:

> On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote:
>> On Wed, 29 Jun 2016, Konstantin Belousov wrote:
>>
>>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote:
>>>> This is a reply to two mails in one, both for r302251 and r302252 threads.
>
>> After removing the foot-shooting tz_minuteswest variable from utc_offset(),
>> all of the variables in it are ones set by adjkerntz sysctls.  The settings
>> are normally ordered by not running more than 1 instance of adjkerntz.
>> When adjkerntz starts, this instance shouldn't have any contention with
>> other initialization doing resettodr().  There is contention every 6
>> months if wall_cmos_clock when adjkerntz changes the offset for daylight
>> savings time.  The chances of this used to be tiny since resettodr() was
>> almost never called, but now there is the periodic resettodr() in
>> kern_ntptime.c.
> I do not see how your text above changes anything I said about consistency.
> Each sysctl sets or fetches integer variable, so individually it is atomic.
> Inter-dependencies between wall_cmos_clock and adjkerntz settings are
> completely up to user, no locking can change it while keeping separate
> sysctls to set and fetch each var individually.
> 
> The only side-effects in resettodr() are possible in CLOCK_SETTIME(),
> which is protected against parallel invocation by resettodr_lock.

It says that the users are sufficiently limited and careful about ordering
for the problem to be small.

>>>>> ...
>>>>> The change in the other part of the diff is related to this, and doesn't
>>>>> seem quite right.  utc_offset() uses the variables tz_minuteswest,
>>>>> wall_cmos_clock and adjkerntz:
>>>>> - tz_minuteswest is set with no locking in kern_settimeofday(), just
>>>>>    after the settime() call.  This last had a chance of being correct
>>>>>    when the kernel was UP and not preemptible.  But it is broken in
>>>>>    a more fundamental way back to at least FreeBSD-1: resettodr() is
>>>>>    called _before_ updating the timezone, so it uses an out-of-date
>>>>>    tz_minuteswest.
>>>> First, the man page is not correct, saying that 'this information is
>>>> kept outside the kernel'.
>>
>> We deprecate the timezone support in settimeofday(), but use wrong wording
>> for this here.  The info set by this sysctl is of course kept in the kernel,
>> and I think the man page is trying to say that this info is never used
>> outside of the kernel.
> How the later statement could be true, since that information is
> returned by gettimeofday(), and we do not control what programs a user
> might run on his machine.

Indeed.  The man page is only trying to say that this info is not used by
libc (and therefore should not be used by any program).

>*...
>>>> Second, why does settime(), logicall, need the updated timezone ?
>>>> I understand that resettodr() is called on successful update of
>>>> the wall clock.  But shouldn't the need to reset not-GMT RTC clock
>>
>> The timezone updates just give foot-shooting, but we need an up to
>> date adjkerntz variable initially and on every daylight saving change
>> in the wall_cmos_clock case.  This is the normal way to keep the rtc
>> on wall time after every daylight saving changes -- adjkerntz() runs,
>> and it should change the adjkerntz variable first and then call
>> settimeofday() with a "null" change to get the side effect of calling
>> resettodr() which does a large change of the rtc.  It is impossible
>> to make a really null change of the software clock using settimeofday(),
>> but I don't know of any better API to do this.  I think the locking that
>> you just added is enough -- adjkerntz() just has to arrange a call to
>> resettodr() strictly after it updates the variable, and that happens
>> almost automatically.
> I think that the way it is done is just by doing sysctl machdep.adjkerntz,
> which calls resettodr().

I probably knew that once, but had forgotten it.

> Old wisdom to re-sync RTC to kernel-maintained
> time was to run the sysctl from cron, but Andrey added the callout
> several years ago.

I never knew that old wisdom, and just avoided re-syncing the RTC.

>>>> I do not think that inittodr() actually needs that locking.  This code
>>>> is executed at the initialization stage, or at the resume stage.
>>
>> Perhaps, but resume runs more often than every 6 months for the daylight
>> savings time race, and it isn't clear if anything stops resettodr() running
>> concurrently then.
>>
>> In my version, something like inittodr() runs 3 seconds after every exit
>> from ddb.  Stopping in ddb is a bit like a short suspend-resume -- it
>> stops or breaks some timers, and inittodr() is a way to fix up the
>> software real time using an unstopped timer.
> Lets postpone this.  Might be, a resettodr_lock can be applied to
> inittodr() as a whole, and additionally merged with some other lock.
> BUt I think inittodr() is not very important right now.

I see some more things that need the common lock:
- the RTC interrupt handler.  resettodr() begins by disabling RTC
   interrupts.  This is to prevent interference from the interrupt
   handler, but it only works for UP systems.  For SMP systems, the
   interrupt handler might already be running, or scheduled to run,
   on another CPU.  The interrupt handler doesn't do many RTC accesses
   (except in my version), but it does delicate interrupt re-enabling
   by reading the volatile status register.  resettodr() ends by
   re-enabling RTC interrupts and reading the volatile status register.
   I think all orderings work, but it would be simpler to not allow the
   contention or maybe to allow it intentionally by not disabling RTC
   interrupts.
- atc_restore().  This runs mainly for resume.  It resets the same
   status register as resettodr() and another status registers.  It
   must not be allowed to run concurrently with resettodr().  Resume
   call it before allowing any callouts.  It is unclear if this is
   guaranteed.
>*...
>>>> So I postponed looking at tc_windup(), and it seems that it was
>>>> useful. After you note above, it is mostly clear that we can skip some
>>>> tc_windup() calls which conflicts with currently active windup calls.
>>>> E.g., the hardclock update, which is done simultaneously with the
>>>> setclock(), could be just skipped.  But we must not skip the tc_windup()
>>>> call from setclock().
>>
>> Several things could be deferred, but I think that would just be more
>> complicated.
>>
>>>> As an additional, but probably excessive measure, invocation of
>>>> tc_windup() from hardclock could ask the setclock() to re-execute
>>>> tc_windup() after its call is done.
>>
>> I don't quite understand this.  hardclock -> tc_windup() normally doesn't
>> have interference from tc_setclock().
> In what sense it does not have interference ?  tc_windup() may be executed
> from hardclock/hardclock_cnt (low half) and concurrently from setclock()
> (top half).  And this is exactly what we want to avoid, isn't it ?

Ues, but you seemed to be saying that hardclock should schedule or call
tc_setclock().  That makes no sense.  So I thought that you meant
tc_setclock() calling or scheduling tc_windup() in a different way than
it does now (it just calls it now).

>>> ...
>>> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
>>> index 0f015b3..a5776d2 100644
>>> --- a/sys/kern/kern_tc.c
>>> +++ b/sys/kern/kern_tc.c
>>> ...
>>> @@ -1237,6 +1238,7 @@ tc_setclock(struct timespec *ts)
>>> 	struct timespec tbef, taft;
>>> 	struct bintime bt, bt2;
>>>
>>> +	critical_enter();
>>> 	cpu_tick_calibrate(1);
>>> 	nanotime(&tbef);
>>> 	timespec2bintime(ts, &bt);
>>> @@ -1247,8 +1249,10 @@ tc_setclock(struct timespec *ts)
>>> 	bintime2timeval(&bt, &boottime);
>>
>> boottime is one of the critical variables.  Before this, there are 2
>> accesses to boottimebin.  The Giant locking that you just removed gave
>> only some protection here.  It prevented concurrent acccess by
>> malicious/stress-testing code doing settime().  It didn't prevent
>> nanotime() and friends seeing boottime in an in-between state.  Oops,
>> mutex locking won't fix that either.  I think the update of these
>> variables needs to be moved into tc_windup() where it will hopefully
>> automatically be protected by the generation count, like the timehands
>> offsets already are.
> I do not understand how that would help.  Do you mean to move the vars
> into current timehands ?

I hoped that it would just work without putting it in timehands, but
now I don't see a better way that putting it in timehands.  The space
wastage is not too bad, and we might need it in timehands for other
reasons.  One is that the actual boot time is invariant, but FreeBSD
varies it; a global is needed for the actual boot time and then it is
natural to put the fudged boot time in timehands (it is not a boot
time, but an offset which is sometimes close to the boot time).

Note that boottimebin is also updated in tc_windup() (for leap seconds).
The new mutex doesn't protect it there.  This is the next of other
reasons to put it in timehands.

>*...
>>> +	for (;;) {
>>> +		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
>>> +			atomic_thread_fence_acq();
>>> +			tc_windup_locked();
>>> +			atomic_store_rel_int(&tc_windup_lock, 0);
>>> +			break;
>>> +		} else if (!top_call) {
>>> +			break;
>>> +		}
>>> +	}
>>> }
>>
>> I like to write optimized locking like that, but don't see why you
>> want it here.
> Because I do not want the fast clock interrupt handler to wait on lock,
> which neccessary becomes spinlock.  The ntp_lock is bad enough already.
> What I coded above is not real lock.  In contention case it bails out,
> so there is no blocking.  In particular, witness is not relevant to it.

I think this is too complicated.  Spinlocks aren't very expensive, and
hardclock() already has some.  I think it has several.  It has at least
one silly one -- in hardclock_cpu(), a thread locking to lock a single
flags update.  hardclock() and tc_windup() just aren't called enough
for the locking overhead or contention to matter, even at too-large hz.

> ...
> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> index 0f015b3..7bb767c 100644
> --- a/sys/kern/kern_tc.c
> +++ b/sys/kern/kern_tc.c
>...
> +static struct mtx tc_setclock_mtx;
> +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF);

I thought it would be a spinlock.  The sleep lock is better if you can
make ot work, but this is complicated.

> +
> /*
>  * Step our concept of UTC.  This is done by modifying our estimate of
>  * when we booted.
> - * XXX: not locked.
>  */

Now "not properly locked" -).

> void
> tc_setclock(struct timespec *ts)
> @@ -1237,6 +1240,8 @@ tc_setclock(struct timespec *ts)
> 	struct timespec tbef, taft;
> 	struct bintime bt, bt2;
>
> +	mtx_lock(&tc_setclock_mtx);
> +	critical_enter();

I thought at first that this critical section was redundant, since a
spinlock would already have it.

> 	cpu_tick_calibrate(1);
> 	nanotime(&tbef);
> 	timespec2bintime(ts, &bt);
> @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts)
> 	bintime2timeval(&bt, &boottime);

The leap second update to boottimebin in tc_windup() races with the
update to boottimebin here.  This can be fixed partially by using the
same locking there.  Then the locking would have to be a spin mutex
(or special).  This still doesn't fix non-atomic accesses to boottimebin
in nanotime() and friends.  Putting it in timehands seems to be best for
fixing that.

boottime is easier to fix (and doesn't need to be in timehands).  It
is only used to copy it out in a historical sysctl.  The locking for
that is buggy.  We convert boottimebin to boottime here (now with locking)
but in the sysctl we copy out boottime non-atomically.


Bruce

From owner-svn-src-all@freebsd.org  Thu Jun 30 19:32:46 2016
Return-Path: 
Delivered-To: svn-src-all@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 EFBEAB87880;
 Thu, 30 Jun 2016 19:32:46 +0000 (UTC) (envelope-from bz@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 BFE5C2A09;
 Thu, 30 Jun 2016 19:32:46 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UJWjOP095282;
 Thu, 30 Jun 2016 19:32:45 GMT (envelope-from bz@FreeBSD.org)
Received: (from bz@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UJWjW8095281;
 Thu, 30 Jun 2016 19:32:45 GMT (envelope-from bz@FreeBSD.org)
Message-Id: <201606301932.u5UJWjW8095281@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org
 using -f
From: "Bjoern A. Zeeb" 
Date: Thu, 30 Jun 2016 19:32:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302302 - head/sys/netpfil/ipfw
X-SVN-Group: head
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.22
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: Thu, 30 Jun 2016 19:32:47 -0000

Author: bz
Date: Thu Jun 30 19:32:45 2016
New Revision: 302302
URL: https://svnweb.freebsd.org/changeset/base/302302

Log:
  In case of the global eventhandler make sure the current VNET
  is still operational before doing any work;  otherwise we might
  run into, e.g., destroyed locks.
  
  PR:		210724
  Reported by:	olevole olevole.ru
  Sponsored by:	The FreeBSD Foundation
  MFC after:	2 weeks
  Obtained from:	projects/vnet
  Approved by:	re (gjb)

Modified:
  head/sys/netpfil/ipfw/ip_fw_nat.c

Modified: head/sys/netpfil/ipfw/ip_fw_nat.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_fw_nat.c	Thu Jun 30 19:09:44 2016	(r302301)
+++ head/sys/netpfil/ipfw/ip_fw_nat.c	Thu Jun 30 19:32:45 2016	(r302302)
@@ -104,6 +104,10 @@ ifaddr_change(void *arg __unused, struct
 
 	KASSERT(curvnet == ifp->if_vnet,
 	    ("curvnet(%p) differs from iface vnet(%p)", curvnet, ifp->if_vnet));
+
+	if (V_ipfw_vnet_ready == 0 || V_ipfw_nat_ready == 0)
+		return;
+
 	chain = &V_layer3_chain;
 	IPFW_UH_WLOCK(chain);
 	/* Check every nat entry... */
@@ -1145,12 +1149,12 @@ vnet_ipfw_nat_uninit(const void *arg __u
 
 	chain = &V_layer3_chain;
 	IPFW_WLOCK(chain);
+	V_ipfw_nat_ready = 0;
 	LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) {
 		LIST_REMOVE(ptr, _next);
 		free_nat_instance(ptr);
 	}
 	flush_nat_ptrs(chain, -1 /* flush all */);
-	V_ipfw_nat_ready = 0;
 	IPFW_WUNLOCK(chain);
 	return (0);
 }

From owner-svn-src-all@freebsd.org  Fri Jul  1 00:00:36 2016
Return-Path: 
Delivered-To: svn-src-all@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 D2408B874F4;
 Fri,  1 Jul 2016 00:00:36 +0000 (UTC) (envelope-from gjb@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 A32532E44;
 Fri,  1 Jul 2016 00:00:36 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6100ZdG093386;
 Fri, 1 Jul 2016 00:00:35 GMT (envelope-from gjb@FreeBSD.org)
Received: (from gjb@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6100Z3J093385;
 Fri, 1 Jul 2016 00:00:35 GMT (envelope-from gjb@FreeBSD.org)
Message-Id: <201607010000.u6100Z3J093385@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org
 using -f
From: Glen Barber 
Date: Fri, 1 Jul 2016 00:00:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302303 - head/sys/conf
X-SVN-Group: head
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.22
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: Fri, 01 Jul 2016 00:00:36 -0000

Author: gjb
Date: Fri Jul  1 00:00:35 2016
New Revision: 302303
URL: https://svnweb.freebsd.org/changeset/base/302303

Log:
  Update 11.0 to ALPHA6.
  
  Approved by:	re (implicit)
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/conf/newvers.sh

Modified: head/sys/conf/newvers.sh
==============================================================================
--- head/sys/conf/newvers.sh	Thu Jun 30 19:32:45 2016	(r302302)
+++ head/sys/conf/newvers.sh	Fri Jul  1 00:00:35 2016	(r302303)
@@ -32,7 +32,7 @@
 
 TYPE="FreeBSD"
 REVISION="11.0"
-BRANCH="ALPHA5"
+BRANCH="ALPHA6"
 if [ -n "${BRANCH_OVERRIDE}" ]; then
 	BRANCH=${BRANCH_OVERRIDE}
 fi

From owner-svn-src-all@freebsd.org  Fri Jul  1 03:16:09 2016
Return-Path: 
Delivered-To: svn-src-all@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 123E1B860CF;
 Fri,  1 Jul 2016 03:16:09 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 6ED1F29C1;
 Fri,  1 Jul 2016 03:16:08 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u613Fo7x031721
 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
 Fri, 1 Jul 2016 06:15:51 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u613Fo7x031721
Received: (from kostik@localhost)
 by tom.home (8.15.2/8.15.2/Submit) id u613Fo06031717;
 Fri, 1 Jul 2016 06:15:50 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Fri, 1 Jul 2016 06:15:50 +0300
From: Konstantin Belousov 
To: Bruce Evans 
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: Re: svn commit: r302252 - head/sys/kern
Message-ID: <20160701031549.GV38613@kib.kiev.ua>
References: <201606281643.u5SGhNsi061606@repo.freebsd.org>
 <20160629175917.O968@besplex.bde.org>
 <20160629145443.GG38613@kib.kiev.ua>
 <20160629153233.GI38613@kib.kiev.ua>
 <20160630040123.F791@besplex.bde.org>
 <20160629211953.GK38613@kib.kiev.ua>
 <20160701005401.Q1084@besplex.bde.org>
 <20160630180106.GU38613@kib.kiev.ua>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160630180106.GU38613@kib.kiev.ua>
User-Agent: Mutt/1.6.1 (2016-04-27)
X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no
 autolearn_force=no version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Fri, 01 Jul 2016 03:16:09 -0000

On Thu, Jun 30, 2016 at 09:01:06PM +0300, Konstantin Belousov wrote:
> Yes, timehands for bootimebin should be the solution, but
> not in the scope of this patch.  I will work on this right after the
> current changeset lands in svn.

Well, there is the move of boottimebin into timehands.  I also reduced
the number of timehands to two, this was discussed many times before.
The feed-forward code is probably broken right now, I did not even
compile it.

diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 56b2ade..a0dce47 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS)
 	struct pcpu *pcpu;
 	long cp_time[CPUSTATES];
 	long *cp;
+	struct timeval boottime;
 	int i;
 
 	read_cpu_time(cp_time);
+	getboottime(&boottime);
 	sbuf_printf(sb, "cpu %ld %ld %ld %ld\n",
 	    T2J(cp_time[CP_USER]),
 	    T2J(cp_time[CP_NICE]),
@@ -624,10 +626,12 @@ static int
 linprocfs_doprocstat(PFS_FILL_ARGS)
 {
 	struct kinfo_proc kp;
+	struct timeval boottime;
 	char state;
 	static int ratelimit = 0;
 	vm_offset_t startcode, startdata;
 
+	getboottime(&boottime);
 	sx_slock(&proctree_lock);
 	PROC_LOCK(p);
 	fill_kinfo_proc(p, &kp);
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 7cc0f9e..afa3da4 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap)
 {
 	struct vnode *vp = ap->a_vp;
 	struct vattr *vap = ap->a_vap;
-	int error;
 	struct devfs_dirent *de;
 	struct devfs_mount *dmp;
 	struct cdev *dev;
+	struct timeval boottime;
+	int error;
 
 	error = devfs_populate_vp(vp);
 	if (error != 0)
@@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap)
 	vap->va_blocksize = DEV_BSIZE;
 	vap->va_type = vp->v_type;
 
+	getboottime(&boottime);
 #define fix(aa)							\
 	do {							\
 		if ((aa).tv_sec <= 3600) {			\
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index 4f6e1b9..65b8a54 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap)
 {
 	struct vnode *vp = ap->a_vp;
 	struct vattr *vap = ap->a_vap;
+	struct timeval boottime;
 
+	getboottime(&boottime);
 	vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
 	vap->va_fileid = VTOFDESC(vp)->fd_ix;
 	vap->va_uid = 0;
diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h
index 921df2d..6b41e2f 100644
--- a/sys/fs/nfs/nfsport.h
+++ b/sys/fs/nfs/nfsport.h
@@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int);
 /*
  * Set boottime.
  */
-#define	NFSSETBOOTTIME(b)	((b) = boottime)
+#define	NFSSETBOOTTIME(b)	(getboottime(&b))
 
 /*
  * The size of directory blocks in the buffer cache.
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c
index 5a00ee1..defdec3 100644
--- a/sys/fs/procfs/procfs_status.c
+++ b/sys/fs/procfs/procfs_status.c
@@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS)
 	const char *wmesg;
 	char *pc;
 	char *sep;
+	struct timeval boottime;
 	int pid, ppid, pgid, sid;
 	int i;
 
@@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS)
 		calcru(p, &ut, &st);
 		PROC_STATUNLOCK(p);
 		start = p->p_stats->p_start;
+		getboottime(&boottime);
 		timevaladd(&start, &boottime);
 		sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld",
 		    (intmax_t)start.tv_sec, start.tv_usec,
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index ef3fd2e..46e6d9b 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -389,7 +389,7 @@ acct_process(struct thread *td)
 	acct.ac_stime = encode_timeval(st);
 
 	/* (4) The elapsed time the command ran (and its starting time) */
-	tmp = boottime;
+	getboottime(&tmp);
 	timevaladd(&tmp, &p->p_stats->p_start);
 	acct.ac_btime = tmp.tv_sec;
 	microuptime(&tmp);
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index d352ee7..efc3713 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -162,29 +162,12 @@ static l_fp time_adj;			/* tick adjust (ns/s) */
 
 static int64_t time_adjtime;		/* correction from adjtime(2) (usec) */
 
-static struct mtx ntpadj_lock;
-MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj",
-#ifdef PPS_SYNC
-    MTX_SPIN
-#else
-    MTX_DEF
-#endif
-);
+static struct mtx ntp_lock;
+MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN);
 
-/*
- * When PPS_SYNC is defined, hardpps() function is provided which can
- * be legitimately called from interrupt filters.  Due to this, use
- * spinlock for ntptime state protection, otherwise sleepable mutex is
- * adequate.
- */
-#ifdef PPS_SYNC
-#define	NTPADJ_LOCK()		mtx_lock_spin(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock_spin(&ntpadj_lock)
-#else
-#define	NTPADJ_LOCK()		mtx_lock(&ntpadj_lock)
-#define	NTPADJ_UNLOCK()		mtx_unlock(&ntpadj_lock)
-#endif
-#define	NTPADJ_ASSERT_LOCKED()	mtx_assert(&ntpadj_lock, MA_OWNED)
+#define	NTP_LOCK()		mtx_lock_spin(&ntp_lock)
+#define	NTP_UNLOCK()		mtx_unlock_spin(&ntp_lock)
+#define	NTP_ASSERT_LOCKED()	mtx_assert(&ntp_lock, MA_OWNED)
 
 #ifdef PPS_SYNC
 /*
@@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp)
 {
 	struct timespec atv;	/* nanosecond time */
 
-	NTPADJ_ASSERT_LOCKED();
+	NTP_ASSERT_LOCKED();
 
 	nanotime(&atv);
 	ntvp->time.tv_sec = atv.tv_sec;
@@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap)
 {	
 	struct ntptimeval ntv;
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ntp_gettime1(&ntv);
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	td->td_retval[0] = ntv.time_state;
 	return (copyout(&ntv, uap->ntvp, sizeof(ntv)));
@@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS)
 {
 	struct ntptimeval ntv;	/* temporary structure */
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ntp_gettime1(&ntv);
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req));
 }
@@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 		error = priv_check(td, PRIV_NTP_ADJTIME);
 	if (error != 0)
 		return (error);
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	if (modes & MOD_MAXERROR)
 		time_maxerror = ntv.maxerror;
 	if (modes & MOD_ESTERROR)
@@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
 	ntv.stbcnt = pps_stbcnt;
 #endif /* PPS_SYNC */
 	retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state;
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 
 	error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv));
 	if (error == 0)
@@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	int tickrate;
 	l_fp ftemp;		/* 32/64-bit temporary */
 
+	NTP_LOCK();
+
 	/*
 	 * On rollover of the second both the nanosecond and microsecond
 	 * clocks are updated and the state machine cranked as
@@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec)
 	else
 		time_status &= ~STA_PPSSIGNAL;
 #endif /* PPS_SYNC */
+
+	NTP_UNLOCK();
 }
 
 /*
@@ -690,7 +677,7 @@ hardupdate(offset)
 	long mtemp;
 	l_fp ftemp;
 
-	NTPADJ_ASSERT_LOCKED();
+	NTP_ASSERT_LOCKED();
 
 	/*
 	 * Select how the phase is to be controlled and from which
@@ -772,7 +759,7 @@ hardpps(tsp, nsec)
 	long u_sec, u_nsec, v_nsec; /* temps */
 	l_fp ftemp;
 
-	NTPADJ_LOCK();
+	NTP_LOCK();
 
 	/*
 	 * The signal is first processed by a range gate and frequency
@@ -956,7 +943,7 @@ hardpps(tsp, nsec)
 		time_freq = pps_freq;
 
 out:
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 }
 #endif /* PPS_SYNC */
 
@@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta)
 			return (error);
 		ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec;
 	}
-	NTPADJ_LOCK();
+	NTP_LOCK();
 	ltr = time_adjtime;
 	if (delta != NULL)
 		time_adjtime = ltw;
-	NTPADJ_UNLOCK();
+	NTP_UNLOCK();
 	if (olddelta != NULL) {
 		atv.tv_sec = ltr / 1000000;
 		atv.tv_usec = ltr % 1000000;
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 2f1f620..892b23a 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp)
 	struct session *sp;
 	struct ucred *cred;
 	struct sigacts *ps;
+	struct timeval boottime;
 
 	/* For proc_realparent. */
 	sx_assert(&proctree_lock, SX_LOCKED);
@@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp)
 	kp->ki_nice = p->p_nice;
 	kp->ki_fibnum = p->p_fibnum;
 	kp->ki_start = p->p_stats->p_start;
+	getboottime(&boottime);
 	timevaladd(&kp->ki_start, &boottime);
 	PROC_STATLOCK(p);
 	rufetch(p, &kp->ki_rusage);
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 0f015b3..1c2d562 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -70,31 +70,36 @@ struct timehands {
 	struct bintime		th_offset;
 	struct timeval		th_microtime;
 	struct timespec		th_nanotime;
+	struct bintime		th_boottime;
 	/* Fields not to be copied in tc_windup start with th_generation. */
 	u_int			th_generation;
 	struct timehands	*th_next;
 };
 
 static struct timehands th0;
-static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0};
-static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9};
-static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8};
-static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7};
-static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6};
-static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5};
-static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4};
-static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3};
-static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2};
+static struct timehands th1 = {
+	.th_counter = NULL,
+	.th_adjustment = 0,
+	.th_scale = 0,
+	.th_offset_count = 0,
+	.th_offset = {0, 0},
+	.th_microtime = {0, 0},
+	.th_nanotime = {0, 0},
+	.th_boottime = {0, 0},
+	.th_generation = 0,
+	.th_next = &th0
+};
 static struct timehands th0 = {
-	&dummy_timecounter,
-	0,
-	(uint64_t)-1 / 1000000,
-	0,
-	{1, 0},
-	{0, 0},
-	{0, 0},
-	1,
-	&th1
+	.th_counter = &dummy_timecounter,
+	.th_adjustment = 0,
+	.th_scale = (uint64_t)-1 / 1000000,
+	.th_offset_count = 0,
+	.th_offset = {1, 0},
+	.th_microtime = {0, 0},
+	.th_nanotime = {0, 0},
+	.th_boottime = {0, 0},
+	.th_generation = 1,
+	.th_next = &th1
 };
 
 static struct timehands *volatile timehands = &th0;
@@ -106,8 +111,6 @@ int tc_min_ticktock_freq = 1;
 volatile time_t time_second = 1;
 volatile time_t time_uptime = 1;
 
-struct bintime boottimebin;
-struct timeval boottime;
 static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS);
 SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD,
     NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime");
@@ -135,14 +138,22 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation,
 
 static int tc_chosen;	/* Non-zero if a specific tc was chosen via sysctl. */
 
-static void tc_windup(void);
+static void tc_windup(bool top_call, struct bintime *new_boottimebin);
+static void tc_windup_locked(struct bintime *new_boottimebin);
 static void cpu_tick_calibrate(int);
+static void binuptime1(struct bintime *bt, struct bintime *boottimebin);
 
 void dtrace_getnanotime(struct timespec *tsp);
 
 static int
 sysctl_kern_boottime(SYSCTL_HANDLER_ARGS)
 {
+	struct bintime boottimebin;
+	struct timeval boottime;
+
+	binuptime1(NULL, &boottimebin);
+	bintime2timeval(&boottimebin, &boottime);
+
 #ifndef __mips__
 #ifdef SCTL_MASK32
 	int tv[2];
@@ -150,11 +161,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS)
 	if (req->flags & SCTL_MASK32) {
 		tv[0] = boottime.tv_sec;
 		tv[1] = boottime.tv_usec;
-		return SYSCTL_OUT(req, tv, sizeof(tv));
-	} else
+		return (SYSCTL_OUT(req, tv, sizeof(tv)));
+	}
 #endif
 #endif
-		return SYSCTL_OUT(req, &boottime, sizeof(boottime));
+	return (SYSCTL_OUT(req, &boottime, sizeof(boottime)));
 }
 
 static int
@@ -164,7 +175,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS)
 	struct timecounter *tc = arg1;
 
 	ncount = tc->tc_get_timecount(tc);
-	return sysctl_handle_int(oidp, &ncount, 0, req);
+	return (sysctl_handle_int(oidp, &ncount, 0, req));
 }
 
 static int
@@ -174,7 +185,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS)
 	struct timecounter *tc = arg1;
 
 	freq = tc->tc_frequency;
-	return sysctl_handle_64(oidp, &freq, 0, req);
+	return (sysctl_handle_64(oidp, &freq, 0, req));
 }
 
 /*
@@ -198,8 +209,8 @@ tc_delta(struct timehands *th)
  */
 
 #ifdef FFCLOCK
-void
-fbclock_binuptime(struct bintime *bt)
+static void
+fbclock_binuptime1(struct bintime *bt, struct bintime *boottimebin)
 {
 	struct timehands *th;
 	unsigned int gen;
@@ -209,11 +220,20 @@ fbclock_binuptime(struct bintime *bt)
 		gen = atomic_load_acq_int(&th->th_generation);
 		*bt = th->th_offset;
 		bintime_addx(bt, th->th_scale * tc_delta(th));
+		if (boottimebin != NULL)
+			*boottimebin = th->th_boottime;
 		atomic_thread_fence_acq();
 	} while (gen == 0 || gen != th->th_generation);
 }
 
 void
+fbclock_binuptime(struct bintime *bt)
+{
+
+	fbclock_binuptime1(bt, NULL);
+}
+
+void
 fbclock_nanouptime(struct timespec *tsp)
 {
 	struct bintime bt;
@@ -234,8 +254,9 @@ fbclock_microuptime(struct timeval *tvp)
 void
 fbclock_bintime(struct bintime *bt)
 {
+	struct bintime boottimebin;
 
-	fbclock_binuptime(bt);
+	fbclock_binuptime1(bt, &boottimebin);
 	bintime_add(bt, &boottimebin);
 }
 
@@ -303,12 +324,14 @@ void
 fbclock_getbintime(struct bintime *bt)
 {
 	struct timehands *th;
+	struct bintime boottimebin;
 	unsigned int gen;
 
 	do {
 		th = timehands;
 		gen = atomic_load_acq_int(&th->th_generation);
 		*bt = th->th_offset;
+		boottimebin = th->th_boottime;
 		atomic_thread_fence_acq();
 	} while (gen == 0 || gen != th->th_generation);
 	bintime_add(bt, &boottimebin);
@@ -342,8 +365,8 @@ fbclock_getmicrotime(struct timeval *tvp)
 	} while (gen == 0 || gen != th->th_generation);
 }
 #else /* !FFCLOCK */
-void
-binuptime(struct bintime *bt)
+static void
+binuptime1(struct bintime *bt, struct bintime *boottimebin)
 {
 	struct timehands *th;
 	u_int gen;
@@ -351,13 +374,24 @@ binuptime(struct bintime *bt)
 	do {
 		th = timehands;
 		gen = atomic_load_acq_int(&th->th_generation);
-		*bt = th->th_offset;
-		bintime_addx(bt, th->th_scale * tc_delta(th));
+		if (bt != NULL) {
+			*bt = th->th_offset;
+			bintime_addx(bt, th->th_scale * tc_delta(th));
+		}
+		if (boottimebin != NULL)
+			*boottimebin = th->th_boottime;
 		atomic_thread_fence_acq();
 	} while (gen == 0 || gen != th->th_generation);
 }
 
 void
+binuptime(struct bintime *bt)
+{
+
+	binuptime1(bt, NULL);
+}
+
+void
 nanouptime(struct timespec *tsp)
 {
 	struct bintime bt;
@@ -378,8 +412,9 @@ microuptime(struct timeval *tvp)
 void
 bintime(struct bintime *bt)
 {
+	struct bintime boottimebin;
 
-	binuptime(bt);
+	binuptime1(bt, &boottimebin);
 	bintime_add(bt, &boottimebin);
 }
 
@@ -447,12 +482,14 @@ void
 getbintime(struct bintime *bt)
 {
 	struct timehands *th;
+	struct bintime boottimebin;
 	u_int gen;
 
 	do {
 		th = timehands;
 		gen = atomic_load_acq_int(&th->th_generation);
 		*bt = th->th_offset;
+		boottimebin = th->th_boottime;
 		atomic_thread_fence_acq();
 	} while (gen == 0 || gen != th->th_generation);
 	bintime_add(bt, &boottimebin);
@@ -487,6 +524,22 @@ getmicrotime(struct timeval *tvp)
 }
 #endif /* FFCLOCK */
 
+void
+getboottime(struct timeval *boottime)
+{
+	struct bintime boottimebin;
+
+	binuptime1(NULL, &boottimebin);
+	bintime2timeval(&boottimebin, boottime);
+}
+
+void
+getboottimebin(struct bintime *boottimebin)
+{
+
+	binuptime1(NULL, boottimebin);
+}
+
 #ifdef FFCLOCK
 /*
  * Support for feed-forward synchronization algorithms. This is heavily inspired
@@ -1103,6 +1156,7 @@ int
 sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt,
     int whichclock, uint32_t flags)
 {
+	struct bintime boottimebin;
 #ifdef FFCLOCK
 	struct bintime bt2;
 	uint64_t period;
@@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt,
 		if (cs->delta > 0)
 			bintime_addx(bt, cs->fb_info.th_scale * cs->delta);
 
-		if ((flags & FBCLOCK_UPTIME) == 0)
+		if ((flags & FBCLOCK_UPTIME) == 0) {
+			binuptime1(NULL, &boottimebin);
 			bintime_add(bt, &boottimebin);
+		}
 		break;
 #ifdef FFCLOCK
 	case SYSCLOCK_FFWD:
@@ -1226,10 +1282,12 @@ tc_getfrequency(void)
 	return (timehands->th_counter->tc_frequency);
 }
 
+static struct mtx tc_setclock_mtx;
+MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF);
+
 /*
  * Step our concept of UTC.  This is done by modifying our estimate of
  * when we booted.
- * XXX: not locked.
  */
 void
 tc_setclock(struct timespec *ts)
@@ -1237,26 +1295,43 @@ tc_setclock(struct timespec *ts)
 	struct timespec tbef, taft;
 	struct bintime bt, bt2;
 
-	cpu_tick_calibrate(1);
-	nanotime(&tbef);
 	timespec2bintime(ts, &bt);
+	nanotime(&tbef);
+	mtx_lock(&tc_setclock_mtx);
+	critical_enter();
+	cpu_tick_calibrate(1);
 	binuptime(&bt2);
 	bintime_sub(&bt, &bt2);
-	bintime_add(&bt2, &boottimebin);
-	boottimebin = bt;
-	bintime2timeval(&bt, &boottime);
 
 	/* XXX fiddle all the little crinkly bits around the fiords... */
-	tc_windup();
-	nanotime(&taft);
+	tc_windup(true, &bt);
+	critical_exit();
+	mtx_unlock(&tc_setclock_mtx);
 	if (timestepwarnings) {
+		nanotime(&taft);
 		log(LOG_INFO,
 		    "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n",
 		    (intmax_t)tbef.tv_sec, tbef.tv_nsec,
 		    (intmax_t)taft.tv_sec, taft.tv_nsec,
 		    (intmax_t)ts->tv_sec, ts->tv_nsec);
 	}
-	cpu_tick_calibrate(1);
+}
+
+static volatile int tc_windup_lock;
+static void
+tc_windup(bool top_call, struct bintime *new_boottimebin)
+{
+
+	for (;;) {
+		if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) {
+			atomic_thread_fence_acq();
+			tc_windup_locked(new_boottimebin);
+			atomic_store_rel_int(&tc_windup_lock, 0);
+			break;
+		} else if (!top_call) {
+			break;
+		}
+	}
 }
 
 /*
@@ -1265,7 +1340,7 @@ tc_setclock(struct timespec *ts)
  * timecounter and/or do seconds processing in NTP.  Slightly magic.
  */
 static void
-tc_windup(void)
+tc_windup_locked(struct bintime *new_boottimebin)
 {
 	struct bintime bt;
 	struct timehands *th, *tho;
@@ -1289,6 +1364,8 @@ tc_windup(void)
 	th->th_generation = 0;
 	atomic_thread_fence_rel();
 	bcopy(tho, th, offsetof(struct timehands, th_generation));
+	if (new_boottimebin != NULL)
+		th->th_boottime = *new_boottimebin;
 
 	/*
 	 * Capture a timecounter delta on the current timecounter and if
@@ -1338,7 +1415,7 @@ tc_windup(void)
 	 * case we missed a leap second.
 	 */
 	bt = th->th_offset;
-	bintime_add(&bt, &boottimebin);
+	bintime_add(&bt, &th->th_boottime);
 	i = bt.sec - tho->th_microtime.tv_sec;
 	if (i > LARGE_STEP)
 		i = 2;
@@ -1346,7 +1423,7 @@ tc_windup(void)
 		t = bt.sec;
 		ntp_update_second(&th->th_adjustment, &bt.sec);
 		if (bt.sec != t)
-			boottimebin.sec += bt.sec - t;
+			th->th_boottime.sec += bt.sec - t;
 	}
 	/* Update the UTC timestamps used by the get*() functions. */
 	/* XXX shouldn't do this here.  Should force non-`get' versions. */
@@ -1769,7 +1846,7 @@ pps_event(struct pps_state *pps, int event)
 	tcount &= pps->capth->th_counter->tc_counter_mask;
 	bt = pps->capth->th_offset;
 	bintime_addx(&bt, pps->capth->th_scale * tcount);
-	bintime_add(&bt, &boottimebin);
+	bintime_add(&bt, &pps->capth->th_boottime);
 	bintime2timespec(&bt, &ts);
 
 	/* If the timecounter was wound up underneath us, bail out. */
@@ -1846,7 +1923,7 @@ tc_ticktock(int cnt)
 	if (count < tc_tick)
 		return;
 	count = 0;
-	tc_windup();
+	tc_windup(false, NULL);
 }
 
 static void __inline
@@ -1921,7 +1998,7 @@ inittimecounter(void *dummy)
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
 	(void)timecounter->tc_get_timecount(timecounter);
-	tc_windup();
+	tc_windup(true, NULL);
 }
 
 SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL);
@@ -2095,7 +2172,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th)
 	vdso_th->th_offset_count = th->th_offset_count;
 	vdso_th->th_counter_mask = th->th_counter->tc_counter_mask;
 	vdso_th->th_offset = th->th_offset;
-	vdso_th->th_boottime = boottimebin;
+	vdso_th->th_boottime = th->th_boottime;
 	enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter);
 	if (!vdso_th_enable)
 		enabled = 0;
@@ -2116,8 +2193,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
 	vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask;
 	vdso_th32->th_offset.sec = th->th_offset.sec;
 	*(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac;
-	vdso_th32->th_boottime.sec = boottimebin.sec;
-	*(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac;
+	vdso_th32->th_boottime.sec = th->th_boottime.sec;
+	*(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac;
 	enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter);
 	if (!vdso_th_enable)
 		enabled = 0;
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 148da2b..82710f7 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv)
 	struct timeval delta, tv1, tv2;
 	static struct timeval maxtime, laststep;
 	struct timespec ts;
-	int s;
 
-	s = splclock();
 	microtime(&tv1);
 	delta = *tv;
 	timevalsub(&delta, &tv1);
@@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv)
 				printf("Time adjustment clamped to -1 second\n");
 			}
 		} else {
-			if (tv1.tv_sec == laststep.tv_sec) {
-				splx(s);
+			if (tv1.tv_sec == laststep.tv_sec)
 				return (EPERM);
-			}
 			if (delta.tv_sec > 1) {
 				tv->tv_sec = tv1.tv_sec + 1;
 				printf("Time adjustment clamped to +1 second\n");
@@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv)
 
 	ts.tv_sec = tv->tv_sec;
 	ts.tv_nsec = tv->tv_usec * 1000;
-	mtx_lock(&Giant);
 	tc_setclock(&ts);
 	resettodr();
-	mtx_unlock(&Giant);
 	return (0);
 }
 
diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c
index dbad36d..4bac324 100644
--- a/sys/kern/subr_rtc.c
+++ b/sys/kern/subr_rtc.c
@@ -172,11 +172,11 @@ resettodr(void)
 	if (disable_rtc_set || clock_dev == NULL)
 		return;
 
-	mtx_lock(&resettodr_lock);
 	getnanotime(&ts);
 	timespecadd(&ts, &clock_adj);
 	ts.tv_sec -= utc_offset();
 	/* XXX: We should really set all registered RTCs */
+	mtx_lock(&resettodr_lock);
 	error = CLOCK_SETTIME(clock_dev, &ts);
 	mtx_unlock(&resettodr_lock);
 	if (error != 0)
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index 37139c1..f47ae7c 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
     struct thread *td)
 {
 	struct procdesc *pd;
-	struct timeval pstart;
+	struct timeval pstart, boottime;
 
 	/*
 	 * XXXRW: Perhaps we should cache some more information from the
@@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
 
 		/* Set birth and [acm] times to process start time. */
 		pstart = pd->pd_proc->p_stats->p_start;
+		getboottime(&boottime);
 		timevaladd(&pstart, &boottime);
 		TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim);
 		sb->st_atim = sb->st_birthtim;
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 3b12cf4..4251f71 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d)
 static void
 bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype)
 {
-	struct bintime bt2;
+	struct bintime bt2, boottimebin;
 	struct timeval tsm;
 	struct timespec tsn;
 
 	if ((tstype & BPF_T_MONOTONIC) == 0) {
 		bt2 = *bt;
+		getboottimebin(&boottimebin);
 		bintime_add(&bt2, &boottimebin);
 		bt = &bt2;
 	}
diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c
index d186ba5..7faf99f 100644
--- a/sys/netpfil/ipfw/ip_fw_sockopt.c
+++ b/sys/netpfil/ipfw/ip_fw_sockopt.c
@@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len)
 static void
 export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr)
 {
+	struct timeval boottime;
 
 	cntr->size = sizeof(*cntr);
 
@@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr)
 		cntr->bcnt = counter_u64_fetch(krule->cntr + 1);
 		cntr->timestamp = krule->timestamp;
 	}
-	if (cntr->timestamp > 0)
+	if (cntr->timestamp > 0) {
+		getboottime(&boottime);
 		cntr->timestamp += boottime.tv_sec;
+	}
 }
 
 static void
 export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr)
 {
+	struct timeval boottime;
 
 	if (krule->cntr != NULL) {
 		cntr->pcnt = counter_u64_fetch(krule->cntr);
 		cntr->bcnt = counter_u64_fetch(krule->cntr + 1);
 		cntr->timestamp = krule->timestamp;
 	}
-	if (cntr->timestamp > 0)
+	if (cntr->timestamp > 0) {
+		getboottime(&boottime);
 		cntr->timestamp += boottime.tv_sec;
+	}
 }
 
 /*
@@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space)
 	char *ep = bp + space;
 	struct ip_fw *rule;
 	struct ip_fw_rule0 *dst;
+	struct timeval boottime;
 	int error, i, l, warnflag;
 	time_t	boot_seconds;
 
 	warnflag = 0;
 
+	getboottime(&boottime);
         boot_seconds = boottime.tv_sec;
 	for (i = 0; i < chain->n_rules; i++) {
 		rule = chain->map[i];
diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c
index 7d11672..c84413e 100644
--- a/sys/nfs/nfs_lock.c
+++ b/sys/nfs/nfs_lock.c
@@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap)
 	struct flock *fl;
 	struct proc *p;
 	struct nfsmount *nmp;
+	struct timeval boottime;
 
 	td = curthread;
 	p = td->td_proc;
@@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap)
 		p->p_nlminfo = malloc(sizeof(struct nlminfo),
 		    M_NLMINFO, M_WAITOK | M_ZERO);
 		p->p_nlminfo->pid_start = p->p_stats->p_start;
+		getboottime(&boottime);
 		timevaladd(&p->p_nlminfo->pid_start, &boottime);
 	}
 	msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start;
diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
index 1d07943..0879299 100644
--- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
+++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
@@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id)
 {
 	struct svc_rpc_gss_client *client;
 	struct svc_rpc_gss_client_list *list;
+	struct timeval boottime;
 	unsigned long hostid;
 
 	rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id);
 
 	getcredhostid(curthread->td_ucred, &hostid);
+	getboottime(&boottime);
 	if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec)
 		return (NULL);
 
@@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void)
 {
 	struct svc_rpc_gss_client *client;
 	struct svc_rpc_gss_client_list *list;
+	struct timeval boottime;
 	unsigned long hostid;
 
 	rpc_gss_log_debug("in svc_rpc_gss_create_client()");
@@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void)
 	sx_init(&client->cl_lock, "GSS-client");
 	getcredhostid(curthread->td_ucred, &hostid);
 	client->cl_id.ci_hostid = hostid;
+	getboottime(&boottime);
 	client->cl_id.ci_boottime = boottime.tv_sec;
 	client->cl_id.ci_id = svc_rpc_gss_next_clientid++;
 	list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
diff --git a/sys/sys/time.h b/sys/sys/time.h
index 395e888..659f8e0 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -372,8 +372,6 @@ void	resettodr(void);
 
 extern volatile time_t	time_second;
 extern volatile time_t	time_uptime;
-extern struct bintime boottimebin;
-extern struct timeval boottime;
 extern struct bintime tc_tick_bt;
 extern sbintime_t tc_tick_sbt;
 extern struct bintime tick_bt;
@@ -440,6 +438,9 @@ void	getbintime(struct bintime *bt);
 void	getnanotime(struct timespec *tsp);
 void	getmicrotime(struct timeval *tvp);
 
+void	getboottime(struct timeval *boottime);
+void	getboottimebin(struct bintime *boottimebin);
+
 /* Other functions */
 int	itimerdecr(struct itimerval *itp, int usec);
 int	itimerfix(struct timeval *tv);

From owner-svn-src-all@freebsd.org  Fri Jul  1 03:21:52 2016
Return-Path: 
Delivered-To: svn-src-all@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 B2D9CB86299;
 Fri,  1 Jul 2016 03:21:52 +0000 (UTC) (envelope-from gjb@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 84A142D0A;
 Fri,  1 Jul 2016 03:21:52 +0000 (UTC) (envelope-from gjb@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u613Lppo070217;
 Fri, 1 Jul 2016 03:21:51 GMT (envelope-from gjb@FreeBSD.org)
Received: (from gjb@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u613LpBM070216;
 Fri, 1 Jul 2016 03:21:51 GMT (envelope-from gjb@FreeBSD.org)
Message-Id: <201607010321.u613LpBM070216@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org
 using -f
From: Glen Barber 
Date: Fri, 1 Jul 2016 03:21:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-svnadmin@freebsd.org
Subject: svn commit: r302304 - svnadmin/conf
X-SVN-Group: svnadmin
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.22
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: Fri, 01 Jul 2016 03:21:52 -0000

Author: gjb
Date: Fri Jul  1 03:21:51 2016
New Revision: 302304
URL: https://svnweb.freebsd.org/changeset/base/302304

Log:
  Premptively create the mail hook for stable/11 commits.
  
  Although we are a week away from stable/11 being branched,
  the mailing list was created early.
  
  Thanks to:	postmaster (flo)
  Sponsored by:	The FreeBSD Foundation

Modified:
  svnadmin/conf/mailer.conf

Modified: svnadmin/conf/mailer.conf
==============================================================================
--- svnadmin/conf/mailer.conf	Fri Jul  1 00:00:35 2016	(r302303)
+++ svnadmin/conf/mailer.conf	Fri Jul  1 03:21:51 2016	(r302304)
@@ -341,6 +341,10 @@ to_addr = src-committers@freebsd.org svn
 for_paths = ^head(/[^/]+)*$
 to_addr = src-committers@freebsd.org svn-src-all@freebsd.org svn-src-head@freebsd.org
 
+[stable-11]
+for_paths = ^stable/11(/[^/]+)*$
+to_addr = src-committers@freebsd.org svn-src-all@freebsd.org svn-src-stable@freebsd.org svn-src-stable-11@freebsd.org
+
 [stable-10]
 for_paths = ^stable/10(/[^/]+)*$
 to_addr = src-committers@freebsd.org svn-src-all@freebsd.org svn-src-stable@freebsd.org svn-src-stable-10@freebsd.org

From owner-svn-src-all@freebsd.org  Fri Jul  1 04:57:25 2016
Return-Path: 
Delivered-To: svn-src-all@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 C3FD7B882A0;
 Fri,  1 Jul 2016 04:57:25 +0000 (UTC)
 (envelope-from loos.br@gmail.com)
Received: from mail-io0-x234.google.com (mail-io0-x234.google.com
 [IPv6:2607:f8b0:4001:c06::234])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 901732E2A;
 Fri,  1 Jul 2016 04:57:25 +0000 (UTC)
 (envelope-from loos.br@gmail.com)
Received: by mail-io0-x234.google.com with SMTP id g13so90516520ioj.1;
 Thu, 30 Jun 2016 21:57:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:from:date:message-id:subject:to
 :cc; bh=efwvS/T7tApG37h5iYiIkvR9hnMV6a9eAnQPqTktOI4=;
 b=WVxCffz9Y1I6bUIS0Ucb6+OJ9NWIL/Kxx+YwVvb+ThDGMVmyy2P6OBXM2L5011kgm4
 MJo+SONV7fTTIVNQY9eoWX252Wn6Uk2CyWLeMrrzkV1jTlMt1oNkoCjl/9b6ccha/SR/
 UgxXhImFcREd3A+KmiHIrYt7J7UzJlQNXqIRmKtTL3SikAnc2HUW3j3VE6SfW5WVsKqM
 MU4hGYx2IrvYyJ5xfhQwC66VZPhA8j6RSBDaarruMz4TlAeZgQ1IWWDG/XPsEaOra/Pj
 9AG6/XxpIPA0yXPkzj2Ucu2kiSbW4qHyxA7neU2+KUZkdOPEMp3JnNL17UHJ+MQHUXz2
 vouA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:in-reply-to:references:from:date
 :message-id:subject:to:cc;
 bh=efwvS/T7tApG37h5iYiIkvR9hnMV6a9eAnQPqTktOI4=;
 b=Yee6mL2CzwTR7p4JVcw9c5yV8jUIPV0kU+QpsPuqloBnGm5X7Pq4rllswYwAHBIwat
 hXGBj/ODOYN0SFB75rXKWBJUCNZzgaEEn0FfT2emnde0kgW9dLmtQADBS5BS+gT72AKX
 vzUOp5cEg45Q94uJisu3pGN4O5NCikl2uf3ybmCi8iqRWmr/hKKNxsr6DiGqS7as8FO4
 ksEF6pSDDMcMJoatM8RbYPpMhEx/zE7id8IycItkZ9gFzsqm0XvLv/xvSPKQiZYStQ5P
 fr3xlMIgK9gynY6JD14PhM9DkymBkOG1eanU6g4sR/wm1ius3MANPo9hz0i16oJ3u0Zd
 wsjQ==
X-Gm-Message-State: ALyK8tLCMlaPzdaSVByDFXaxROA1vlNqrRFFGLQ34Vpu6AdaVobzUxPlCH6OqASxLOtPMj+HwR1EcHm+jJc01w==
X-Received: by 10.107.138.6 with SMTP id m6mr17198942iod.181.1467349044873;
 Thu, 30 Jun 2016 21:57:24 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.33.132 with HTTP; Thu, 30 Jun 2016 21:57:24 -0700 (PDT)
In-Reply-To: <201606171821.u5HILudm021649@repo.freebsd.org>
References: <201606171821.u5HILudm021649@repo.freebsd.org>
From: Luiz Otavio O Souza 
Date: Fri, 1 Jul 2016 01:57:24 -0300
Message-ID: 
Subject: Re: svn commit: r301998 - in head: sbin/pfctl share/man/man5 sys/net
 sys/netpfil/pf
To: Kristof Provost 
Cc: src-committers ,
 svn-src-all , 
 svn-src-head 
Content-Type: text/plain; charset=UTF-8
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.22
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: Fri, 01 Jul 2016 04:57:25 -0000

On Fri, Jun 17, 2016 at 3:21 PM, Kristof Provost wrote:
> Author: kp
> Date: Fri Jun 17 18:21:55 2016
> New Revision: 301998
> URL: https://svnweb.freebsd.org/changeset/base/301998
>
> Log:
>   pf: Filter on and set vlan PCP values
>
>   Adopt the OpenBSD syntax for setting and filtering on VLAN PCP values. This
>   introduces two new keywords: 'set prio' to set the PCP value, and 'prio' to
>   filter on it.
>
>   Reviewed by:    allanjude, araujo
>   Approved by:  re (gjb)
>   Obtained from:  OpenBSD (mostly)
>   Differential Revision:  https://reviews.freebsd.org/D6786

Thanks Kristof!

Luiz

From owner-svn-src-all@freebsd.org  Fri Jul  1 05:48:47 2016
Return-Path: 
Delivered-To: svn-src-all@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 59F83B8C899;
 Fri,  1 Jul 2016 05:48:47 +0000 (UTC)
 (envelope-from delphij@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 1E74B2C5F;
 Fri,  1 Jul 2016 05:48:47 +0000 (UTC)
 (envelope-from delphij@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u615mkqZ023149;
 Fri, 1 Jul 2016 05:48:46 GMT (envelope-from delphij@FreeBSD.org)
Received: (from delphij@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u615mjSU023139;
 Fri, 1 Jul 2016 05:48:45 GMT (envelope-from delphij@FreeBSD.org)
Message-Id: <201607010548.u615mjSU023139@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: delphij set sender to
 delphij@FreeBSD.org using -f
From: Xin LI 
Date: Fri, 1 Jul 2016 05:48:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r302305 - in head/contrib/expat: . doc examples lib tests
 tests/benchmark xmlwf
X-SVN-Group: head
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.22
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: Fri, 01 Jul 2016 05:48:47 -0000

Author: delphij
Date: Fri Jul  1 05:48:45 2016
New Revision: 302305
URL: https://svnweb.freebsd.org/changeset/base/302305

Log:
  MFV r302260: expat 2.2.0
  
  Approved by:	re (kib)

Added:
  head/contrib/expat/configure.ac
     - copied unchanged from r302260, vendor/expat/dist/configure.ac
  head/contrib/expat/doc/xmlwf.xml
     - copied unchanged from r302260, vendor/expat/dist/doc/xmlwf.xml
Deleted:
  head/contrib/expat/configure.in
  head/contrib/expat/doc/xmlwf.sgml
Modified:
  head/contrib/expat/COPYING
  head/contrib/expat/Changes
  head/contrib/expat/MANIFEST
  head/contrib/expat/Makefile.in
  head/contrib/expat/README
  head/contrib/expat/doc/expat.png   (contents, props changed)
  head/contrib/expat/doc/reference.html
  head/contrib/expat/doc/xmlwf.1
  head/contrib/expat/examples/elements.c
  head/contrib/expat/examples/outline.c
  head/contrib/expat/expat_config.h.in
  head/contrib/expat/lib/expat.h
  head/contrib/expat/lib/expat_external.h
  head/contrib/expat/lib/internal.h
  head/contrib/expat/lib/xmlparse.c
  head/contrib/expat/lib/xmlrole.c
  head/contrib/expat/lib/xmltok.c
  head/contrib/expat/lib/xmltok.h
  head/contrib/expat/lib/xmltok_impl.c
  head/contrib/expat/tests/benchmark/README.txt
  head/contrib/expat/tests/chardata.c
  head/contrib/expat/tests/minicheck.c
  head/contrib/expat/tests/minicheck.h
  head/contrib/expat/tests/runtests.c
  head/contrib/expat/tests/xmltest.sh
  head/contrib/expat/xmlwf/codepage.c
  head/contrib/expat/xmlwf/readfilemap.c
  head/contrib/expat/xmlwf/unixfilemap.c
  head/contrib/expat/xmlwf/xmlfile.c
  head/contrib/expat/xmlwf/xmlwf.c
Directory Properties:
  head/contrib/expat/   (props changed)

Modified: head/contrib/expat/COPYING
==============================================================================
--- head/contrib/expat/COPYING	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/COPYING	Fri Jul  1 05:48:45 2016	(r302305)
@@ -1,6 +1,5 @@
-Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-                               and Clark Cooper
-Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
+Copyright (c) 2001-2016 Expat maintainers
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the

Modified: head/contrib/expat/Changes
==============================================================================
--- head/contrib/expat/Changes	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/Changes	Fri Jul  1 05:48:45 2016	(r302305)
@@ -1,3 +1,67 @@
+Release 2.2.0 Tue June 21 2016
+        Security fixes:
+            #537  CVE-2016-0718 -- Fix crash on malformed input
+                  CVE-2016-4472 -- Improve insufficient fix to CVE-2015-1283 /
+                                   CVE-2015-2716 introduced with Expat 2.1.1
+            #499  CVE-2016-5300 -- Use more entropy for hash initialization
+                                   than the original fix to CVE-2012-0876
+            #519  CVE-2012-6702 -- Resolve troublesome internal call to srand
+                                   that was introduced with Expat 2.1.0
+                                   when addressing CVE-2012-0876 (issue #496)
+
+        Bug fixes:
+                  Fix uninitialized reads of size 1
+                    (e.g. in little2_updatePosition)
+                  Fix detection of UTF-8 character boundaries
+
+        Other changes:
+            #532  Fix compilation for Visual Studio 2010 (keyword "C99")
+                  Autotools: Resolve use of "$<" to better support bmake
+                  Autotools: Add QA script "qa.sh" (and make target "qa")
+                  Autotools: Respect CXXFLAGS if given
+                  Autotools: Fix "make run-xmltest"
+                  Autotools: Have "make run-xmltest" check for expected output
+             p90  CMake: Fix static build (BUILD_shared=OFF) on Windows
+            #536  CMake: Add soversion, support -DNO_SONAME=yes to bypass
+            #323  CMake: Add suffix "d" to differentiate debug from release
+                  CMake: Define WIN32 with CMake on Windows
+                  Annotate memory allocators for GCC
+                  Address all currently known compile warnings
+                  Make sure that API symbols remain visible despite
+                    -fvisibility=hidden
+                  Remove executable flag from source files
+                  Resolve COMPILED_FROM_DSP in favor of WIN32
+
+        Special thanks to:
+            Björn Lindahl
+            Christian Heimes
+            Cristian Rodríguez
+            Daniel Krügler
+            Gustavo Grieco
+            Karl Waclawek
+            László Böszörményi
+            Marco Grassi
+            Pascal Cuoq
+            Sergei Nikulov
+            Thomas Beutlich
+            Warren Young
+            Yann Droneaud
+
+Release 2.1.1 Sat March 12 2016
+        Security fixes:
+            #582: CVE-2015-1283 - Multiple integer overflows in XML_GetBuffer
+
+        Bug fixes:
+            #502: Fix potential null pointer dereference
+            #520: Symbol XML_SetHashSalt was not exported
+            Output of "xmlwf -h" was incomplete
+
+        Other changes:
+            #503: Document behavior of calling XML_SetHashSalt with salt 0
+            Minor improvements to man page xmlwf(1)
+            Improvements to the experimental CMake build system
+            libtool now invoked with --verbose
+
 Release 2.1.0 Sat March 24 2012
         - Bug Fixes:
           #1742315: Harmful XML_ParserCreateNS suggestion.
@@ -23,7 +87,7 @@ Release 2.1.0 Sat March 24 2012
           #3312568: CMake support.
           #3446384: Report byte offsets for attr names and values.
         - New Features / API changes:
-          Added new API member XML_SetHashSalt() that allows setting an intial
+          Added new API member XML_SetHashSalt() that allows setting an initial
                 value (salt) for hash calculations. This is part of the fix for
                 bug #3496608 to randomize hash parameters.
           When compiled with XML_ATTR_INFO defined, adds new API member

Modified: head/contrib/expat/MANIFEST
==============================================================================
--- head/contrib/expat/MANIFEST	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/MANIFEST	Fri Jul  1 05:48:45 2016	(r302305)
@@ -44,7 +44,7 @@ doc/reference.html
 doc/style.css
 doc/valid-xhtml10.png
 doc/xmlwf.1
-doc/xmlwf.sgml
+doc/xmlwf.xml
 CMakeLists.txt
 CMake.README
 COPYING
@@ -54,7 +54,7 @@ MANIFEST
 Makefile.in
 README
 configure
-configure.in
+configure.ac
 expat_config.h.in
 expat_config.h.cmake
 expat.pc.in

Modified: head/contrib/expat/Makefile.in
==============================================================================
--- head/contrib/expat/Makefile.in	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/Makefile.in	Fri Jul  1 05:48:45 2016	(r302305)
@@ -42,7 +42,7 @@ INSTALL_DATA = @INSTALL_DATA@
 mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs
 
 MANFILE = $(srcdir)/doc/xmlwf.1
-APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h
+APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h expat_config.h
 LIBRARY = libexpat.la
 
 DESTDIR = $(INSTALL_ROOT)
@@ -51,7 +51,7 @@ default:  buildlib xmlwf/xmlwf@EXEEXT@
 
 buildlib: $(LIBRARY) expat.pc
 
-all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline
+all: $(LIBRARY) expat.pc xmlwf/xmlwf@EXEEXT@ examples/elements examples/outline $(MANFILE)
 
 clean:
 	cd lib && rm -f $(LIBRARY) *.@OBJEXT@ *.lo && rm -rf .libs _libs
@@ -77,7 +77,10 @@ check: tests/runtests tests/runtestspp
 	tests/runtests
 	tests/runtestspp
 
-install: xmlwf/xmlwf@EXEEXT@ installlib
+$(MANFILE):
+	$(MAKE) -C doc xmlwf.1
+
+install: xmlwf/xmlwf@EXEEXT@ installlib $(MANFILE)
 	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
 	$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) xmlwf/xmlwf@EXEEXT@ $(DESTDIR)$(bindir)/xmlwf
 	$(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(man1dir)
@@ -116,7 +119,7 @@ CXXFLAGS = @CXXFLAGS@
 VSNFLAG = -version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
 
 ### autoconf this?
-LTFLAGS = --silent
+LTFLAGS = --verbose
 
 COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(DEFS) $(CPPFLAGS)
 CXXCOMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) $(DEFS) $(CPPFLAGS)
@@ -154,11 +157,11 @@ xmlwf/xmlwf@EXEEXT@: $(XMLWF_OBJS) $(LIB
 
 examples/elements.@OBJEXT@: examples/elements.c
 examples/elements: examples/elements.@OBJEXT@ $(LIBRARY)
-	$(LINK_EXE) $< $(LIBRARY)
+	$(LINK_EXE) examples/elements.@OBJEXT@ $(LIBRARY)
 
 examples/outline.@OBJEXT@: examples/outline.c
 examples/outline: examples/outline.@OBJEXT@ $(LIBRARY)
-	$(LINK_EXE) $< $(LIBRARY)
+	$(LINK_EXE) examples/outline.@OBJEXT@ $(LIBRARY)
 
 tests/chardata.@OBJEXT@: tests/chardata.c tests/chardata.h
 tests/minicheck.@OBJEXT@: tests/minicheck.c tests/minicheck.h
@@ -180,11 +183,19 @@ tests/xmlts.zip:
 	wget --output-document=tests/xmlts.zip \
 		http://www.w3.org/XML/Test/xmlts20080827.zip
 
-tests/XML-Test-Suite: tests/xmlts.zip
+tests/xmlconf: tests/xmlts.zip
 	cd tests && unzip -q xmlts.zip
 
-run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/XML-Test-Suite
-	tests/xmltest.sh
+run-xmltest: xmlwf/xmlwf@EXEEXT@ tests/xmlconf
+	tests/xmltest.sh 2>&1 | tee tests/xmltest.log
+	diff -u tests/xmltest.log.expected tests/xmltest.log
+
+.PHONY: qa
+qa:
+	./qa.sh address
+	./qa.sh memory
+	./qa.sh undefined
+	./qa.sh coverage
 
 .SUFFIXES: .c .cpp .lo .@OBJEXT@
 

Modified: head/contrib/expat/README
==============================================================================
--- head/contrib/expat/README	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/README	Fri Jul  1 05:48:45 2016	(r302305)
@@ -1,5 +1,5 @@
 
-                        Expat, Release 2.1.0
+                        Expat, Release 2.2.0
 
 This is Expat, a C library for parsing XML, written by James Clark.
 Expat is a stream-oriented XML parser.  This means that you register
@@ -114,7 +114,7 @@ Note for Solaris users:  The "ar" comman
 "/usr/ccs/bin", which is not in the default PATH.  You will need to
 add this to your path for the "make" command, and probably also switch
 to GNU make (the "make" found in /usr/ccs/bin does not seem to work
-properly -- appearantly it does not understand .PHONY directives).  If
+properly -- apparently it does not understand .PHONY directives).  If
 you're using ksh or bash, use this command to build:
 
         PATH=/usr/ccs/bin:$PATH make

Copied: head/contrib/expat/configure.ac (from r302260, vendor/expat/dist/configure.ac)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/expat/configure.ac	Fri Jul  1 05:48:45 2016	(r302305, copy of r302260, vendor/expat/dist/configure.ac)
@@ -0,0 +1,157 @@
+dnl   configuration script for expat
+dnl   Process this file with autoconf to produce a configure script.
+dnl
+dnl   Copyright 2000 Clark Cooper
+dnl
+dnl   This file is part of EXPAT.
+dnl
+dnl   EXPAT is free software; you can redistribute it and/or modify it
+dnl   under the terms of the License (based on the MIT/X license) contained
+dnl   in the file COPYING that comes with this distribution.
+dnl
+
+dnl Ensure that Expat is configured with autoconf 2.58 or newer
+AC_PREREQ(2.58)
+
+dnl Get the version number of Expat, using m4's esyscmd() command to run
+dnl the command at m4-generation time. This allows us to create an m4
+dnl symbol holding the correct version number. AC_INIT() requires the
+dnl version number at m4-time, rather than when ./configure is run, so
+dnl all this must happen as part of m4, not as part of the shell code
+dnl contained in ./configure.
+dnl
+dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
+dnl test. I believe this test will work, but I don't have a place with non-
+dnl GNU M4 to test it right now.
+define([expat_version], ifdef([__gnu__],
+                              [esyscmd(conftools/get-version.sh lib/expat.h)],
+                              [2.2.x]))
+AC_INIT(expat, expat_version, expat-bugs@libexpat.org)
+undefine([expat_version])
+
+AC_CONFIG_SRCDIR(Makefile.in)
+AC_CONFIG_AUX_DIR(conftools)
+AC_CONFIG_MACRO_DIR([m4])
+
+
+dnl
+dnl Increment LIBREVISION if source code has changed at all
+dnl
+dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
+dnl
+dnl If the API changes compatibly (i.e. simply adding a new function
+dnl without changing or removing earlier interfaces), then increment LIBAGE.
+dnl 
+dnl If the API changes incompatibly set LIBAGE back to 0
+dnl
+
+LIBCURRENT=7   # sync
+LIBREVISION=2  # with
+LIBAGE=6       # CMakeLists.txt!
+
+AC_CONFIG_HEADER(expat_config.h)
+
+sinclude(conftools/ac_c_bigendian_cross.m4)
+
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+
+AC_SUBST(LIBCURRENT)
+AC_SUBST(LIBREVISION)
+AC_SUBST(LIBAGE)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_INSTALL
+
+if test "$GCC" = yes ; then
+    dnl
+    dnl Be careful about adding the -fexceptions option; some versions of
+    dnl GCC don't support it and it causes extra warnings that are only
+    dnl distracting; avoid.
+    dnl
+    OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
+    CFLAGS="$OLDCFLAGS -fexceptions"
+    AC_MSG_CHECKING(whether $CC accepts -fexceptions)
+    AC_TRY_LINK( , ,
+                   AC_MSG_RESULT(yes),
+                   AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
+    if test "x$CXXFLAGS" = x ; then
+    CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
+    fi
+fi
+
+dnl Checks for header files.
+AC_HEADER_STDC
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+
+dnl Note: Avoid using AC_C_BIGENDIAN because it does not
+dnl work in a cross compile.
+AC_C_BIGENDIAN_CROSS
+
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_CHECK_FUNCS(memmove bcopy)
+
+dnl Only needed for xmlwf:
+AC_CHECK_HEADERS(fcntl.h unistd.h)
+AC_TYPE_OFF_T
+AC_FUNC_MMAP
+
+if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
+    FILEMAP=unixfilemap
+else
+    FILEMAP=readfilemap
+fi
+AC_SUBST(FILEMAP)
+
+dnl Needed for the test support code; this was found at
+dnl http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html
+
+# AC_CPP_FUNC
+# ------------------ #
+# Checks to see if ANSI C99 CPP variable __func__ works.
+# If not, perhaps __FUNCTION__ works instead. 
+# If not, we'll just define __func__ to "". 
+AC_DEFUN([AC_CPP_FUNC],
+[AC_REQUIRE([AC_PROG_CC_STDC])dnl
+AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
+[[char *foo = __func__;]])],
+  [ac_cv_cpp_func=yes], 
+  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
+[[char *foo = __FUNCTION__;]])],
+  [ac_cv_cpp_func=__FUNCTION__], 
+  [ac_cv_cpp_func=no])])])
+if test $ac_cv_cpp_func = __FUNCTION__; then
+  AC_DEFINE(__func__,__FUNCTION__,
+            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
+ANSI C.])
+elif test $ac_cv_cpp_func = no; then
+  AC_DEFINE(__func__,"",
+            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
+ANSI C.])
+fi
+])# AC_CPP_FUNC
+
+AC_CPP_FUNC
+
+
+dnl Some basic configuration:
+AC_DEFINE([XML_NS], 1,
+          [Define to make XML Namespaces functionality available.])
+AC_DEFINE([XML_DTD], 1,
+          [Define to make parameter entity parsing functionality available.])
+AC_DEFINE([XML_CONTEXT_BYTES], 1024,
+          [Define to specify how much context to retain around the current parse point.])
+
+AC_CONFIG_FILES([Makefile expat.pc])
+AC_OUTPUT
+
+abs_srcdir="`cd $srcdir && pwd`"
+abs_builddir="`pwd`"
+if test "$abs_srcdir" != "$abs_builddir"; then
+  make mkdir-init
+fi

Modified: head/contrib/expat/doc/expat.png
==============================================================================
Binary file (source and/or target). No diff available.

Modified: head/contrib/expat/doc/reference.html
==============================================================================
--- head/contrib/expat/doc/reference.html	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/doc/reference.html	Fri Jul  1 05:48:45 2016	(r302305)
@@ -2151,8 +2151,12 @@ Helps in preventing DoS attacks based on
 function behavior. In order to have an effect this must be called
 before parsing has started. Returns 1 if successful, 0 when called
 after XML_Parse or XML_ParseBuffer.
-

Note: This call is optional, as the parser will auto-generate a new -random salt value if no value has been set at the start of parsing.

+

Note:This call is optional, as the parser will auto-generate +a new random salt value if no value has been set at the start of parsing. +

Note:One should not call XML_SetHashSalt with a +hash salt value of 0, as this value is used as sentinel value to indicate +that XML_SetHashSalt has not been called. Consequently +such a call will have no effect, even if it returns 1.


Modified: head/contrib/expat/doc/xmlwf.1
==============================================================================
--- head/contrib/expat/doc/xmlwf.1	Fri Jul  1 03:21:51 2016	(r302304)
+++ head/contrib/expat/doc/xmlwf.1	Fri Jul  1 05:48:45 2016	(r302305)
@@ -1,33 +1,40 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\"  
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng .
-.TH "XMLWF" "1" "24 January 2003" "" ""
+'\" -*- coding: us-ascii -*-
+.if \n(.g .ds T< \\FC
+.if \n(.g .ds T> \\F[\n[.fam]]
+.de URL
+\\$2 \(la\\$1\(ra\\$3
+..
+.if \n(.g .mso www.tmac
+.TH XMLWF 1 "March 11, 2016" "" ""
 .SH NAME
 xmlwf \- Determines if an XML document is well-formed
 .SH SYNOPSIS
-
-\fBxmlwf\fR [ \fB-s\fR]  [ \fB-n\fR]  [ \fB-p\fR]  [ \fB-x\fR]  [ \fB-e \fIencoding\fB\fR]  [ \fB-w\fR]  [ \fB-d \fIoutput-dir\fB\fR]  [ \fB-c\fR]  [ \fB-m\fR]  [ \fB-r\fR]  [ \fB-t\fR]  [ \fB-v\fR]  [ \fBfile ...\fR] 
-
-.SH "DESCRIPTION"
-.PP
+'nh
+.fi
+.ad l
+\fBxmlwf\fR \kx
+.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
+'in \n(.iu+\nxu
+[\fB-s\fR] [\fB-n\fR] [\fB-p\fR] [\fB-x\fR] [\fB-e \fIencoding\fB\fR] [\fB-w\fR] [\fB-d \fIoutput-dir\fB\fR] [\fB-c\fR] [\fB-m\fR] [\fB-r\fR] [\fB-t\fR] [\fB-v\fR] [file ...]
+'in \n(.iu-\nxu
+.ad b
+'hy
+.SH DESCRIPTION
 \fBxmlwf\fR uses the Expat library to
-determine if an XML document is well-formed.  It is
+determine if an XML document is well-formed. It is
 non-validating.
 .PP
 If you do not specify any files on the command-line, and you
 have a recent version of \fBxmlwf\fR, the
 input file will be read from standard input.
 .SH "WELL-FORMED DOCUMENTS"
-.PP
 A well-formed document must adhere to the
 following rules:
 .TP 0.2i
 \(bu
-The file begins with an XML declaration.  For instance,
-.
-\fBNOTE:\fR
+The file begins with an XML declaration. For instance,
+\*(T<\*(T>.
+\fINOTE:\fR
 \fBxmlwf\fR does not currently
 check for a valid XML declaration.
 .TP 0.2i
@@ -36,8 +43,8 @@ Every start tag is either empty ()
 or has a corresponding end tag.
 .TP 0.2i
 \(bu
-There is exactly one root element.  This element must contain
-all other elements in the document.  Only comments, white
+There is exactly one root element. This element must contain
+all other elements in the document. Only comments, white
 space, and processing instructions may come after the close
 of the root element.
 .TP 0.2i
@@ -49,39 +56,38 @@ All attribute values are enclosed in quo
 or double).
 .PP
 If the document has a DTD, and it strictly complies with that
-DTD, then the document is also considered \fBvalid\fR.
+DTD, then the document is also considered \fIvalid\fR.
 \fBxmlwf\fR is a non-validating parser --
-it does not check the DTD.  However, it does support
-external entities (see the \fB-x\fR option).
-.SH "OPTIONS"
-.PP
+it does not check the DTD. However, it does support
+external entities (see the \*(T<\fB\-x\fR\*(T> option).
+.SH OPTIONS
 When an option includes an argument, you may specify the argument either
-separately ("\fB-d\fR output") or concatenated with the
-option ("\fB-d\fRoutput").  \fBxmlwf\fR
+separately ("\*(T<\fB\-d\fR\*(T> output") or concatenated with the
+option ("\*(T<\fB\-d\fR\*(T>output"). \fBxmlwf\fR
 supports both.
-.TP
-\fB-c\fR
+.TP 
+\*(T<\fB\-c\fR\*(T>
 If the input file is well-formed and \fBxmlwf\fR
 doesn't encounter any errors, the input file is simply copied to
 the output directory unchanged.
-This implies no namespaces (turns off \fB-n\fR) and
-requires \fB-d\fR to specify an output file.
-.TP
-\fB-d output-dir\fR
+This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
+requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-d output\-dir\fR\*(T>
 Specifies a directory to contain transformed
 representations of the input files.
-By default, \fB-d\fR outputs a canonical representation
+By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
 (described below).
-You can select different output formats using \fB-c\fR
-and \fB-m\fR.
+You can select different output formats using \*(T<\fB\-c\fR\*(T>
+and \*(T<\fB\-m\fR\*(T>.
 
 The output filenames will
 be exactly the same as the input filenames or "STDIN" if the input is
-coming from standard input.  Therefore, you must be careful that the
+coming from standard input. Therefore, you must be careful that the
 output file does not go into the same directory as the input
-file.  Otherwise, \fBxmlwf\fR will delete the
+file. Otherwise, \fBxmlwf\fR will delete the
 input file before it generates the output file (just like running
-cat < file > file in most shells).
+\*(T file\*(T> in most shells).
 
 Two structurally equivalent XML documents have a byte-for-byte
 identical canonical XML representation.
@@ -89,39 +95,39 @@ Note that ignorable white space is consi
 is treated equivalently to data.
 More on canonical XML can be found at
 http://www.jclark.com/xml/canonxml.html .
-.TP
-\fB-e encoding\fR
+.TP 
+\*(T<\fB\-e encoding\fR\*(T>
 Specifies the character encoding for the document, overriding
-any document encoding declaration.  \fBxmlwf\fR
+any document encoding declaration. \fBxmlwf\fR
 supports four built-in encodings:
-US-ASCII,
-UTF-8,
-UTF-16, and
-ISO-8859-1.
-Also see the \fB-w\fR option.
-.TP
-\fB-m\fR
+\*(T,
+\*(T,
+\*(T, and
+\*(T.
+Also see the \*(T<\fB\-w\fR\*(T> option.
+.TP 
+\*(T<\fB\-m\fR\*(T>
 Outputs some strange sort of XML file that completely
 describes the input file, including character positions.
-Requires \fB-d\fR to specify an output file.
-.TP
-\fB-n\fR
-Turns on namespace processing.  (describe namespaces)
-\fB-c\fR disables namespaces.
-.TP
-\fB-p\fR
+Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
+.TP 
+\*(T<\fB\-n\fR\*(T>
+Turns on namespace processing. (describe namespaces)
+\*(T<\fB\-c\fR\*(T> disables namespaces.
+.TP 
+\*(T<\fB\-p\fR\*(T>
 Tells xmlwf to process external DTDs and parameter
 entities.
 
 Normally \fBxmlwf\fR never parses parameter
-entities.  \fB-p\fR tells it to always parse them.
-\fB-p\fR implies \fB-x\fR.
-.TP
-\fB-r\fR
+entities. \*(T<\fB\-p\fR\*(T> tells it to always parse them.
+\*(T<\fB\-p\fR\*(T> implies \*(T<\fB\-x\fR\*(T>.
+.TP 
+\*(T<\fB\-r\fR\*(T>
 Normally \fBxmlwf\fR memory-maps the XML file
 before parsing; this can result in faster parsing on many
 platforms.
-\fB-r\fR turns off memory-mapping and uses normal file
+\*(T<\fB\-r\fR\*(T> turns off memory-mapping and uses normal file
 IO calls instead.
 Of course, memory-mapping is automatically turned off
 when reading from standard input.
@@ -131,34 +137,33 @@ substantially higher memory usage for
 \fBxmlwf\fR, but this appears to be a matter of
 the operating system reporting memory in a strange way; there is
 not a leak in \fBxmlwf\fR.
-.TP
-\fB-s\fR
+.TP 
+\*(T<\fB\-s\fR\*(T>
 Prints an error if the document is not standalone. 
 A document is standalone if it has no external subset and no
 references to parameter entities.
-.TP
-\fB-t\fR
-Turns on timings.  This tells Expat to parse the entire file,
+.TP 
+\*(T<\fB\-t\fR\*(T>
+Turns on timings. This tells Expat to parse the entire file,
 but not perform any processing.
 This gives a fairly accurate idea of the raw speed of Expat itself
 without client overhead.
-\fB-t\fR turns off most of the output options
-(\fB-d\fR, \fB-m\fR, \fB-c\fR,
-\&...).
-.TP
-\fB-v\fR
+\*(T<\fB\-t\fR\*(T> turns off most of the output options
+(\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-m\fR\*(T>, \*(T<\fB\-c\fR\*(T>, ...).
+.TP 
+\*(T<\fB\-v\fR\*(T>
 Prints the version of the Expat library being used, including some
 information on the compile-time configuration of the library, and
 then exits.
-.TP
-\fB-w\fR
+.TP 
+\*(T<\fB\-w\fR\*(T>
 Enables support for Windows code pages.
 Normally, \fBxmlwf\fR will throw an error if it
-runs across an encoding that it is not equipped to handle itself.  With
-\fB-w\fR, xmlwf will try to use a Windows code
-page.  See also \fB-e\fR.
-.TP
-\fB-x\fR
+runs across an encoding that it is not equipped to handle itself. With
+\*(T<\fB\-w\fR\*(T>, xmlwf will try to use a Windows code
+page. See also \*(T<\fB\-e\fR\*(T>.
+.TP 
+\*(T<\fB\-x\fR\*(T>
 Turns on parsing external entities.
 
 Non-validating parsers are not required to resolve external
@@ -172,80 +177,75 @@ data from outside the XML file currently
 This is an example of an internal entity:
 
 .nf
+
 
 .fi
 
 And here are some examples of external entities:
 
 .nf
-  (parsed)
+
+  (parsed)
          (unparsed)
 .fi
-.TP
-\fB--\fR
+.TP 
+\*(T<\fB\-\-\fR\*(T>
 (Two hyphens.)
-Terminates the list of options.  This is only needed if a filename
-starts with a hyphen.  For example:
+Terminates the list of options. This is only needed if a filename
+starts with a hyphen. For example:
 
 .nf
-xmlwf -- -myfile.xml
+
+xmlwf \-\- \-myfile.xml
 .fi
 
 will run \fBxmlwf\fR on the file
-\fI-myfile.xml\fR.
+\*(T<\fI\-myfile.xml\fR\*(T>.
 .PP
 Older versions of \fBxmlwf\fR do not support
 reading from standard input.
-.SH "OUTPUT"
-.PP
+.SH OUTPUT
 If an input file is not well-formed,
 \fBxmlwf\fR prints a single line describing
-the problem to standard output.  If a file is well formed,
+the problem to standard output. If a file is well formed,
 \fBxmlwf\fR outputs nothing.
-Note that the result code is \fBnot\fR set.
-.SH "BUGS"
-.PP
-According to the W3C standard, an XML file without a
-declaration at the beginning is not considered well-formed.
-However, \fBxmlwf\fR allows this to pass.
-.PP
+Note that the result code is \fInot\fR set.
+.SH BUGS
 \fBxmlwf\fR returns a 0 - noerr result,
-even if the file is not well-formed.  There is no good way for
+even if the file is not well-formed. There is no good way for
 a program to use \fBxmlwf\fR to quickly
 check a file -- it must parse \fBxmlwf\fR's
 standard output.
 .PP
 The errors should go to standard error, not standard output.
 .PP
-There should be a way to get \fB-d\fR to send its
+There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
 output to standard output rather than forcing the user to send
 it to a file.
 .PP
 I have no idea why anyone would want to use the
-\fB-d\fR, \fB-c\fR, and
-\fB-m\fR options.  If someone could explain it to
+\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
+\*(T<\fB\-m\fR\*(T> options. If someone could explain it to
 me, I'd like to add this information to this manpage.
-.SH "ALTERNATIVES"
-.PP
+.SH ALTERNATIVES
 Here are some XML validators on the web:
 
 .nf
-http://www.hcrc.ed.ac.uk/~richard/xml-check.html
+
+http://www.hcrc.ed.ac.uk/~richard/xml\-check.html
 http://www.stg.brown.edu/service/xmlvalid/
 http://www.scripting.com/frontier5/xml/code/xmlValidator.html
 http://www.xml.com/pub/a/tools/ruwf/check.html
 .fi
 .SH "SEE ALSO"
-.PP
-
 .nf
+
 The Expat home page:        http://www.libexpat.org/
-The W3 XML specification:   http://www.w3.org/TR/REC-xml
+The W3 XML specification:   http://www.w3.org/TR/REC\-xml
 .fi
-.SH "AUTHOR"
-.PP
-This manual page was written by Scott Bronson  for
-the Debian GNU/Linux system (but may be used by others).  Permission is
+.SH AUTHOR
+This manual page was written by Scott Bronson <\*(T> for
+the Debian GNU/Linux system (but may be used by others). Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU Free Documentation
 License, Version 1.1.

Copied: head/contrib/expat/doc/xmlwf.xml (from r302260, vendor/expat/dist/doc/xmlwf.xml)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/expat/doc/xmlwf.xml	Fri Jul  1 05:48:45 2016	(r302305, copy of r302260, vendor/expat/dist/doc/xmlwf.xml)
@@ -0,0 +1,440 @@
+
+  Scott">
+  Bronson">
+  
+  March 11, 2016">
+  
+  1">
+  bronson@rinspin.com">
+  
+  XMLWF">
+  
+
+  Debian GNU/Linux">
+  GNU">
+]>
+
+
+  
+    
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2001 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + Determines if an XML document is well-formed + + + + &dhpackage; + + + + + + + + + + + + + + + + + + file ... + + + + + DESCRIPTION + + + &dhpackage; uses the Expat library to + determine if an XML document is well-formed. It is + non-validating. + + + + If you do not specify any files on the command-line, and you + have a recent version of &dhpackage;, the + input file will be read from standard input. + + + + + + WELL-FORMED DOCUMENTS + + + A well-formed document must adhere to the + following rules: + + + + + The file begins with an XML declaration. For instance, + <?xml version="1.0" standalone="yes"?>. + NOTE: + &dhpackage; does not currently + check for a valid XML declaration. + + + Every start tag is either empty (<tag/>) + or has a corresponding end tag. + + + There is exactly one root element. This element must contain + all other elements in the document. Only comments, white + space, and processing instructions may come after the close + of the root element. + + + All elements nest properly. + + + All attribute values are enclosed in quotes (either single + or double). + + + + + If the document has a DTD, and it strictly complies with that + DTD, then the document is also considered valid. + &dhpackage; is a non-validating parser -- + it does not check the DTD. However, it does support + external entities (see the option). + + + + + OPTIONS + + +When an option includes an argument, you may specify the argument either +separately (" output") or concatenated with the +option ("output"). &dhpackage; +supports both. + + + + + + + + + If the input file is well-formed and &dhpackage; + doesn't encounter any errors, the input file is simply copied to + the output directory unchanged. + This implies no namespaces (turns off ) and + requires to specify an output file. + + + + + + + + + Specifies a directory to contain transformed + representations of the input files. + By default, outputs a canonical representation + (described below). + You can select different output formats using + and . + + + The output filenames will + be exactly the same as the input filenames or "STDIN" if the input is + coming from standard input. Therefore, you must be careful that the + output file does not go into the same directory as the input + file. Otherwise, &dhpackage; will delete the + input file before it generates the output file (just like running + cat < file > file in most shells). + + + Two structurally equivalent XML documents have a byte-for-byte + identical canonical XML representation. + Note that ignorable white space is considered significant and + is treated equivalently to data. + More on canonical XML can be found at + http://www.jclark.com/xml/canonxml.html . + + + + + + + + + Specifies the character encoding for the document, overriding + any document encoding declaration. &dhpackage; + supports four built-in encodings: + US-ASCII, + UTF-8, + UTF-16, and + ISO-8859-1. + Also see the option. + + + + + + + + + Outputs some strange sort of XML file that completely + describes the input file, including character positions. + Requires to specify an output file. + + + + + + + + + Turns on namespace processing. (describe namespaces) + disables namespaces. + + + + + + + + + Tells xmlwf to process external DTDs and parameter + entities. + + + Normally &dhpackage; never parses parameter + entities. tells it to always parse them. + implies . + + + + + + + + + Normally &dhpackage; memory-maps the XML file + before parsing; this can result in faster parsing on many + platforms. + turns off memory-mapping and uses normal file + IO calls instead. + Of course, memory-mapping is automatically turned off + when reading from standard input. + + + Use of memory-mapping can cause some platforms to report + substantially higher memory usage for + &dhpackage;, but this appears to be a matter of + the operating system reporting memory in a strange way; there is + not a leak in &dhpackage;. + + + + + + + + + Prints an error if the document is not standalone. + A document is standalone if it has no external subset and no + references to parameter entities. + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Jul 1 07:27:34 2016 Return-Path: Delivered-To: svn-src-all@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 2EACDB8E4D7; Fri, 1 Jul 2016 07:27:34 +0000 (UTC) (envelope-from hselasky@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 00E732609; Fri, 1 Jul 2016 07:27:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u617RXUt059934; Fri, 1 Jul 2016 07:27:33 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u617RXbN059933; Fri, 1 Jul 2016 07:27:33 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201607010727.u617RXbN059933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 1 Jul 2016 07:27:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302306 - head/sys/dev/usb/controller X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 07:27:34 -0000 Author: hselasky Date: Fri Jul 1 07:27:33 2016 New Revision: 302306 URL: https://svnweb.freebsd.org/changeset/base/302306 Log: Fix detection of USB device disconnects in USB host mode when the USB device is connected directly to the USB port of the DWC OTG, in this case a RPI-zero. PR: 210695 Approved by: re (gjb) MFC after: 1 week Modified: head/sys/dev/usb/controller/dwc_otg.c Modified: head/sys/dev/usb/controller/dwc_otg.c ============================================================================== --- head/sys/dev/usb/controller/dwc_otg.c Fri Jul 1 05:48:45 2016 (r302305) +++ head/sys/dev/usb/controller/dwc_otg.c Fri Jul 1 07:27:33 2016 (r302306) @@ -2985,7 +2985,8 @@ dwc_otg_interrupt(void *arg) else sc->sc_flags.status_bus_reset = 0; - if (hprt & HPRT_PRTENCHNG) + if ((hprt & HPRT_PRTENCHNG) && + (hprt & HPRT_PRTENA) == 0) sc->sc_flags.change_enabled = 1; if (hprt & HPRT_PRTENA) @@ -4745,6 +4746,8 @@ tr_handle_get_port_status: value = 0; + if (sc->sc_flags.change_enabled) + value |= UPS_C_PORT_ENABLED; if (sc->sc_flags.change_connect) value |= UPS_C_CONNECT_STATUS; if (sc->sc_flags.change_suspend) From owner-svn-src-all@freebsd.org Fri Jul 1 08:54:57 2016 Return-Path: Delivered-To: svn-src-all@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 E9CBDB87CB2; Fri, 1 Jul 2016 08:54:57 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 915422AB1; Fri, 1 Jul 2016 08:54:57 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 371A01045278; Fri, 1 Jul 2016 18:54:48 +1000 (AEST) Date: Fri, 1 Jul 2016 18:54:47 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160630180106.GU38613@kib.kiev.ua> Message-ID: <20160701160438.U1233@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=zejX9Yh8_zp2-627HP4A:9 a=sE8r4AzeOeev_3Q_:21 a=1KXmKgoS2apXmfzf:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 08:54:58 -0000 On Thu, 30 Jun 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 03:30:41AM +1000, Bruce Evans wrote: >> On Thu, 30 Jun 2016, Konstantin Belousov wrote: >> >>> On Thu, Jun 30, 2016 at 05:47:39AM +1000, Bruce Evans wrote: >>>> On Wed, 29 Jun 2016, Konstantin Belousov wrote: >>>> >>>>> On Wed, Jun 29, 2016 at 05:54:43PM +0300, Konstantin Belousov wrote: >>>>>> As an additional, but probably excessive measure, invocation of >>>>>> tc_windup() from hardclock could ask the setclock() to re-execute >>>>>> tc_windup() after its call is done. >>>> >>>> I don't quite understand this. hardclock -> tc_windup() normally doesn't >>>> have interference from tc_setclock(). >>> In what sense it does not have interference ? tc_windup() may be executed >>> from hardclock/hardclock_cnt (low half) and concurrently from setclock() >>> (top half). And this is exactly what we want to avoid, isn't it ? >> >> Ues, but you seemed to be saying that hardclock should schedule or call >> tc_setclock(). That makes no sense. So I thought that you meant >> tc_setclock() calling or scheduling tc_windup() in a different way than >> it does now (it just calls it now). > More precisely, I mean that hardclock, when not able to execute tc_windup() > due to the top-half currently executing tc_windup(), may ask top-half to > re-execute tc_windup() (and not tc_setclock()) once the current invocation > finishes. I see. I think that is unnecessary. tc_windup() from from the quasi-periodic hardclock() just needs to be called often enough to keep the timecounters from overflowing, but not so often as to expose races or inefficiencies by cycling through the timehands too rapidly. So if there are problems with the extra calls from tc_setclock(), then it is the case where the lock is contended that is least harmful! In that case, the call from tc_setclock() replaces a call from hardclock() with the same timing to within a few nanoseconds. We might have problems in other cases: - malicous/stress-testing calls to settime() cause rapid cycling of the timehands. Hopefully we fixed the races exposed by this last year. You are now reducing the number of timehands to 2. This runs the races more often. But if the fixes work, then even 1 timehands should work. The multiple timehands are just an optimization that works by increasing the chance that biuptime() and friends don't have to wait for a usable timehands. - on idle systems, tickless kernels are close to not calling tc_windup() enough to keep the timecounters from overflowing. I use HZ = 100 and this gives only 20-30 timer interrupts/second. The TSC timecounter at 4 GHz would overflow after 1 second, and the bogus TSC-low timecounter at 2 GHz overflows after 2 seconds. Other timecounters might have overflow in less than 1 second, or tickless kernels might get closer to actually tickless and give only 1 timer interrupt every few seconds on idle systems. Suspended systems give no timer interrupts, and the resume code for restarting the timecounter isn't quite right. - on idle systems, after coming out of idle, IIRC the timer code delivers virtual ticks to the timercounter and other subsystems. This also isn't quite right. It risks rapidly cycling through the timehands. It is better than for restarting for resume. In both cases, whenever the sleep interval is so long that timecounter state is lost by stopping or wrapping, the timecounter should be reset. The length of the sleep interval must be determined using another timer if the timecounter stops or wraps. >>> *... >>>>> + for (;;) { >>>>> + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { >>>>> + atomic_thread_fence_acq(); >>>>> + tc_windup_locked(); >>>>> + atomic_store_rel_int(&tc_windup_lock, 0); >>>>> + break; >>>>> + } else if (!top_call) { >>>>> + break; >>>>> + } >>>>> + } >>>>> } >>>> >>>> I like to write optimized locking like that, but don't see why you >>>> want it here. >>> Because I do not want the fast clock interrupt handler to wait on lock, >>> which neccessary becomes spinlock. The ntp_lock is bad enough already. >>> What I coded above is not real lock. In contention case it bails out, >>> so there is no blocking. In particular, witness is not relevant to it. >> >> I think this is too complicated. Spinlocks aren't very expensive, and >> hardclock() already has some. I think it has several. It has at least >> one silly one -- in hardclock_cpu(), a thread locking to lock a single >> flags update. hardclock() and tc_windup() just aren't called enough >> for the locking overhead or contention to matter, even at too-large hz. > Spinlocks are quite expensive. They delay interrupt delivery. > I do not want the fast interrupt handler to be delayed due to the top-half > of the kernel executing settimeofday(2) in loop. I still think it is too complicated. Malicious/stress-testing users can easily find many other denial of service attacks involving mutexes, without needing root privilege like settimeofday(). Just using time syscalls, there is a thread_lock() (not on curthread(?)) in get_thread_cputme(). Thread locking doesn't have much contention but it does use spinlocks so it delays fast interrupts much the same as a general spinlock, especially in the UP case. I counted spinlocks and instructions in the "fast" clock interrupt handler. There aren't many spinlocks, but there are too many instructions to be fast: -current my-5.2 Xtimerint 10k-50k - clkintr - 896 hardclock 1091 842 (later counts are included in callers) tc_windup 987 693 __udivdi3 498 422 timehands_update 163 - -current is on i386 with an SMP kernel but on a 4x2 core system reduced to 1x1 since tracing is too broken to work with multiple cores (the multiple core are hard to control, and bugs cause crashes). my-5.2 is on i386 with a UP kernel on a 1x1 core system. Xtimerint is a "fast" interrupt handler. clkintr is a normal interrupt handler scheduled by a fast interrupt handler since the locking for a fast timer interrupt handler is too hard to get right. So the times for all the timer interrupt handling that is now done by Xtimerint are unavailable in ~5.2. They are even larger -- much more for context switches. tc_windup takes 30% more instructions in -current for not completely obvious reasons. 50-60% of the overhead is for a pessimized division, and somehow the compiler pessimizes this even better in -current than in 5.2 (using old gcc instead of older gcc). The division is 64/64 -> 64 bits. On amd64, this would be a single instruction, but on i386 the libcall is used. The pessimizations are: - the divisor (tc_frequency) is 64 bits, but for all supported timecounters it only needs 32 bits. My CPU can be overclocked to need 33 bits for the TSC timecounter, but the only the bogus TSC-low timecounter is available, partly to avoid needing the 33rd bit - i386 has a 64/32 -> 32 bit division instruction which can handle all the 32-bit divisors that can occur, but no one ever bother to optimize __udivdi3 to use this, so the full 64-bit division is always done. __udivdi3 shows up in other instruction traces. This is annoying but doesn't really matter since it is not called very often. >>> cpu_tick_calibrate(1); >>> nanotime(&tbef); >>> timespec2bintime(ts, &bt); >>> @@ -1247,8 +1252,10 @@ tc_setclock(struct timespec *ts) >>> bintime2timeval(&bt, &boottime); >> >> The leap second update to boottimebin in tc_windup() races with the >> update to boottimebin here. This can be fixed partially by using the >> same locking there. Then the locking would have to be a spin mutex >> (or special). This still doesn't fix non-atomic accesses to boottimebin >> in nanotime() and friends. Putting it in timehands seems to be best for >> fixing that. > Yes, timehands for bootimebin should be the solution, but > not in the scope of this patch. I will work on this right after the > current changeset lands in svn. You wrote the patch faster than I can reply :-). >> boottime is easier to fix (and doesn't need to be in timehands). It >> is only used to copy it out in a historical sysctl. The locking for >> that is buggy. We convert boottimebin to boottime here (now with locking) >> but in the sysctl we copy out boottime non-atomically. > Do we need boottime at all ? Can't it be calculated from boottimebin > on the sysctl invocation ? Later calculation is cleaner and probably easier with correct locking. boottime should be invariant after initialization. The invariant copy doesn't need any locking, except to initialize it. With our fuzzy/broken boottime, boottime has an error of about 1 seconds initially and later. Errors from races in not locking it are at most 1 second (except with 32-bit time they are 2**32 during a 1-second race in 2038). So null locking is good enough. The first write to the RTC in the ntp callout is a good place to freeze boottime so that it is invariant. I think that only applications doing buggy calculations of the current real time like 'now = boottime + CLOCK_UPTIME_time' would be broken further by fixing boottime. uptime(1) used to do the reverse of this calculation. It now uses CLOCK_UPTIME_time directly. This would work if CLOCK_UPTIME worked. Both CLOCK_UPTIME and CLOCK_MONOTONIC fail to count the time while the system is suspended, and have relatively minor errors for some clock drifts. Bruce From owner-svn-src-all@freebsd.org Fri Jul 1 10:39:58 2016 Return-Path: Delivered-To: svn-src-all@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 BFADCB89F04; Fri, 1 Jul 2016 10:39:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 71686288D; Fri, 1 Jul 2016 10:39:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 1ED07D48CAF; Fri, 1 Jul 2016 20:39:49 +1000 (AEST) Date: Fri, 1 Jul 2016 20:39:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160701031549.GV38613@kib.kiev.ua> Message-ID: <20160701185743.Q1600@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=pR1UwPydhmiD0_zUYnMA:9 a=x9fn74RsOB4bHPEa:21 a=fkw4OJNAAa02I7wV:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 10:39:58 -0000 On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Thu, Jun 30, 2016 at 09:01:06PM +0300, Konstantin Belousov wrote: >> Yes, timehands for bootimebin should be the solution, but >> not in the scope of this patch. I will work on this right after the >> current changeset lands in svn. > > Well, there is the move of boottimebin into timehands. I also reduced > the number of timehands to two, this was discussed many times before. > The feed-forward code is probably broken right now, I did not even > compile it. That was fast. It seems simple and clean enough, but is too much during a re freeze. I will only make some minor comments about style. > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > index 56b2ade..a0dce47 100644 > --- a/sys/compat/linprocfs/linprocfs.c > +++ b/sys/compat/linprocfs/linprocfs.c > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > struct pcpu *pcpu; > long cp_time[CPUSTATES]; > long *cp; > + struct timeval boottime; > int i; > > read_cpu_time(cp_time); > + getboottime(&boottime); This is used surprisingly often by too many subsystems. With the value still broken so that locking it doesn't help much, I would leave it as a global. > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..1c2d562 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > @@ -70,31 +70,36 @@ struct timehands { > ... > -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; > ... > +static struct timehands th1 = { > + .th_counter = NULL, > + .th_adjustment = 0, > + .th_scale = 0, > + .th_offset_count = 0, > + .th_offset = {0, 0}, > + .th_microtime = {0, 0}, > + .th_nanotime = {0, 0}, > + .th_boottime = {0, 0}, > + .th_generation = 0, > + .th_next = &th0 > +}; This shouldn't spell out all the 0 initializers. That was only needed to reach the non-0 initializer at the end of the initializer. > static struct timehands th0 = { > - &dummy_timecounter, > - 0, > - (uint64_t)-1 / 1000000, > - 0, > - {1, 0}, > - {0, 0}, > - {0, 0}, > - 1, > - &th1 > + .th_counter = &dummy_timecounter, > + .th_adjustment = 0, > + .th_scale = (uint64_t)-1 / 1000000, > + .th_offset_count = 0, > + .th_offset = {1, 0}, > + .th_microtime = {0, 0}, > + .th_nanotime = {0, 0}, > + .th_boottime = {0, 0}, > + .th_generation = 1, > + .th_next = &th1 > }; > @@ -135,14 +138,22 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, > ... > static int > sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) > { > + struct bintime boottimebin; > + struct timeval boottime; > + > + binuptime1(NULL, &boottimebin); > + bintime2timeval(&boottimebin, &boottime); Use the wrapper function getboottime() if you keep it. > @@ -342,8 +365,8 @@ fbclock_getmicrotime(struct timeval *tvp) > } while (gen == 0 || gen != th->th_generation); > } > #else /* !FFCLOCK */ > -void > -binuptime(struct bintime *bt) > +static void > +binuptime1(struct bintime *bt, struct bintime *boottimebin) > { > struct timehands *th; > u_int gen; > @@ -351,13 +374,24 @@ binuptime(struct bintime *bt) > do { > th = timehands; > gen = atomic_load_acq_int(&th->th_generation); > - *bt = th->th_offset; > - bintime_addx(bt, th->th_scale * tc_delta(th)); > + if (bt != NULL) { > + *bt = th->th_offset; > + bintime_addx(bt, th->th_scale * tc_delta(th)); > + } > + if (boottimebin != NULL) > + *boottimebin = th->th_boottime; > atomic_thread_fence_acq(); > } while (gen == 0 || gen != th->th_generation); > } > > void > +binuptime(struct bintime *bt) > +{ > + > + binuptime1(bt, NULL); > +} Uptime functions don't use boottimebin, so it is ugly for the general binuptime1() function to return it. This is also pessimal. Maybe the compiler can optimize away the boottimebin == NULL case for the uptime functions, but none of the functions is explicitly inlined. I like functions not being inlined when this is not explicit. gcc only inlines ones that are static and called once. I don't like this, and turn it off using -fno-inline-functions-called-once. clang is too broken to support this flag. So maybe use a new general function that returns boottimebin for the non-uptime functions only. Possibly it can add the offset directly. > @@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, > if (cs->delta > 0) > bintime_addx(bt, cs->fb_info.th_scale * cs->delta); > > - if ((flags & FBCLOCK_UPTIME) == 0) > + if ((flags & FBCLOCK_UPTIME) == 0) { > + binuptime1(NULL, &boottimebin); Perhaps use a more direct way to get boottimebin(). binuptime1() is pessimized by null pointer checks for both its args. Use the new function getboottimebin() even if is not direct. > ... > diff --git a/sys/net/bpf.c b/sys/net/bpf.c > index 3b12cf4..4251f71 100644 > --- a/sys/net/bpf.c > +++ b/sys/net/bpf.c > @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) > static void > bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) > { > - struct bintime bt2; > + struct bintime bt2, boottimebin; > struct timeval tsm; > struct timespec tsn; > > if ((tstype & BPF_T_MONOTONIC) == 0) { > bt2 = *bt; > + getboottimebin(&boottimebin); > bintime_add(&bt2, &boottimebin); > bt = &bt2; > } This is still too chummy with the (mis)implementation. I think it is to convert a relative CLOCK_MONOTONIC time to an absolute CLOCK_REALTIME time. That should be done in the time subsystem. It is unclear if we care about strict real time with leap seconds adjustments. BPF_T_MONOTONIC is not documented in any man page or used in any library or applicatiion in /usr/src. BPF_T_BINTIME is documented bpf(4) but not used in any library or application in /usr/src. Similarly for all of BPF_T_*. contrib/libpcap has 47 lines matching timeval, 2 matching timespec and 0 matching bintime. > diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c > index d186ba5..7faf99f 100644 > --- a/sys/netpfil/ipfw/ip_fw_sockopt.c > +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c > @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) > static void > export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > { > + struct timeval boottime; > > cntr->size = sizeof(*cntr); > > @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > cntr->bcnt = counter_u64_fetch(krule->cntr + 1); > cntr->timestamp = krule->timestamp; > } > - if (cntr->timestamp > 0) > + if (cntr->timestamp > 0) { > + getboottime(&boottime); > cntr->timestamp += boottime.tv_sec; > + } > } Looks like another home made conversion from CLOCK_MONOTONIC to CLOCK_REALTIME. Easier to understand since it is actually used. ipfw seems to use only getmicrouptime() for timestamping. There are good reasons for using monotonic time for everything except presenting the time to the user and the conversion for that should be more careful than the above. > diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c > index 7d11672..c84413e 100644 > --- a/sys/nfs/nfs_lock.c > +++ b/sys/nfs/nfs_lock.c > @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) > struct flock *fl; > struct proc *p; > struct nfsmount *nmp; > + struct timeval boottime; > > td = curthread; > p = td->td_proc; > @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) > p->p_nlminfo = malloc(sizeof(struct nlminfo), > M_NLMINFO, M_WAITOK | M_ZERO); > p->p_nlminfo->pid_start = p->p_stats->p_start; > + getboottime(&boottime); > timevaladd(&p->p_nlminfo->pid_start, &boottime); > } > msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; Looks like most uses of boottime are for this buggy addition. I would only trust it for telling the user the boot time, though it is broken for that too. > diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > index 1d07943..0879299 100644 > --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) > { > struct svc_rpc_gss_client *client; > struct svc_rpc_gss_client_list *list; > + struct timeval boottime; > unsigned long hostid; > > rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); > > getcredhostid(curthread->td_ucred, &hostid); > + getboottime(&boottime); > if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) > return (NULL); Here it is hopefully just a magic id, with the user being a remote system. Any time that doesn't go backwards or forwards so far that it is in the lieftime of an old or new boot instance works well for identifying the boot instance. Bruce From owner-svn-src-all@freebsd.org Fri Jul 1 14:25:31 2016 Return-Path: Delivered-To: svn-src-all@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 82232B88F31; Fri, 1 Jul 2016 14:25:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02EB720A9; Fri, 1 Jul 2016 14:25:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u61EPHxW089967 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 Jul 2016 17:25:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u61EPHxW089967 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u61EPGgK089963; Fri, 1 Jul 2016 17:25:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 1 Jul 2016 17:25:16 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160701142516.GW38613@kib.kiev.ua> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160701185743.Q1600@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 01 Jul 2016 14:25:31 -0000 On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: > It seems simple and clean enough, but is too much during a re freeze. > > I will only make some minor comments about style. Well, it is not only about style. If you have no more comments, I will ask for testing. The patch is about fixing bugs, although in somewhat extended scope, so I think it is still fine as the things do not explode. I added the stats to the patch, it is not that intrusive actually. I still do not see why/do not want to use spinlock for the tc_windup() exclusion. Patch is at the end of the message. > > > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > > index 56b2ade..a0dce47 100644 > > --- a/sys/compat/linprocfs/linprocfs.c > > +++ b/sys/compat/linprocfs/linprocfs.c > > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > > struct pcpu *pcpu; > > long cp_time[CPUSTATES]; > > long *cp; > > + struct timeval boottime; > > int i; > > > > read_cpu_time(cp_time); > > + getboottime(&boottime); > > This is used surprisingly often by too many subsystems. With the value still > broken so that locking it doesn't help much, I would leave it as a global. I prefer to keep the KPI consistent. > > + .th_generation = 0, > > + .th_next = &th0 > > +}; > > This shouldn't spell out all the 0 initializers. That was only needed to > reach the non-0 initializer at the end of the initializer. I thought about it, but initially did not liked the implicit initialization. Changed. > > static int > > sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) > > { > > + struct bintime boottimebin; > > + struct timeval boottime; > > + > > + binuptime1(NULL, &boottimebin); > > + bintime2timeval(&boottimebin, &boottime); > > Use the wrapper function getboottime() if you keep it. Yes, I wrote this before I added the helper. > So maybe use a new general function that returns boottimebin for the > non-uptime functions only. Possibly it can add the offset directly. I changed getbintime() and getboottimebin() to use the fenced magic and fetch boottime inside the loop. This removed the need for binuptime1(). > > > @@ -1116,8 +1170,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, > > if (cs->delta > 0) > > bintime_addx(bt, cs->fb_info.th_scale * cs->delta); > > > > - if ((flags & FBCLOCK_UPTIME) == 0) > > + if ((flags & FBCLOCK_UPTIME) == 0) { > > + binuptime1(NULL, &boottimebin); > > Perhaps use a more direct way to get boottimebin(). binuptime1() is > pessimized by null pointer checks for both its args. Use the new > function getboottimebin() even if is not direct. Used it, and now it is a direct interface into timehands as well. > > > ... > > diff --git a/sys/net/bpf.c b/sys/net/bpf.c > > index 3b12cf4..4251f71 100644 > > --- a/sys/net/bpf.c > > +++ b/sys/net/bpf.c > > @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) > > static void > > bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) > > { > > - struct bintime bt2; > > + struct bintime bt2, boottimebin; > > struct timeval tsm; > > struct timespec tsn; > > > > if ((tstype & BPF_T_MONOTONIC) == 0) { > > bt2 = *bt; > > + getboottimebin(&boottimebin); > > bintime_add(&bt2, &boottimebin); > > bt = &bt2; > > } > > This is still too chummy with the (mis)implementation. I think it is to > convert a relative CLOCK_MONOTONIC time to an absolute CLOCK_REALTIME > time. That should be done in the time subsystem. It is unclear if > we care about strict real time with leap seconds adjustments. > > BPF_T_MONOTONIC is not documented in any man page or used in any library > or applicatiion in /usr/src. BPF_T_BINTIME is documented bpf(4) but not > used in any library or application in /usr/src. Similarly for all of > BPF_T_*. contrib/libpcap has 47 lines matching timeval, 2 matching > timespec and 0 matching bintime. I will leave this to bpf maintainers. > > > diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c > > index d186ba5..7faf99f 100644 > > --- a/sys/netpfil/ipfw/ip_fw_sockopt.c > > +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c > > @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) > > static void > > export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > > { > > + struct timeval boottime; > > > > cntr->size = sizeof(*cntr); > > > > @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) > > cntr->bcnt = counter_u64_fetch(krule->cntr + 1); > > cntr->timestamp = krule->timestamp; > > } > > - if (cntr->timestamp > 0) > > + if (cntr->timestamp > 0) { > > + getboottime(&boottime); > > cntr->timestamp += boottime.tv_sec; > > + } > > } > > Looks like another home made conversion from CLOCK_MONOTONIC to > CLOCK_REALTIME. Easier to understand since it is actually used. > ipfw seems to use only getmicrouptime() for timestamping. There are > good reasons for using monotonic time for everything except presenting > the time to the user and the conversion for that should be more careful > than the above. I leave this one to net- people as well. > > diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > index 1d07943..0879299 100644 > > --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c > > @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) > > { > > struct svc_rpc_gss_client *client; > > struct svc_rpc_gss_client_list *list; > > + struct timeval boottime; > > unsigned long hostid; > > > > rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); > > > > getcredhostid(curthread->td_ucred, &hostid); > > + getboottime(&boottime); > > if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) > > return (NULL); > > Here it is hopefully just a magic id, with the user being a remote system. > Any time that doesn't go backwards or forwards so far that it is in the > lieftime of an old or new boot instance works well for identifying the > boot instance. It does not work for leap seconds in the same way as is does not work after setclock(). So I just leave this conversion as is. sys/compat/linprocfs/linprocfs.c | 4 + sys/fs/devfs/devfs_vnops.c | 4 +- sys/fs/fdescfs/fdesc_vnops.c | 2 + sys/fs/nfs/nfsport.h | 2 +- sys/fs/procfs/procfs_status.c | 2 + sys/kern/kern_acct.c | 2 +- sys/kern/kern_ntptime.c | 55 +++++------- sys/kern/kern_proc.c | 2 + sys/kern/kern_tc.c | 161 +++++++++++++++++++++++++----------- sys/kern/kern_time.c | 8 +- sys/kern/subr_rtc.c | 2 +- sys/kern/sys_procdesc.c | 3 +- sys/net/bpf.c | 3 +- sys/netpfil/ipfw/ip_fw_sockopt.c | 12 ++- sys/nfs/nfs_lock.c | 2 + sys/rpc/rpcsec_gss/svc_rpcsec_gss.c | 4 + sys/sys/time.h | 5 +- 17 files changed, 174 insertions(+), 99 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 56b2ade..a0dce47 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) struct pcpu *pcpu; long cp_time[CPUSTATES]; long *cp; + struct timeval boottime; int i; read_cpu_time(cp_time); + getboottime(&boottime); sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", T2J(cp_time[CP_USER]), T2J(cp_time[CP_NICE]), @@ -624,10 +626,12 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + struct timeval boottime; char state; static int ratelimit = 0; vm_offset_t startcode, startdata; + getboottime(&boottime); sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7cc0f9e..afa3da4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - int error; struct devfs_dirent *de; struct devfs_mount *dmp; struct cdev *dev; + struct timeval boottime; + int error; error = devfs_populate_vp(vp); if (error != 0) @@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap) vap->va_blocksize = DEV_BSIZE; vap->va_type = vp->v_type; + getboottime(&boottime); #define fix(aa) \ do { \ if ((aa).tv_sec <= 3600) { \ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 4f6e1b9..65b8a54 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval boottime; + getboottime(&boottime); vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_fileid = VTOFDESC(vp)->fd_ix; vap->va_uid = 0; diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 921df2d..6b41e2f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int); /* * Set boottime. */ -#define NFSSETBOOTTIME(b) ((b) = boottime) +#define NFSSETBOOTTIME(b) (getboottime(&b)) /* * The size of directory blocks in the buffer cache. diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 5a00ee1..defdec3 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) const char *wmesg; char *pc; char *sep; + struct timeval boottime; int pid, ppid, pgid, sid; int i; @@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) calcru(p, &ut, &st); PROC_STATUNLOCK(p); start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&start, &boottime); sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", (intmax_t)start.tv_sec, start.tv_usec, diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ef3fd2e..46e6d9b 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -389,7 +389,7 @@ acct_process(struct thread *td) acct.ac_stime = encode_timeval(st); /* (4) The elapsed time the command ran (and its starting time) */ - tmp = boottime; + getboottime(&tmp); timevaladd(&tmp, &p->p_stats->p_start); acct.ac_btime = tmp.tv_sec; microuptime(&tmp); diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2f1f620..892b23a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct session *sp; struct ucred *cred; struct sigacts *ps; + struct timeval boottime; /* For proc_realparent. */ sx_assert(&proctree_lock, SX_LOCKED); @@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_nice = p->p_nice; kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&kp->ki_start, &boottime); PROC_STATLOCK(p); rufetch(p, &kp->ki_rusage); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..c9676fc 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -70,31 +70,22 @@ struct timehands { struct bintime th_offset; struct timeval th_microtime; struct timespec th_nanotime; + struct bintime th_boottime; /* Fields not to be copied in tc_windup start with th_generation. */ u_int th_generation; struct timehands *th_next; }; static struct timehands th0; -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; -static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; -static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; -static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; -static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; -static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; -static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; -static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; -static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; +static struct timehands th1 = { + .th_next = &th0 +}; static struct timehands th0 = { - &dummy_timecounter, - 0, - (uint64_t)-1 / 1000000, - 0, - {1, 0}, - {0, 0}, - {0, 0}, - 1, - &th1 + .th_counter = &dummy_timecounter, + .th_scale = (uint64_t)-1 / 1000000, + .th_offset = {1, 0}, + .th_generation = 1, + .th_next = &th1 }; static struct timehands *volatile timehands = &th0; @@ -106,8 +97,6 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; -struct bintime boottimebin; -struct timeval boottime; static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); @@ -135,7 +124,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(bool top_call, struct bintime *new_boottimebin); +static void tc_windup_locked(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -143,6 +133,10 @@ void dtrace_getnanotime(struct timespec *tsp); static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { + struct timeval boottime; + + getboottime(&boottime); + #ifndef __mips__ #ifdef SCTL_MASK32 int tv[2]; @@ -150,11 +144,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) if (req->flags & SCTL_MASK32) { tv[0] = boottime.tv_sec; tv[1] = boottime.tv_usec; - return SYSCTL_OUT(req, tv, sizeof(tv)); - } else + return (SYSCTL_OUT(req, tv, sizeof(tv))); + } #endif #endif - return SYSCTL_OUT(req, &boottime, sizeof(boottime)); + return (SYSCTL_OUT(req, &boottime, sizeof(boottime))); } static int @@ -164,7 +158,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; ncount = tc->tc_get_timecount(tc); - return sysctl_handle_int(oidp, &ncount, 0, req); + return (sysctl_handle_int(oidp, &ncount, 0, req)); } static int @@ -174,7 +168,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; freq = tc->tc_frequency; - return sysctl_handle_64(oidp, &freq, 0, req); + return (sysctl_handle_64(oidp, &freq, 0, req)); } /* @@ -198,7 +192,7 @@ tc_delta(struct timehands *th) */ #ifdef FFCLOCK -void +static void fbclock_binuptime(struct bintime *bt) { struct timehands *th; @@ -234,8 +228,18 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { + struct bintime boottimebin; + struct timehands *th; + unsigned int gen; - fbclock_binuptime(bt); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); } @@ -303,12 +307,14 @@ void fbclock_getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; unsigned int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { + struct bintime boottimebin; + struct timehands *th; + u_int gen; - binuptime(bt); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); } @@ -447,12 +463,14 @@ void getbintime(struct bintime *bt) { struct timehands *th; + struct bintime boottimebin; u_int gen; do { th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + boottimebin = th->th_boottime; atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); bintime_add(bt, &boottimebin); @@ -487,6 +505,29 @@ getmicrotime(struct timeval *tvp) } #endif /* FFCLOCK */ +void +getboottime(struct timeval *boottime) +{ + struct bintime boottimebin; + + getboottimebin(&boottimebin); + bintime2timeval(&boottimebin, boottime); +} + +void +getboottimebin(struct bintime *boottimebin) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); +} + #ifdef FFCLOCK /* * Support for feed-forward synchronization algorithms. This is heavily inspired @@ -1103,6 +1144,7 @@ int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags) { + struct bintime boottimebin; #ifdef FFCLOCK struct bintime bt2; uint64_t period; @@ -1116,8 +1158,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, if (cs->delta > 0) bintime_addx(bt, cs->fb_info.th_scale * cs->delta); - if ((flags & FBCLOCK_UPTIME) == 0) + if ((flags & FBCLOCK_UPTIME) == 0) { + getboottimebin(&boottimebin); bintime_add(bt, &boottimebin); + } break; #ifdef FFCLOCK case SYSCLOCK_FFWD: @@ -1226,10 +1270,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_DEF); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,26 +1283,43 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; - cpu_tick_calibrate(1); - nanotime(&tbef); timespec2bintime(ts, &bt); + nanotime(&tbef); + mtx_lock(&tc_setclock_mtx); + critical_enter(); + cpu_tick_calibrate(1); binuptime(&bt2); bintime_sub(&bt, &bt2); - bintime_add(&bt2, &boottimebin); - boottimebin = bt; - bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); - nanotime(&taft); + tc_windup(true, &bt); + critical_exit(); + mtx_unlock(&tc_setclock_mtx); if (timestepwarnings) { + nanotime(&taft); log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", (intmax_t)tbef.tv_sec, tbef.tv_nsec, (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); +} + +static volatile int tc_windup_lock; +static void +tc_windup(bool top_call, struct bintime *new_boottimebin) +{ + + for (;;) { + if (atomic_cmpset_int(&tc_windup_lock, 0, 1)) { + atomic_thread_fence_acq(); + tc_windup_locked(new_boottimebin); + atomic_store_rel_int(&tc_windup_lock, 0); + break; + } else if (!top_call) { + break; + } + } } /* @@ -1265,7 +1328,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup_locked(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; @@ -1289,6 +1352,8 @@ tc_windup(void) th->th_generation = 0; atomic_thread_fence_rel(); bcopy(tho, th, offsetof(struct timehands, th_generation)); + if (new_boottimebin != NULL) + th->th_boottime = *new_boottimebin; /* * Capture a timecounter delta on the current timecounter and if @@ -1338,7 +1403,7 @@ tc_windup(void) * case we missed a leap second. */ bt = th->th_offset; - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; if (i > LARGE_STEP) i = 2; @@ -1346,7 +1411,7 @@ tc_windup(void) t = bt.sec; ntp_update_second(&th->th_adjustment, &bt.sec); if (bt.sec != t) - boottimebin.sec += bt.sec - t; + th->th_boottime.sec += bt.sec - t; } /* Update the UTC timestamps used by the get*() functions. */ /* XXX shouldn't do this here. Should force non-`get' versions. */ @@ -1769,7 +1834,7 @@ pps_event(struct pps_state *pps, int event) tcount &= pps->capth->th_counter->tc_counter_mask; bt = pps->capth->th_offset; bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &pps->capth->th_boottime); bintime2timespec(&bt, &ts); /* If the timecounter was wound up underneath us, bail out. */ @@ -1846,7 +1911,7 @@ tc_ticktock(int cnt) if (count < tc_tick) return; count = 0; - tc_windup(); + tc_windup(false, NULL); } static void __inline @@ -1921,7 +1986,7 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + tc_windup(true, NULL); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); @@ -2095,7 +2160,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) vdso_th->th_offset_count = th->th_offset_count; vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; + vdso_th->th_boottime = th->th_boottime; enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; @@ -2116,8 +2181,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th32->th_offset.sec = th->th_offset.sec; *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + vdso_th32->th_boottime.sec = th->th_boottime.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac; enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 37139c1..f47ae7c 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { struct procdesc *pd; - struct timeval pstart; + struct timeval pstart, boottime; /* * XXXRW: Perhaps we should cache some more information from the @@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, /* Set birth and [acm] times to process start time. */ pstart = pd->pd_proc->p_stats->p_start; + getboottime(&boottime); timevaladd(&pstart, &boottime); TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); sb->st_atim = sb->st_birthtim; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 3b12cf4..4251f71 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) static void bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) { - struct bintime bt2; + struct bintime bt2, boottimebin; struct timeval tsm; struct timespec tsn; if ((tstype & BPF_T_MONOTONIC) == 0) { bt2 = *bt; + getboottimebin(&boottimebin); bintime_add(&bt2, &boottimebin); bt = &bt2; } diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index d186ba5..7faf99f 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) static void export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) { + struct timeval boottime; cntr->size = sizeof(*cntr); @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } static void export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) { + struct timeval boottime; if (krule->cntr != NULL) { cntr->pcnt = counter_u64_fetch(krule->cntr); cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } /* @@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) char *ep = bp + space; struct ip_fw *rule; struct ip_fw_rule0 *dst; + struct timeval boottime; int error, i, l, warnflag; time_t boot_seconds; warnflag = 0; + getboottime(&boottime); boot_seconds = boottime.tv_sec; for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 7d11672..c84413e 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) struct flock *fl; struct proc *p; struct nfsmount *nmp; + struct timeval boottime; td = curthread; p = td->td_proc; @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) p->p_nlminfo = malloc(sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 1d07943..0879299 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); getcredhostid(curthread->td_ucred, &hostid); + getboottime(&boottime); if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) return (NULL); @@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_create_client()"); @@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void) sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); client->cl_id.ci_hostid = hostid; + getboottime(&boottime); client->cl_id.ci_boottime = boottime.tv_sec; client->cl_id.ci_id = svc_rpc_gss_next_clientid++; list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; diff --git a/sys/sys/time.h b/sys/sys/time.h index 395e888..659f8e0 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -372,8 +372,6 @@ void resettodr(void); extern volatile time_t time_second; extern volatile time_t time_uptime; -extern struct bintime boottimebin; -extern struct timeval boottime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; extern struct bintime tick_bt; @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); void getnanotime(struct timespec *tsp); void getmicrotime(struct timeval *tvp); +void getboottime(struct timeval *boottime); +void getboottimebin(struct bintime *boottimebin); + /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); From owner-svn-src-all@freebsd.org Fri Jul 1 19:58:14 2016 Return-Path: Delivered-To: svn-src-all@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 968BDB8F77F; Fri, 1 Jul 2016 19:58:14 +0000 (UTC) (envelope-from adrian@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 4B4642F68; Fri, 1 Jul 2016 19:58:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61JwDoc039801; Fri, 1 Jul 2016 19:58:13 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61JwD6W039800; Fri, 1 Jul 2016 19:58:13 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201607011958.u61JwD6W039800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Fri, 1 Jul 2016 19:58:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302307 - head/sys/net80211 X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 19:58:14 -0000 Author: adrian Date: Fri Jul 1 19:58:13 2016 New Revision: 302307 URL: https://svnweb.freebsd.org/changeset/base/302307 Log: [net80211] teach AMRR to log the initial MCS rate as "MCS X" Otheriwse it logs it as the rate value, which is 0x80 (MCS flag) + MCS, which isn't that helpful. Approved by: re (gjb) Modified: head/sys/net80211/ieee80211_amrr.c Modified: head/sys/net80211/ieee80211_amrr.c ============================================================================== --- head/sys/net80211/ieee80211_amrr.c Fri Jul 1 07:27:33 2016 (r302306) +++ head/sys/net80211/ieee80211_amrr.c Fri Jul 1 19:58:13 2016 (r302307) @@ -220,10 +220,13 @@ amrr_node_init(struct ieee80211_node *ni ni->ni_txrate = rate; amn->amn_ticks = ticks; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "AMRR: nrates=%d, initial rate %d", + "AMRR: nrates=%d, initial rate %s%d", rs->rs_nrates, - rate); + amrr_node_is_11n(ni) ? "MCS " : "", + rate & IEEE80211_RATE_VAL); } static void @@ -249,6 +252,8 @@ amrr_update(struct ieee80211_amrr *amrr, rs = &ni->ni_rates; } + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR: current rate %d, txcnt=%d, retrycnt=%d", rs->rs_rates[rix] & IEEE80211_RATE_VAL, @@ -270,6 +275,8 @@ amrr_update(struct ieee80211_amrr *amrr, amn->amn_recovery = 1; amn->amn_success = 0; rix++; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR increasing rate %d (txcnt=%d retrycnt=%d)", rs->rs_rates[rix] & IEEE80211_RATE_VAL, @@ -291,6 +298,8 @@ amrr_update(struct ieee80211_amrr *amrr, amrr->amrr_min_success_threshold; } rix--; + /* XXX TODO: we really need a rate-to-string method */ + /* XXX TODO: non-11n rate should be divided by two.. */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, "AMRR decreasing rate %d (txcnt=%d retrycnt=%d)", rs->rs_rates[rix] & IEEE80211_RATE_VAL, From owner-svn-src-all@freebsd.org Fri Jul 1 20:11:29 2016 Return-Path: Delivered-To: svn-src-all@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 F2733B8F997; Fri, 1 Jul 2016 20:11:29 +0000 (UTC) (envelope-from kib@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 BFD59270A; Fri, 1 Jul 2016 20:11:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KBSiV044548; Fri, 1 Jul 2016 20:11:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KBSEL044547; Fri, 1 Jul 2016 20:11:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201607012011.u61KBSEL044547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 1 Jul 2016 20:11:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302308 - head/sys/kern X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 20:11:30 -0000 Author: kib Date: Fri Jul 1 20:11:28 2016 New Revision: 302308 URL: https://svnweb.freebsd.org/changeset/base/302308 Log: When a process knote was attached to the process which is already exiting, the knote is activated immediately. If the exit1() later activates knotes, such knote is attempted to be activated second time. Detect the condition by zeroed kn_ptr.p_proc pointer, and avoid excessive activation. Before r302235, such knotes were removed from the knlist immediately upon activation. Reported by: truckman Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Modified: head/sys/kern/kern_event.c Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Fri Jul 1 19:58:13 2016 (r302307) +++ head/sys/kern/kern_event.c Fri Jul 1 20:11:28 2016 (r302308) @@ -451,6 +451,9 @@ filt_proc(struct knote *kn, long hint) u_int event; p = kn->kn_ptr.p_proc; + if (p == NULL) /* already activated, from attach filter */ + return (0); + /* Mask off extra data. */ event = (u_int)hint & NOTE_PCTRLMASK; From owner-svn-src-all@freebsd.org Fri Jul 1 20:16:36 2016 Return-Path: Delivered-To: svn-src-all@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 5FCB5B8FB45; Fri, 1 Jul 2016 20:16:36 +0000 (UTC) (envelope-from skreuzer@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 31FF62A26; Fri, 1 Jul 2016 20:16:36 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KGZsP047388; Fri, 1 Jul 2016 20:16:35 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KGZxS047387; Fri, 1 Jul 2016 20:16:35 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012016.u61KGZxS047387@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:16:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302309 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 20:16:36 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:16:35 2016 New Revision: 302309 URL: https://svnweb.freebsd.org/changeset/base/302309 Log: Document r263698, Add code for enabling second CPU core for A20 SoC. Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:11:28 2016 (r302308) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:16:35 2016 (r302309) @@ -1509,6 +1509,10 @@ Support for the HiSilicon HI6220 SoC has been added. + + The second CPU core on + Allwinner A20 SoC have been enabled. + From owner-svn-src-all@freebsd.org Fri Jul 1 20:19:03 2016 Return-Path: Delivered-To: svn-src-all@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 5DE4BB8FBB0; Fri, 1 Jul 2016 20:19:03 +0000 (UTC) (envelope-from skreuzer@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 2E2082BAC; Fri, 1 Jul 2016 20:19:03 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KJ25M047504; Fri, 1 Jul 2016 20:19:02 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KJ29e047503; Fri, 1 Jul 2016 20:19:02 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012019.u61KJ29e047503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:19:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302310 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 20:19:03 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:19:02 2016 New Revision: 302310 URL: https://svnweb.freebsd.org/changeset/base/302310 Log: Document r299688, Add support for H3 SoC Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:16:35 2016 (r302309) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:19:02 2016 (r302310) @@ -1513,6 +1513,9 @@ The second CPU core on Allwinner A20 SoC have been enabled. + Support for the Allwinner H3 SoC + has been added. + From owner-svn-src-all@freebsd.org Fri Jul 1 20:26:01 2016 Return-Path: Delivered-To: svn-src-all@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 3C4A4B8FDB5; Fri, 1 Jul 2016 20:26:01 +0000 (UTC) (envelope-from skreuzer@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 08E222051; Fri, 1 Jul 2016 20:26:00 +0000 (UTC) (envelope-from skreuzer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61KQ0DM051141; Fri, 1 Jul 2016 20:26:00 GMT (envelope-from skreuzer@FreeBSD.org) Received: (from skreuzer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61KQ02r051140; Fri, 1 Jul 2016 20:26:00 GMT (envelope-from skreuzer@FreeBSD.org) Message-Id: <201607012026.u61KQ02r051140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skreuzer set sender to skreuzer@FreeBSD.org using -f From: Steven Kreuzer Date: Fri, 1 Jul 2016 20:26:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302311 - head/release/doc/en_US.ISO8859-1/relnotes X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 20:26:01 -0000 Author: skreuzer (doc,ports committer) Date: Fri Jul 1 20:25:59 2016 New Revision: 302311 URL: https://svnweb.freebsd.org/changeset/base/302311 Log: Document 300777, Add support for GPIO, Sensors and interrupts on AXP209 PMIC Approved by: re (gjb, implicit, relnotes) Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:19:02 2016 (r302310) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml Fri Jul 1 20:25:59 2016 (r302311) @@ -1516,6 +1516,10 @@ Support for the Allwinner H3 SoC has been added. + Support for GPIO, Sensors and + interrupts on AXP209 power management integrated circuits have been + added. + From owner-svn-src-all@freebsd.org Fri Jul 1 21:09:31 2016 Return-Path: Delivered-To: svn-src-all@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 77DCFB8F599; Fri, 1 Jul 2016 21:09:31 +0000 (UTC) (envelope-from nwhitehorn@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 552432212; Fri, 1 Jul 2016 21:09:31 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61L9U2M065960; Fri, 1 Jul 2016 21:09:30 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61L9U13065958; Fri, 1 Jul 2016 21:09:30 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201607012109.u61L9U13065958@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Fri, 1 Jul 2016 21:09:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302312 - in head/sys/boot: fdt powerpc/ofw X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 21:09:31 -0000 Author: nwhitehorn Date: Fri Jul 1 21:09:30 2016 New Revision: 302312 URL: https://svnweb.freebsd.org/changeset/base/302312 Log: Clean up some FDT-related code in the PowerPC bootloader, improving error checking and robustness. Prevents errors and crashes in FDT commands on PowerMac G5 systems. Approved by: re (gjb) Modified: head/sys/boot/fdt/fdt_loader_cmd.c head/sys/boot/powerpc/ofw/ofwfdt.c Modified: head/sys/boot/fdt/fdt_loader_cmd.c ============================================================================== --- head/sys/boot/fdt/fdt_loader_cmd.c Fri Jul 1 20:25:59 2016 (r302311) +++ head/sys/boot/fdt/fdt_loader_cmd.c Fri Jul 1 21:09:30 2016 (r302312) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #endif #define FDT_CWD_LEN 256 -#define FDT_MAX_DEPTH 6 +#define FDT_MAX_DEPTH 12 #define FDT_PROP_SEP " = " @@ -1029,7 +1029,7 @@ fdt_cmd_ls(int argc, char *argv[]) const char *prevname[FDT_MAX_DEPTH] = { NULL }; const char *name; char *path; - int i, o, depth, len; + int i, o, depth; path = (argc > 2) ? argv[2] : NULL; if (path == NULL) @@ -1045,7 +1045,7 @@ fdt_cmd_ls(int argc, char *argv[]) (o >= 0) && (depth >= 0); o = fdt_next_node(fdtp, o, &depth)) { - name = fdt_get_name(fdtp, o, &len); + name = fdt_get_name(fdtp, o, NULL); if (depth > FDT_MAX_DEPTH) { printf("max depth exceeded: %d\n", depth); Modified: head/sys/boot/powerpc/ofw/ofwfdt.c ============================================================================== --- head/sys/boot/powerpc/ofw/ofwfdt.c Fri Jul 1 20:25:59 2016 (r302311) +++ head/sys/boot/powerpc/ofw/ofwfdt.c Fri Jul 1 21:09:30 2016 (r302312) @@ -33,24 +33,37 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +extern int command_fdt_internal(int argc, char *argv[]); + static int OF_hasprop(phandle_t node, const char *prop) { - return (OF_getproplen(node, prop) > 0); + return (OF_getproplen(node, (char *)prop) > 0); } static void add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset) { - int i, child_offset, error; - char name[2048], *lastprop, *subname; + int i, child_offset, error; + char name[255], *lastprop, *subname; void *propbuf; - size_t proplen; + ssize_t proplen; lastprop = NULL; while (OF_nextprop(node, lastprop, name) > 0) { proplen = OF_getproplen(node, name); + + /* Detect and correct for errors and strangeness */ + if (proplen < 0) + proplen = 0; + if (proplen > 1024) + proplen = 1024; + propbuf = malloc(proplen); + if (propbuf == NULL) { + printf("Cannot allocate memory for prop %s\n", name); + return; + } OF_getprop(node, name, propbuf, proplen); error = fdt_setprop(buffer, fdt_offset, name, propbuf, proplen); free(propbuf); @@ -64,7 +77,7 @@ add_node_to_fdt(void *buffer, phandle_t && !OF_hasprop(node, "ibm,phandle")) fdt_setprop(buffer, fdt_offset, "phandle", &node, sizeof(node)); - for (node = OF_child(node); node > 0; node = OF_peer(node)) { + for (node = OF_child(node); node > 0; node = OF_peer(node)) { OF_package_to_path(node, name, sizeof(name)); subname = strrchr(name, '/'); subname++; @@ -76,7 +89,7 @@ add_node_to_fdt(void *buffer, phandle_t } add_node_to_fdt(buffer, node, child_offset); - } + } } static void @@ -123,18 +136,16 @@ ofwfdt_fixups(void *fdtp) fdt_add_mem_rsv(fdtp, base, len); } else { /* - * Remove /memory/available properties, which reflect long-gone OF - * state. Note that this doesn't work if we need RTAS still, since - * that's part of the firmware. + * Remove /memory/available properties, which reflect long-gone + * OF state. Note that this doesn't work if we need RTAS still, + * since that's part of the firmware. */ - offset = fdt_path_offset(fdtp, "/memory@0"); if (offset > 0) fdt_delprop(fdtp, offset, "available"); } - - /* + /* * Convert stored ihandles under /chosen to xref phandles */ @@ -158,7 +169,8 @@ ofwfdt_fixups(void *fdtp) OF_getprop(node, "ibm,phandle", &node, sizeof(node)); node = cpu_to_fdt32(node); - fdt_setprop(fdtp, offset, chosenprops[i], &node, sizeof(node)); + fdt_setprop(fdtp, offset, chosenprops[i], &node, + sizeof(node)); } /* Refind node in case it moved */ From owner-svn-src-all@freebsd.org Fri Jul 1 23:18:50 2016 Return-Path: Delivered-To: svn-src-all@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 F1DA4B8F817; Fri, 1 Jul 2016 23:18:50 +0000 (UTC) (envelope-from np@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 C24BA2FF8; Fri, 1 Jul 2016 23:18:50 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u61NInOH014380; Fri, 1 Jul 2016 23:18:49 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u61NInK9014379; Fri, 1 Jul 2016 23:18:49 GMT (envelope-from np@FreeBSD.org) Message-Id: <201607012318.u61NInK9014379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Fri, 1 Jul 2016 23:18:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302313 - head/sys/dev/cxgbe X-SVN-Group: head 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.22 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: Fri, 01 Jul 2016 23:18:51 -0000 Author: np Date: Fri Jul 1 23:18:49 2016 New Revision: 302313 URL: https://svnweb.freebsd.org/changeset/base/302313 Log: cxgbe(4): Avoid a NULL dereference while dumping the L2 table. Entries used by switching filters that rewrite L2 information do not have any associated ifnet. Approved by: re@ (gjb@) Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_l2t.c Modified: head/sys/dev/cxgbe/t4_l2t.c ============================================================================== --- head/sys/dev/cxgbe/t4_l2t.c Fri Jul 1 21:09:30 2016 (r302312) +++ head/sys/dev/cxgbe/t4_l2t.c Fri Jul 1 23:18:49 2016 (r302313) @@ -307,7 +307,6 @@ sysctl_l2t(SYSCTL_HANDLER_ARGS) } /* - * XXX: e->ifp may not be around. * XXX: IPv6 addresses may not align properly in the output. */ sbuf_printf(sb, "\n%4u %-15s %02x:%02x:%02x:%02x:%02x:%02x %4d" @@ -316,7 +315,7 @@ sysctl_l2t(SYSCTL_HANDLER_ARGS) e->dmac[3], e->dmac[4], e->dmac[5], e->vlan & 0xfff, vlan_prio(e), e->lport, l2e_state(e), atomic_load_acq_int(&e->refcnt), - e->ifp->if_xname); + e->ifp ? e->ifp->if_xname : "-"); skip: mtx_unlock(&e->lock); } From owner-svn-src-all@freebsd.org Sat Jul 2 05:30:29 2016 Return-Path: Delivered-To: svn-src-all@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 51BE0B8F888; Sat, 2 Jul 2016 05:30:29 +0000 (UTC) (envelope-from ngie@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 1E7C52F7A; Sat, 2 Jul 2016 05:30:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u625USWK052693; Sat, 2 Jul 2016 05:30:28 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u625USXd052691; Sat, 2 Jul 2016 05:30:28 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201607020530.u625USXd052691@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 2 Jul 2016 05:30:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r302314 - in vendor/Juniper/libxo/dist: . tests/core X-SVN-Group: vendor 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.22 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: Sat, 02 Jul 2016 05:30:29 -0000 Author: ngie Date: Sat Jul 2 05:30:27 2016 New Revision: 302314 URL: https://svnweb.freebsd.org/changeset/base/302314 Log: Update libxo to 0.6.3 Obtained from: https://github.com/Juniper/libxo/tree/0.6.3 Sponsored by: EMC / Isilon Storage Division Modified: vendor/Juniper/libxo/dist/configure.ac vendor/Juniper/libxo/dist/tests/core/test_02.c Modified: vendor/Juniper/libxo/dist/configure.ac ============================================================================== --- vendor/Juniper/libxo/dist/configure.ac Fri Jul 1 23:18:49 2016 (r302313) +++ vendor/Juniper/libxo/dist/configure.ac Sat Jul 2 05:30:27 2016 (r302314) @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [0.6.2], [phil@juniper.net]) +AC_INIT([libxo], [0.6.3], [phil@juniper.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability]) # Support silent build rules. Requires at least automake-1.11. Modified: vendor/Juniper/libxo/dist/tests/core/test_02.c ============================================================================== --- vendor/Juniper/libxo/dist/tests/core/test_02.c Fri Jul 1 23:18:49 2016 (r302313) +++ vendor/Juniper/libxo/dist/tests/core/test_02.c Sat Jul 2 05:30:27 2016 (r302314) @@ -70,7 +70,7 @@ main (int argc, char **argv) xo_emit(" {:lines/%7ju} {:words/%7ju} " "{:characters/%7ju} {d:filename/%s}\n", - 20, 30, 40, "file"); + (uintmax_t) 20, (uintmax_t) 30, (uintmax_t) 40, "file"); int i; for (i = 0; i < 5; i++) From owner-svn-src-all@freebsd.org Sat Jul 2 05:32:00 2016 Return-Path: Delivered-To: svn-src-all@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 A6DFFB8F9D8; Sat, 2 Jul 2016 05:32:00 +0000 (UTC) (envelope-from ngie@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 5E75E226D; Sat, 2 Jul 2016 05:32:00 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u625VxGM056008; Sat, 2 Jul 2016 05:31:59 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u625VxMC056007; Sat, 2 Jul 2016 05:31:59 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201607020531.u625VxMC056007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 2 Jul 2016 05:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r302315 - vendor/Juniper/libxo/0.6.3 X-SVN-Group: vendor 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.22 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: Sat, 02 Jul 2016 05:32:00 -0000 Author: ngie Date: Sat Jul 2 05:31:59 2016 New Revision: 302315 URL: https://svnweb.freebsd.org/changeset/base/302315 Log: Copy .../dist to .../0.6.3 Added: - copied from r302314, vendor/Juniper/libxo/dist/ Directory Properties: vendor/Juniper/libxo/0.6.3/ (props changed) From owner-svn-src-all@freebsd.org Sat Jul 2 08:04:48 2016 Return-Path: Delivered-To: svn-src-all@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 CFD75B8E87C; Sat, 2 Jul 2016 08:04:48 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 4AF652917; Sat, 2 Jul 2016 08:04:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-149.carlnfd1.nsw.optusnet.com.au [110.21.100.149]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 068ACD42CAC; Sat, 2 Jul 2016 18:04:43 +1000 (AEST) Date: Sat, 2 Jul 2016 18:04:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Bruce Evans , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern In-Reply-To: <20160701142516.GW38613@kib.kiev.ua> Message-ID: <20160702153817.O1458@besplex.bde.org> References: <201606281643.u5SGhNsi061606@repo.freebsd.org> <20160629175917.O968@besplex.bde.org> <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> <20160701142516.GW38613@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=M8SwUHEs c=1 sm=1 tr=0 a=XDAe9YG+7EcdVXYrgT+/UQ==:117 a=XDAe9YG+7EcdVXYrgT+/UQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=4ILv6jHNVIxmPAOTChkA:9 a=VCnQGyt-0XnCwhVq:21 a=62pVOZO2BG-M9G8m:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 08:04:48 -0000 On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: >> It seems simple and clean enough, but is too much during a re freeze. >> >> I will only make some minor comments about style. > Well, it is not only about style. If you have no more comments, I will > ask for testing. The patch is about fixing bugs, although in somewhat > extended scope, so I think it is still fine as the things do not explode. What about FFCLOCK? That is hard to test. > I added the stats to the patch, it is not that intrusive actually. > > I still do not see why/do not want to use spinlock for the tc_windup() > exclusion. Patch is at the end of the message. It subverts the mutex/witness method for no good reason. You can use mtx_trylock() for the conditional locking. Not so good reasons for doing this are to micro-optimize and to avoid hard-disabling interrupts on the current CPU). But here optimization is not important and hard-disabling interrupts is a feature. Mutexes are only slightly slower, except with debugging options they are much slower but give more features. >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c >>> index 56b2ade..a0dce47 100644 >>> --- a/sys/compat/linprocfs/linprocfs.c >>> +++ b/sys/compat/linprocfs/linprocfs.c >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) >>> struct pcpu *pcpu; >>> long cp_time[CPUSTATES]; >>> long *cp; >>> + struct timeval boottime; >>> int i; >>> >>> read_cpu_time(cp_time); >>> + getboottime(&boottime); >> >> This is used surprisingly often by too many subsystems. With the value still >> broken so that locking it doesn't help much, I would leave it as a global. > I prefer to keep the KPI consistent. Not changing the KPI means keeping boottime as a global. getboottime() is a good KPI for accessing/converting a volatile implementation detail, but a correctly implemented boottime wouldn't be volatile and most uses of boottime are apparently wrong. Most uses are apparently to convert from monotic time to real time. For that, the KPI should be a conversion function. >... >> So maybe use a new general function that returns boottimebin for the >> non-uptime functions only. Possibly it can add the offset directly. > I changed getbintime() and getboottimebin() to use the fenced magic and > fetch boottime inside the loop. This removed the need for binuptime1(). Good. >>> diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> index 1d07943..0879299 100644 >>> --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) >>> { >>> struct svc_rpc_gss_client *client; >>> struct svc_rpc_gss_client_list *list; >>> + struct timeval boottime; >>> unsigned long hostid; >>> >>> rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); >>> >>> getcredhostid(curthread->td_ucred, &hostid); >>> + getboottime(&boottime); >>> if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) >>> return (NULL); >> >> Here it is hopefully just a magic id, with the user being a remote system. >> Any time that doesn't go backwards or forwards so far that it is in the >> lieftime of an old or new boot instance works well for identifying the >> boot instance. > It does not work for leap seconds in the same way as is does not work after > setclock(). So I just leave this conversion as is. We need to understand what such conversions are trying to do. Currently, adding boottime mostly does work for converting monotonic time to real time, since it is the same as what nanotime() and friends do (except with more races). E.g., the leap seconds adjustment normally subtracts 1 second from boottime so that when the monotonic time advances by 1 second the sum doesn't advance and thus gives the real time with POSIX's broken encoding. So the conversion is currently correct if the result is supposed to be the real time with POSIX's encoding. It is unclear what this is useful for. It is non-monotic, and you can't even depend on reversing the conversion by subtracting boottime since boottime isn't invariant. On Fri, 1 Jul 2016, Konstantin Belousov wrote: > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: >> It seems simple and clean enough, but is too much during a re freeze. >> >> I will only make some minor comments about style. > Well, it is not only about style. If you have no more comments, I will > ask for testing. The patch is about fixing bugs, although in somewhat > extended scope, so I think it is still fine as the things do not explode. What about FFCLOCK? That is hard to test. > I added the stats to the patch, it is not that intrusive actually. > > I still do not see why/do not want to use spinlock for the tc_windup() > exclusion. Patch is at the end of the message. It subverts the mutex/witness method for no good reason. You can use mtx_trylock() for the conditional locking. Not so good reasons for doing this are to micro-optimize and to avoid hard-disabling interrupts on the current CPU). But here optimization is not important and hard-disabling interrupts is a feature. Mutexes are only slightly slower, except with debugging options they are much slower but give more features. >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c >>> index 56b2ade..a0dce47 100644 >>> --- a/sys/compat/linprocfs/linprocfs.c >>> +++ b/sys/compat/linprocfs/linprocfs.c >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) >>> struct pcpu *pcpu; >>> long cp_time[CPUSTATES]; >>> long *cp; >>> + struct timeval boottime; >>> int i; >>> >>> read_cpu_time(cp_time); >>> + getboottime(&boottime); >> >> This is used surprisingly often by too many subsystems. With the value still >> broken so that locking it doesn't help much, I would leave it as a global. > I prefer to keep the KPI consistent. Not changing the KPI means keeping boottime as a global. getboottime() is a good KPI for accessing/converting a volatile implementation detail, but a correctly implemented boottime wouldn't be volatile and most uses of boottime are apparently wrong. Most uses are apparently to convert from monotic time to real time. For that, the KPI should be a conversion function. >... >> So maybe use a new general function that returns boottimebin for the >> non-uptime functions only. Possibly it can add the offset directly. > I changed getbintime() and getboottimebin() to use the fenced magic and > fetch boottime inside the loop. This removed the need for binuptime1(). Good. >>> diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> index 1d07943..0879299 100644 >>> --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c >>> @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) >>> { >>> struct svc_rpc_gss_client *client; >>> struct svc_rpc_gss_client_list *list; >>> + struct timeval boottime; >>> unsigned long hostid; >>> >>> rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); >>> >>> getcredhostid(curthread->td_ucred, &hostid); >>> + getboottime(&boottime); >>> if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) >>> return (NULL); >> >> Here it is hopefully just a magic id, with the user being a remote system. >> Any time that doesn't go backwards or forwards so far that it is in the >> lieftime of an old or new boot instance works well for identifying the >> boot instance. > It does not work for leap seconds in the same way as is does not work after > setclock(). So I just leave this conversion as is. We need to understand what such conversions are trying to do. Currently, adding boottime mostly does work for converting monotonic time to real time, since it is the same as what nanotime() and friends do (except with more races). E.g., the leap seconds adjustment normally subtracts 1 second from boottime so that when the monotonic time advances by 1 second the sum doesn't advance and thus gives the real time with POSIX's broken encoding. So the conversion is currently correct if the result is supposed to be the real time with POSIX's encoding. It is unclear what this is useful for. It is non-monotic, and you can't even depend on reversing the conversion by subtracting boottime since boottime isn't invariant. > diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > index 56b2ade..a0dce47 100644 > --- a/sys/compat/linprocfs/linprocfs.c > +++ b/sys/compat/linprocfs/linprocfs.c > @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > struct pcpu *pcpu; > long cp_time[CPUSTATES]; > long *cp; > + struct timeval boottime; > int i; > > read_cpu_time(cp_time); > + getboottime(&boottime); > sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", > T2J(cp_time[CP_USER]), > T2J(cp_time[CP_NICE]), linprocfs's use of boottime is easy to understand. One use is quite broken. linprocfs prints the boot time. This use is OK. linprocfs wants to print ki_start. ki_start is a real time. ps just prints it. But linprocfs subtracts the boot time from it before printing it. This make no sense. Kernel times are kept in p->p_stats->p_start. These are monotonic times. ki_start is this monotonic time misconverted by adding the current boottime. This would be correct if boottime were invariant. Currently it adds the current leap seconds adjustment and larger non-invariance. p_start is not used for much except to print it in ps and friends, so using monotonic time for it seems to be wrong. In FreeBSD-4, it was the real time. des changed it in 2003 to "This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process." But it obviously causes much larger non-potential problems -- any step to fix drift or stopping (suspension) of the clock should not affect times in the past like the start time, but now does. Oops, there is a problem in acct_process(). This needs both a real time and a monotonic time for the start time. ac_btime is the real time of the start. This is calculated by adding boottime to p_start. ac_etime is the elapsed time. This is calculated by subtracing the current monotonic time from the monotonic p_start. des's change fixes this. Applications would still be confused if they add ac_btime to ac_etime and get a time in the future. des maintains linprocfs, and perhaps the difference is supposed to be the elapsed time there too, but its keyword is "starttime". > diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c > index 7cc0f9e..afa3da4 100644 > --- a/sys/fs/devfs/devfs_vnops.c > +++ b/sys/fs/devfs/devfs_vnops.c > @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) > { > struct vnode *vp = ap->a_vp; > struct vattr *vap = ap->a_vap; > - int error; > struct devfs_dirent *de; > struct devfs_mount *dmp; > struct cdev *dev; > + struct timeval boottime; > + int error; > > error = devfs_populate_vp(vp); > if (error != 0) devfs's use of boottime is also easy to understand, and we (you :-) get to maintain devfs. devfs has problems initializing times because it creates device files before the current (real) time is fully initialized (I think before it is initialized at all). For early initialization, it is natural to set all times to the Epoch (0). This can be used as a flag for uninitialized. devfs actually uses the condition tv_sec <= 3600 as a condition for uninitialized. (3600 is a strange value. Why not 86400 so as to handle all possible timezone misadjustments?). When the todr is on wall time, this fixup only works East of Greenwich. It never works here. Device times here are initialized to a time 10-11 hours in the future if first access to the device is before adjkerntz runs to fix up the time. The future times are not considered to be uninitialized, so the fixup is not applied. same problem may affect other file systems, but mostly only affects ones with buggy setting of access times for read-only mounts. This bug was fixed in ffs a couple of years ago.) devfs doesn't support birth times, or the problem would be even more obvious. Later accesses tend to clobber the future times back to the current time, but the birth time would be invariant. This problem is much like the one of getting an invariant boot time. Real times are not really known until after adjkerntz adjusts for the timezone offset in the todr and ntp adjusts for the error in the todr. > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 0f015b3..c9676fc 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > @@ -70,31 +70,22 @@ struct timehands { > ... > static struct timehands th0 = { > - &dummy_timecounter, > - 0, > - (uint64_t)-1 / 1000000, > - 0, > - {1, 0}, > - {0, 0}, > - {0, 0}, > - 1, > - &th1 > + .th_counter = &dummy_timecounter, > + .th_scale = (uint64_t)-1 / 1000000, > + .th_offset = {1, 0}, Is there a syntax for avoiding the explicit 0 in a nested initializer? Something like th_offset.tv_sec = 1. > @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) > void > bintime(struct bintime *bt) > { > + struct bintime boottimebin; > + struct timehands *th; > + u_int gen; > > - binuptime(bt); > + do { > + th = timehands; > + gen = atomic_load_acq_int(&th->th_generation); > + *bt = th->th_offset; > + bintime_addx(bt, th->th_scale * tc_delta(th)); > + boottimebin = th->th_boottime; > + atomic_thread_fence_acq(); > + } while (gen == 0 || gen != th->th_generation); > bintime_add(bt, &boottimebin); > } Better add th_boottime in the loop (and not use a local variable). This saves copying it in the usual case where the loop is only iterated once. Note that th_offset is already copied to the caller's variable and not to a local variable. This is not so good for adding the boot time to it. It might be better to go the other way and copy everything to local variables, but I fear that register pressure and memory clobbers will prevent generating best code then. Best code is to copy everything to registers, then check the generation count, then combine the registers outside the loop. > ... > diff --git a/sys/sys/time.h b/sys/sys/time.h > index 395e888..659f8e0 100644 > --- a/sys/sys/time.h > +++ b/sys/sys/time.h > @@ -372,8 +372,6 @@ void resettodr(void); > > extern volatile time_t time_second; > extern volatile time_t time_uptime; > -extern struct bintime boottimebin; > -extern struct timeval boottime; > extern struct bintime tc_tick_bt; > extern sbintime_t tc_tick_sbt; > extern struct bintime tick_bt; Can we fix more style bugs in this file? Here the variables were unsorted and misindented. > @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); > void getnanotime(struct timespec *tsp); > void getmicrotime(struct timeval *tvp); > > +void getboottime(struct timeval *boottime); > +void getboottimebin(struct bintime *boottimebin); > + > /* Other functions */ > int itimerdecr(struct itimerval *itp, int usec); > int itimerfix(struct timeval *tv); > The new functions probably belong in a new section, but they are only in a subsection of the previous section. They are "Other", not ones described in the comment for the previous section. The comment also doesn't describe the sbintime functions in the section. The placement of these functions also breaks the style of putting inline functions earlier. Other style bugs visible here are verbose variable names and missing 'p' in pointer names mostly for newer functions. The worse names were copied from the function implementations. Bruce From owner-svn-src-all@freebsd.org Sat Jul 2 11:54:22 2016 Return-Path: Delivered-To: svn-src-all@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 3ED77B86DF8; Sat, 2 Jul 2016 11:54:22 +0000 (UTC) (envelope-from ae@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 0BEE82DB8; Sat, 2 Jul 2016 11:54:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u62BsLf2098726; Sat, 2 Jul 2016 11:54:21 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u62BsLI5098724; Sat, 2 Jul 2016 11:54:21 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201607021154.u62BsLI5098724@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sat, 2 Jul 2016 11:54:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302316 - head/sbin/ipfw X-SVN-Group: head 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.22 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: Sat, 02 Jul 2016 11:54:22 -0000 Author: ae Date: Sat Jul 2 11:54:20 2016 New Revision: 302316 URL: https://svnweb.freebsd.org/changeset/base/302316 Log: Hide warning about non-existent lookup tables and informational messages about modified table entry when quied mode enabled. Approved by: re (hrs) Obtained from: Yandex LLC Modified: head/sbin/ipfw/tables.c Modified: head/sbin/ipfw/tables.c ============================================================================== --- head/sbin/ipfw/tables.c Sat Jul 2 05:31:59 2016 (r302315) +++ head/sbin/ipfw/tables.c Sat Jul 2 11:54:20 2016 (r302316) @@ -914,9 +914,10 @@ table_modify_record(ipfw_obj_header *oh, xi.vmask = vmask; strlcpy(xi.tablename, oh->ntlv.name, sizeof(xi.tablename)); - fprintf(stderr, "DEPRECATED: inserting data into " - "non-existent table %s. (auto-created)\n", - xi.tablename); + if (quiet == 0) + warnx("DEPRECATED: inserting data into " + "non-existent table %s. (auto-created)", + xi.tablename); table_do_create(oh, &xi); } @@ -937,8 +938,6 @@ table_modify_record(ipfw_obj_header *oh, error = table_do_modify_record(cmd, oh, tent_buf, count, atomic); - quiet = 0; - /* * Compatibility stuff: do not yell on duplicate keys or * failed deletions. From owner-svn-src-all@freebsd.org Sat Jul 2 14:51:47 2016 Return-Path: Delivered-To: svn-src-all@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 70FF0B8FB05; Sat, 2 Jul 2016 14:51:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB5DE2D1B; Sat, 2 Jul 2016 14:51:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u62EpYHX037165 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 2 Jul 2016 17:51:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u62EpYHX037165 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u62EpYla037164; Sat, 2 Jul 2016 17:51:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 2 Jul 2016 17:51:34 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302252 - head/sys/kern Message-ID: <20160702145134.GI38613@kib.kiev.ua> References: <20160629145443.GG38613@kib.kiev.ua> <20160629153233.GI38613@kib.kiev.ua> <20160630040123.F791@besplex.bde.org> <20160629211953.GK38613@kib.kiev.ua> <20160701005401.Q1084@besplex.bde.org> <20160630180106.GU38613@kib.kiev.ua> <20160701031549.GV38613@kib.kiev.ua> <20160701185743.Q1600@besplex.bde.org> <20160701142516.GW38613@kib.kiev.ua> <20160702153817.O1458@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160702153817.O1458@besplex.bde.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 14:51:47 -0000 On Sat, Jul 02, 2016 at 06:04:43PM +1000, Bruce Evans wrote: > On Fri, 1 Jul 2016, Konstantin Belousov wrote: > > > On Fri, Jul 01, 2016 at 08:39:48PM +1000, Bruce Evans wrote: > >> It seems simple and clean enough, but is too much during a re freeze. > >> > >> I will only make some minor comments about style. > > Well, it is not only about style. If you have no more comments, I will > > ask for testing. The patch is about fixing bugs, although in somewhat > > extended scope, so I think it is still fine as the things do not explode. > > What about FFCLOCK? That is hard to test. I will only ensure that it compiles. > > > I added the stats to the patch, it is not that intrusive actually. > > > > I still do not see why/do not want to use spinlock for the tc_windup() > > exclusion. Patch is at the end of the message. > > It subverts the mutex/witness method for no good reason. You can use > mtx_trylock() for the conditional locking. Not so good reasons for > doing this are to micro-optimize and to avoid hard-disabling interrupts > on the current CPU). But here optimization is not important and > hard-disabling interrupts is a feature. Mutexes are only slightly > slower, except with debugging options they are much slower but give > more features. A reason not to use what you described is that our spinlocks lack try method. I implemented non-recursive trylock_spin. > > >>> diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c > >>> index 56b2ade..a0dce47 100644 > >>> --- a/sys/compat/linprocfs/linprocfs.c > >>> +++ b/sys/compat/linprocfs/linprocfs.c > >>> @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) > >>> struct pcpu *pcpu; > >>> long cp_time[CPUSTATES]; > >>> long *cp; > >>> + struct timeval boottime; > >>> int i; > >>> > >>> read_cpu_time(cp_time); > >>> + getboottime(&boottime); > >> > >> This is used surprisingly often by too many subsystems. With the value still > >> broken so that locking it doesn't help much, I would leave it as a global. > > I prefer to keep the KPI consistent. > > Not changing the KPI means keeping boottime as a global. getboottime() is > a good KPI for accessing/converting a volatile implementation detail, but > a correctly implemented boottime wouldn't be volatile and most uses of > boottime are apparently wrong. Most uses are apparently to convert from > monotic time to real time. For that, the KPI should be a conversion function. I have to stop somewhere with this patch. In particular, I decided to not do the sweeping pass over random subsystems doing bugfixes for what you described above. Current patch bug-to-bug compatible with the existing code, and I will not expand it. > We need to understand what such conversions are trying to do. ... some time later. > > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > > index 0f015b3..c9676fc 100644 > > --- a/sys/kern/kern_tc.c > > +++ b/sys/kern/kern_tc.c > > @@ -70,31 +70,22 @@ struct timehands { > > ... > > static struct timehands th0 = { > > - &dummy_timecounter, > > - 0, > > - (uint64_t)-1 / 1000000, > > - 0, > > - {1, 0}, > > - {0, 0}, > > - {0, 0}, > > - 1, > > - &th1 > > + .th_counter = &dummy_timecounter, > > + .th_scale = (uint64_t)-1 / 1000000, > > + .th_offset = {1, 0}, > > Is there a syntax for avoiding the explicit 0 in a nested initializer? > Something like th_offset.tv_sec = 1. .th_offset = { .sec = 1 }, > > > @@ -378,8 +384,18 @@ microuptime(struct timeval *tvp) > > void > > bintime(struct bintime *bt) > > { > > + struct bintime boottimebin; > > + struct timehands *th; > > + u_int gen; > > > > - binuptime(bt); > > + do { > > + th = timehands; > > + gen = atomic_load_acq_int(&th->th_generation); > > + *bt = th->th_offset; > > + bintime_addx(bt, th->th_scale * tc_delta(th)); > > + boottimebin = th->th_boottime; > > + atomic_thread_fence_acq(); > > + } while (gen == 0 || gen != th->th_generation); > > bintime_add(bt, &boottimebin); > > } > > Better add th_boottime in the loop (and not use a local variable). This > saves copying it in the usual case where the loop is only iterated once. Ok. > > Note that th_offset is already copied to the caller's variable and not > to a local variable. This is not so good for adding the boot time to > it. It might be better to go the other way and copy everything to > local variables, but I fear that register pressure and memory clobbers > will prevent generating best code then. Best code is to copy everything > to registers, then check the generation count, then combine the registers > outside the loop. Lets postpone this, the patch does already enough rototiling. > > > ... > > diff --git a/sys/sys/time.h b/sys/sys/time.h > > index 395e888..659f8e0 100644 > > --- a/sys/sys/time.h > > +++ b/sys/sys/time.h > > @@ -372,8 +372,6 @@ void resettodr(void); > > > > extern volatile time_t time_second; > > extern volatile time_t time_uptime; > > -extern struct bintime boottimebin; > > -extern struct timeval boottime; > > extern struct bintime tc_tick_bt; > > extern sbintime_t tc_tick_sbt; > > extern struct bintime tick_bt; > > Can we fix more style bugs in this file? Here the variables were unsorted > and misindented. And this. diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 56b2ade..a0dce47 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -447,9 +447,11 @@ linprocfs_dostat(PFS_FILL_ARGS) struct pcpu *pcpu; long cp_time[CPUSTATES]; long *cp; + struct timeval boottime; int i; read_cpu_time(cp_time); + getboottime(&boottime); sbuf_printf(sb, "cpu %ld %ld %ld %ld\n", T2J(cp_time[CP_USER]), T2J(cp_time[CP_NICE]), @@ -624,10 +626,12 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + struct timeval boottime; char state; static int ratelimit = 0; vm_offset_t startcode, startdata; + getboottime(&boottime); sx_slock(&proctree_lock); PROC_LOCK(p); fill_kinfo_proc(p, &kp); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7cc0f9e..afa3da4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -707,10 +707,11 @@ devfs_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - int error; struct devfs_dirent *de; struct devfs_mount *dmp; struct cdev *dev; + struct timeval boottime; + int error; error = devfs_populate_vp(vp); if (error != 0) @@ -740,6 +741,7 @@ devfs_getattr(struct vop_getattr_args *ap) vap->va_blocksize = DEV_BSIZE; vap->va_type = vp->v_type; + getboottime(&boottime); #define fix(aa) \ do { \ if ((aa).tv_sec <= 3600) { \ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 4f6e1b9..65b8a54 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -394,7 +394,9 @@ fdesc_getattr(struct vop_getattr_args *ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval boottime; + getboottime(&boottime); vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_fileid = VTOFDESC(vp)->fd_ix; vap->va_uid = 0; diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 921df2d..6b41e2f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -872,7 +872,7 @@ int newnfs_realign(struct mbuf **, int); /* * Set boottime. */ -#define NFSSETBOOTTIME(b) ((b) = boottime) +#define NFSSETBOOTTIME(b) (getboottime(&b)) /* * The size of directory blocks in the buffer cache. diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 5a00ee1..defdec3 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) const char *wmesg; char *pc; char *sep; + struct timeval boottime; int pid, ppid, pgid, sid; int i; @@ -129,6 +130,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) calcru(p, &ut, &st); PROC_STATUNLOCK(p); start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&start, &boottime); sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", (intmax_t)start.tv_sec, start.tv_usec, diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index ef3fd2e..46e6d9b 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -389,7 +389,7 @@ acct_process(struct thread *td) acct.ac_stime = encode_timeval(st); /* (4) The elapsed time the command ran (and its starting time) */ - tmp = boottime; + getboottime(&tmp); timevaladd(&tmp, &p->p_stats->p_start); acct.ac_btime = tmp.tv_sec; microuptime(&tmp); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index e7a7a99..39ffdb3 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -381,7 +381,9 @@ volatile int ticks; int psratio; static DPCPU_DEFINE(int, pcputicks); /* Per-CPU version of ticks. */ -static int global_hardclock_run = 0; +#ifdef DEVICE_POLLING +static int devpoll_run = 0; +#endif /* * Initialize clock frequencies and start both clocks running. @@ -584,15 +586,15 @@ hardclock_cnt(int cnt, int usermode) #endif /* We are in charge to handle this tick duty. */ if (newticks > 0) { - /* Dangerous and no need to call these things concurrently. */ - if (atomic_cmpset_acq_int(&global_hardclock_run, 0, 1)) { - tc_ticktock(newticks); + tc_ticktock(newticks); #ifdef DEVICE_POLLING + /* Dangerous and no need to call these things concurrently. */ + if (atomic_cmpset_acq_int(&devpoll_run, 0, 1)) { /* This is very short and quick. */ hardclock_device_poll(); -#endif /* DEVICE_POLLING */ - atomic_store_rel_int(&global_hardclock_run, 0); + atomic_store_rel_int(&devpoll_run, 0); } +#endif /* DEVICE_POLLING */ #ifdef SW_WATCHDOG if (watchdog_enabled > 0) { i = atomic_fetchadd_int(&watchdog_ticks, -newticks); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index d167205..ae236eb 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -281,6 +281,39 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); } +int +__mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, const char *file, + int line) +{ + struct mtx *m; + + if (SCHEDULER_STOPPED()) + return (1); + + m = mtxlock2mtx(c); + + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_lock_spin() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin, + ("mtx_lock_spin() of sleep mutex %s @ %s:%d", + m->lock_object.lo_name, file, line)); + if (mtx_owned(m)) + KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0 || + (opts & MTX_RECURSE) != 0, + ("mtx_lock_spin: recursed on non-recursive mutex %s @ %s:%d\n", + m->lock_object.lo_name, file, line)); + opts &= ~MTX_RECURSE; + WITNESS_CHECKORDER(&m->lock_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, + file, line, NULL); + if (__mtx_trylock_spin(m, curthread, opts, file, line)) { + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 1, file, line); + WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line); + return (1); + } + LOCK_LOG_TRY("LOCK", &m->lock_object, opts, 0, file, line); + return (0); +} + void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line) diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index d352ee7..efc3713 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -162,29 +162,12 @@ static l_fp time_adj; /* tick adjust (ns/s) */ static int64_t time_adjtime; /* correction from adjtime(2) (usec) */ -static struct mtx ntpadj_lock; -MTX_SYSINIT(ntpadj, &ntpadj_lock, "ntpadj", -#ifdef PPS_SYNC - MTX_SPIN -#else - MTX_DEF -#endif -); +static struct mtx ntp_lock; +MTX_SYSINIT(ntp, &ntp_lock, "ntp", MTX_SPIN); -/* - * When PPS_SYNC is defined, hardpps() function is provided which can - * be legitimately called from interrupt filters. Due to this, use - * spinlock for ntptime state protection, otherwise sleepable mutex is - * adequate. - */ -#ifdef PPS_SYNC -#define NTPADJ_LOCK() mtx_lock_spin(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock_spin(&ntpadj_lock) -#else -#define NTPADJ_LOCK() mtx_lock(&ntpadj_lock) -#define NTPADJ_UNLOCK() mtx_unlock(&ntpadj_lock) -#endif -#define NTPADJ_ASSERT_LOCKED() mtx_assert(&ntpadj_lock, MA_OWNED) +#define NTP_LOCK() mtx_lock_spin(&ntp_lock) +#define NTP_UNLOCK() mtx_unlock_spin(&ntp_lock) +#define NTP_ASSERT_LOCKED() mtx_assert(&ntp_lock, MA_OWNED) #ifdef PPS_SYNC /* @@ -271,7 +254,7 @@ ntp_gettime1(struct ntptimeval *ntvp) { struct timespec atv; /* nanosecond time */ - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); nanotime(&atv); ntvp->time.tv_sec = atv.tv_sec; @@ -302,9 +285,9 @@ sys_ntp_gettime(struct thread *td, struct ntp_gettime_args *uap) { struct ntptimeval ntv; - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); td->td_retval[0] = ntv.time_state; return (copyout(&ntv, uap->ntvp, sizeof(ntv))); @@ -315,9 +298,9 @@ ntp_sysctl(SYSCTL_HANDLER_ARGS) { struct ntptimeval ntv; /* temporary structure */ - NTPADJ_LOCK(); + NTP_LOCK(); ntp_gettime1(&ntv); - NTPADJ_UNLOCK(); + NTP_UNLOCK(); return (sysctl_handle_opaque(oidp, &ntv, sizeof(ntv), req)); } @@ -382,7 +365,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) error = priv_check(td, PRIV_NTP_ADJTIME); if (error != 0) return (error); - NTPADJ_LOCK(); + NTP_LOCK(); if (modes & MOD_MAXERROR) time_maxerror = ntv.maxerror; if (modes & MOD_ESTERROR) @@ -484,7 +467,7 @@ sys_ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap) ntv.stbcnt = pps_stbcnt; #endif /* PPS_SYNC */ retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); error = copyout((caddr_t)&ntv, (caddr_t)uap->tp, sizeof(ntv)); if (error == 0) @@ -506,6 +489,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) int tickrate; l_fp ftemp; /* 32/64-bit temporary */ + NTP_LOCK(); + /* * On rollover of the second both the nanosecond and microsecond * clocks are updated and the state machine cranked as @@ -627,6 +612,8 @@ ntp_update_second(int64_t *adjustment, time_t *newsec) else time_status &= ~STA_PPSSIGNAL; #endif /* PPS_SYNC */ + + NTP_UNLOCK(); } /* @@ -690,7 +677,7 @@ hardupdate(offset) long mtemp; l_fp ftemp; - NTPADJ_ASSERT_LOCKED(); + NTP_ASSERT_LOCKED(); /* * Select how the phase is to be controlled and from which @@ -772,7 +759,7 @@ hardpps(tsp, nsec) long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; - NTPADJ_LOCK(); + NTP_LOCK(); /* * The signal is first processed by a range gate and frequency @@ -956,7 +943,7 @@ hardpps(tsp, nsec) time_freq = pps_freq; out: - NTPADJ_UNLOCK(); + NTP_UNLOCK(); } #endif /* PPS_SYNC */ @@ -999,11 +986,11 @@ kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta) return (error); ltw = (int64_t)delta->tv_sec * 1000000 + delta->tv_usec; } - NTPADJ_LOCK(); + NTP_LOCK(); ltr = time_adjtime; if (delta != NULL) time_adjtime = ltw; - NTPADJ_UNLOCK(); + NTP_UNLOCK(); if (olddelta != NULL) { atv.tv_sec = ltr / 1000000; atv.tv_usec = ltr % 1000000; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2f1f620..892b23a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -872,6 +872,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct session *sp; struct ucred *cred; struct sigacts *ps; + struct timeval boottime; /* For proc_realparent. */ sx_assert(&proctree_lock, SX_LOCKED); @@ -953,6 +954,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_nice = p->p_nice; kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&kp->ki_start, &boottime); PROC_STATLOCK(p); rufetch(p, &kp->ki_rusage); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 0f015b3..e917b5a 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -70,31 +70,22 @@ struct timehands { struct bintime th_offset; struct timeval th_microtime; struct timespec th_nanotime; + struct bintime th_boottime; /* Fields not to be copied in tc_windup start with th_generation. */ u_int th_generation; struct timehands *th_next; }; static struct timehands th0; -static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; -static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; -static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; -static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; -static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; -static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; -static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; -static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; -static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; +static struct timehands th1 = { + .th_next = &th0 +}; static struct timehands th0 = { - &dummy_timecounter, - 0, - (uint64_t)-1 / 1000000, - 0, - {1, 0}, - {0, 0}, - {0, 0}, - 1, - &th1 + .th_counter = &dummy_timecounter, + .th_scale = (uint64_t)-1 / 1000000, + .th_offset = { .sec = 1 }, + .th_generation = 1, + .th_next = &th1 }; static struct timehands *volatile timehands = &th0; @@ -106,8 +97,6 @@ int tc_min_ticktock_freq = 1; volatile time_t time_second = 1; volatile time_t time_uptime = 1; -struct bintime boottimebin; -struct timeval boottime; static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); @@ -135,7 +124,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ -static void tc_windup(void); +static void tc_windup(struct bintime *new_boottimebin); static void cpu_tick_calibrate(int); void dtrace_getnanotime(struct timespec *tsp); @@ -143,6 +132,10 @@ void dtrace_getnanotime(struct timespec *tsp); static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) { + struct timeval boottime; + + getboottime(&boottime); + #ifndef __mips__ #ifdef SCTL_MASK32 int tv[2]; @@ -150,11 +143,11 @@ sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) if (req->flags & SCTL_MASK32) { tv[0] = boottime.tv_sec; tv[1] = boottime.tv_usec; - return SYSCTL_OUT(req, tv, sizeof(tv)); - } else + return (SYSCTL_OUT(req, tv, sizeof(tv))); + } #endif #endif - return SYSCTL_OUT(req, &boottime, sizeof(boottime)); + return (SYSCTL_OUT(req, &boottime, sizeof(boottime))); } static int @@ -164,7 +157,7 @@ sysctl_kern_timecounter_get(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; ncount = tc->tc_get_timecount(tc); - return sysctl_handle_int(oidp, &ncount, 0, req); + return (sysctl_handle_int(oidp, &ncount, 0, req)); } static int @@ -174,7 +167,7 @@ sysctl_kern_timecounter_freq(SYSCTL_HANDLER_ARGS) struct timecounter *tc = arg1; freq = tc->tc_frequency; - return sysctl_handle_64(oidp, &freq, 0, req); + return (sysctl_handle_64(oidp, &freq, 0, req)); } /* @@ -198,7 +191,7 @@ tc_delta(struct timehands *th) */ #ifdef FFCLOCK -void +static void fbclock_binuptime(struct bintime *bt) { struct timehands *th; @@ -234,9 +227,17 @@ fbclock_microuptime(struct timeval *tvp) void fbclock_bintime(struct bintime *bt) { + struct timehands *th; + unsigned int gen; - fbclock_binuptime(bt); - bintime_add(bt, &boottimebin); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + bintime_add(bt, &th->th_boottime); + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); } void @@ -309,9 +310,9 @@ fbclock_getbintime(struct bintime *bt) th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + bintime_add(bt, &th->th_boottime); atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); - bintime_add(bt, &boottimebin); } void @@ -378,9 +379,17 @@ microuptime(struct timeval *tvp) void bintime(struct bintime *bt) { + struct timehands *th; + u_int gen; - binuptime(bt); - bintime_add(bt, &boottimebin); + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *bt = th->th_offset; + bintime_addx(bt, th->th_scale * tc_delta(th)); + bintime_add(bt, &th->th_boottime); + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); } void @@ -453,9 +462,9 @@ getbintime(struct bintime *bt) th = timehands; gen = atomic_load_acq_int(&th->th_generation); *bt = th->th_offset; + bintime_add(bt, &th->th_boottime); atomic_thread_fence_acq(); } while (gen == 0 || gen != th->th_generation); - bintime_add(bt, &boottimebin); } void @@ -487,6 +496,29 @@ getmicrotime(struct timeval *tvp) } #endif /* FFCLOCK */ +void +getboottime(struct timeval *boottime) +{ + struct bintime boottimebin; + + getboottimebin(&boottimebin); + bintime2timeval(&boottimebin, boottime); +} + +void +getboottimebin(struct bintime *boottimebin) +{ + struct timehands *th; + u_int gen; + + do { + th = timehands; + gen = atomic_load_acq_int(&th->th_generation); + *boottimebin = th->th_boottime; + atomic_thread_fence_acq(); + } while (gen == 0 || gen != th->th_generation); +} + #ifdef FFCLOCK /* * Support for feed-forward synchronization algorithms. This is heavily inspired @@ -1103,6 +1135,7 @@ int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, int whichclock, uint32_t flags) { + struct bintime boottimebin; #ifdef FFCLOCK struct bintime bt2; uint64_t period; @@ -1116,8 +1149,10 @@ sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, if (cs->delta > 0) bintime_addx(bt, cs->fb_info.th_scale * cs->delta); - if ((flags & FBCLOCK_UPTIME) == 0) + if ((flags & FBCLOCK_UPTIME) == 0) { + getboottimebin(&boottimebin); bintime_add(bt, &boottimebin); + } break; #ifdef FFCLOCK case SYSCLOCK_FFWD: @@ -1226,10 +1261,12 @@ tc_getfrequency(void) return (timehands->th_counter->tc_frequency); } +static struct mtx tc_setclock_mtx; +MTX_SYSINIT(tc_setclock_init, &tc_setclock_mtx, "tcsetc", MTX_SPIN); + /* * Step our concept of UTC. This is done by modifying our estimate of * when we booted. - * XXX: not locked. */ void tc_setclock(struct timespec *ts) @@ -1237,26 +1274,24 @@ tc_setclock(struct timespec *ts) struct timespec tbef, taft; struct bintime bt, bt2; - cpu_tick_calibrate(1); - nanotime(&tbef); timespec2bintime(ts, &bt); + nanotime(&tbef); + mtx_lock_spin(&tc_setclock_mtx); + cpu_tick_calibrate(1); binuptime(&bt2); bintime_sub(&bt, &bt2); - bintime_add(&bt2, &boottimebin); - boottimebin = bt; - bintime2timeval(&bt, &boottime); /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(); - nanotime(&taft); + tc_windup(&bt); + mtx_unlock_spin(&tc_setclock_mtx); if (timestepwarnings) { + nanotime(&taft); log(LOG_INFO, "Time stepped from %jd.%09ld to %jd.%09ld (%jd.%09ld)\n", (intmax_t)tbef.tv_sec, tbef.tv_nsec, (intmax_t)taft.tv_sec, taft.tv_nsec, (intmax_t)ts->tv_sec, ts->tv_nsec); } - cpu_tick_calibrate(1); } /* @@ -1265,7 +1300,7 @@ tc_setclock(struct timespec *ts) * timecounter and/or do seconds processing in NTP. Slightly magic. */ static void -tc_windup(void) +tc_windup(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; @@ -1289,6 +1324,8 @@ tc_windup(void) th->th_generation = 0; atomic_thread_fence_rel(); bcopy(tho, th, offsetof(struct timehands, th_generation)); + if (new_boottimebin != NULL) + th->th_boottime = *new_boottimebin; /* * Capture a timecounter delta on the current timecounter and if @@ -1338,7 +1375,7 @@ tc_windup(void) * case we missed a leap second. */ bt = th->th_offset; - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; if (i > LARGE_STEP) i = 2; @@ -1346,7 +1383,7 @@ tc_windup(void) t = bt.sec; ntp_update_second(&th->th_adjustment, &bt.sec); if (bt.sec != t) - boottimebin.sec += bt.sec - t; + th->th_boottime.sec += bt.sec - t; } /* Update the UTC timestamps used by the get*() functions. */ /* XXX shouldn't do this here. Should force non-`get' versions. */ @@ -1769,7 +1806,7 @@ pps_event(struct pps_state *pps, int event) tcount &= pps->capth->th_counter->tc_counter_mask; bt = pps->capth->th_offset; bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime_add(&bt, &boottimebin); + bintime_add(&bt, &pps->capth->th_boottime); bintime2timespec(&bt, &ts); /* If the timecounter was wound up underneath us, bail out. */ @@ -1842,11 +1879,14 @@ tc_ticktock(int cnt) { static int count; - count += cnt; - if (count < tc_tick) - return; - count = 0; - tc_windup(); + if (mtx_trylock_spin(&tc_setclock_mtx)) { + count += cnt; + if (count >= tc_tick) { + count = 0; + tc_windup(NULL); + } + mtx_unlock_spin(&tc_setclock_mtx); + } } static void __inline @@ -1921,7 +1961,9 @@ inittimecounter(void *dummy) /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter); - tc_windup(); + mtx_lock_spin(&tc_setclock_mtx); + tc_windup(NULL); + mtx_unlock_spin(&tc_setclock_mtx); } SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); @@ -2095,7 +2137,7 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th) vdso_th->th_offset_count = th->th_offset_count; vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; - vdso_th->th_boottime = boottimebin; + vdso_th->th_boottime = th->th_boottime; enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; @@ -2116,8 +2158,8 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) vdso_th32->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th32->th_offset.sec = th->th_offset.sec; *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; - vdso_th32->th_boottime.sec = boottimebin.sec; - *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; + vdso_th32->th_boottime.sec = th->th_boottime.sec; + *(uint64_t *)&vdso_th32->th_boottime.frac[0] = th->th_boottime.frac; enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 148da2b..82710f7 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -115,9 +115,7 @@ settime(struct thread *td, struct timeval *tv) struct timeval delta, tv1, tv2; static struct timeval maxtime, laststep; struct timespec ts; - int s; - s = splclock(); microtime(&tv1); delta = *tv; timevalsub(&delta, &tv1); @@ -147,10 +145,8 @@ settime(struct thread *td, struct timeval *tv) printf("Time adjustment clamped to -1 second\n"); } } else { - if (tv1.tv_sec == laststep.tv_sec) { - splx(s); + if (tv1.tv_sec == laststep.tv_sec) return (EPERM); - } if (delta.tv_sec > 1) { tv->tv_sec = tv1.tv_sec + 1; printf("Time adjustment clamped to +1 second\n"); @@ -161,10 +157,8 @@ settime(struct thread *td, struct timeval *tv) ts.tv_sec = tv->tv_sec; ts.tv_nsec = tv->tv_usec * 1000; - mtx_lock(&Giant); tc_setclock(&ts); resettodr(); - mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c index dbad36d..4bac324 100644 --- a/sys/kern/subr_rtc.c +++ b/sys/kern/subr_rtc.c @@ -172,11 +172,11 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; - mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ + mtx_lock(&resettodr_lock); error = CLOCK_SETTIME(clock_dev, &ts); mtx_unlock(&resettodr_lock); if (error != 0) diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 37139c1..f47ae7c 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -517,7 +517,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { struct procdesc *pd; - struct timeval pstart; + struct timeval pstart, boottime; /* * XXXRW: Perhaps we should cache some more information from the @@ -532,6 +532,7 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, /* Set birth and [acm] times to process start time. */ pstart = pd->pd_proc->p_stats->p_start; + getboottime(&boottime); timevaladd(&pstart, &boottime); TIMEVAL_TO_TIMESPEC(&pstart, &sb->st_birthtim); sb->st_atim = sb->st_birthtim; diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 3b12cf4..4251f71 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -2328,12 +2328,13 @@ bpf_hdrlen(struct bpf_d *d) static void bpf_bintime2ts(struct bintime *bt, struct bpf_ts *ts, int tstype) { - struct bintime bt2; + struct bintime bt2, boottimebin; struct timeval tsm; struct timespec tsn; if ((tstype & BPF_T_MONOTONIC) == 0) { bt2 = *bt; + getboottimebin(&boottimebin); bintime_add(&bt2, &boottimebin); bt = &bt2; } diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index d186ba5..7faf99f 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -395,6 +395,7 @@ swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) static void export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) { + struct timeval boottime; cntr->size = sizeof(*cntr); @@ -403,21 +404,26 @@ export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } static void export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) { + struct timeval boottime; if (krule->cntr != NULL) { cntr->pcnt = counter_u64_fetch(krule->cntr); cntr->bcnt = counter_u64_fetch(krule->cntr + 1); cntr->timestamp = krule->timestamp; } - if (cntr->timestamp > 0) + if (cntr->timestamp > 0) { + getboottime(&boottime); cntr->timestamp += boottime.tv_sec; + } } /* @@ -2048,11 +2054,13 @@ ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) char *ep = bp + space; struct ip_fw *rule; struct ip_fw_rule0 *dst; + struct timeval boottime; int error, i, l, warnflag; time_t boot_seconds; warnflag = 0; + getboottime(&boottime); boot_seconds = boottime.tv_sec; for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 7d11672..c84413e 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -241,6 +241,7 @@ nfs_dolock(struct vop_advlock_args *ap) struct flock *fl; struct proc *p; struct nfsmount *nmp; + struct timeval boottime; td = curthread; p = td->td_proc; @@ -284,6 +285,7 @@ nfs_dolock(struct vop_advlock_args *ap) p->p_nlminfo = malloc(sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + getboottime(&boottime); timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 1d07943..0879299 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -504,11 +504,13 @@ svc_rpc_gss_find_client(struct svc_rpc_gss_clientid *id) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_find_client(%d)", id->ci_id); getcredhostid(curthread->td_ucred, &hostid); + getboottime(&boottime); if (id->ci_hostid != hostid || id->ci_boottime != boottime.tv_sec) return (NULL); @@ -537,6 +539,7 @@ svc_rpc_gss_create_client(void) { struct svc_rpc_gss_client *client; struct svc_rpc_gss_client_list *list; + struct timeval boottime; unsigned long hostid; rpc_gss_log_debug("in svc_rpc_gss_create_client()"); @@ -547,6 +550,7 @@ svc_rpc_gss_create_client(void) sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); client->cl_id.ci_hostid = hostid; + getboottime(&boottime); client->cl_id.ci_boottime = boottime.tv_sec; client->cl_id.ci_id = svc_rpc_gss_next_clientid++; list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE]; diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 0443922..db05fc9 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -112,6 +112,8 @@ void __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line); void __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); +int __mtx_trylock_spin_flags(volatile uintptr_t *c, int opts, + const char *file, int line); void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, const char *file, int line); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -152,6 +154,8 @@ void thread_lock_flags_(struct thread *, int, const char *, int); __mtx_unlock_flags(&(m)->mtx_lock, o, f, l) #define _mtx_lock_spin_flags(m, o, f, l) \ __mtx_lock_spin_flags(&(m)->mtx_lock, o, f, l) +#define _mtx_trylock_spin_flags(m, o, f, l) \ + __mtx_trylock_spin_flags(&(m)->mtx_lock, o, f, l) #define _mtx_unlock_spin_flags(m, o, f, l) \ __mtx_unlock_spin_flags(&(m)->mtx_lock, o, f, l) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) @@ -212,6 +216,21 @@ void thread_lock_flags_(struct thread *, int, const char *, int); LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ mp, 0, 0, file, line); \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid))) {\ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ + mp, 0, 0, file, line); \ + _ret = 1; \ + } \ + _ret; \ +}) #else /* SMP */ #define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ @@ -224,6 +243,20 @@ void thread_lock_flags_(struct thread *, int, const char *, int); (mp)->mtx_lock = _tid; \ } \ } while (0) +#define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ + uintptr_t _tid = (uintptr_t)(tid); \ + int _ret; \ + \ + spinlock_enter(); \ + if (((mp)->mtx_lock != MTX_UNOWNED) \ + spinlock_exit(); \ + _ret = 0; \ + } else { \ + (mp)->mtx_lock = _tid; \ + _ret = 1; \ + } \ + _ret; \ +}) #endif /* SMP */ /* Unlock a normal mutex. */ @@ -302,6 +335,7 @@ void thread_lock_flags_(struct thread *, int, const char *, int); #define mtx_lock(m) mtx_lock_flags((m), 0) #define mtx_lock_spin(m) mtx_lock_spin_flags((m), 0) #define mtx_trylock(m) mtx_trylock_flags((m), 0) +#define mtx_trylock_spin(m) mtx_trylock_spin_flags((m), 0) #define mtx_unlock(m) mtx_unlock_flags((m), 0) #define mtx_unlock_spin(m) mtx_unlock_spin_flags((m), 0) @@ -335,6 +369,8 @@ extern struct mtx_pool *mtxpool_sleep; _mtx_unlock_flags((m), (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ _mtx_lock_spin_flags((m), (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + _mtx_trylock_spin_flags((m), (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ _mtx_unlock_spin_flags((m), (opts), (file), (line)) #else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ @@ -344,6 +380,8 @@ extern struct mtx_pool *mtxpool_sleep; __mtx_unlock((m), curthread, (opts), (file), (line)) #define mtx_lock_spin_flags_(m, opts, file, line) \ __mtx_lock_spin((m), curthread, (opts), (file), (line)) +#define mtx_trylock_spin_flags_(m, opts, file, line) \ + __mtx_trylock_spin((m), curthread, (opts), (file), (line)) #define mtx_unlock_spin_flags_(m, opts, file, line) \ __mtx_unlock_spin((m)) #endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ @@ -369,6 +407,8 @@ extern struct mtx_pool *mtxpool_sleep; mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_trylock_flags(m, opts) \ mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) +#define mtx_trylock_spin_flags(m, opts) \ + mtx_trylock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) #define mtx_assert(m, what) \ mtx_assert_((m), (what), __FILE__, __LINE__) diff --git a/sys/sys/time.h b/sys/sys/time.h index 395e888..659f8e0 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -372,8 +372,6 @@ void resettodr(void); extern volatile time_t time_second; extern volatile time_t time_uptime; -extern struct bintime boottimebin; -extern struct timeval boottime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; extern struct bintime tick_bt; @@ -440,6 +438,9 @@ void getbintime(struct bintime *bt); void getnanotime(struct timespec *tsp); void getmicrotime(struct timeval *tvp); +void getboottime(struct timeval *boottime); +void getboottimebin(struct bintime *boottimebin); + /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); From owner-svn-src-all@freebsd.org Sat Jul 2 16:09:22 2016 Return-Path: Delivered-To: svn-src-all@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 87A51B8FC48; Sat, 2 Jul 2016 16:09:22 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A2112EA8; Sat, 2 Jul 2016 16:09:22 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x235.google.com with SMTP id a66so64632725wme.0; Sat, 02 Jul 2016 09:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MH4cRgkbLTXWokF9jS0AJTH+mHR5T95Hz/NaZETFwZg=; b=K+uH4dgmpFNGe1TbNSJL/cJNZAzqvEgT3BIl79rqw0qgoOpjPgkVQHujIdn1Hunn2U dMg9pHTw8AFN/Wsz9Cl3tShKrS6fTplc4Ab+083qcO6FudS2NAzfXbkBfLEmFm9ixRVx Mi3xNSqiG1bsreT+Fsttf4EKSRDzgz7tBypwecKnMEnG2SeS1vF64jknYm6PHfOj73vV UqJBTfo9J+/nbSrytEABhrCtCVucnTTYXebcUlcm3CdqnOljL+AIRjhStrTaDXWHIYTz 6GO67mqE4eXCfAuXOIBbxvpkByWi0h0ptWwNz0RHJDVwElO5iOlS0UfOQ/D6nhR8LVfE nkjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=MH4cRgkbLTXWokF9jS0AJTH+mHR5T95Hz/NaZETFwZg=; b=I+0Lq3g88KciAZZDGhVIQ7gf6CfjL7/zLyJZHw76/QtregMBphdVl/uRi5MSBRbJI8 G238zuCuxvjmdtbuvlQ0T8R9H1TaSqYZsFdByMIxh3qhfa6Iw5lCovzKt3g9Uo1R4VTF j+HPASx1wKm9JquBHw+GmHpdpMjI6e1YU3wYQ7jWA6Sq76FKnyLX4W66kYc9oMm+WRBC S8Jn/suAOnUNVrm4yVzKgL5Op7Kn03EOmvT3cUr3aViqsZINrwRe5Oxg5jZl1D0hFHEJ DHbv/rz07LNU21HNhP0iBBVx0kDMeQhCsDjcr/Ki9tLuHF2qTQlFBvYUmu3Q/EZh11d0 Ut9w== X-Gm-Message-State: ALyK8tJq6Oh9yXGgiU6/4vZPWGkYZIHObYimKWzXBj5FjZJ4Af0yDh9yL4XCMS19Mdnd1A== X-Received: by 10.194.239.232 with SMTP id vv8mr3227618wjc.166.1467475760470; Sat, 02 Jul 2016 09:09:20 -0700 (PDT) Received: from brick (adeg137.neoplus.adsl.tpnet.pl. [79.184.84.137]) by smtp.gmail.com with ESMTPSA id r130sm3983531wmf.20.2016.07.02.09.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jul 2016 09:09:19 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Sat, 2 Jul 2016 18:09:16 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r302297 - in head/sys/cddl/contrib/opensolaris: common/acl uts/common/fs/zfs uts/common/sys Message-ID: <20160702160916.GA1985@brick> Mail-Followup-To: Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201606301455.u5UEtnLs090648@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201606301455.u5UEtnLs090648@repo.freebsd.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 02 Jul 2016 16:09:22 -0000 On 0630T1455, Alexander Motin wrote: > Author: mav > Date: Thu Jun 30 14:55:49 2016 > New Revision: 302297 > URL: https://svnweb.freebsd.org/changeset/base/302297 > > Log: > Revert r299454 and r299448. > > Those changes were found confusing FreeBSD libc ACL code, that doesn't > differentiate ACL for directories and files, and report ACLs for all > directories created after those patches as non-trivial. On the other > side these changes were considered wrong from POSIX and NFSv4 points of > view. Until further investigation done upstream, revert those changes > locally in preparation for FreeBSD 11.0 release. Thanks! But it still doesn't pass the regression tests, due to broken (or at least incompatible) interaction between inheritance and umask.