From owner-svn-src-head@freebsd.org Sun Mar 31 04:57:52 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 084BC1572CE7; Sun, 31 Mar 2019 04:57:52 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A001C8FF58; Sun, 31 Mar 2019 04:57:51 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 774D721DB9; Sun, 31 Mar 2019 04:57:51 +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 x2V4vpdn091158; Sun, 31 Mar 2019 04:57:51 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V4vp1R091156; Sun, 31 Mar 2019 04:57:51 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201903310457.x2V4vp1R091156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sun, 31 Mar 2019 04:57:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345744 - in head/libexec: rc/rc.d save-entropy X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/libexec: rc/rc.d save-entropy X-SVN-Commit-Revision: 345744 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A001C8FF58 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.92)[-0.925,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 04:57:52 -0000 Author: cem Date: Sun Mar 31 04:57:50 2019 New Revision: 345744 URL: https://svnweb.freebsd.org/changeset/base/345744 Log: random(4): Attempt to persist entropy promptly The goal of saving entropy in Fortuna is two-fold: (1) to provide early availability of the random device (unblocking) on next boot; and (2), to have known, high-quality entropy available for that initial seed. We know it is high quality because it's output taken from Fortuna. The FS&K paper makes it clear that Fortuna unblocks when enough bits have been input that the output //may// be safely seeded. But they emphasize that the quality of various entropy sources is unknown, and a saved entropy file is essential for both availability and ensuring initial unpredictability. In FreeBSD we persist entropy using two mechanisms: 1. The /etc/rc.d/random shutdown() function, which is used for ordinary shutdowns and reboots; and, 2. A cron job that runs every dozen minutes or so to persist new entropy, in case the system suffers from power loss or a crash (bypassing the ordinary shutdown path). Filesystems are free to cache dirty data indefinitely, with arbitrary flush policy. Fsync must be used to ensure the data is persisted, especially for the cron job save-entropy, whose entire goal is power loss and crash safe entropy persistence. Ordinary shutdown may not need the fsync because unmount should flush out the dirty entropy file shortly afterwards. But it is always possible power loss or crash occurs during the short window after rc.d/random shutdown runs and before the filesystem is unmounted, so the additional fsync there seems harmless. PR: 230876 Reviewed by: delphij, markj, markm Approved by: secteam (delphij) Differential Revision: https://reviews.freebsd.org/D19742 Modified: head/libexec/rc/rc.d/random head/libexec/save-entropy/save-entropy.sh Modified: head/libexec/rc/rc.d/random ============================================================================== --- head/libexec/rc/rc.d/random Sun Mar 31 04:24:51 2019 (r345743) +++ head/libexec/rc/rc.d/random Sun Mar 31 04:57:50 2019 (r345744) @@ -25,7 +25,8 @@ save_dev_random() for f ; do debug "saving entropy to $f" dd if=/dev/random of="$f" bs=4096 count=1 status=none && - chmod 600 "$f" + chmod 600 "$f" && + fsync "$f" "$(dirname "$f")" done umask ${oumask} } @@ -120,6 +121,9 @@ random_stop() dd if=/dev/random of=${entropy_file_confirmed} \ bs=4096 count=1 2> /dev/null || warn 'write failed (unwriteable file or full fs?)' + fsync "${entropy_file_confirmed}" \ + "$(dirname "${entropy_file_confirmed}")" \ + 2> /dev/null echo '.' ;; esac @@ -145,6 +149,9 @@ random_stop() dd if=/dev/random of=${entropy_boot_file_confirmed} \ bs=4096 count=1 2> /dev/null || warn 'write failed (unwriteable file or full fs?)' + fsync "${entropy_boot_file_confirmed}" \ + "$(dirname "${entropy_boot_file_confirmed}")" \ + 2> /dev/null echo '.' ;; esac Modified: head/libexec/save-entropy/save-entropy.sh ============================================================================== --- head/libexec/save-entropy/save-entropy.sh Sun Mar 31 04:24:51 2019 (r345743) +++ head/libexec/save-entropy/save-entropy.sh Sun Mar 31 04:57:50 2019 (r345744) @@ -90,5 +90,6 @@ while [ ${n} -ge 1 ]; do done dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null +fsync saved-entropy.1 "." exit 0 From owner-svn-src-head@freebsd.org Sun Mar 31 09:52:38 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED0B91555AB9; Sun, 31 Mar 2019 09:52:37 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9021771859; Sun, 31 Mar 2019 09:52:37 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B5EB251B0; Sun, 31 Mar 2019 09:52:37 +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 x2V9qbAC048822; Sun, 31 Mar 2019 09:52:37 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V9qaAC048820; Sun, 31 Mar 2019 09:52:36 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903310952.x2V9qaAC048820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 31 Mar 2019 09:52:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345751 - head/sys/dev/usb/wlan X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: head/sys/dev/usb/wlan X-SVN-Commit-Revision: 345751 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9021771859 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 09:52:38 -0000 Author: avos Date: Sun Mar 31 09:52:36 2019 New Revision: 345751 URL: https://svnweb.freebsd.org/changeset/base/345751 Log: uath(4), urtw(4): restart driver if device does not respond after Tx request MFC after: 1 week Modified: head/sys/dev/usb/wlan/if_uath.c head/sys/dev/usb/wlan/if_urtw.c Modified: head/sys/dev/usb/wlan/if_uath.c ============================================================================== --- head/sys/dev/usb/wlan/if_uath.c Sun Mar 31 06:21:32 2019 (r345750) +++ head/sys/dev/usb/wlan/if_uath.c Sun Mar 31 09:52:36 2019 (r345751) @@ -1276,8 +1276,8 @@ uath_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - /*uath_init(sc); XXX needs a process context! */ counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc); Modified: head/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- head/sys/dev/usb/wlan/if_urtw.c Sun Mar 31 06:21:32 2019 (r345750) +++ head/sys/dev/usb/wlan/if_urtw.c Sun Mar 31 09:52:36 2019 (r345751) @@ -1891,11 +1891,13 @@ static void urtw_watchdog(void *arg) { struct urtw_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - counter_u64_add(sc->sc_ic.ic_oerrors, 1); + counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); From owner-svn-src-head@freebsd.org Sun Mar 31 13:04:58 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19401155CF71; Sun, 31 Mar 2019 13:04:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 52DF8801C6; Sun, 31 Mar 2019 13:04:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id C140A435AFF; Mon, 1 Apr 2019 00:04:46 +1100 (AEDT) Date: Mon, 1 Apr 2019 00:04:45 +1100 (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: r345696 - head/lib/libvgl In-Reply-To: <20190331121015.GK1923@kib.kiev.ua> Message-ID: <20190331231926.M1259@besplex.bde.org> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> <20190329182100.GZ1923@kib.kiev.ua> <20190330142319.I1011@besplex.bde.org> <20190330094558.GA1923@kib.kiev.ua> <20190331214235.K961@besplex.bde.org> <20190331121015.GK1923@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.2 cv=P6RKvmIu c=1 sm=1 tr=0 cx=a_idp_d a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=eXRxiV3CohSvq8xHZQUA:9 a=H1mtotZp0YcqXXkM:21 a=0wmE6ijukHcXjSzu:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-Rspamd-Queue-Id: 52DF8801C6 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.85 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.85)[-0.850,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 13:04:58 -0000 On Sun, 31 Mar 2019, Konstantin Belousov wrote: > On Sun, Mar 31, 2019 at 10:27:54PM +1100, Bruce Evans wrote: >> On Sat, 30 Mar 2019, Konstantin Belousov wrote: >> >>> On Sat, Mar 30, 2019 at 03:24:40PM +1100, Bruce Evans wrote: >>>> On Fri, 29 Mar 2019, Konstantin Belousov wrote: >>>> >>>>> On Fri, Mar 29, 2019 at 03:57:09PM +0000, Bruce Evans wrote: >>>>>> Author: bde >>>>>> Date: Fri Mar 29 15:57:08 2019 >>>>>> New Revision: 345696 >>>>>> URL: https://svnweb.freebsd.org/changeset/base/345696 >>>>>> >>>>>> Log: >>>>>> Fix endless loops for handling SIGBUS and SIGSEGV. >>>>>> >>>>>> r80270 has the usual wrong fix for unsafe signal handling -- just set >>>>>> a flag and return to let an event loop check the flag and do safe >>>>>> handling. This never works for signals like SIGBUS and SIGSEGV that >>>>>> repeat and works poorly for others unless the application has an event >>>>>> loop designed to support this. >>>>>> >>>>>> For these signals, clean up unsafely as before, except for arranging that >>>>>> nested signals are fatal and forcing a nested signal if the cleanup doesn't >>>>>> cause one. >>>>>> >>>>>> Modified: >>>>>> head/lib/libvgl/main.c >>>>>> >>>>>> Modified: head/lib/libvgl/main.c >>>>>> ============================================================================== >>>>>> --- head/lib/libvgl/main.c Fri Mar 29 15:20:48 2019 (r345695) >>>>>> +++ head/lib/libvgl/main.c Fri Mar 29 15:57:08 2019 (r345696) >>>>>> ... >>>>>> @@ -107,14 +107,22 @@ struct vt_mode smode; >>>>>> } >>>>>> >>>>>> static void >>>>>> -VGLAbort(int arg __unused) >>>>>> +VGLAbort(int arg) >>>>>> { >>>>>> + sigset_t mask; >>>>>> + >>>>>> VGLAbortPending = 1; >>>>>> signal(SIGINT, SIG_IGN); >>>>>> signal(SIGTERM, SIG_IGN); >>>>>> - signal(SIGSEGV, SIG_IGN); >>>>>> - signal(SIGBUS, SIG_IGN); >>>>>> signal(SIGUSR2, SIG_IGN); >>>>>> + if (arg == SIGBUS || arg == SIGSEGV) { >>>>>> + signal(arg, SIG_DFL); >>>>>> + sigemptyset(&mask); >>>>>> + sigaddset(&mask, arg); >>>>>> + sigprocmask(SIG_UNBLOCK, &mask, NULL); >>>>>> + VGLEnd(); >>>>>> + kill(getpid(), arg); >>>>> This of course misses the siginfo information from the real fault. >>>> >>>> It is in the nested signal frame. >>>> >>>>> Why SIGBUS/SIGSEGV are caught at all ? >>>> >>>> Otherwise, the screen is left in an application mode that the kernel >>>> doesn't support (except to not write to the screen, so that the >>>> application has full control). >> >> Also, the keyboard may be left in a strange state. Usually this is no >> worse than termios raw mode, but it may be raw scancodes. In raw scancodes >> mode, Alt-Fn to switch to another vty to fix the problem. libvgl disables >> switching to another vty without going through a libvgl handler anyway. >> The combination is usually enough to break switching to vty0 to run ddb, >> though that should work for at least breakpoints in the kernel. IIRC, >> sc_cngrab() switches the keyboard mode, and my version of it restores >> ignoring of the anti-switch flag. >> >>> ... >>> I am more about not doing kill(2) from the handler, instead do plain >>> return to the context which caused the original signal. >> >> That won't work well for SIGBUS's and SIGSEGV's related to the library. >> If the above cleanup is not done, then it is too hard to debug the problem, >> and if the above cleanup is done then it is impossible to debug the original >> problem if it was for and invalid access in libvgl code. >> >> The latter is a problem for the above cleanup too -- the cleanup clobbers >> the libvgl state. >> >> However, I could do a more limited cleanup of just restoring the screen and >> keyboard state using ioctls. ioctl() isn't async-signal safe in POSIX, but >> most ioctls are async-signal safe in practice provided they don't use >> global variables that were set too recently or too non-atomically. >> VGLEnd() uses main globals established by VGLInit(). It depends on program >> order which is not guaranteed in signal handlers for testing the flags set >> by initialization. The cleanup now also does: >> - screen clearing. This breaks debugging and is dangerous if the bug is >> in screen clearing. Screen clearing is also very slow, and belongs >> in the kernel. It is now done 4 times per libvgl use, but its >> slowness is limited by the kernel not clearing properly and the >> kernel not allowing the application to mmap() the whole physical >> frame buffer in some versions of FreeBSD (this breaks panning). >> - munmap(). This breaks debugging. >> - free() of backing store buffer and the main VGLDisplay data. This breaks >> debugging and is unnecessary if we are going to exit. > > You can only try to do async-safe calls from SIGSEGV handler, to not > break a limited chances to success. Also you should not modify in-memory > state for the library, for the same reason, and then it fits your goal > of keeping the state intact for debugging. Then you should return to > re-create the original situation causing and not kill(2). That is what I suggested in "however". However2, it is extra work to write a different exit path. When running the program directly under gdb, you also have to tell gdb to not stop at any caught signal, since the screen will be unusable then. > I find it weird to try to debug mode-switched code without serial console. Running gdb on a remote system via a remote shell works almost as well. It is inconvenient to type lots of unobvious redirection commands like 0<>/dev/ttyv0. (libvgl needs fd 0 open for both reading and writing for mmap(), while vidcontrol needs fd 0 only open for reading to do write-like ioctls to it, and fd 2 (actually stdio stderr) open for writing to write escape sequences to it.) Serial consoles are not always available. Better debuggers switch the screen mode as necessary. I recently noticed another mode switching problem. On i386, cycling through about 50 modes to test them all takes a small fraction of a second for each mode switch (done directly in syscons or by a vm86 BIOS call) even when the monitor takes too long to resync (the monitor resyncs are coalesced, so 50 resyncs take about 5 seconds instead of 250). But on amd64, mode switches to VESA mode and back take about 20 seconds. They are not coalesced, and most of the system is stopped waiting for them (at least remote network access is stopped). amd64 can't use vm86, so it emulates BIOS calls. Why does the emulation stop the rest of the system and take so long? Bruce From owner-svn-src-head@freebsd.org Sun Mar 31 11:28:15 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBCAF155A15E; Sun, 31 Mar 2019 11:28:14 +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 76BF875490; Sun, 31 Mar 2019 11:28:06 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 0B273105D0D5; Sun, 31 Mar 2019 22:27:55 +1100 (AEDT) Date: Sun, 31 Mar 2019 22:27:54 +1100 (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: r345696 - head/lib/libvgl In-Reply-To: <20190330094558.GA1923@kib.kiev.ua> Message-ID: <20190331214235.K961@besplex.bde.org> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> <20190329182100.GZ1923@kib.kiev.ua> <20190330142319.I1011@besplex.bde.org> <20190330094558.GA1923@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.2 cv=UJetJGXy c=1 sm=1 tr=0 cx=a_idp_d a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=fx17AMauYh6YMvl-fBgA:9 a=owp30hQRNWXAININ:21 a=82lPrFZ9h1KNQv0H:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-Rspamd-Queue-Id: 76BF875490 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of brde@optusnet.com.au designates 211.29.132.249 as permitted sender) smtp.mailfrom=brde@optusnet.com.au X-Spamd-Result: default: False [-5.55 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[optusnet.com.au]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[optusnet.com.au]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[extmail.optusnet.com.au]; NEURAL_HAM_SHORT(-0.86)[-0.859,0]; IP_SCORE(-2.38)[ip: (-5.60), ipnet: 211.28.0.0/14(-3.48), asn: 4804(-2.77), country: AU(-0.04)]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_IN_DNSWL_LOW(-0.10)[249.132.29.211.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 11:28:15 -0000 On Sat, 30 Mar 2019, Konstantin Belousov wrote: > On Sat, Mar 30, 2019 at 03:24:40PM +1100, Bruce Evans wrote: >> On Fri, 29 Mar 2019, Konstantin Belousov wrote: >> >>> On Fri, Mar 29, 2019 at 03:57:09PM +0000, Bruce Evans wrote: >>>> Author: bde >>>> Date: Fri Mar 29 15:57:08 2019 >>>> New Revision: 345696 >>>> URL: https://svnweb.freebsd.org/changeset/base/345696 >>>> >>>> Log: >>>> Fix endless loops for handling SIGBUS and SIGSEGV. >>>> >>>> r80270 has the usual wrong fix for unsafe signal handling -- just set >>>> a flag and return to let an event loop check the flag and do safe >>>> handling. This never works for signals like SIGBUS and SIGSEGV that >>>> repeat and works poorly for others unless the application has an event >>>> loop designed to support this. >>>> >>>> For these signals, clean up unsafely as before, except for arranging that >>>> nested signals are fatal and forcing a nested signal if the cleanup doesn't >>>> cause one. >>>> >>>> Modified: >>>> head/lib/libvgl/main.c >>>> >>>> Modified: head/lib/libvgl/main.c >>>> ============================================================================== >>>> --- head/lib/libvgl/main.c Fri Mar 29 15:20:48 2019 (r345695) >>>> +++ head/lib/libvgl/main.c Fri Mar 29 15:57:08 2019 (r345696) >>>> ... >>>> @@ -107,14 +107,22 @@ struct vt_mode smode; >>>> } >>>> >>>> static void >>>> -VGLAbort(int arg __unused) >>>> +VGLAbort(int arg) >>>> { >>>> + sigset_t mask; >>>> + >>>> VGLAbortPending = 1; >>>> signal(SIGINT, SIG_IGN); >>>> signal(SIGTERM, SIG_IGN); >>>> - signal(SIGSEGV, SIG_IGN); >>>> - signal(SIGBUS, SIG_IGN); >>>> signal(SIGUSR2, SIG_IGN); >>>> + if (arg == SIGBUS || arg == SIGSEGV) { >>>> + signal(arg, SIG_DFL); >>>> + sigemptyset(&mask); >>>> + sigaddset(&mask, arg); >>>> + sigprocmask(SIG_UNBLOCK, &mask, NULL); >>>> + VGLEnd(); >>>> + kill(getpid(), arg); >>> This of course misses the siginfo information from the real fault. >> >> It is in the nested signal frame. >> >>> Why SIGBUS/SIGSEGV are caught at all ? >> >> Otherwise, the screen is left in an application mode that the kernel >> doesn't support (except to not write to the screen, so that the >> application has full control). Also, the keyboard may be left in a strange state. Usually this is no worse than termios raw mode, but it may be raw scancodes. In raw scancodes mode, Alt-Fn to switch to another vty to fix the problem. libvgl disables switching to another vty without going through a libvgl handler anyway. The combination is usually enough to break switching to vty0 to run ddb, though that should work for at least breakpoints in the kernel. IIRC, sc_cngrab() switches the keyboard mode, and my version of it restores ignoring of the anti-switch flag. > ... > I am more about not doing kill(2) from the handler, instead do plain > return to the context which caused the original signal. That won't work well for SIGBUS's and SIGSEGV's related to the library. If the above cleanup is not done, then it is too hard to debug the problem, and if the above cleanup is done then it is impossible to debug the original problem if it was for and invalid access in libvgl code. The latter is a problem for the above cleanup too -- the cleanup clobbers the libvgl state. However, I could do a more limited cleanup of just restoring the screen and keyboard state using ioctls. ioctl() isn't async-signal safe in POSIX, but most ioctls are async-signal safe in practice provided they don't use global variables that were set too recently or too non-atomically. VGLEnd() uses main globals established by VGLInit(). It depends on program order which is not guaranteed in signal handlers for testing the flags set by initialization. The cleanup now also does: - screen clearing. This breaks debugging and is dangerous if the bug is in screen clearing. Screen clearing is also very slow, and belongs in the kernel. It is now done 4 times per libvgl use, but its slowness is limited by the kernel not clearing properly and the kernel not allowing the application to mmap() the whole physical frame buffer in some versions of FreeBSD (this breaks panning). - munmap(). This breaks debugging. - free() of backing store buffer and the main VGLDisplay data. This breaks debugging and is unnecessary if we are going to exit. Bruce From owner-svn-src-head@freebsd.org Sun Mar 31 13:41:22 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C03B155E6EB; Sun, 31 Mar 2019 13:41:22 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E2E2382239; Sun, 31 Mar 2019 13:41:21 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B23B27784; Sun, 31 Mar 2019 13:41:21 +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 x2VDfLYn069601; Sun, 31 Mar 2019 13:41:21 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VDfL01069600; Sun, 31 Mar 2019 13:41:21 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903311341.x2VDfL01069600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 31 Mar 2019 13:41:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345753 - head/sys/dev/usb/wlan X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: head/sys/dev/usb/wlan X-SVN-Commit-Revision: 345753 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E2E2382239 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 13:41:22 -0000 Author: avos Date: Sun Mar 31 13:41:20 2019 New Revision: 345753 URL: https://svnweb.freebsd.org/changeset/base/345753 Log: run(4): do not clear PROTECTED bit if frame was not decrypted by NIC. Tested with D-Link DWA-140 rev B3, STA / MONITOR modes. MFC after: 1 week Modified: head/sys/dev/usb/wlan/if_run.c Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Sun Mar 31 11:31:01 2019 (r345752) +++ head/sys/dev/usb/wlan/if_run.c Sun Mar 31 13:41:20 2019 (r345753) @@ -2865,8 +2865,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin wh = mtod(m, struct ieee80211_frame *); - /* XXX wrong for monitor mode */ - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && + (flags & RT2860_RX_DEC) != 0) { wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; m->m_flags |= M_WEP; } From owner-svn-src-head@freebsd.org Sun Mar 31 12:10:32 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63879155B5EC; Sun, 31 Mar 2019 12:10:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 8767776849; Sun, 31 Mar 2019 12:10:31 +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 x2VCAFb8063504 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 31 Mar 2019 15:10:18 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x2VCAFb8063504 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x2VCAF3A063503; Sun, 31 Mar 2019 15:10:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 31 Mar 2019 15:10:15 +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: r345696 - head/lib/libvgl Message-ID: <20190331121015.GK1923@kib.kiev.ua> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> <20190329182100.GZ1923@kib.kiev.ua> <20190330142319.I1011@besplex.bde.org> <20190330094558.GA1923@kib.kiev.ua> <20190331214235.K961@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190331214235.K961@besplex.bde.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 12:10:32 -0000 On Sun, Mar 31, 2019 at 10:27:54PM +1100, Bruce Evans wrote: > On Sat, 30 Mar 2019, Konstantin Belousov wrote: > > > On Sat, Mar 30, 2019 at 03:24:40PM +1100, Bruce Evans wrote: > >> On Fri, 29 Mar 2019, Konstantin Belousov wrote: > >> > >>> On Fri, Mar 29, 2019 at 03:57:09PM +0000, Bruce Evans wrote: > >>>> Author: bde > >>>> Date: Fri Mar 29 15:57:08 2019 > >>>> New Revision: 345696 > >>>> URL: https://svnweb.freebsd.org/changeset/base/345696 > >>>> > >>>> Log: > >>>> Fix endless loops for handling SIGBUS and SIGSEGV. > >>>> > >>>> r80270 has the usual wrong fix for unsafe signal handling -- just set > >>>> a flag and return to let an event loop check the flag and do safe > >>>> handling. This never works for signals like SIGBUS and SIGSEGV that > >>>> repeat and works poorly for others unless the application has an event > >>>> loop designed to support this. > >>>> > >>>> For these signals, clean up unsafely as before, except for arranging that > >>>> nested signals are fatal and forcing a nested signal if the cleanup doesn't > >>>> cause one. > >>>> > >>>> Modified: > >>>> head/lib/libvgl/main.c > >>>> > >>>> Modified: head/lib/libvgl/main.c > >>>> ============================================================================== > >>>> --- head/lib/libvgl/main.c Fri Mar 29 15:20:48 2019 (r345695) > >>>> +++ head/lib/libvgl/main.c Fri Mar 29 15:57:08 2019 (r345696) > >>>> ... > >>>> @@ -107,14 +107,22 @@ struct vt_mode smode; > >>>> } > >>>> > >>>> static void > >>>> -VGLAbort(int arg __unused) > >>>> +VGLAbort(int arg) > >>>> { > >>>> + sigset_t mask; > >>>> + > >>>> VGLAbortPending = 1; > >>>> signal(SIGINT, SIG_IGN); > >>>> signal(SIGTERM, SIG_IGN); > >>>> - signal(SIGSEGV, SIG_IGN); > >>>> - signal(SIGBUS, SIG_IGN); > >>>> signal(SIGUSR2, SIG_IGN); > >>>> + if (arg == SIGBUS || arg == SIGSEGV) { > >>>> + signal(arg, SIG_DFL); > >>>> + sigemptyset(&mask); > >>>> + sigaddset(&mask, arg); > >>>> + sigprocmask(SIG_UNBLOCK, &mask, NULL); > >>>> + VGLEnd(); > >>>> + kill(getpid(), arg); > >>> This of course misses the siginfo information from the real fault. > >> > >> It is in the nested signal frame. > >> > >>> Why SIGBUS/SIGSEGV are caught at all ? > >> > >> Otherwise, the screen is left in an application mode that the kernel > >> doesn't support (except to not write to the screen, so that the > >> application has full control). > > Also, the keyboard may be left in a strange state. Usually this is no > worse than termios raw mode, but it may be raw scancodes. In raw scancodes > mode, Alt-Fn to switch to another vty to fix the problem. libvgl disables > switching to another vty without going through a libvgl handler anyway. > The combination is usually enough to break switching to vty0 to run ddb, > though that should work for at least breakpoints in the kernel. IIRC, > sc_cngrab() switches the keyboard mode, and my version of it restores > ignoring of the anti-switch flag. > > > ... > > I am more about not doing kill(2) from the handler, instead do plain > > return to the context which caused the original signal. > > That won't work well for SIGBUS's and SIGSEGV's related to the library. > If the above cleanup is not done, then it is too hard to debug the problem, > and if the above cleanup is done then it is impossible to debug the original > problem if it was for and invalid access in libvgl code. > > The latter is a problem for the above cleanup too -- the cleanup clobbers > the libvgl state. > > However, I could do a more limited cleanup of just restoring the screen and > keyboard state using ioctls. ioctl() isn't async-signal safe in POSIX, but > most ioctls are async-signal safe in practice provided they don't use > global variables that were set too recently or too non-atomically. > VGLEnd() uses main globals established by VGLInit(). It depends on program > order which is not guaranteed in signal handlers for testing the flags set > by initialization. The cleanup now also does: > - screen clearing. This breaks debugging and is dangerous if the bug is > in screen clearing. Screen clearing is also very slow, and belongs > in the kernel. It is now done 4 times per libvgl use, but its > slowness is limited by the kernel not clearing properly and the > kernel not allowing the application to mmap() the whole physical > frame buffer in some versions of FreeBSD (this breaks panning). > - munmap(). This breaks debugging. > - free() of backing store buffer and the main VGLDisplay data. This breaks > debugging and is unnecessary if we are going to exit. You can only try to do async-safe calls from SIGSEGV handler, to not break a limited chances to success. Also you should not modify in-memory state for the library, for the same reason, and then it fits your goal of keeping the state intact for debugging. Then you should return to re-create the original situation causing and not kill(2). I find it weird to try to debug mode-switched code without serial console. From owner-svn-src-head@freebsd.org Sun Mar 31 14:51:37 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53E7C1560E36; Sun, 31 Mar 2019 14:51:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 89E8284FF7; Sun, 31 Mar 2019 14:51:36 +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 x2VEpO3a000811 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 31 Mar 2019 17:51:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x2VEpO3a000811 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x2VEpMJn000810; Sun, 31 Mar 2019 17:51:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 31 Mar 2019 17:51:22 +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: r345696 - head/lib/libvgl Message-ID: <20190331145122.GL1923@kib.kiev.ua> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> <20190329182100.GZ1923@kib.kiev.ua> <20190330142319.I1011@besplex.bde.org> <20190330094558.GA1923@kib.kiev.ua> <20190331214235.K961@besplex.bde.org> <20190331121015.GK1923@kib.kiev.ua> <20190331231926.M1259@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190331231926.M1259@besplex.bde.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 14:51:37 -0000 On Mon, Apr 01, 2019 at 12:04:45AM +1100, Bruce Evans wrote: > Serial consoles are not always available. > > Better debuggers switch the screen mode as necessary. > > I recently noticed another mode switching problem. On i386, cycling > through about 50 modes to test them all takes a small fraction of a > second for each mode switch (done directly in syscons or by a vm86 > BIOS call) even when the monitor takes too long to resync (the monitor > resyncs are coalesced, so 50 resyncs take about 5 seconds instead of > 250). But on amd64, mode switches to VESA mode and back take about > 20 seconds. They are not coalesced, and most of the system is stopped > waiting for them (at least remote network access is stopped). amd64 > can't use vm86, so it emulates BIOS calls. Why does the emulation stop > the rest of the system and take so long? How many CPUs do you have ? x86bios.c x86bios_call() does spinlock_enter() around emulator calls. This disables interrupts. If you have only one CPU, the consequences are obvious. If you have more than one, then perhaps next IPI targeted to this CPU blocks the originator, if IPI requires ack, which typically true for most common TLB shutdown IPIs. Then both this CPU and originator block any other CPU trying to send an IPI. For this reason I have to come through several hoops to not disable interrupts for duration of EFI runtime calls, otherwise spinlocks die due to 'spin lock held too long' on other CPUs. From owner-svn-src-head@freebsd.org Sun Mar 31 14:18:04 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4AE4155F72C; Sun, 31 Mar 2019 14:18:03 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7AB9183C04; Sun, 31 Mar 2019 14:18:03 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 55C6127E08; Sun, 31 Mar 2019 14:18:03 +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 x2VEI36g087611; Sun, 31 Mar 2019 14:18:03 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VEI3ma087610; Sun, 31 Mar 2019 14:18:03 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903311418.x2VEI3ma087610@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 31 Mar 2019 14:18:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345754 - head/sys/dev/usb/wlan X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: head/sys/dev/usb/wlan X-SVN-Commit-Revision: 345754 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7AB9183C04 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 14:18:04 -0000 Author: avos Date: Sun Mar 31 14:18:02 2019 New Revision: 345754 URL: https://svnweb.freebsd.org/changeset/base/345754 Log: run(4): properly set F_DATAPAD radiotap flag if frame has padding between frame header and data. This will fix 'Mysterious OLPC stuff' for received frames and wrong CCMP / TKIP / data decoding for transmitted frames in net/wireshark dissector. While here, drop unneeded comment - net80211 handles padding requirements for Tx & Rx without driver adjustment. Tested with D-Link DWA-140 rev B3, STA mode. MFC after: 1 week Modified: head/sys/dev/usb/wlan/if_run.c Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Sun Mar 31 13:41:20 2019 (r345753) +++ head/sys/dev/usb/wlan/if_run.c Sun Mar 31 14:18:02 2019 (r345754) @@ -2851,10 +2851,6 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin } if (flags & RT2860_RX_L2PAD) { - /* - * XXX OpenBSD removes padding between header - * and payload here... - */ RUN_DPRINTF(sc, RUN_DEBUG_RECV, "received RT2860_RX_L2PAD frame\n"); len += 2; @@ -2896,6 +2892,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin uint16_t phy; tap->wr_flags = 0; + if (flags & RT2860_RX_L2PAD) + tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; tap->wr_antsignal = rssi; tap->wr_antenna = ant; tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); @@ -3162,14 +3160,23 @@ tr_setup: vap = data->ni->ni_vap; if (ieee80211_radiotap_active_vap(vap)) { + const struct ieee80211_frame *wh; struct run_tx_radiotap_header *tap = &sc->sc_txtap; struct rt2860_txwi *txwi = (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd)); + int has_l2pad; + + wh = mtod(m, struct ieee80211_frame *); + has_l2pad = IEEE80211_HAS_ADDR4(wh) != + IEEE80211_QOS_HAS_SEQ(wh); + tap->wt_flags = 0; tap->wt_rate = rt2860_rates[data->ridx].rate; tap->wt_hwqueue = index; if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; + if (has_l2pad) + tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; ieee80211_radiotap_tx(vap, m); } From owner-svn-src-head@freebsd.org Sun Mar 31 21:34:59 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95828156DA00; Sun, 31 Mar 2019 21:34:59 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 39D1C92864; Sun, 31 Mar 2019 21:34:59 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 131B74C9A; Sun, 31 Mar 2019 21:34:59 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2VLYwo7018670; Sun, 31 Mar 2019 21:34:58 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VLYwO9018669; Sun, 31 Mar 2019 21:34:58 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201903312134.x2VLYwO9018669@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sun, 31 Mar 2019 21:34:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345758 - head/sys/dev/md X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/dev/md X-SVN-Commit-Revision: 345758 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 39D1C92864 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 21:34:59 -0000 Author: mckusick Date: Sun Mar 31 21:34:58 2019 New Revision: 345758 URL: https://svnweb.freebsd.org/changeset/base/345758 Log: When using the force option to shut down a memory-disk device, I/O operations already in its queue were not being properly drained. The GEOM framework does the queue draining, but the device driver needs to wait for the draining to happen. The waiting is done by adding a g_md_providergone() function to wait for the I/O operations to finish up. It is likely that every GEOM provider that implements orphaning attached GEOM consumers needs to use the "providergone" mechanism for this same reason, but some of them do not do so. Apparently Kenneth Merry (ken@) added the drain for just such races, but he missed adding it to some of the device drivers that needed it. Submitted by: Chuck Silvers Reviewed by: imp Tested by: Chuck Silvers MFC after: 1 week Sponsored by: Netflix Modified: head/sys/dev/md/md.c Modified: head/sys/dev/md/md.c ============================================================================== --- head/sys/dev/md/md.c Sun Mar 31 19:27:44 2019 (r345757) +++ head/sys/dev/md/md.c Sun Mar 31 21:34:58 2019 (r345758) @@ -110,6 +110,7 @@ #define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */ #define MD_EXITING 0x20000 /* Worker thread is exiting. */ +#define MD_PROVIDERGONE 0x40000 /* Safe to free the softc */ #ifndef MD_NSECT #define MD_NSECT (10000 * 2) @@ -199,6 +200,7 @@ static g_start_t g_md_start; static g_access_t g_md_access; static void g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp); +static g_provgone_t g_md_providergone; static struct cdev *status_dev = NULL; static struct sx md_sx; @@ -220,6 +222,7 @@ struct g_class g_md_class = { .start = g_md_start, .access = g_md_access, .dumpconf = g_md_dumpconf, + .providergone = g_md_providergone, }; DECLARE_GEOM_CLASS(g_md_class, g_md); @@ -481,8 +484,8 @@ g_md_start(struct bio *bp) } mtx_lock(&sc->queue_mtx); bioq_disksort(&sc->bio_queue, bp); - mtx_unlock(&sc->queue_mtx); wakeup(sc); + mtx_unlock(&sc->queue_mtx); } #define MD_MALLOC_MOVE_ZERO 1 @@ -1496,17 +1499,30 @@ bad: return (error); } +static void +g_md_providergone(struct g_provider *pp) +{ + struct md_s *sc = pp->geom->softc; + + mtx_lock(&sc->queue_mtx); + sc->flags |= MD_PROVIDERGONE; + wakeup(&sc->flags); + mtx_unlock(&sc->queue_mtx); +} + static int mddestroy(struct md_s *sc, struct thread *td) { if (sc->gp) { - sc->gp->softc = NULL; g_topology_lock(); g_wither_geom(sc->gp, ENXIO); g_topology_unlock(); - sc->gp = NULL; - sc->pp = NULL; + + mtx_lock(&sc->queue_mtx); + while (!(sc->flags & MD_PROVIDERGONE)) + msleep(&sc->flags, &sc->queue_mtx, PRIBIO, "mddestroy", 0); + mtx_unlock(&sc->queue_mtx); } if (sc->devstat) { devstat_remove_entry(sc->devstat); From owner-svn-src-head@freebsd.org Sun Mar 31 19:27:45 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B69281569FB9; Sun, 31 Mar 2019 19:27:45 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DE018E74F; Sun, 31 Mar 2019 19:27:45 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38C9633C2; Sun, 31 Mar 2019 19:27:45 +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 x2VJRjMr051051; Sun, 31 Mar 2019 19:27:45 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VJRj1u051050; Sun, 31 Mar 2019 19:27:45 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201903311927.x2VJRj1u051050@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sun, 31 Mar 2019 19:27:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345757 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/arm/broadcom/bcm2835 X-SVN-Commit-Revision: 345757 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5DE018E74F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 19:27:45 -0000 Author: bz Date: Sun Mar 31 19:27:44 2019 New Revision: 345757 URL: https://svnweb.freebsd.org/changeset/base/345757 Log: Improve debugging options in bcm2835_sdhci.c Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively turn on debugging printfs if debugging is turned on at compile time. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Reviewed by: gonzo, andrew Differential Revision: https://reviews.freebsd.org/D19745 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sun Mar 31 17:27:28 2019 (r345756) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sun Mar 31 19:27:44 2019 (r345757) @@ -66,8 +66,17 @@ __FBSDID("$FreeBSD$"); #define NUM_DMA_SEGS 2 #ifdef DEBUG -#define dprintf(fmt, args...) do { printf("%s(): ", __func__); \ - printf(fmt,##args); } while (0) +static int bcm2835_sdhci_debug = 0; + +TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug); +SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN, + &bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level"); + +#define dprintf(fmt, args...) \ + do { \ + if (bcm2835_sdhci_debug) \ + printf("%s: " fmt, __func__, ##args); \ + } while (0) #else #define dprintf(fmt, args...) #endif From owner-svn-src-head@freebsd.org Mon Apr 1 09:02:53 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81FB6154F741; Mon, 1 Apr 2019 09:02:53 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id C904F8CED4; Mon, 1 Apr 2019 09:02:52 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 86AB043D588; Mon, 1 Apr 2019 20:02:49 +1100 (AEDT) Date: Mon, 1 Apr 2019 20:02:46 +1100 (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: r345696 - head/lib/libvgl In-Reply-To: <20190331145122.GL1923@kib.kiev.ua> Message-ID: <20190401185606.Q2155@besplex.bde.org> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> <20190329182100.GZ1923@kib.kiev.ua> <20190330142319.I1011@besplex.bde.org> <20190330094558.GA1923@kib.kiev.ua> <20190331214235.K961@besplex.bde.org> <20190331121015.GK1923@kib.kiev.ua> <20190331231926.M1259@besplex.bde.org> <20190331145122.GL1923@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.2 cv=UJetJGXy c=1 sm=1 tr=0 cx=a_idp_d a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=nR6jlSWGY1YSvxl2fiIA:9 a=CjuIK1q_8ugA:10 X-Rspamd-Queue-Id: C904F8CED4 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.87 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.87)[-0.874,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 09:02:53 -0000 On Sun, 31 Mar 2019, Konstantin Belousov wrote: > On Mon, Apr 01, 2019 at 12:04:45AM +1100, Bruce Evans wrote: >> Serial consoles are not always available. >> >> Better debuggers switch the screen mode as necessary. >> >> I recently noticed another mode switching problem. On i386, cycling >> through about 50 modes to test them all takes a small fraction of a >> second for each mode switch (done directly in syscons or by a vm86 >> BIOS call) even when the monitor takes too long to resync (the monitor >> resyncs are coalesced, so 50 resyncs take about 5 seconds instead of >> 250). But on amd64, mode switches to VESA mode and back take about >> 20 seconds. They are not coalesced, and most of the system is stopped >> waiting for them (at least remote network access is stopped). amd64 >> can't use vm86, so it emulates BIOS calls. Why does the emulation stop >> the rest of the system and take so long? > > How many CPUs do you have ? 8 on the machine that shows the problem -- an underdesktop with Haswell graphics. A laptop with Sandybridge graphics only waits for 0.25 seconds (sys time) I don't know if it stops the system for that long (it would be 2 blockages for half that long). The laptop's integrated screen also syncs instantly. The undermydesktop has an LED screen connected by DVI-D. > x86bios.c x86bios_call() does spinlock_enter() around emulator calls. > This disables interrupts. > > If you have only one CPU, the consequences are obvious. If you have > more than one, then perhaps next IPI targeted to this CPU blocks the > originator, if IPI requires ack, which typically true for most common > TLB shutdown IPIs. Then both this CPU and originator block any other CPU > trying to send an IPI. Serial console interrupts on another CPU work to enter ddb instantly and show the emulator stopped. Binding drivers to CPU unimproves scheduling in general, and here it might result in iflib waiting for the CPU with interrupts disabled, but usually the CPU with interrupts disabled is not the one(s) bound to by iflib, and binding the graphics program to one not used by iflib doesn't help. Removing the spinlock_enter/exit() using ddb makes no difference. > For this reason I have to come through several hoops to not disable > interrupts for duration of EFI runtime calls, otherwise spinlocks die > due to 'spin lock held too long' on other CPUs. I turn off the 'spin lock held too long' panics in my fixes for console and message buffer i/o. Printing "spin lock held too long\n" takes 120 seconds at 2 bps. Draining 16K of buffered messages takes 81920 seconds at 2 bps. The main fix is to cancel the timeouts here while any console driver is making progress (hopefully printing messages about the actual error). 2 bps is too slow to be useful, but it gives a good stress test and a check that the timeouts are scaled properly by the console speed. Disabling interrupts might be FUD. vm86 on i386 only uses critical_enter() in addition to its sleep lock. But this is bad for scheduling too. Bruce From owner-svn-src-head@freebsd.org Mon Apr 1 12:14:46 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF85715615F0; Mon, 1 Apr 2019 12:14:46 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6BE656CBB0; Mon, 1 Apr 2019 12:14:46 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 428E7E406; Mon, 1 Apr 2019 12:14:46 +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 x31CEk40078035; Mon, 1 Apr 2019 12:14:46 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31CEkpw078034; Mon, 1 Apr 2019 12:14:46 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201904011214.x31CEkpw078034@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 1 Apr 2019 12:14:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345763 - head/contrib/bsnmp/snmpd X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/contrib/bsnmp/snmpd X-SVN-Commit-Revision: 345763 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6BE656CBB0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 12:14:47 -0000 Author: ae Date: Mon Apr 1 12:14:45 2019 New Revision: 345763 URL: https://svnweb.freebsd.org/changeset/base/345763 Log: Correct a port number assignment. PR: 236930 MFC after: 1 week Modified: head/contrib/bsnmp/snmpd/trap.c Modified: head/contrib/bsnmp/snmpd/trap.c ============================================================================== --- head/contrib/bsnmp/snmpd/trap.c Mon Apr 1 10:51:24 2019 (r345762) +++ head/contrib/bsnmp/snmpd/trap.c Mon Apr 1 12:14:45 2019 (r345763) @@ -726,8 +726,7 @@ target_activate_address(struct target_address *addrs) sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | (addrs->address[1] << 16) | (addrs->address[2] << 8) | (addrs->address[3] << 0)); - sa.sin_port = htons(addrs->address[4]) << 8 | - htons(addrs->address[5]) << 0; + sa.sin_port = htons(addrs->address[4] << 8 | addrs->address[5]); if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { syslog(LOG_ERR, "connect(%s,%u): %m", From owner-svn-src-head@freebsd.org Mon Apr 1 14:21:33 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FEE41564826; Mon, 1 Apr 2019 14:21:33 +0000 (UTC) (envelope-from olivier@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D45A870EB5; Mon, 1 Apr 2019 14:21:32 +0000 (UTC) (envelope-from olivier@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B33D0F935; Mon, 1 Apr 2019 14:21:32 +0000 (UTC) (envelope-from olivier@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31ELWiR044156; Mon, 1 Apr 2019 14:21:32 GMT (envelope-from olivier@FreeBSD.org) Received: (from olivier@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31ELWaR044154; Mon, 1 Apr 2019 14:21:32 GMT (envelope-from olivier@FreeBSD.org) Message-Id: <201904011421.x31ELWaR044154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: olivier set sender to olivier@FreeBSD.org using -f From: Olivier Cochard Date: Mon, 1 Apr 2019 14:21:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345765 - head/tests/sys/audit X-SVN-Group: head X-SVN-Commit-Author: olivier X-SVN-Commit-Paths: head/tests/sys/audit X-SVN-Commit-Revision: 345765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D45A870EB5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.956,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 14:21:33 -0000 Author: olivier (ports committer) Date: Mon Apr 1 14:21:32 2019 New Revision: 345765 URL: https://svnweb.freebsd.org/changeset/base/345765 Log: Fix and simplify code by using ATF_REQUIRE_FEATURE macro PR: 236857 Reviewed by: asomers, ngie Approved by: emaste MFC after: 1 month Sponsored by: Netflix Modified: head/tests/sys/audit/Makefile head/tests/sys/audit/process-control.c Modified: head/tests/sys/audit/Makefile ============================================================================== --- head/tests/sys/audit/Makefile Mon Apr 1 14:19:09 2019 (r345764) +++ head/tests/sys/audit/Makefile Mon Apr 1 14:21:32 2019 (r345765) @@ -55,4 +55,6 @@ WARNS?= 6 LDFLAGS+= -lbsm -lutil +CFLAGS.process-control.c+= -I${SRCTOP}/tests + .include Modified: head/tests/sys/audit/process-control.c ============================================================================== --- head/tests/sys/audit/process-control.c Mon Apr 1 14:19:09 2019 (r345764) +++ head/tests/sys/audit/process-control.c Mon Apr 1 14:21:32 2019 (r345765) @@ -48,6 +48,8 @@ #include "utils.h" +#include "freebsd_test_suite/macros.h" + static pid_t pid; static int filedesc, status; static struct pollfd fds[1]; @@ -1512,15 +1514,8 @@ ATF_TC_HEAD(cap_enter_success, tc) ATF_TC_BODY(cap_enter_success, tc) { - int capinfo; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + ATF_REQUIRE_FEATURE("security_capability_mode"); - /* Without CAPABILITY_MODE enabled, cap_enter() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); - FILE *pipefd = setup(fds, auclass); ATF_REQUIRE((pid = fork()) != -1); if (pid) { @@ -1550,14 +1545,9 @@ ATF_TC_HEAD(cap_getmode_success, tc) ATF_TC_BODY(cap_getmode_success, tc) { - int capinfo, modep; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + int modep; - /* Without CAPABILITY_MODE enabled, cap_getmode() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); + ATF_REQUIRE_FEATURE("security_capability_mode"); pid = getpid(); snprintf(pcregex, sizeof(pcregex), "cap_getmode.*%d.*success", pid); From owner-svn-src-head@freebsd.org Mon Apr 1 17:44:21 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87FDC156A71D; Mon, 1 Apr 2019 17:44:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2BDDC8132A; Mon, 1 Apr 2019 17:44:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1CFAF19D3E; Mon, 1 Apr 2019 17:44:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31HiKlo051604; Mon, 1 Apr 2019 17:44:20 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31HiK7G051602; Mon, 1 Apr 2019 17:44:20 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201904011744.x31HiK7G051602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 1 Apr 2019 17:44:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345769 - in head: lib/libbe sbin/bectl/tests X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: lib/libbe sbin/bectl/tests X-SVN-Commit-Revision: 345769 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2BDDC8132A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 17:44:21 -0000 Author: kevans Date: Mon Apr 1 17:44:20 2019 New Revision: 345769 URL: https://svnweb.freebsd.org/changeset/base/345769 Log: libbe: Fix zfs_is_mounted check w/ snapshots 'be_destroy' can destroy a boot environment (by name) or a given snapshot. If the target to be destroyed is a dataset, check if it's mounted. We don't want to check if the origin dataset is mounted when destroying a snapshot. PR: 236043 Submitted by: Rob Fairbanks MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19650 Modified: head/lib/libbe/be.c head/sbin/bectl/tests/bectl_test.sh Modified: head/lib/libbe/be.c ============================================================================== --- head/lib/libbe/be.c Mon Apr 1 16:36:02 2019 (r345768) +++ head/lib/libbe/be.c Mon Apr 1 17:44:20 2019 (r345769) @@ -265,6 +265,16 @@ be_destroy(libbe_handle_t *lbh, const char *name, int zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), NULL, NULL, 0, 1) != 0) return (set_error(lbh, BE_ERR_NOORIGIN)); + + /* Don't destroy a mounted dataset unless force is specified */ + if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { + if (force) { + zfs_unmount(fs, NULL, 0); + } else { + free(bdd.snapname); + return (set_error(lbh, BE_ERR_DESTROYMNT)); + } + } } else { if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); @@ -277,16 +287,6 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) { free(bdd.snapname); return (set_error(lbh, BE_ERR_ZFSOPEN)); - } - } - - /* Check if mounted, unmount if force is specified */ - if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { - if (force) { - zfs_unmount(fs, NULL, 0); - } else { - free(bdd.snapname); - return (set_error(lbh, BE_ERR_DESTROYMNT)); } } Modified: head/sbin/bectl/tests/bectl_test.sh ============================================================================== --- head/sbin/bectl/tests/bectl_test.sh Mon Apr 1 16:36:02 2019 (r345768) +++ head/sbin/bectl/tests/bectl_test.sh Mon Apr 1 17:44:20 2019 (r345769) @@ -123,12 +123,21 @@ bectl_destroy_body() zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt + root=${mount}/root bectl_create_setup ${zpool} ${disk} ${mount} atf_check bectl -r ${zpool}/ROOT create -e default default2 atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 atf_check -e not-empty -s not-exit:0 zfs get mountpoint ${zpool}/ROOT/default2 + + # Test origin snapshot deletion when the snapshot to be destroyed + # belongs to a mounted dataset, see PR 236043. + atf_check mkdir -p ${root} + atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} + atf_check bectl -r ${zpool}/ROOT create -e default default3 + atf_check bectl -r ${zpool}/ROOT destroy -o default3 + atf_check bectl -r ${zpool}/ROOT unmount default } bectl_destroy_cleanup() { From owner-svn-src-head@freebsd.org Mon Apr 1 18:07:50 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 812C5156B05C; Mon, 1 Apr 2019 18:07:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 28E3182758; Mon, 1 Apr 2019 18:07:50 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E95631A0DA; Mon, 1 Apr 2019 18:07:49 +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 x31I7nf9062724; Mon, 1 Apr 2019 18:07:49 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31I7mKF062717; Mon, 1 Apr 2019 18:07:48 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904011807.x31I7mKF062717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 18:07:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345770 - in head: contrib/googletest/googletest contrib/googletest/googletest/docs contrib/googletest/googletest/src contrib/googletest/googletest/test lib/googletest/gtest_main/tests X-SVN-Group: head X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in head: contrib/googletest/googletest contrib/googletest/googletest/docs contrib/googletest/googletest/src contrib/googletest/googletest/test lib/googletest/gtest_main/tests X-SVN-Commit-Revision: 345770 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 28E3182758 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:07:50 -0000 Author: ngie Date: Mon Apr 1 18:07:48 2019 New Revision: 345770 URL: https://svnweb.freebsd.org/changeset/base/345770 Log: Import proof-of-concept for handling `GTEST_SKIP()` in `Environment::SetUp` Per the upstream pull-request [1]: ``` gtest prior to this change would completely ignore `GTEST_SKIP()` if called in `Environment::SetUp()`, instead of bailing out early, unlike `Test::SetUp()`, which would cause the tests themselves to be skipped. The only way (prior to this change) to skip the tests would be to trigger a fatal error via `GTEST_FAIL()`. Desirable behavior, in this case, when dealing with `Environment::SetUp()` is to check for prerequisites on a system (example, kernel supports a particular featureset, e.g., capsicum), and skip the tests. The alternatives prior to this change would be undesirable: - Failing sends the wrong message to the test user, as the result of the tests is indeterminate, not failed. - Having to add per-test class abstractions that override `SetUp()` to test for the capsicum feature set, then skip all of the tests in their respective SetUp fixtures, would be a lot of human and computational work; checking for the feature would need to be done for all of the tests, instead of once for all of the tests. For those reasons, making `Environment::SetUp()` handle `GTEST_SKIP()`, by not executing the testcases, is the most desirable solution. In order to properly diagnose what happened when running the tests if they are skipped, print out the diagnostics in an ad hoc manner. Update the documentation to note this change and integrate a new test, gtest_skip_in_environment_setup_test, into the test suite. This change addresses #2189. Signed-off-by: Enji Cooper ``` The goal with my merging in this change is to avoid requiring extensive refactoring/retesting of test suites when ensuring prerequisites are met, e.g., checking for a CAPABILITIES-enabled kernel before running capsicum-test (see D19758 for more details). The proof-of-concept is being imported before accepted by the upstream project due to the fact that the upstream project is undergoing a potential development freeze and the maintainers aren't responding to my PR. 1. https://github.com/google/googletest/pull/2203 Reported by: asomers (https://github.com/google/googletest/issues/2189) Reviewed by: asomers Approved by: emaste (mentor) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D19765 Added: head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (contents, props changed) Modified: head/contrib/googletest/googletest/CMakeLists.txt head/contrib/googletest/googletest/Makefile.am head/contrib/googletest/googletest/docs/advanced.md head/contrib/googletest/googletest/src/gtest.cc head/contrib/googletest/googletest/test/BUILD.bazel head/lib/googletest/gtest_main/tests/Makefile Modified: head/contrib/googletest/googletest/CMakeLists.txt ============================================================================== --- head/contrib/googletest/googletest/CMakeLists.txt Mon Apr 1 17:44:20 2019 (r345769) +++ head/contrib/googletest/googletest/CMakeLists.txt Mon Apr 1 18:07:48 2019 (r345770) @@ -217,6 +217,7 @@ if (gtest_build_tests) test/gtest-typed-test2_test.cc) cxx_test(gtest_unittest gtest_main) cxx_test(gtest-unittest-api_test gtest) + cxx_test(gtest_skip_in_environment_setup_test gtest_main) cxx_test(gtest_skip_test gtest_main) ############################################################ Modified: head/contrib/googletest/googletest/Makefile.am ============================================================================== --- head/contrib/googletest/googletest/Makefile.am Mon Apr 1 17:44:20 2019 (r345769) +++ head/contrib/googletest/googletest/Makefile.am Mon Apr 1 18:07:48 2019 (r345770) @@ -290,6 +290,12 @@ test_gtest_all_test_SOURCES = test/gtest_all_test.cc test_gtest_all_test_LDADD = lib/libgtest_main.la \ lib/libgtest.la +TESTS += test/gtest_skip_in_environment_setup_test +check_PROGRAMS += test/gtest_skip_in_environment_setup_test +test_gtest_skip_in_environment_setup_test_SOURCES = test/gtest_skip_in_environment_setup_test.cc +test_gtest_skip_in_environment_setup_test_LDADD= lib/libgtest_main.la \ + lib/libgtest.la + # Tests that fused gtest files compile and work. FUSED_GTEST_SRC = \ fused-src/gtest/gtest-all.cc \ Modified: head/contrib/googletest/googletest/docs/advanced.md ============================================================================== --- head/contrib/googletest/googletest/docs/advanced.md Mon Apr 1 17:44:20 2019 (r345769) +++ head/contrib/googletest/googletest/docs/advanced.md Mon Apr 1 18:07:48 2019 (r345770) @@ -1289,8 +1289,10 @@ Environment* AddGlobalTestEnvironment(Environment* env ``` Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of -the environment object, then runs the tests if there was no fatal failures, and -finally calls `TearDown()` of the environment object. +each environment object, then runs the tests if none of the environments +reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()` +always calls `TearDown()` with each environment object, regardless of whether +or not the tests were run. It's OK to register multiple environment objects. In this case, their `SetUp()` will be called in the order they are registered, and their `TearDown()` will be Modified: head/contrib/googletest/googletest/src/gtest.cc ============================================================================== --- head/contrib/googletest/googletest/src/gtest.cc Mon Apr 1 17:44:20 2019 (r345769) +++ head/contrib/googletest/googletest/src/gtest.cc Mon Apr 1 18:07:48 2019 (r345770) @@ -5243,9 +5243,23 @@ bool UnitTestImpl::RunAllTests() { ForEach(environments_, SetUpEnvironment); repeater->OnEnvironmentsSetUpEnd(*parent_); - // Runs the tests only if there was no fatal failure during global - // set-up. - if (!Test::HasFatalFailure()) { + // Runs the tests only if there was no fatal failure or skip triggered + // during global set-up. + if (Test::IsSkipped()) { + // Emit diagnostics when global set-up calls skip, as it will not be + // emitted by default. + TestResult& test_result = + *internal::GetUnitTestImpl()->current_test_result(); + for (int j = 0; j < test_result.total_part_count(); ++j) { + const TestPartResult& test_part_result = + test_result.GetTestPartResult(j); + if (test_part_result.type() == TestPartResult::kSkip) { + const std::string& result = test_part_result.message(); + printf("%s\n", result.c_str()); + } + } + fflush(stdout); + } else if (!Test::HasFatalFailure()) { for (int test_index = 0; test_index < total_test_case_count(); test_index++) { GetMutableTestCase(test_index)->Run(); Modified: head/contrib/googletest/googletest/test/BUILD.bazel ============================================================================== --- head/contrib/googletest/googletest/test/BUILD.bazel Mon Apr 1 17:44:20 2019 (r345769) +++ head/contrib/googletest/googletest/test/BUILD.bazel Mon Apr 1 18:07:48 2019 (r345770) @@ -311,6 +311,13 @@ cc_binary( deps = ["//:gtest"], ) +cc_test( + name = "gtest_skip_in_environment_setup_test", + size = "small", + srcs = ["gtest_skip_in_environment_setup_test.cc"], + deps = ["//:gtest_main"], +) + py_test( name = "googletest-list-tests-unittest", size = "small", Added: head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Mon Apr 1 18:07:48 2019 (r345770) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * 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. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT +// OWNER 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. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include +#include + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} Modified: head/lib/googletest/gtest_main/tests/Makefile ============================================================================== --- head/lib/googletest/gtest_main/tests/Makefile Mon Apr 1 17:44:20 2019 (r345769) +++ head/lib/googletest/gtest_main/tests/Makefile Mon Apr 1 18:07:48 2019 (r345770) @@ -19,6 +19,7 @@ GTESTS+= gtest_sole_header_test GTESTS+= googletest-test-part-test GTESTS+= gtest-typed-test_test GTESTS+= gtest_skip_test +GTESTS+= gtest_skip_in_environment_setup_test GTESTS+= gtest_unittest CXXFLAGS+= -I${GOOGLETEST_SRCROOT}/include From owner-svn-src-head@freebsd.org Mon Apr 1 18:49:41 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 814F6156C286; Mon, 1 Apr 2019 18:49:41 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1FE668424C; Mon, 1 Apr 2019 18:49:41 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EBD1E1A811; Mon, 1 Apr 2019 18:49:40 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31Ineee084041; Mon, 1 Apr 2019 18:49:40 GMT (envelope-from kibab@FreeBSD.org) Received: (from kibab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31IneXA084037; Mon, 1 Apr 2019 18:49:40 GMT (envelope-from kibab@FreeBSD.org) Message-Id: <201904011849.x31IneXA084037@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kibab set sender to kibab@FreeBSD.org using -f From: Ilya Bakulin Date: Mon, 1 Apr 2019 18:49:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345775 - in head/sys: arm/allwinner cam cam/mmc dev/sdhci X-SVN-Group: head X-SVN-Commit-Author: kibab X-SVN-Commit-Paths: in head/sys: arm/allwinner cam cam/mmc dev/sdhci X-SVN-Commit-Revision: 345775 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1FE668424C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:49:41 -0000 Author: kibab Date: Mon Apr 1 18:49:39 2019 New Revision: 345775 URL: https://svnweb.freebsd.org/changeset/base/345775 Log: Use information about max data size that the controller is able to operate Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the controller driver to provide maximum data size to MMCCAM, and use it there. The old stack already does this. Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15892 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/cam/cam_ccb.h head/sys/cam/mmc/mmc_da.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/arm/allwinner/aw_mmc.c ============================================================================== --- head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:49:39 2019 (r345775) @@ -256,6 +256,8 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = sc->aw_host.f_min; cts->proto_specific.mmc.host_f_max = sc->aw_host.f_max; cts->proto_specific.mmc.host_caps = sc->aw_host.caps; + cts->proto_specific.mmc.host_max_data = (sc->aw_mmc_conf->dma_xferlen * + AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE; memcpy(&cts->proto_specific.mmc.ios, &sc->aw_host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; Modified: head/sys/cam/cam_ccb.h ============================================================================== --- head/sys/cam/cam_ccb.h Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/cam/cam_ccb.h Mon Apr 1 18:49:39 2019 (r345775) @@ -1051,6 +1051,7 @@ struct ccb_trans_settings_mmc { #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ #define MMC_CAP_HSPEED (1 << 2) /* Can do High Speed transfers */ uint32_t host_caps; + uint32_t host_max_data; }; /* Get/Set transfer rate/width/disconnection/tag queueing settings */ Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019 (r345775) @@ -1195,6 +1195,27 @@ sdda_get_host_caps(struct cam_periph *periph, union cc return (cts->host_caps); } +static uint32_t +sdda_get_max_data(struct cam_periph *periph, union ccb *ccb) +{ + struct ccb_trans_settings_mmc *cts; + + cts = &ccb->cts.proto_specific.mmc; + memset(cts, 0, sizeof(struct ccb_trans_settings_mmc)); + + ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + ccb->ccb_h.flags = CAM_DIR_NONE; + ccb->ccb_h.retry_count = 0; + ccb->ccb_h.timeout = 100; + ccb->ccb_h.cbfcnp = NULL; + xpt_action(ccb); + + if (ccb->ccb_h.status != CAM_REQ_CMP) + panic("Cannot get host max data"); + KASSERT(cts->host_max_data != 0, ("host_max_data == 0?!")); + return (cts->host_max_data); +} + static void sdda_start_init(void *context, union ccb *start_ccb) { @@ -1420,7 +1441,6 @@ sdda_add_part(struct cam_periph *periph, u_int type, c struct sdda_softc *sc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct ccb_pathinq cpi; - u_int maxio; CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Partition type '%s', size %ju %s\n", @@ -1479,12 +1499,9 @@ sdda_add_part(struct cam_periph *periph, u_int type, c part->disk->d_gone = sddadiskgonecb; part->disk->d_name = part->name; part->disk->d_drv1 = part; - maxio = cpi.maxio; /* Honor max I/O size of SIM */ - if (maxio == 0) - maxio = DFLTPHYS; /* traditional default */ - else if (maxio > MAXPHYS) - maxio = MAXPHYS; /* for safety */ - part->disk->d_maxsize = maxio; + part->disk->d_maxsize = + MIN(MAXPHYS, sdda_get_max_data(periph, + (union ccb *)&cpi) * mmc_get_sector_size(periph)); part->disk->d_unit = cnt; part->disk->d_flags = 0; strlcpy(part->disk->d_descr, sc->card_id_string, Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:49:39 2019 (r345775) @@ -2580,6 +2580,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; + uint32_t max_data; if (sdhci_debug > 1) slot_printf(slot, "Got XPT_GET_TRAN_SETTINGS\n"); @@ -2593,6 +2594,19 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = slot->host.f_min; cts->proto_specific.mmc.host_f_max = slot->host.f_max; cts->proto_specific.mmc.host_caps = slot->host.caps; + /* + * Re-tuning modes 1 and 2 restrict the maximum data length + * per read/write command to 4 MiB. + */ + if (slot->opt & SDHCI_TUNING_ENABLED && + (slot->retune_mode == SDHCI_RETUNE_MODE_1 || + slot->retune_mode == SDHCI_RETUNE_MODE_2)) { + max_data = 4 * 1024 * 1024 / MMC_SECTOR_SIZE; + } else { + max_data = 65535; + } + cts->proto_specific.mmc.host_max_data = max_data; + memcpy(&cts->proto_specific.mmc.ios, &slot->host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; From owner-svn-src-head@freebsd.org Mon Apr 1 18:54:16 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3031156C4B6; Mon, 1 Apr 2019 18:54:16 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 445EC84665; Mon, 1 Apr 2019 18:54:16 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 19DCE1A9CF; Mon, 1 Apr 2019 18:54:16 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31IsFBO089318; Mon, 1 Apr 2019 18:54:15 GMT (envelope-from kibab@FreeBSD.org) Received: (from kibab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31IsFKR089317; Mon, 1 Apr 2019 18:54:15 GMT (envelope-from kibab@FreeBSD.org) Message-Id: <201904011854.x31IsFKR089317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kibab set sender to kibab@FreeBSD.org using -f From: Ilya Bakulin Date: Mon, 1 Apr 2019 18:54:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345776 - head/sys/cam/mmc X-SVN-Group: head X-SVN-Commit-Author: kibab X-SVN-Commit-Paths: head/sys/cam/mmc X-SVN-Commit-Revision: 345776 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 445EC84665 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:54:16 -0000 Author: kibab Date: Mon Apr 1 18:54:15 2019 New Revision: 345776 URL: https://svnweb.freebsd.org/changeset/base/345776 Log: Refactor error handling There is some code duplication in error handling paths in a few functions. Create a function for printing such errors in human-readable way and get rid of duplicates. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15912 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019 (r345775) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:54:15 2019 (r345776) @@ -150,6 +150,17 @@ struct sdda_softc { struct timeval log_time; }; +static const char *mmc_errmsg[] = +{ + "None", + "Timeout", + "Bad CRC", + "Fifo", + "Failed", + "Invalid", + "NO MEMORY" +}; + #define ccb_bp ppriv_ptr1 static disk_strategy_t sddastrategy; @@ -165,6 +176,7 @@ static void sddadone(struct cam_periph *periph, static int sddaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); +static int mmc_handle_reply(union ccb *ccb); static uint16_t get_rca(struct cam_periph *periph); static void sdda_start_init(void *context, union ccb *start_ccb); static void sdda_start_init_task(void *context, int pending); @@ -218,6 +230,37 @@ get_rca(struct cam_periph *periph) { return periph->path->device->mmc_ident_data.card_rca; } +/* + * Figure out if CCB execution resulted in error. + * Look at both CAM-level errors and on MMC protocol errors. +*/ +static int +mmc_handle_reply(union ccb *ccb) +{ + + KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, + ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", + ccb, ccb->ccb_h.func_code)); + + /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { + if (ccb->mmcio.cmd.error != 0) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + return (EIO); + } + } else { + cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); + return (EIO); + } + + return (0); /* Normal return */ +} + + static uint32_t mmc_get_bits(uint32_t *bits, int bit_len, int start, int size) { @@ -777,11 +820,12 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ NULL, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); if (err != 0) - return err; + return (err); if (!(ccb->mmcio.cmd.resp[0] & R1_APP_CMD)) - return MMC_ERR_FAILED; + return (EIO); /* Now exec actual command */ int flags = 0; @@ -803,12 +847,14 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ cmd->data, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + if (err != 0) + return (err); memcpy(cmd->resp, ccb->mmcio.cmd.resp, sizeof(cmd->resp)); cmd->error = ccb->mmcio.cmd.error; - if (err != 0) - return err; - return 0; + + return (0); } static int @@ -858,10 +904,9 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb /*mmc_data*/ &d, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - if (err != 0) - return (err); - return (MMC_ERR_NONE); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + return (err); } static void @@ -904,7 +949,7 @@ mmc_switch_fill_mmcio(union ccb *ccb, static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca) { - int flags; + int flags, err; flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; cam_fill_mmcio(&ccb->mmcio, @@ -918,42 +963,20 @@ mmc_select_card(struct cam_periph *periph, union ccb * /*timeout*/ 0); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC_SELECT command failed", __func__)); - return EIO; - } - return 0; /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return EIO; - } + err = mmc_handle_reply(ccb); + return (err); } static int mmc_switch(struct cam_periph *periph, union ccb *ccb, uint8_t set, uint8_t index, uint8_t value, u_int timeout) { + int err; mmc_switch_fill_mmcio(ccb, set, index, value, timeout); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC command failed", __func__)); - return (EIO); - } - return (0); /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return (EIO); - } - + err = mmc_handle_reply(ccb); + return (err); } static uint32_t @@ -987,6 +1010,7 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc struct mmc_data mmc_d; uint32_t arg; + int err; memset(res, 0, 64); mmc_d.len = 64; @@ -1009,19 +1033,8 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc /*timeout*/ 0); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC command failed", __func__)); - return EIO; - } - return 0; /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return EIO; - } + err = mmc_handle_reply(ccb); + return (err); } static int From owner-svn-src-head@freebsd.org Mon Apr 1 19:08:06 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2253E156C7ED; Mon, 1 Apr 2019 19:08:06 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B951584BBE; Mon, 1 Apr 2019 19:08:05 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F4501AB84; Mon, 1 Apr 2019 19:08:05 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31J85Ax094862; Mon, 1 Apr 2019 19:08:05 GMT (envelope-from tychon@FreeBSD.org) Received: (from tychon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31J850N094861; Mon, 1 Apr 2019 19:08:05 GMT (envelope-from tychon@FreeBSD.org) Message-Id: <201904011908.x31J850N094861@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tychon set sender to tychon@FreeBSD.org using -f From: Tycho Nightingale Date: Mon, 1 Apr 2019 19:08:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345777 - head/sys/dev/pci X-SVN-Group: head X-SVN-Commit-Author: tychon X-SVN-Commit-Paths: head/sys/dev/pci X-SVN-Commit-Revision: 345777 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B951584BBE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 19:08:06 -0000 Author: tychon Date: Mon Apr 1 19:08:05 2019 New Revision: 345777 URL: https://svnweb.freebsd.org/changeset/base/345777 Log: Devices behind downstream bridges should still get DMAR protection. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19717 Modified: head/sys/dev/pci/pci.c Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Mon Apr 1 18:54:15 2019 (r345776) +++ head/sys/dev/pci/pci.c Mon Apr 1 19:08:05 2019 (r345777) @@ -31,6 +31,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" #include "opt_bus.h" #include @@ -5693,13 +5694,34 @@ pci_get_resource_list (device_t dev, device_t child) return (&dinfo->resources); } +#ifdef ACPI_DMAR +bus_dma_tag_t dmar_get_dma_tag(device_t dev, device_t child); bus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev) { + bus_dma_tag_t tag; + struct pci_softc *sc; + + if (device_get_parent(dev) == bus) { + /* try dmar and return if it works */ + tag = dmar_get_dma_tag(bus, dev); + } else + tag = NULL; + if (tag == NULL) { + sc = device_get_softc(bus); + tag = sc->sc_dma_tag; + } + return (tag); +} +#else +bus_dma_tag_t +pci_get_dma_tag(device_t bus, device_t dev) +{ struct pci_softc *sc = device_get_softc(bus); return (sc->sc_dma_tag); } +#endif uint32_t pci_read_config_method(device_t dev, device_t child, int reg, int width) From owner-svn-src-head@freebsd.org Mon Apr 1 19:19:53 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0099E156CA32; Mon, 1 Apr 2019 19:19:52 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D3E48514B; Mon, 1 Apr 2019 19:19:52 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5F3FD1AD37; Mon, 1 Apr 2019 19:19:52 +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 x31JJqRs000581; Mon, 1 Apr 2019 19:19:52 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31JJpOv000579; Mon, 1 Apr 2019 19:19:51 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201904011919.x31JJpOv000579@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 1 Apr 2019 19:19:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345778 - in head/gnu/usr.bin/gdb: gdb kgdb X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head/gnu/usr.bin/gdb: gdb kgdb X-SVN-Commit-Revision: 345778 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8D3E48514B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 19:19:53 -0000 Author: emaste Date: Mon Apr 1 19:19:51 2019 New Revision: 345778 URL: https://svnweb.freebsd.org/changeset/base/345778 Log: Fix gdb/kgdb build under WITH_PIE Explicitly specified bare .a libraries need ${PIE_SUFFIX}. Reported by: David E. Cross, on twitter Sponsored by: The FreeBSD Foundation Modified: head/gnu/usr.bin/gdb/gdb/Makefile head/gnu/usr.bin/gdb/kgdb/Makefile Modified: head/gnu/usr.bin/gdb/gdb/Makefile ============================================================================== --- head/gnu/usr.bin/gdb/gdb/Makefile Mon Apr 1 19:08:05 2019 (r345777) +++ head/gnu/usr.bin/gdb/gdb/Makefile Mon Apr 1 19:19:51 2019 (r345778) @@ -3,9 +3,10 @@ PROG= gdb${GDB_SUFFIX} SRCS= gdb.c -BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ - ${OBJ_BU}/libiberty/libiberty.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a +BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ + ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ + ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a # libthread_db.so calls back into gdb for the proc services. Make all the # global symbols visible. Modified: head/gnu/usr.bin/gdb/kgdb/Makefile ============================================================================== --- head/gnu/usr.bin/gdb/kgdb/Makefile Mon Apr 1 19:08:05 2019 (r345777) +++ head/gnu/usr.bin/gdb/kgdb/Makefile Mon Apr 1 19:19:51 2019 (r345778) @@ -4,9 +4,10 @@ PROG= kgdb${GDB_SUFFIX} SRCS= main.c kld.c kthr.c trgt.c trgt_${TARGET_CPUARCH}.c WARNS?= 2 -BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ - ${OBJ_BU}/libiberty/libiberty.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a +BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ + ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ + ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a DPADD= ${GDBLIBS} ${BULIBS} LDADD= ${GDBLIBS} ${BULIBS} From owner-svn-src-head@freebsd.org Mon Apr 1 21:24:52 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D921C156F9F2; Mon, 1 Apr 2019 21:24:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 834458AA0A; Mon, 1 Apr 2019 21:24:51 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 503291C481; Mon, 1 Apr 2019 21:24:51 +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 x31LOp4w071267; Mon, 1 Apr 2019 21:24:51 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31LOoVg071263; Mon, 1 Apr 2019 21:24:50 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012124.x31LOoVg071263@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 21:24:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345783 - in head: contrib/capsicum-test tests/sys/capsicum X-SVN-Group: head X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in head: contrib/capsicum-test tests/sys/capsicum X-SVN-Commit-Revision: 345783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 834458AA0A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 21:24:52 -0000 Author: ngie Date: Mon Apr 1 21:24:50 2019 New Revision: 345783 URL: https://svnweb.freebsd.org/changeset/base/345783 Log: Integrate capsicum-test into the FreeBSD test suite This change takes capsicum-test from upstream and applies some local changes to make the tests work on FreeBSD when executed via Kyua. The local modifications are as follows: 1. Make `OpenatTest.WithFlag` pass with the new dot-dot lookup behavior in FreeBSD 12.x+. 2. capsicum-test references a set of helper binaries: `mini-me`, `mini-me.noexec`, and `mini-me.setuid`, as part of the execve/fexecve tests, via execve, fexecve, and open. It achieves this upstream by assuming `mini-me*` is in the current directory, however, in order for Kyua to execute `capsicum-test`, it needs to provide a full path to `mini-me*`. In order to achieve this, I made `capsicum-test` cache the executable's path from argv[0] in main(..) and use the cached value to compute the path to `mini-me*` as part of the execve/fexecve testcases. 3. The capsicum-test test suite assumes that it's always being run on CAPABILITIES enabled kernels. However, there's a chance that the test will be run on a host without a CAPABILITIES enabled kernel, so we must check for the support before running the tests. The way to achieve this is to add the relevant `feature_present("security_capabilities")` check to SetupEnvironment::SetUp() and skip the tests when the support is not available. While here, add a check for `kern.trap_enotcap` being enabled. As noted by markj@ in https://github.com/google/capsicum-test/issues/23, this sysctl being enabled can trigger non-deterministic failures. Therefore, the tests should be skipped if this sysctl is enabled. All local changes have been submitted to the capsicum-test project (https://github.com/google/capsicum-test) and are in various stages of review. Please see the following pull requests for more details: 1. https://github.com/google/capsicum-test/pull/35 2. https://github.com/google/capsicum-test/pull/41 3. https://github.com/google/capsicum-test/pull/42 Reviewed by: asomers Discussed with: emaste, markj Approved by: emaste (mentor) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D19758 Added: head/contrib/capsicum-test/ - copied from r345782, vendor/google/capsicum-test/dist/ Modified: head/contrib/capsicum-test/capsicum-test-main.cc head/contrib/capsicum-test/capsicum.h head/contrib/capsicum-test/fexecve.cc head/contrib/capsicum-test/openat.cc head/tests/sys/capsicum/Makefile Modified: head/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- vendor/google/capsicum-test/dist/capsicum-test-main.cc Mon Apr 1 21:04:13 2019 (r345782) +++ head/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 21:24:50 2019 (r345783) @@ -2,16 +2,25 @@ #ifdef __linux__ #include #include +#elif defined(__FreeBSD__) +#include #endif #include #include +#include #include #include #include +#include #include #include "gtest/gtest.h" #include "capsicum-test.h" +// For versions of googletest that lack GTEST_SKIP. +#ifndef GTEST_SKIP +#define GTEST_SKIP GTEST_FAIL +#endif + std::string tmpdir; class SetupEnvironment : public ::testing::Environment @@ -19,6 +28,7 @@ class SetupEnvironment : public ::testing::Environment public: SetupEnvironment() : teardown_tmpdir_(false) {} void SetUp() override { + CheckCapsicumSupport(); if (tmpdir.empty()) { std::cerr << "Generating temporary directory root: "; CreateTemporaryRoot(); @@ -27,6 +37,31 @@ class SetupEnvironment : public ::testing::Environment } std::cerr << tmpdir << std::endl; } + void CheckCapsicumSupport() { +#ifdef __FreeBSD__ + int rc; + bool trap_enotcap_enabled; + size_t trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); + + if (feature_present("security_capabilities") == 0) { + GTEST_SKIP() << "Skipping tests because capsicum support is not " + << "enabled in the kernel."; + } + // If this OID is enabled, it will send SIGTRAP to the process when + // `ENOTCAPABLE` is returned. + const char *oid = "kern.trap_enotcap"; + rc = sysctlbyname(oid, &trap_enotcap_enabled, &trap_enotcap_enabled_len, + nullptr, 0); + if (rc != 0) { + GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); + } + if (trap_enotcap_enabled) { + GTEST_SKIP() << "Debug sysctl, " << oid << ", enabled. " + << "Skipping tests because its enablement invalidates the " + << "test results."; + } +#endif /* FreeBSD */ + } void CreateTemporaryRoot() { char *tmpdir_name = tempnam(nullptr, "cptst"); @@ -47,7 +82,27 @@ class SetupEnvironment : public ::testing::Environment bool teardown_tmpdir_; }; +std::string capsicum_test_bindir; + int main(int argc, char* argv[]) { + // Set up the test program path, so capsicum-test can find programs, like + // mini-me* when executed from an absolute path. + { + char *new_path, *old_path, *program_name; + + program_name = strdup(argv[0]); + assert(program_name); + capsicum_test_bindir = std::string(dirname(program_name)); + free(program_name); + + old_path = getenv("PATH"); + assert(old_path); + + assert(asprintf(&new_path, "%s:%s", capsicum_test_bindir.c_str(), + old_path) > 0); + assert(setenv("PATH", new_path, 1) == 0); + } + ::testing::InitGoogleTest(&argc, argv); for (int ii = 1; ii < argc; ii++) { if (strcmp(argv[ii], "-v") == 0) { Modified: head/contrib/capsicum-test/capsicum.h ============================================================================== --- vendor/google/capsicum-test/dist/capsicum.h Mon Apr 1 21:04:13 2019 (r345782) +++ head/contrib/capsicum-test/capsicum.h Mon Apr 1 21:24:50 2019 (r345783) @@ -167,4 +167,9 @@ static inline void cap_rights_describe(const cap_right #endif /* new/old style rights manipulation */ +#ifdef __cplusplus +#include +extern std::string capsicum_test_bindir; +#endif + #endif /*__CAPSICUM_H__*/ Modified: head/contrib/capsicum-test/fexecve.cc ============================================================================== --- vendor/google/capsicum-test/dist/fexecve.cc Mon Apr 1 21:04:13 2019 (r345782) +++ head/contrib/capsicum-test/fexecve.cc Mon Apr 1 21:24:50 2019 (r345783) @@ -1,12 +1,12 @@ -#include -#include #include #include #include +#include #include -#include #include #include +#include +#include #include @@ -14,41 +14,76 @@ #include "capsicum.h" #include "capsicum-test.h" -// We need a program to exec(), but for fexecve() to work in capability -// mode that program needs to be statically linked (otherwise ld.so will -// attempt to traverse the filesystem to load (e.g.) /lib/libc.so and -// fail). -#define EXEC_PROG "./mini-me" -#define EXEC_PROG_NOEXEC EXEC_PROG ".noexec" -#define EXEC_PROG_SETUID EXEC_PROG ".setuid" - // Arguments to use in execve() calls. -static char* argv_pass[] = {(char*)EXEC_PROG, (char*)"--pass", NULL}; -static char* argv_fail[] = {(char*)EXEC_PROG, (char*)"--fail", NULL}; -static char* argv_checkroot[] = {(char*)EXEC_PROG, (char*)"--checkroot", NULL}; static char* null_envp[] = {NULL}; class Execve : public ::testing::Test { public: - Execve() : exec_fd_(open(EXEC_PROG, O_RDONLY)) { + Execve() : exec_fd_(-1) { + // We need a program to exec(), but for fexecve() to work in capability + // mode that program needs to be statically linked (otherwise ld.so will + // attempt to traverse the filesystem to load (e.g.) /lib/libc.so and + // fail). + exec_prog_ = capsicum_test_bindir + "/mini-me"; + exec_prog_noexec_ = capsicum_test_bindir + "/mini-me.noexec"; + exec_prog_setuid_ = capsicum_test_bindir + "/mini-me.setuid"; + + exec_fd_ = open(exec_prog_.c_str(), O_RDONLY); if (exec_fd_ < 0) { - fprintf(stderr, "Error! Failed to open %s\n", EXEC_PROG); + fprintf(stderr, "Error! Failed to open %s\n", exec_prog_.c_str()); } + argv_checkroot_[0] = (char*)exec_prog_.c_str(); + argv_fail_[0] = (char*)exec_prog_.c_str(); + argv_pass_[0] = (char*)exec_prog_.c_str(); } - ~Execve() { if (exec_fd_ >= 0) close(exec_fd_); } + ~Execve() { + if (exec_fd_ >= 0) { + close(exec_fd_); + exec_fd_ = -1; + } + } protected: + char* argv_checkroot_[3] = {nullptr, (char*)"--checkroot", nullptr}; + char* argv_fail_[3] = {nullptr, (char*)"--fail", nullptr}; + char* argv_pass_[3] = {nullptr, (char*)"--pass", nullptr}; + std::string exec_prog_, exec_prog_noexec_, exec_prog_setuid_; int exec_fd_; }; +class Fexecve : public Execve { + public: + Fexecve() : Execve() {} +}; + +class FexecveWithScript : public Fexecve { + public: + FexecveWithScript() : + Fexecve(), temp_script_filename_(TmpFile("cap_sh_script")) {} + + void SetUp() override { + // First, build an executable shell script + int fd = open(temp_script_filename_, O_RDWR|O_CREAT, 0755); + EXPECT_OK(fd); + const char* contents = "#!/bin/sh\nexit 99\n"; + EXPECT_OK(write(fd, contents, strlen(contents))); + close(fd); + } + void TearDown() override { + (void)::unlink(temp_script_filename_); + } + + const char *temp_script_filename_; +}; + FORK_TEST_F(Execve, BasicFexecve) { - EXPECT_OK(fexecve_(exec_fd_, argv_pass, null_envp)); + EXPECT_OK(fexecve_(exec_fd_, argv_pass_, null_envp)); // Should not reach here, exec() takes over. EXPECT_TRUE(!"fexecve() should never return"); } FORK_TEST_F(Execve, InCapMode) { EXPECT_OK(cap_enter()); - EXPECT_OK(fexecve_(exec_fd_, argv_pass, null_envp)); + EXPECT_OK(fexecve_(exec_fd_, argv_pass_, null_envp)); // Should not reach here, exec() takes over. EXPECT_TRUE(!"fexecve() should never return"); } @@ -60,7 +95,7 @@ FORK_TEST_F(Execve, FailWithoutCap) { cap_rights_t rights; cap_rights_init(&rights, 0); EXPECT_OK(cap_rights_limit(cap_fd, &rights)); - EXPECT_EQ(-1, fexecve_(cap_fd, argv_fail, null_envp)); + EXPECT_EQ(-1, fexecve_(cap_fd, argv_fail_, null_envp)); EXPECT_EQ(ENOTCAPABLE, errno); } @@ -73,59 +108,54 @@ FORK_TEST_F(Execve, SucceedWithCap) { // rights -- just CAP_FEXECVE|CAP_READ or CAP_FEXECVE would be preferable. cap_rights_init(&rights, CAP_FEXECVE, CAP_LOOKUP, CAP_READ); EXPECT_OK(cap_rights_limit(cap_fd, &rights)); - EXPECT_OK(fexecve_(cap_fd, argv_pass, null_envp)); + EXPECT_OK(fexecve_(cap_fd, argv_pass_, null_envp)); // Should not reach here, exec() takes over. EXPECT_TRUE(!"fexecve() should have succeeded"); } -FORK_TEST(Fexecve, ExecutePermissionCheck) { - int fd = open(EXEC_PROG_NOEXEC, O_RDONLY); +FORK_TEST_F(Fexecve, ExecutePermissionCheck) { + int fd = open(exec_prog_noexec_.c_str(), O_RDONLY); EXPECT_OK(fd); if (fd >= 0) { struct stat data; EXPECT_OK(fstat(fd, &data)); EXPECT_EQ((mode_t)0, data.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)); - EXPECT_EQ(-1, fexecve_(fd, argv_fail, null_envp)); + EXPECT_EQ(-1, fexecve_(fd, argv_fail_, null_envp)); EXPECT_EQ(EACCES, errno); close(fd); } } -FORK_TEST(Fexecve, SetuidIgnored) { +FORK_TEST_F(Fexecve, SetuidIgnored) { if (geteuid() == 0) { TEST_SKIPPED("requires non-root"); return; } - int fd = open(EXEC_PROG_SETUID, O_RDONLY); + int fd = open(exec_prog_setuid_.c_str(), O_RDONLY); EXPECT_OK(fd); EXPECT_OK(cap_enter()); if (fd >= 0) { struct stat data; EXPECT_OK(fstat(fd, &data)); EXPECT_EQ((mode_t)S_ISUID, data.st_mode & S_ISUID); - EXPECT_OK(fexecve_(fd, argv_checkroot, null_envp)); + EXPECT_OK(fexecve_(fd, argv_checkroot_, null_envp)); // Should not reach here, exec() takes over. EXPECT_TRUE(!"fexecve() should have succeeded"); close(fd); } } -FORK_TEST(Fexecve, ExecveFailure) { +FORK_TEST_F(Fexecve, ExecveFailure) { EXPECT_OK(cap_enter()); - EXPECT_EQ(-1, execve(argv_fail[0], argv_fail, null_envp)); + EXPECT_EQ(-1, execve(argv_fail_[0], argv_fail_, null_envp)); EXPECT_EQ(ECAPMODE, errno); } -FORK_TEST_ON(Fexecve, CapModeScriptFail, TmpFile("cap_sh_script")) { - // First, build an executable shell script - int fd = open(TmpFile("cap_sh_script"), O_RDWR|O_CREAT, 0755); - EXPECT_OK(fd); - const char* contents = "#!/bin/sh\nexit 99\n"; - EXPECT_OK(write(fd, contents, strlen(contents))); - close(fd); +FORK_TEST_F(FexecveWithScript, CapModeScriptFail) { + int fd; // Open the script file, with CAP_FEXECVE rights. - fd = open(TmpFile("cap_sh_script"), O_RDONLY); + fd = open(temp_script_filename_, O_RDONLY); cap_rights_t rights; cap_rights_init(&rights, CAP_FEXECVE, CAP_READ, CAP_SEEK); EXPECT_OK(cap_rights_limit(fd, &rights)); @@ -133,12 +163,17 @@ FORK_TEST_ON(Fexecve, CapModeScriptFail, TmpFile("cap_ EXPECT_OK(cap_enter()); // Enter capability mode // Attempt fexecve; should fail, because "/bin/sh" is inaccessible. - EXPECT_EQ(-1, fexecve_(fd, argv_pass, null_envp)); + EXPECT_EQ(-1, fexecve_(fd, argv_pass_, null_envp)); } #ifdef HAVE_EXECVEAT -TEST(Execveat, NoUpwardTraversal) { - char *abspath = realpath(EXEC_PROG, NULL); +class Execveat : public Execve { + public: + Execveat() : Execve() {} +}; + +TEST_F(Execveat, NoUpwardTraversal) { + char *abspath = realpath(exec_prog_, NULL); char cwd[1024]; getcwd(cwd, sizeof(cwd)); @@ -148,9 +183,9 @@ TEST(Execveat, NoUpwardTraversal) { EXPECT_OK(cap_enter()); // Enter capability mode. // Can't execveat() an absolute path, even relative to a dfd. EXPECT_SYSCALL_FAIL(ECAPMODE, - execveat(AT_FDCWD, abspath, argv_pass, null_envp, 0)); + execveat(AT_FDCWD, abspath, argv_pass_, null_envp, 0)); EXPECT_SYSCALL_FAIL(E_NO_TRAVERSE_CAPABILITY, - execveat(dfd, abspath, argv_pass, null_envp, 0)); + execveat(dfd, abspath, argv_pass_, null_envp, 0)); // Can't execveat() a relative path ("..//./"). char *p = cwd + strlen(cwd); @@ -158,9 +193,9 @@ TEST(Execveat, NoUpwardTraversal) { char buffer[1024] = "../"; strcat(buffer, ++p); strcat(buffer, "/"); - strcat(buffer, EXEC_PROG); + strcat(buffer, exec_prog_); EXPECT_SYSCALL_FAIL(E_NO_TRAVERSE_CAPABILITY, - execveat(dfd, buffer, argv_pass, null_envp, 0)); + execveat(dfd, buffer, argv_pass_, null_envp, 0)); exit(HasFailure() ? 99 : 123); } int status; Modified: head/contrib/capsicum-test/openat.cc ============================================================================== --- vendor/google/capsicum-test/dist/openat.cc Mon Apr 1 21:04:13 2019 (r345782) +++ head/contrib/capsicum-test/openat.cc Mon Apr 1 21:24:50 2019 (r345783) @@ -148,7 +148,7 @@ FORK_TEST(Openat, Relative) { } #define TOPDIR "cap_topdir" -#define SUBDIR_ABS TOPDIR "/subdir" +#define SUBDIR TOPDIR "/subdir" class OpenatTest : public ::testing::Test { public: // Build a collection of files, subdirs and symlinks: @@ -156,20 +156,20 @@ class OpenatTest : public ::testing::Test { // /topfile // /subdir/ // /subdir/bottomfile - // /symlink.samedir -> topfile - // /dsymlink.samedir -> ./ - // /symlink.down -> subdir/bottomfile - // /dsymlink.down -> subdir/ - // /symlink.absolute_in -> /tmp/cap_topdir/topfile - // /dsymlink.absolute_in -> /tmp/cap_topdir/ - // /symlink.absolute_out -> /etc/passwd - // /dsymlink.absolute_out -> /etc/ - // /symlink.relative_in -> ../../tmp/cap_topdir/topfile - // /dsymlink.relative_in -> ../../tmp/cap_topdir/ - // /symlink.relative_out -> ../../etc/passwd - // /dsymlink.relative_out -> ../../etc/ - // /subdir/symlink.up -> ../topfile - // /subdir/dsymlink.up -> ../ + // /symlink.samedir -> topfile + // /dsymlink.samedir -> ./ + // /symlink.down -> subdir/bottomfile + // /dsymlink.down -> subdir/ + // /symlink.absolute_out -> /etc/passwd + // /dsymlink.absolute_out -> /etc/ + // /symlink.relative_in -> ../../tmp/cap_topdir/topfile + // /dsymlink.relative_in -> ../../tmp/cap_topdir/ + // /symlink.relative_out -> ../../etc/passwd + // /dsymlink.relative_out -> ../../etc/ + // /subdir/dsymlink.absolute_in -> /tmp/cap_topdir/ + // /subdir/dsymlink.up -> ../ + // /subdir/symlink.absolute_in -> /tmp/cap_topdir/topfile + // /subdir/symlink.up -> ../topfile // (In practice, this is a little more complicated because tmpdir might // not be "/tmp".) OpenatTest() { @@ -179,7 +179,7 @@ class OpenatTest : public ::testing::Test { if (rc < 0) { EXPECT_EQ(EEXIST, errno); } - rc = mkdir(TmpFile(SUBDIR_ABS), 0755); + rc = mkdir(TmpFile(SUBDIR), 0755); EXPECT_OK(rc); if (rc < 0) { EXPECT_EQ(EEXIST, errno); @@ -197,34 +197,34 @@ class OpenatTest : public ::testing::Test { // Create normal files in each. CreateFile(TmpFile(TOPDIR "/topfile"), "Top-level file"); - CreateFile(TmpFile(SUBDIR_ABS "/bottomfile"), "File in subdirectory"); + CreateFile(TmpFile(SUBDIR "/bottomfile"), "File in subdirectory"); // Create various symlinks to files. EXPECT_OK(symlink("topfile", TmpFile(TOPDIR "/symlink.samedir"))); EXPECT_OK(symlink("subdir/bottomfile", TmpFile(TOPDIR "/symlink.down"))); - EXPECT_OK(symlink(TmpFile(TOPDIR "/topfile"), TmpFile(TOPDIR "/symlink.absolute_in"))); + EXPECT_OK(symlink(TmpFile(TOPDIR "/topfile"), TmpFile(SUBDIR "/symlink.absolute_in"))); EXPECT_OK(symlink("/etc/passwd", TmpFile(TOPDIR "/symlink.absolute_out"))); std::string dots2top = dots2root + TmpFile(TOPDIR "/topfile"); EXPECT_OK(symlink(dots2top.c_str(), TmpFile(TOPDIR "/symlink.relative_in"))); std::string dots2passwd = dots2root + "/etc/passwd"; EXPECT_OK(symlink(dots2passwd.c_str(), TmpFile(TOPDIR "/symlink.relative_out"))); - EXPECT_OK(symlink("../topfile", TmpFile(SUBDIR_ABS "/symlink.up"))); + EXPECT_OK(symlink("../topfile", TmpFile(SUBDIR "/symlink.up"))); // Create various symlinks to directories. EXPECT_OK(symlink("./", TmpFile(TOPDIR "/dsymlink.samedir"))); EXPECT_OK(symlink("subdir/", TmpFile(TOPDIR "/dsymlink.down"))); - EXPECT_OK(symlink(TmpFile(TOPDIR "/"), TmpFile(TOPDIR "/dsymlink.absolute_in"))); + EXPECT_OK(symlink(TmpFile(TOPDIR "/"), TmpFile(SUBDIR "/dsymlink.absolute_in"))); EXPECT_OK(symlink("/etc/", TmpFile(TOPDIR "/dsymlink.absolute_out"))); std::string dots2cwd = dots2root + tmpdir + "/"; EXPECT_OK(symlink(dots2cwd.c_str(), TmpFile(TOPDIR "/dsymlink.relative_in"))); std::string dots2etc = dots2root + "/etc/"; EXPECT_OK(symlink(dots2etc.c_str(), TmpFile(TOPDIR "/dsymlink.relative_out"))); - EXPECT_OK(symlink("../", TmpFile(SUBDIR_ABS "/dsymlink.up"))); + EXPECT_OK(symlink("../", TmpFile(SUBDIR "/dsymlink.up"))); // Open directory FDs for those directories and for cwd. dir_fd_ = open(TmpFile(TOPDIR), O_RDONLY); EXPECT_OK(dir_fd_); - sub_fd_ = open(TmpFile(SUBDIR_ABS), O_RDONLY); + sub_fd_ = open(TmpFile(SUBDIR), O_RDONLY); EXPECT_OK(sub_fd_); cwd_ = openat(AT_FDCWD, ".", O_RDONLY); EXPECT_OK(cwd_); @@ -236,23 +236,23 @@ class OpenatTest : public ::testing::Test { close(cwd_); close(sub_fd_); close(dir_fd_); - unlink(TmpFile(SUBDIR_ABS "/symlink.up")); - unlink(TmpFile(TOPDIR "/symlink.absolute_in")); + unlink(TmpFile(SUBDIR "/symlink.up")); + unlink(TmpFile(SUBDIR "/symlink.absolute_in")); unlink(TmpFile(TOPDIR "/symlink.absolute_out")); unlink(TmpFile(TOPDIR "/symlink.relative_in")); unlink(TmpFile(TOPDIR "/symlink.relative_out")); unlink(TmpFile(TOPDIR "/symlink.down")); unlink(TmpFile(TOPDIR "/symlink.samedir")); - unlink(TmpFile(SUBDIR_ABS "/dsymlink.up")); - unlink(TmpFile(TOPDIR "/dsymlink.absolute_in")); + unlink(TmpFile(SUBDIR "/dsymlink.up")); + unlink(TmpFile(SUBDIR "/dsymlink.absolute_in")); unlink(TmpFile(TOPDIR "/dsymlink.absolute_out")); unlink(TmpFile(TOPDIR "/dsymlink.relative_in")); unlink(TmpFile(TOPDIR "/dsymlink.relative_out")); unlink(TmpFile(TOPDIR "/dsymlink.down")); unlink(TmpFile(TOPDIR "/dsymlink.samedir")); - unlink(TmpFile(SUBDIR_ABS "/bottomfile")); + unlink(TmpFile(SUBDIR "/bottomfile")); unlink(TmpFile(TOPDIR "/topfile")); - rmdir(TmpFile(SUBDIR_ABS)); + rmdir(TmpFile(SUBDIR)); rmdir(TmpFile(TOPDIR)); } @@ -281,18 +281,18 @@ class OpenatTest : public ::testing::Test { // Should only be able to open symlinks that stay within the directory. EXPECT_OPEN_OK(openat(dir_fd_, "symlink.samedir", O_RDONLY|oflag)); EXPECT_OPEN_OK(openat(dir_fd_, "symlink.down", O_RDONLY|oflag)); - EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "symlink.absolute_in", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "symlink.absolute_out", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "symlink.relative_in", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "symlink.relative_out", O_RDONLY|oflag); + EXPECT_OPENAT_FAIL_TRAVERSAL(sub_fd_, "symlink.absolute_in", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(sub_fd_, "symlink.up", O_RDONLY|oflag); EXPECT_OPEN_OK(openat(dir_fd_, "dsymlink.samedir/topfile", O_RDONLY|oflag)); EXPECT_OPEN_OK(openat(dir_fd_, "dsymlink.down/bottomfile", O_RDONLY|oflag)); - EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "dsymlink.absolute_in/topfile", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "dsymlink.absolute_out/passwd", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "dsymlink.relative_in/topfile", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(dir_fd_, "dsymlink.relative_out/passwd", O_RDONLY|oflag); + EXPECT_OPENAT_FAIL_TRAVERSAL(sub_fd_, "dsymlink.absolute_in/topfile", O_RDONLY|oflag); EXPECT_OPENAT_FAIL_TRAVERSAL(sub_fd_, "dsymlink.up/topfile", O_RDONLY|oflag); // Although recall that O_NOFOLLOW prevents symlink following in final component. @@ -310,10 +310,10 @@ TEST_F(OpenatTest, WithCapability) { // Any kind of symlink can be opened relative to an ordinary directory FD. EXPECT_OPEN_OK(openat(dir_fd_, "symlink.samedir", O_RDONLY)); EXPECT_OPEN_OK(openat(dir_fd_, "symlink.down", O_RDONLY)); - EXPECT_OPEN_OK(openat(dir_fd_, "symlink.absolute_in", O_RDONLY)); EXPECT_OPEN_OK(openat(dir_fd_, "symlink.absolute_out", O_RDONLY)); EXPECT_OPEN_OK(openat(dir_fd_, "symlink.relative_in", O_RDONLY)); EXPECT_OPEN_OK(openat(dir_fd_, "symlink.relative_out", O_RDONLY)); + EXPECT_OPEN_OK(openat(sub_fd_, "symlink.absolute_in", O_RDONLY)); EXPECT_OPEN_OK(openat(sub_fd_, "symlink.up", O_RDONLY)); // Now make both DFDs into Capsicum capabilities. Modified: head/tests/sys/capsicum/Makefile ============================================================================== --- head/tests/sys/capsicum/Makefile Mon Apr 1 21:04:13 2019 (r345782) +++ head/tests/sys/capsicum/Makefile Mon Apr 1 21:24:50 2019 (r345783) @@ -1,11 +1,56 @@ # $FreeBSD$ +.include + TESTSDIR= ${TESTSBASE}/sys/capsicum ATF_TESTS_C+= bindat_connectat ATF_TESTS_C+= ioctls_test CFLAGS+= -I${SRCTOP}/tests + +.if ${MK_GOOGLETEST} != no + +.PATH: ${SRCTOP}/contrib/capsicum-test + +GTESTS+= capsicum-test + +SRCS.capsicum-test+= \ + capsicum-test-main.cc \ + capsicum-test.cc \ + capability-fd.cc \ + fexecve.cc \ + procdesc.cc \ + capmode.cc \ + fcntl.cc \ + ioctl.cc \ + openat.cc \ + sysctl.cc \ + select.cc \ + mqueue.cc \ + socket.cc \ + sctp.cc \ + capability-fd-pair.cc \ + overhead.cc \ + rename.cc + +LIBADD.capsicum-test+= gtest pthread +TEST_METADATA.capsicum-test= required_user="unprivileged" + +.for p in mini-me mini-me.noexec mini-me.setuid +PROGS+= $p +NO_SHARED.$p= +SRCS.$p= mini-me.c +.endfor + +BINDIR= ${TESTSDIR} + +BINMODE.mini-me.noexec= ${NOBINMODE} +BINMODE.mini-me.setuid= 4555 + +WARNS.capsicum-test= 3 + +.endif WARNS?= 6 From owner-svn-src-head@freebsd.org Tue Apr 2 04:00:03 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9E53155381C; Tue, 2 Apr 2019 04:00:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7DDB97095A; Tue, 2 Apr 2019 04:00:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E75A2083B; Tue, 2 Apr 2019 04:00:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32402tO076809; Tue, 2 Apr 2019 04:00:02 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32401O8076808; Tue, 2 Apr 2019 04:00:01 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904020400.x32401O8076808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Tue, 2 Apr 2019 04:00:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345789 - head/sys/powerpc/powernv X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/powernv X-SVN-Commit-Revision: 345789 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7DDB97095A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 04:00:03 -0000 Author: jhibbits Date: Tue Apr 2 04:00:01 2019 New Revision: 345789 URL: https://svnweb.freebsd.org/changeset/base/345789 Log: powerpc/powernv: Add OPAL heartbeat thread Summary: OPAL needs to be kicked periodically in order for the firmware to make progress on its tasks. To do so, create a heartbeat thread to perform this task every N milliseconds, defined by the device tree. This task is also a central location to handle all messages received from OPAL. Reviewed By: luporl Differential Revision: https://reviews.freebsd.org/D19743 Modified: head/sys/powerpc/powernv/opal.h head/sys/powerpc/powernv/opal_dev.c Modified: head/sys/powerpc/powernv/opal.h ============================================================================== --- head/sys/powerpc/powernv/opal.h Mon Apr 1 23:37:21 2019 (r345788) +++ head/sys/powerpc/powernv/opal.h Tue Apr 2 04:00:01 2019 (r345789) @@ -31,6 +31,7 @@ #include #include +#include /* Check if OPAL is correctly instantiated. Will try to instantiate it. */ int opal_check(void); @@ -72,6 +73,7 @@ int opal_call(uint64_t token, ...); #define OPAL_RETURN_CPU 69 #define OPAL_REINIT_CPUS 70 #define OPAL_CHECK_TOKEN 80 +#define OPAL_GET_MSG 85 #define OPAL_CHECK_ASYNC_COMPLETION 86 #define OPAL_SENSOR_READ 88 #define OPAL_HANDLE_HMI 98 @@ -140,6 +142,19 @@ int opal_call(uint64_t token, ...); #define OPAL_TOKEN_ABSENT 0 #define OPAL_TOKEN_PRESENT 1 +#define OPAL_EVENT_OPAL_INTERNAL 0x1 +#define OPAL_EVENT_NVRAM 0x2 +#define OPAL_EVENT_RTC 0x4 +#define OPAL_EVENT_CONSOLE_INPUT 0x8 +#define OPAL_EVENT_CONSOLE_OUTPUT 0x10 +#define OPAL_EVENT_ERROR_LOG_AVAIL 0x20 +#define OPAL_EVENT_ERROR_LOG 0x40 +#define OPAL_EVENT_EPOW 0x80 +#define OPAL_EVENT_LED_STATUS 0x100 +#define OPAL_EVENT_PCI_ERROR 0x200 +#define OPAL_EVENT_DUMP_AVAIL 0x400 +#define OPAL_EVENT_MSG_PENDING 0x800 + #define OPAL_HMI_FLAGS_TB_RESYNC (1ull << 0) #define OPAL_HMI_FLAGS_DEC_LOST (1ull << 1) #define OPAL_HMI_FLAGS_HDEC_LOST (1ull << 2) @@ -188,4 +203,17 @@ int opal_alloc_async_token(void); void opal_free_async_token(int); int opal_wait_completion(void *, uint64_t, uint64_t); +typedef void (*opal_msg_handler_fn)(void *, struct opal_msg *); +EVENTHANDLER_DECLARE(OPAL_ASYNC_COMP, opal_msg_handler_fn); +EVENTHANDLER_DECLARE(OPAL_EPOW, opal_msg_handler_fn); +EVENTHANDLER_DECLARE(OPAL_SHUTDOWN, opal_msg_handler_fn); +EVENTHANDLER_DECLARE(OPAL_HMI_EVT, opal_msg_handler_fn); +EVENTHANDLER_DECLARE(OPAL_DPO, opal_msg_handler_fn); +EVENTHANDLER_DECLARE(OPAL_OCC, opal_msg_handler_fn); +EVENTHANDLER_LIST_DECLARE(OPAL_ASYNC_COMP); +EVENTHANDLER_LIST_DECLARE(OPAL_EPOW); +EVENTHANDLER_LIST_DECLARE(OPAL_SHUTDOWN); +EVENTHANDLER_LIST_DECLARE(OPAL_HMI_EVT); +EVENTHANDLER_LIST_DECLARE(OPAL_DPO); +EVENTHANDLER_LIST_DECLARE(OPAL_OCC); #endif Modified: head/sys/powerpc/powernv/opal_dev.c ============================================================================== --- head/sys/powerpc/powernv/opal_dev.c Mon Apr 1 23:37:21 2019 (r345788) +++ head/sys/powerpc/powernv/opal_dev.c Tue Apr 2 04:00:01 2019 (r345789) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -59,6 +60,8 @@ static const struct ofw_bus_devinfo *opaldev_get_devin device_t child); static void opal_shutdown(void *arg, int howto); +static void opal_handle_shutdown_message(void *unused, + struct opal_msg *msg); static void opal_intr(void *); static device_method_t opaldev_methods[] = { @@ -94,6 +97,49 @@ static devclass_t opaldev_devclass; DRIVER_MODULE(opaldev, ofwbus, opaldev_driver, opaldev_devclass, 0, 0); +static void opal_heartbeat(void); +static void opal_handle_messages(void); + +static struct proc *opal_hb_proc; +static struct kproc_desc opal_heartbeat_kp = { + "opal_heartbeat", + opal_heartbeat, + &opal_hb_proc +}; + +SYSINIT(opal_heartbeat_setup, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, kproc_start, + &opal_heartbeat_kp); + +static int opal_heartbeat_ms; +EVENTHANDLER_LIST_DEFINE(OPAL_ASYNC_COMP); +EVENTHANDLER_LIST_DEFINE(OPAL_EPOW); +EVENTHANDLER_LIST_DEFINE(OPAL_SHUTDOWN); +EVENTHANDLER_LIST_DEFINE(OPAL_HMI_EVT); +EVENTHANDLER_LIST_DEFINE(OPAL_DPO); +EVENTHANDLER_LIST_DEFINE(OPAL_OCC); + +#define OPAL_SOFT_OFF 0 +#define OPAL_SOFT_REBOOT 1 + +static void +opal_heartbeat(void) +{ + uint64_t events; + + if (opal_heartbeat_ms == 0) + kproc_exit(0); + + while (1) { + events = 0; + /* Turn the OPAL state crank */ + opal_call(OPAL_POLL_EVENTS, vtophys(&events)); + if (events & OPAL_EVENT_MSG_PENDING) + opal_handle_messages(); + tsleep(opal_hb_proc, 0, "opal", + MSEC_2_TICKS(opal_heartbeat_ms)); + } +} + static int opaldev_probe(device_t dev) { @@ -150,9 +196,13 @@ opaldev_attach(device_t dev) if (rv == OPAL_SUCCESS) clock_register(dev, 2000); + EVENTHANDLER_REGISTER(OPAL_SHUTDOWN, opal_handle_shutdown_message, + NULL, EVENTHANDLER_PRI_ANY); EVENTHANDLER_REGISTER(shutdown_final, opal_shutdown, NULL, SHUTDOWN_PRI_LAST); + OF_getencprop(ofw_bus_get_node(dev), "ibm,heartbeat-ms", + &opal_heartbeat_ms, sizeof(opal_heartbeat_ms)); /* Bind to interrupts */ for (i = 0; (irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, RF_ACTIVE)) != NULL; i++) @@ -306,13 +356,68 @@ opal_shutdown(void *arg, int howto) } static void +opal_handle_shutdown_message(void *unused, struct opal_msg *msg) +{ + int howto; + + switch (be64toh(msg->params[0])) { + case OPAL_SOFT_OFF: + howto = RB_POWEROFF; + break; + case OPAL_SOFT_REBOOT: + howto = RB_REROOT; + break; + } + shutdown_nice(howto); +} + +static void +opal_handle_messages(void) +{ + static struct opal_msg msg; + uint64_t rv; + uint32_t type; + + rv = opal_call(OPAL_GET_MSG, vtophys(&msg), sizeof(msg)); + + if (rv != OPAL_SUCCESS) + return; + + type = be32toh(msg.msg_type); + switch (type) { + case OPAL_MSG_ASYNC_COMP: + EVENTHANDLER_DIRECT_INVOKE(OPAL_ASYNC_COMP, &msg); + break; + case OPAL_MSG_EPOW: + EVENTHANDLER_DIRECT_INVOKE(OPAL_EPOW, &msg); + break; + case OPAL_MSG_SHUTDOWN: + EVENTHANDLER_DIRECT_INVOKE(OPAL_SHUTDOWN, &msg); + break; + case OPAL_MSG_HMI_EVT: + EVENTHANDLER_DIRECT_INVOKE(OPAL_HMI_EVT, &msg); + break; + case OPAL_MSG_DPO: + EVENTHANDLER_DIRECT_INVOKE(OPAL_DPO, &msg); + break; + case OPAL_MSG_OCC: + EVENTHANDLER_DIRECT_INVOKE(OPAL_OCC, &msg); + break; + default: + printf("Unknown OPAL message type %d\n", type); + } +} + +static void opal_intr(void *xintr) { uint64_t events = 0; opal_call(OPAL_HANDLE_INTERRUPT, (uint32_t)(uint64_t)xintr, vtophys(&events)); - /* XXX: do something useful with this information */ + /* Wake up the heartbeat, if it's been setup. */ + if (events != 0 && opal_hb_proc != NULL) + wakeup(opal_hb_proc); } From owner-svn-src-head@freebsd.org Tue Apr 2 04:02:59 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DD321553AF4; Tue, 2 Apr 2019 04:02:59 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B1BD570DBE; Tue, 2 Apr 2019 04:02:58 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5F445209F5; Tue, 2 Apr 2019 04:02:58 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3242wir081561; Tue, 2 Apr 2019 04:02:58 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3242woQ081560; Tue, 2 Apr 2019 04:02:58 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904020402.x3242woQ081560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Tue, 2 Apr 2019 04:02:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345790 - head/sys/powerpc/powernv X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/powernv X-SVN-Commit-Revision: 345790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B1BD570DBE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 04:02:59 -0000 Author: jhibbits Date: Tue Apr 2 04:02:57 2019 New Revision: 345790 URL: https://svnweb.freebsd.org/changeset/base/345790 Log: powernv: Port OPAL asynchronous framework to use the new message framework Since OPAL_GET_MSG does not discriminate between message types, asynchronous completion events may be received in the OPAL_GET_MSG call, which dequeues them from the list, thus preventing OPAL_CHECK_ASYNC_COMPLETION from succeeding. Handle this case by integrating with the messaging framework. Modified: head/sys/powerpc/powernv/opal_async.c Modified: head/sys/powerpc/powernv/opal_async.c ============================================================================== --- head/sys/powerpc/powernv/opal_async.c Tue Apr 2 04:00:01 2019 (r345789) +++ head/sys/powerpc/powernv/opal_async.c Tue Apr 2 04:02:57 2019 (r345790) @@ -35,6 +35,8 @@ #include #include "opal.h" +#include + /* * Manage asynchronous tokens for the OPAL abstraction layer. * @@ -45,6 +47,15 @@ */ static vmem_t *async_token_pool; +static void opal_handle_async_completion(void *, struct opal_msg *); + +struct async_completion { + uint64_t rval; + bool completed; +}; + +struct async_completion *completions; + /* Setup the token pool. */ int opal_init_async_tokens(int count) @@ -55,7 +66,12 @@ opal_init_async_tokens(int count) async_token_pool = vmem_create("OPAL Async", 0, count, 1, 1, M_WAITOK | M_FIRSTFIT); + completions = malloc(count * sizeof(struct async_completion), + M_DEVBUF, M_WAITOK | M_ZERO); + EVENTHANDLER_REGISTER(OPAL_ASYNC_COMP, opal_handle_async_completion, + NULL, EVENTHANDLER_PRI_ANY); + return (0); } @@ -65,6 +81,7 @@ opal_alloc_async_token(void) vmem_addr_t token; vmem_alloc(async_token_pool, 1, M_FIRSTFIT | M_WAITOK, &token); + completions[token].completed = false; return (token); } @@ -88,7 +105,20 @@ opal_wait_completion(void *buf, uint64_t size, uint64_ do { err = opal_call(OPAL_CHECK_ASYNC_COMPLETION, vtophys(buf), size, token); + if (err == OPAL_BUSY) + if (completions[token].completed) + return (completions[token].rval); } while (err == OPAL_BUSY); return (err); +} + +static void opal_handle_async_completion(void *arg, struct opal_msg *msg) +{ + int token; + + token = msg->params[0]; + completions[token].rval = msg->params[1]; + isync(); + completions[token].completed = true; } From owner-svn-src-head@freebsd.org Tue Apr 2 04:12:07 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C11A91553ECA; Tue, 2 Apr 2019 04:12:07 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 609847138E; Tue, 2 Apr 2019 04:12:07 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E97F20B7B; Tue, 2 Apr 2019 04:12:07 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x324C7Y1084525; Tue, 2 Apr 2019 04:12:07 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x324C7q8084524; Tue, 2 Apr 2019 04:12:07 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904020412.x324C7q8084524@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Tue, 2 Apr 2019 04:12:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345791 - head/sys/dev/ipmi X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/dev/ipmi X-SVN-Commit-Revision: 345791 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 609847138E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 04:12:08 -0000 Author: jhibbits Date: Tue Apr 2 04:12:06 2019 New Revision: 345791 URL: https://svnweb.freebsd.org/changeset/base/345791 Log: ipmi: Fixes for ipmi_opal(powernv) * Crank the OPAL state machine during the receive loop, to make sure the pollers are executed * Add a proper detach function, so the module can be unloaded and reloaded at runtime. It still doesn't reliably work 100% of the time on POWER9, and it appears timing and/or cache related. It may work on POWER8 now. MFC after: 2 weeks Modified: head/sys/dev/ipmi/ipmi_opal.c Modified: head/sys/dev/ipmi/ipmi_opal.c ============================================================================== --- head/sys/dev/ipmi/ipmi_opal.c Tue Apr 2 04:02:57 2019 (r345790) +++ head/sys/dev/ipmi/ipmi_opal.c Tue Apr 2 04:12:06 2019 (r345791) @@ -99,6 +99,8 @@ opal_ipmi_polled_request(struct opal_ipmi_softc *sc, s timo *= 10; /* Timeout is in milliseconds, we delay in 100us */ do { msg_len = sizeof(struct opal_ipmi_msg) + IPMI_MAX_RX; + /* Crank the OPAL state machine while we poll for a reply. */ + opal_call(OPAL_POLL_EVENTS, NULL); err = opal_call(OPAL_IPMI_RECV, sc->sc_interface, vtophys(sc->sc_msg), vtophys(&msg_len)); if (err != OPAL_EMPTY) @@ -113,6 +115,7 @@ opal_ipmi_polled_request(struct opal_ipmi_softc *sc, s req->ir_replylen = min(req->ir_replylen, req->ir_replybuflen); memcpy(req->ir_reply, &sc->sc_msg->data[1], req->ir_replylen); req->ir_compcode = sc->sc_msg->data[0]; + err = 0; break; case OPAL_RESOURCE: err = ENOMEM; @@ -223,7 +226,15 @@ opal_ipmi_attach(device_t dev) static int opal_ipmi_detach(device_t dev) { - return (EBUSY); + struct opal_ipmi_softc *sc; + int err; + + sc = device_get_softc(dev); + err = ipmi_detach(dev); + if (err == 0) + free(sc->sc_msg, M_IPMI); + + return (err); } static device_method_t opal_ipmi_methods[] = { From owner-svn-src-head@freebsd.org Tue Apr 2 12:02:36 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3374D156422B; Tue, 2 Apr 2019 12:02:36 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0E3488F41; Tue, 2 Apr 2019 12:02:35 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8316F25B91; Tue, 2 Apr 2019 12:02:35 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32C2ZO6032460; Tue, 2 Apr 2019 12:02:35 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32C2Z3T032459; Tue, 2 Apr 2019 12:02:35 GMT (envelope-from br@FreeBSD.org) Message-Id: <201904021202.x32C2Z3T032459@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 2 Apr 2019 12:02:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345796 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 345796 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B0E3488F41 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 12:02:36 -0000 Author: br Date: Tue Apr 2 12:02:35 2019 New Revision: 345796 URL: https://svnweb.freebsd.org/changeset/base/345796 Log: o Grab the number of devices supported by PLIC from FDT. o Fix bug in PLIC_ENABLE macro when irq >= 32. Tested on the real hardware, which is HiFive Unleashed board. Thanks to SiFive, Inc. for the board provided. Reviewed by: markj Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D19775 Modified: head/sys/riscv/riscv/plic.c Modified: head/sys/riscv/riscv/plic.c ============================================================================== --- head/sys/riscv/riscv/plic.c Tue Apr 2 09:33:30 2019 (r345795) +++ head/sys/riscv/riscv/plic.c Tue Apr 2 12:02:35 2019 (r345796) @@ -52,9 +52,9 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" -#define PLIC_NIRQS 32 +#define PLIC_MAX_IRQS 2048 #define PLIC_PRIORITY(n) (0x000000 + (n) * 0x4) -#define PLIC_ENABLE(n, h) (0x002000 + (h) * 0x80 + (n) / 32) +#define PLIC_ENABLE(n, h) (0x002000 + (h) * 0x80 + 4 * ((n) / 32)) #define PLIC_THRESHOLD(h) (0x200000 + (h) * 0x1000 + 0x0) #define PLIC_CLAIM(h) (0x200000 + (h) * 0x1000 + 0x4) @@ -66,7 +66,8 @@ struct plic_irqsrc { struct plic_softc { device_t dev; struct resource * intc_res; - struct plic_irqsrc isrcs[PLIC_NIRQS]; + struct plic_irqsrc isrcs[PLIC_MAX_IRQS]; + int ndev; }; #define RD4(sc, reg) \ @@ -158,7 +159,7 @@ plic_map_intr(device_t dev, struct intr_map_data *data return (ENOTSUP); daf = (struct intr_map_data_fdt *)data; - if (daf->ncells != 1 || daf->cells[0] >= PLIC_NIRQS) + if (daf->ncells != 1 || daf->cells[0] > sc->ndev) return (EINVAL); *isrcp = &sc->isrcs[daf->cells[0]].isrc; @@ -189,6 +190,7 @@ plic_attach(device_t dev) struct intr_pic *pic; uint32_t irq; const char *name; + phandle_t node; phandle_t xref; uint32_t cpu; int error; @@ -198,6 +200,20 @@ plic_attach(device_t dev) sc->dev = dev; + node = ofw_bus_get_node(dev); + if ((OF_getencprop(node, "riscv,ndev", &sc->ndev, + sizeof(sc->ndev))) < 0) { + device_printf(dev, + "Error: could not get number of devices\n"); + return (ENXIO); + } + + if (sc->ndev >= PLIC_MAX_IRQS) { + device_printf(dev, + "Error: invalid ndev (%d)\n", sc->ndev); + return (ENXIO); + } + /* Request memory resources */ rid = 0; sc->intc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, @@ -211,7 +227,7 @@ plic_attach(device_t dev) isrcs = sc->isrcs; name = device_get_nameunit(sc->dev); cpu = PCPU_GET(cpuid); - for (irq = 0; irq < PLIC_NIRQS; irq++) { + for (irq = 1; irq <= sc->ndev; irq++) { isrcs[irq].irq = irq; error = intr_isrc_register(&isrcs[irq].isrc, sc->dev, 0, "%s,%u", name, irq); @@ -223,7 +239,7 @@ plic_attach(device_t dev) } WR4(sc, PLIC_THRESHOLD(cpu), 0); - xref = OF_xref_from_node(ofw_bus_get_node(sc->dev)); + xref = OF_xref_from_node(node); pic = intr_pic_register(sc->dev, xref); if (pic == NULL) return (ENXIO); From owner-svn-src-head@freebsd.org Tue Apr 2 12:50:03 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC13F1565CA6; Tue, 2 Apr 2019 12:50:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6BFF78AA5C; Tue, 2 Apr 2019 12:50:02 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 480E02624F; Tue, 2 Apr 2019 12:50:02 +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 x32Co2uh053576; Tue, 2 Apr 2019 12:50:02 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Co13P053573; Tue, 2 Apr 2019 12:50:01 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201904021250.x32Co13P053573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 2 Apr 2019 12:50:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd X-SVN-Commit-Revision: 345797 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6BFF78AA5C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.985,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 12:50:03 -0000 Author: ae Date: Tue Apr 2 12:50:01 2019 New Revision: 345797 URL: https://svnweb.freebsd.org/changeset/base/345797 Log: Add IPv6 transport for bsnmp. This patch adds a new table begemotSnmpdTransInetTable that uses the InetAddressType textual convention and can be used to create listening ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports future extension beyond UDP by adding a protocol identifier to the table index. In order to support this gensnmptree had to be modified. Submitted by: harti MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16654 Added: head/contrib/bsnmp/snmpd/trans_inet.c head/contrib/bsnmp/snmpd/trans_inet.h Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.1 head/contrib/bsnmp/gensnmptree/gensnmptree.c head/contrib/bsnmp/lib/snmpclient.c head/contrib/bsnmp/lib/snmpclient.h head/contrib/bsnmp/lib/tc.def head/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt head/contrib/bsnmp/snmpd/main.c head/contrib/bsnmp/snmpd/snmpd.config head/contrib/bsnmp/snmpd/snmpd.h head/contrib/bsnmp/snmpd/snmpmod.h head/contrib/bsnmp/snmpd/trans_lsock.c head/contrib/bsnmp/snmpd/trans_udp.c head/contrib/bsnmp/snmpd/tree.def head/lib/libbsnmp/libbsnmp/Makefile head/usr.sbin/bsnmpd/bsnmpd/Makefile head/usr.sbin/bsnmpd/bsnmpd/snmpd.config Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- head/contrib/bsnmp/gensnmptree/gensnmptree.1 Tue Apr 2 12:02:35 2019 (r345796) +++ head/contrib/bsnmp/gensnmptree/gensnmptree.1 Tue Apr 2 12:50:01 2019 (r345797) @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd June 29, 2018 +.Dd April 2, 2019 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -100,25 +100,11 @@ is the length of the OID. is the last component of the OID. .El .It Fl F -Together with -.Fl E -causes -.Nm -instead of the generation of enum definitions the generation of -functions for checking a value to be one of the enumeration variants and -for conversion between strings and the enum. The file is sent to standard -output and is meant to be included into a C-file for compilation. +emit definitions for C-functions includeable in a C-file that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl f -This flag can be used together with -.Fl E -or when generating the tree files. It causes -.Nm -to emit static inline functions for checking a value to be one of the -enumeration values and for conversion between strings and the enum. -If used when generating the tree files, the preprocessor symbol -.Ar SNMPTREE_TYPES -must be defined when including the tree header file for these definitions -to become visible. +emit definitions for inline C-functions that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl h Print a short help page. .It Fl I Ar directory @@ -136,36 +122,6 @@ Instead of normal output print the resulting tree. Prefix the file names and the table name with .Ar prefix . .El -.Pp -The following functions are generated by -.Fl f -or -.Fl F : -.Pp -.Ft static inline int -.Fn isok_EnumName "enum EnumName" ; -.Pp -.Ft static inline const char * -.Fn tostr_EnumName "enum EnumName" ; -.Pp -.Ft static inline int -.Fn fromstr_EnumName "const char *" "enum EnumName *" ; -.Pp -The -.Fa EnumName -is replaced with the enumeration name. -.Fn isok_EnumName -returns 1 if the argument is one of the valid enum values and 0 otherwise. -.Fn tostr_EnumName -returns a string representation of the enumeration value. -If the values is not one of the legal values -.Ar EnumName??? -is returned. -.Fn fromstr_EnumName -returns 1 if the string represents one of the legal enumeration values and -0 otherwise. -If 1 is return the variable pointed to by the second argument is set to -the enumeration value. .Sh MIBS The syntax of the MIB description file can formally be specified as follows: .Bd -unfilled -offset indent Modified: head/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- head/contrib/bsnmp/gensnmptree/gensnmptree.c Tue Apr 2 12:02:35 2019 (r345796) +++ head/contrib/bsnmp/gensnmptree/gensnmptree.c Tue Apr 2 12:50:01 2019 (r345797) @@ -110,7 +110,6 @@ static int debug; static const char usgtxt[] = "\ Generate SNMP tables.\n\ -$Id$\n\ usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\ [name]...\n\ options:\n\ @@ -127,6 +126,37 @@ options:\n\ -t generate a .def file\n\ "; +/** + * Program operation. + */ +enum op { + /** generate the tree */ + OP_GEN, + + /** extract OIDs */ + OP_EXTRACT, + + /** print the parsed tree */ + OP_TREE, + + /** extract enums */ + OP_ENUMS, +}; + +/** + * Which functions to create. + */ +enum gen_funcs { + /** none */ + GEN_FUNCS_NONE, + + /** functions for header files */ + GEN_FUNCS_H, + + /** functions for C files */ + GEN_FUNCS_C, +}; + /* * A node in the OID tree */ @@ -162,15 +192,18 @@ struct node { uint32_t index; /* index for table entry */ char *func; /* function for tables */ struct node_list subs; + char *subtypes[SNMP_INDEXES_MAX]; } entry; struct leaf { enum snmp_syntax syntax; /* syntax for this leaf */ char *func; /* function name */ + char *subtype; /* subtype */ } leaf; struct column { enum snmp_syntax syntax; /* syntax for this column */ + char *subtype; /* subtype */ } column; } u; }; @@ -214,7 +247,7 @@ xalloc(size_t size) { void *ptr; - if ((ptr = malloc(size)) == NULL) + if ((ptr = calloc(1, size)) == NULL) err(1, "allocing %zu bytes", size); return (ptr); @@ -710,12 +743,14 @@ make_type(const char *s) * token. */ static u_int -parse_type(enum tok *tok, struct type *t, const char *vname) +parse_type(enum tok *tok, struct type *t, const char *vname, char **subtype) { u_int syntax; struct enums *e; syntax = val; + if (subtype != NULL) + *subtype = NULL; if (*tok == TOK_ENUM || *tok == TOK_BITS) { if (t == NULL && vname != NULL) { @@ -759,6 +794,8 @@ parse_type(enum tok *tok, struct type *t, const char * if ((*tok = gettoken()) == '|') { if (gettoken() != TOK_STR) report("subtype expected after '|'"); + if (subtype != NULL) + *subtype = savetok(); *tok = gettoken(); } } @@ -794,18 +831,21 @@ parse(enum tok tok) if ((tok = gettoken()) == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { /* LEAF or COLUM */ - u_int syntax = parse_type(&tok, NULL, node->name); + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, &subtype); if (tok == TOK_STR) { /* LEAF */ node->type = NODE_LEAF; node->u.leaf.func = savetok(); node->u.leaf.syntax = syntax; + node->u.leaf.subtype = subtype; tok = gettoken(); } else { /* COLUMN */ node->type = NODE_COLUMN; node->u.column.syntax = syntax; + node->u.column.subtype = subtype; } while (tok != ')') { @@ -825,9 +865,12 @@ parse(enum tok tok) tok = gettoken(); while (tok == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { - u_int syntax = parse_type(&tok, NULL, node->name); - if (index_count++ == SNMP_INDEXES_MAX) + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, + &subtype); + if (index_count == SNMP_INDEXES_MAX) report("too many table indexes"); + node->u.entry.subtypes[index_count++] = subtype; node->u.entry.index |= syntax << (SNMP_INDEX_SHIFT * index_count); } @@ -882,7 +925,8 @@ parse_top(enum tok tok) tok = gettoken(); t->is_enum = (tok == TOK_ENUM); t->is_bits = (tok == TOK_BITS); - t->syntax = parse_type(&tok, t, NULL); + + t->syntax = parse_type(&tok, t, NULL, NULL); pushback(tok); return (NULL); @@ -903,7 +947,7 @@ parse_top(enum tok tok) * Generate the C-code table part for one node. */ static void -gen_node(FILE *fp, struct node *np, struct asn_oid *oid, u_int idx, +gen_node(FILE *fp, const struct node *np, struct asn_oid *oid, u_int idx, const char *func) { u_int n; @@ -1008,7 +1052,7 @@ gen_node(FILE *fp, struct node *np, struct asn_oid *oi * Generate the header file with the function declarations. */ static void -gen_header(FILE *fp, struct node *np, u_int oidlen, const char *func) +gen_header(FILE *fp, const struct node *np, u_int oidlen, const char *func) { char f[MAXSTR + 4]; struct node *sub; @@ -1058,7 +1102,7 @@ gen_header(FILE *fp, struct node *np, u_int oidlen, co * Generate the OID table. */ static void -gen_table(FILE *fp, struct node *node) +gen_table(FILE *fp, const struct node *node) { struct asn_oid oid; @@ -1067,7 +1111,6 @@ gen_table(FILE *fp, struct node *node) #ifdef HAVE_STDINT_H fprintf(fp, "#include \n"); #endif - fprintf(fp, "#include \n"); if (localincs) { fprintf(fp, "#include \"asn1.h\"\n"); fprintf(fp, "#include \"snmp.h\"\n"); @@ -1118,6 +1161,8 @@ gen_tree(const struct node *np, int level) case NODE_LEAF: print_syntax(np->u.leaf.syntax); + if (np->u.leaf.subtype != NULL) + printf(" | %s", np->u.leaf.subtype); printf(" %s%s%s)\n", np->u.leaf.func, (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); @@ -1137,8 +1182,11 @@ gen_tree(const struct node *np, int level) case NODE_ENTRY: printf(" :"); - for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) + for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) { print_syntax(SNMP_INDEX(np->u.entry.index, i)); + if (np->u.entry.subtypes[i] != NULL) + printf(" | %s", np->u.entry.subtypes[i]); + } printf(" %s\n", np->u.entry.func); TAILQ_FOREACH(sp, &np->u.entry.subs, link) gen_tree(sp, level + 1); @@ -1147,6 +1195,8 @@ gen_tree(const struct node *np, int level) case NODE_COLUMN: print_syntax(np->u.column.syntax); + if (np->u.column.subtype != NULL) + printf(" | %s", np->u.column.subtype); printf("%s%s)\n", (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); break; @@ -1194,15 +1244,6 @@ extract(FILE *fp, const struct node *np, struct asn_oi return (1); } -/** - * Extract the named OID. - * - * \param fp file to extract to - * \param root root of the tree - * \param object name of the object to extract - * - * \return 0 on success, -1 if the object was not found - */ static int gen_extract(FILE *fp, const struct node *root, char *object) { @@ -1391,45 +1432,6 @@ unminus(FILE *fp, const char *s) } /** - * Generate a definition for the enum packed into a guard against multiple - * definitions. - * - * \param fp file to write definition to - * \param t type - */ -static void -gen_enum(FILE *fp, const struct type *t) -{ - const struct enums *e; - long min = LONG_MAX; - - fprintf(fp, "\n"); - fprintf(fp, "#ifndef %s_defined__\n", t->name); - fprintf(fp, "#define %s_defined__\n", t->name); - fprintf(fp, "/*\n"); - fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); - fprintf(fp, " */\n"); - fprintf(fp, "enum %s {\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t%s_", t->name); - unminus(fp, e->name); - fprintf(fp, " = %ld,\n", e->value); - if (e->value < min) - min = e->value; - } - fprintf(fp, "};\n"); - fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); - fprintf(fp, "#define STRING_%s \\\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); - unminus(fp, e->name); - fprintf(fp, "\",\\\n"); - } - fprintf(fp, "\n"); - fprintf(fp, "#endif /* %s_defined__ */\n", t->name); -} - -/** * Generate helper functions for an enum. * * We always generate a switch statement for the isok function. The compiler @@ -1494,6 +1496,54 @@ gen_enum_funcs(FILE *fp, const struct type *t, int cco } /** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + * \param dof generate functions too + */ +static void +gen_enum(FILE *fp, const struct type *t, int dof) +{ + const struct enums *e; + long min = LONG_MAX; + + fprintf(fp, "\n"); + fprintf(fp, "#ifndef %s_defined__\n", t->name); + fprintf(fp, "#define %s_defined__\n", t->name); + fprintf(fp, "/*\n"); + fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); + fprintf(fp, " */\n"); + fprintf(fp, "enum %s {\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t%s_", t->name); + unminus(fp, e->name); + fprintf(fp, " = %ld,\n", e->value); + if (e->value < min) + min = e->value; + } + fprintf(fp, "};\n"); + fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); + fprintf(fp, "#define STRING_%s \\\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); + unminus(fp, e->name); + fprintf(fp, "\",\\\n"); + } + fprintf(fp, "\n"); + if (dof) { + fprintf(fp, "#ifdef SNMPENUM_FUNCS\n"); + fprintf(fp, "\n"); + gen_enum_funcs(fp, t, 0); + fprintf(fp, "\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + } + fprintf(fp, "#endif /* %s_defined__ */\n", t->name); +} + +/** * Generate helper functions for an enum. This generates code for a c file. * * \param fp file to write to @@ -1529,6 +1579,16 @@ gen_all_enum_funcs(FILE *fp, int ccode) gen_enum_funcs(fp, t, ccode); } +static void +gen_enums(FILE *fp, int dof) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) + if (t->is_enum || t->is_bits) + gen_enum(fp, t, dof); +} + /** * Extract a given enum to the specified file and optionally generate static * inline helper functions for them. @@ -1546,9 +1606,7 @@ extract_enum(FILE *fp, const char *name, int gen_funcs LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); + gen_enum(fp, t, gen_funcs); return (0); } return (-1); @@ -1567,11 +1625,8 @@ extract_all_enums(FILE *fp, int gen_funcs) const struct type *t; LIST_FOREACH(t, &types, link) - if (t->is_enum || t->is_bits) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); - } + if (t->is_enum || t->is_bits) + gen_enum(fp, t, gen_funcs); } /** @@ -1579,13 +1634,12 @@ extract_all_enums(FILE *fp, int gen_funcs) * * \param argc number of arguments * \param argv arguments (enum names) - * \param gen_funcs_h generate functions into the header file - * \param gen_funcs_c generate a .c file with functions + * \param gen_funcs which functions to generate */ static void -make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +make_enums(int argc, char *argv[], enum gen_funcs gen_funcs) { - if (gen_funcs_c) { + if (gen_funcs == GEN_FUNCS_C) { if (argc == 0) gen_all_enum_funcs(stdout, 1); else { @@ -1595,30 +1649,58 @@ make_enums(int argc, char *argv[], int gen_funcs_h, in } } else { if (argc == 0) - extract_all_enums(stdout, gen_funcs_h); + extract_all_enums(stdout, gen_funcs == GEN_FUNCS_H); else { for (int i = 0; i < argc; i++) - if (extract_enum(stdout, argv[i], gen_funcs_h)) + if (extract_enum(stdout, argv[i], + gen_funcs == GEN_FUNCS_H)) errx(1, "enum not found: %s", argv[i]); } } } +/** + * Produce the operation tables for the daemon or a module. + * + * \param root tree root + * \param gen_funcs generate enum funcs + */ +static void +make_table(const struct node *root, int gen_funcs) +{ + FILE *fp; + + char fname[MAXPATHLEN + 1]; + sprintf(fname, "%stree.h", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_header(fp, root, PREFIX_LEN, NULL); + + fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); + gen_enums(fp, gen_funcs); + fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); + + fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); + fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); + + fclose(fp); + + sprintf(fname, "%stree.c", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_table(fp, root); + fclose(fp); +} + int main(int argc, char *argv[]) { - int do_extract = 0; - int do_tree = 0; - int do_enums = 0; - int gen_funcs_h = 0; - int gen_funcs_c = 0; - int opt; - struct node *root; - char fname[MAXPATHLEN + 1]; - int tok; - FILE *fp; + enum op op = OP_GEN; + enum gen_funcs gen_funcs = GEN_FUNCS_NONE; + char *infile = NULL; + int opt; while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { @@ -1627,19 +1709,29 @@ main(int argc, char *argv[]) break; case 'E': - do_enums = 1; + if (op != OP_GEN && op != OP_ENUMS) + errx(1, "-E conflicts with earlier options"); + op = OP_ENUMS; break; case 'e': - do_extract = 1; + if (op != OP_GEN && op != OP_EXTRACT) + errx(1, "-e conflicts with earlier options"); + op = OP_EXTRACT; break; case 'F': - gen_funcs_c = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_C) + errx(1, "-F conflicts with -f"); + gen_funcs = GEN_FUNCS_C; break; case 'f': - gen_funcs_h = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_H) + errx(1, "-f conflicts with -F"); + gen_funcs = GEN_FUNCS_H; break; case 'h': @@ -1666,75 +1758,61 @@ main(int argc, char *argv[]) break; case 't': - do_tree = 1; + if (op != OP_GEN && op != OP_TREE) + errx(1, "-t conflicts with earlier options"); + op = OP_TREE; break; } - if (do_extract + do_tree + do_enums > 1) - errx(1, "conflicting options -e/-t/-E"); - if (!do_extract && !do_enums && argc != optind) - errx(1, "no arguments allowed"); - if (do_extract && argc == optind) - errx(1, "no objects specified"); + argc -= optind; + argv += optind; - if ((gen_funcs_h || gen_funcs_c) && (do_extract || do_tree)) - errx(1, "-f and -F not allowed with -e or -t"); - if (gen_funcs_c && !do_enums) - errx(1, "-F requires -E"); - if (gen_funcs_h && gen_funcs_c) - errx(1, "-f and -F are mutually exclusive"); - + /* open input */ if (infile == NULL) { input_new(stdin, NULL, ""); } else { + FILE *fp; if ((fp = fopen(infile, "r")) == NULL) err(1, "%s", infile); input_new(fp, NULL, infile); } - root = parse_top(gettoken()); + /* parse and check input */ + struct node *root = parse_top(gettoken()); + + int tok; while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); if (root) check_tree(root); - if (do_extract) { - while (optind < argc) { - if (gen_extract(stdout, root, argv[optind])) - errx(1, "object not found: %s", argv[optind]); - optind++; - } + /* do what the user has requested */ + switch (op) { + + case OP_EXTRACT: + if (argc == 0) + errx(1, "-e requires arguments"); + + for (int i = 0; i < argc; i++) + if (gen_extract(stdout, root, argv[i])) + errx(1, "object not found: %s", argv[i]); return (0); - } - if (do_enums) { - make_enums(argc - optind, argv + optind, - gen_funcs_h, gen_funcs_c); + + case OP_ENUMS: + make_enums(argc, argv, gen_funcs); return (0); - } - if (do_tree) { + + case OP_TREE: + if (argc != 0) + errx(1, "-t allows no arguments"); gen_tree(root, 0); return (0); - } - sprintf(fname, "%stree.h", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_header(fp, root, PREFIX_LEN, NULL); - fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - extract_all_enums(fp, gen_funcs_h); - fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); - - fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); - fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); - - fclose(fp); - - sprintf(fname, "%stree.c", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_table(fp, root); - fclose(fp); - - return (0); + case OP_GEN: + if (argc != 0) + errx(1, "tree generation allows no arguments"); + make_table(root, gen_funcs == GEN_FUNCS_H); + return (0); + } } Modified: head/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- head/contrib/bsnmp/lib/snmpclient.c Tue Apr 2 12:02:35 2019 (r345796) +++ head/contrib/bsnmp/lib/snmpclient.c Tue Apr 2 12:50:01 2019 (r345797) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 + * Copyright (c) 2004-2005,2018 * Hartmut Brandt. * All rights reserved. * Copyright (c) 2001-2003 @@ -34,11 +34,13 @@ * * Support functions for SNMP clients. */ -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -58,12 +60,16 @@ #include #endif +#include + #include "support.h" #include "asn1.h" #include "snmp.h" #include "snmpclient.h" #include "snmppriv.h" +#define DEBUG_PARSE 0 + /* global context */ struct snmp_client snmp_client; @@ -924,7 +930,8 @@ open_client_udp(const char *host, const char *port) /* open connection */ memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_INET; + hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET: + AF_INET6; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0); @@ -1068,6 +1075,7 @@ snmp_open(const char *host, const char *port, const ch switch (snmp_client.trans) { case SNMP_TRANS_UDP: + case SNMP_TRANS_UDP6: if (open_client_udp(host, port) != 0) return (-1); break; @@ -1866,99 +1874,410 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } -/* - * parse a server specification +/** + * Try to get a transport identifier which is a leading alphanumeric string + * (starting with '_' or a letter and including also '_') terminated by + * a double colon. The string may not be empty. The transport identifier + * is optional. * - * [trans::][community@][server][:port] + * \param sc client struct to set errors + * \param strp possible start of transport; updated to point to + * the next character to parse + * + * \return end of transport; equals *strp if there is none; NULL if there + * was an error */ -int -snmp_parse_server(struct snmp_client *sc, const char *str) +static inline const char * +get_transp(struct snmp_client *sc, const char **strp) { - const char *p, *s = str; + const char *p = *strp; - /* look for a double colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { + if (isascii(*p) && (isalpha(*p) || *p == '_')) { + p++; + while (isascii(*p) && (isalnum(*p) || *p == '_')) p++; - continue; + if (p[0] == ':' && p[1] == ':') { + *strp = p + 2; + return (p); } - if (*p == ':' && p[1] == ':') - break; } - if (*p != '\0') { - if (p > s) { - if (p - s == 3 && strncmp(s, "udp", 3) == 0) - sc->trans = SNMP_TRANS_UDP; - else if (p - s == 6 && strncmp(s, "stream", 6) == 0) - sc->trans = SNMP_TRANS_LOC_STREAM; - else if (p - s == 5 && strncmp(s, "dgram", 5) == 0) - sc->trans = SNMP_TRANS_LOC_DGRAM; - else { - seterr(sc, "unknown SNMP transport '%.*s'", - (int)(p - s), s); - return (-1); - } - } - s = p + 2; + if (p[0] == ':' && p[1] == ':') { + seterr(sc, "empty transport specifier"); + return (NULL); } + return (*strp); +} - /* look for a @ */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == '@') - break; +/** + * Try to get community string. Eat everything up to the last @ (if there is + * any) but only if it is not longer than SNMP_COMMUNITY_MAXLEN. Empty + * community strings are legal. + * + * \param sc client struct to set errors + * \param strp possible start of community; updated to the point to + * the next character to parse + * + * \return end of community; equals *strp if there is none; NULL if there + * was an error + */ +static inline const char * +get_comm(struct snmp_client *sc, const char **strp) +{ + const char *p = strrchr(*strp, '@'); + + if (p == NULL) + /* no community string */ + return (*strp); + + if (p - *strp > SNMP_COMMUNITY_MAXLEN) { + seterr(sc, "community string too long '%.*s'", + p - *strp, *strp); + return (NULL); } - if (*p != '\0') { - if (p - s > SNMP_COMMUNITY_MAXLEN) { - seterr(sc, "community string too long"); - return (-1); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv6 address. This starts with an [ and should end with an ] + * and everything between should be not longer than INET6_ADDRSTRLEN and + * parseable by inet_pton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv6 address (the '['); updated to point to + * the next character to parse (the one after the closing ']') + * + * \return end of address (equals *strp + 1 if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv6(struct snmp_client *sc, const char **strp) +{ + char str[INET6_ADDRSTRLEN + IF_NAMESIZE]; + struct addrinfo hints, *res; + int error; + + if (**strp != '[') + return (*strp + 1); + + const char *p = *strp + 1; + while (*p != ']' ) { + if (*p == '\0') { + seterr(sc, "unterminated IPv6 address '%.*s'", + p - *strp, *strp); + return (NULL); } - strncpy(sc->read_community, s, p - s); - sc->read_community[p - s] = '\0'; - strncpy(sc->write_community, s, p - s); - sc->write_community[p - s] = '\0'; - s = p + 1; + p++; } - /* look for a colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == ':') - break; + if (p - *strp > INET6_ADDRSTRLEN + IF_NAMESIZE) { + seterr(sc, "IPv6 address too long '%.*s'", p - *strp, *strp); + return (NULL); } - if (*p == ':') { - if (p > s) { - /* host:port */ - free(sc->chost); - if ((sc->chost = malloc(p - s + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } - strncpy(sc->chost, s, p - s); - sc->chost[p - s] = '\0'; + strncpy(str, *strp + 1, p - (*strp + 1)); + str[p - (*strp + 1)] = '\0'; + + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME | AI_NUMERICHOST; + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + error = getaddrinfo(str, NULL, &hints, &res); + if (error != 0) { + seterr(sc, "%s: %s", str, gai_strerror(error)); + return (NULL); + } + freeaddrinfo(res); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv4 address. This starts with a digit and consists of digits + * and dots, is not longer INET_ADDRSTRLEN and must be parseable by + * inet_aton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv4 address; updated to point to the + * next character to parse + * + * \return end of address (equals *strp if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv4(struct snmp_client *sc, const char **strp) +{ + const char *p = *strp; + + while (isascii(*p) && (isdigit(*p) || *p == '.')) + p++; + + if (p - *strp > INET_ADDRSTRLEN) { + seterr(sc, "IPv4 address too long '%.*s'", p - *strp, *strp); + return (NULL); + } + if (*strp == p) + return *strp; + + char str[INET_ADDRSTRLEN + 1]; + strncpy(str, *strp, p - *strp); + str[p - *strp] = '\0'; + + struct in_addr addr; + if (inet_aton(str, &addr) != 1) { + seterr(sc, "illegal IPv4 address '%s'", str); + return (NULL); + } + + *strp = p; + return (p); +} + +/** + * Try to get a hostname. This includes everything up to but not including + * the last colon (if any). There is no length restriction. + * + * \param sc client struct to set errors + * \param strp possible start of hostname; updated to point to the next + * character to parse (the trailing NUL character or the last + * colon) + * + * \return end of address (equals *strp if there is none) + */ +static inline const char * +get_host(struct snmp_client *sc __unused, const char **strp) +{ + const char *p = strrchr(*strp, ':'); + + if (p == NULL) { + *strp += strlen(*strp); + return (*strp); + } + + *strp = p; + return (p); +} + +/** + * Try to get a port number. This start with a colon and extends to the end + * of string. The port number must not be empty. + * + * \param sc client struct to set errors *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Apr 2 13:38:01 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 425CD1566F08; Tue, 2 Apr 2019 13:38:01 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D5A1C8C3FC; Tue, 2 Apr 2019 13:38:00 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9622526BAE; Tue, 2 Apr 2019 13:38:00 +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 x32Dc04v079675; Tue, 2 Apr 2019 13:38:00 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Dc0Mj079674; Tue, 2 Apr 2019 13:38:00 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201904021338.x32Dc0Mj079674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 2 Apr 2019 13:38:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345798 - head/contrib/bsnmp/snmp_mibII X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/contrib/bsnmp/snmp_mibII X-SVN-Commit-Revision: 345798 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D5A1C8C3FC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:38:01 -0000 Author: ae Date: Tue Apr 2 13:38:00 2019 New Revision: 345798 URL: https://svnweb.freebsd.org/changeset/base/345798 Log: Create 64bit mibII counters for all interfaces. PR: 157015 Obtained from: Yandex LLC MFC after: 1 month Modified: head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Modified: head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c ============================================================================== --- head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Tue Apr 2 12:50:01 2019 (r345797) +++ head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Tue Apr 2 13:38:00 2019 (r345798) @@ -373,11 +373,6 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_valu switch (op) { - again: - if (op != SNMP_OP_GETNEXT) - return (SNMP_ERR_NOSUCHNAME); - /* FALLTHROUGH */ - case SNMP_OP_GETNEXT: if ((ifp = NEXT_OBJECT_INT(&mibif_list, &value->var, sub)) == NULL) return (SNMP_ERR_NOSUCHNAME); @@ -460,52 +455,36 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_valu break; case LEAF_ifHCInOctets: - if (!(ifp->flags & MIBIF_HIGHSPEED)) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_inoctets; break; case LEAF_ifHCInUcastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_ipackets - MIBIF_PRIV(ifp)->hc_imcasts; break; case LEAF_ifHCInMulticastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_imcasts; break; case LEAF_ifHCInBroadcastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = 0; break; case LEAF_ifHCOutOctets: - if (!(ifp->flags & MIBIF_HIGHSPEED)) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_outoctets; break; case LEAF_ifHCOutUcastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_opackets - MIBIF_PRIV(ifp)->hc_omcasts; break; case LEAF_ifHCOutMulticastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = MIBIF_PRIV(ifp)->hc_omcasts; break; case LEAF_ifHCOutBroadcastPkts: - if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED))) - goto again; value->v.counter64 = 0; break; From owner-svn-src-head@freebsd.org Tue Apr 2 13:40:21 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D05621567066; Tue, 2 Apr 2019 13:40:20 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6DE4C8C651; Tue, 2 Apr 2019 13:40:20 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from ivaldir.etoilebsd.net (etoilebsd.net [178.32.217.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bapt) by smtp.freebsd.org (Postfix) with ESMTPSA id 33E8E6FE2; Tue, 2 Apr 2019 13:40:20 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: by ivaldir.etoilebsd.net (Postfix, from userid 1001) id 61BEFB73E4; Tue, 2 Apr 2019 15:40:19 +0200 (CEST) Date: Tue, 2 Apr 2019 15:40:19 +0200 From: Baptiste Daroussin To: "Andrey V. Elsukov" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd Message-ID: <20190402134019.j325zduvwstcgz3s@ivaldir.net> References: <201904021250.x32Co13P053573@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ybi72zk2xf2apl4e" Content-Disposition: inline In-Reply-To: <201904021250.x32Co13P053573@repo.freebsd.org> User-Agent: NeoMutt/20180716 X-Rspamd-Queue-Id: 6DE4C8C651 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.96)[-0.957,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:40:21 -0000 --ybi72zk2xf2apl4e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 02, 2019 at 12:50:01PM +0000, Andrey V. Elsukov wrote: > Author: ae > Date: Tue Apr 2 12:50:01 2019 > New Revision: 345797 > URL: https://svnweb.freebsd.org/changeset/base/345797 >=20 > Log: > Add IPv6 transport for bsnmp. > =20 > This patch adds a new table begemotSnmpdTransInetTable that uses the > InetAddressType textual convention and can be used to create listening > ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also suppor= ts > future extension beyond UDP by adding a protocol identifier to the table > index. In order to support this gensnmptree had to be modified. > =20 > Submitted by: harti > MFC after: 1 month > Relnotes: yes > Differential Revision: https://reviews.freebsd.org/D16654 >=20 Jumping in this commit, maybe it is time to move bsnmpd out of contrib, giv= en that all the dev appears to only be in our own source tree right? Best regards, Bapt --ybi72zk2xf2apl4e Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAlyjZkMACgkQY4mL3PG3 PlqArBAAxD0B7DuGM0mYH92bwr6Tvc0gN1fsXpAqehTMRcQhx3dXboPjrAn4VOKl nhe+CGzp4fV/on34u/ZcaJA7WGcQ8Lk7S4LzT/ADmPy+L7SNbhBxx+LlmWBfzOSd ICjmnI5sl0rIAD9vr5Xdrb9UxudySxgWR7Bojze70Od2HGyb9a+eBCL+xqzj2GT5 xnlE1dxNjp4zgpr8x+ZlT0PhicPgPgCkNO5r5URR7+q+j9gGKU4v/cFFizoqgNZb lKv+OTF3VHWHYjDIKtWWUqMt1CQWgvmcgb2OyMsuIqZpQez1Vbt1vSkVTXQGltfo rjpd/b51fwPZWSibbV+cMg60K13Vc+b2HR1U2zr1HofCXJJYlAoVhftYykEjiO+D 3+9MzmAxw0sFCQ9h4TWXf24LdZSpt6y9NbqXWC4o/ut0MHSraDVyX37ICd/y9AzK oxpTH9ERQY76CtSpnxOq9EkDMxVYTGl7hOx6H0demM9KxBCDXbzszyC4d2/RDhwd jPSNMiyiKXdSy939n47mT8ExBJSBOIOYvy0UHSELqKiNCmb72BeDHjVr1sGJfCYZ wWVwI4hdC8EwBSd0hQOBf4H58JVncFKZda1X+CFrsizNHyAWx1uQQPMcZjc3Pe64 cP+aGma6qdYJmiMA0Z+Ylz/XpFewUEksAohWcinTs5NBb4fbQjU= =a94Y -----END PGP SIGNATURE----- --ybi72zk2xf2apl4e-- From owner-svn-src-head@freebsd.org Tue Apr 2 13:41:27 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C09715671D5; Tue, 2 Apr 2019 13:41:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E52678C8EA; Tue, 2 Apr 2019 13:41: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEEB726D19; Tue, 2 Apr 2019 13:41:26 +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 x32DfQiR080809; Tue, 2 Apr 2019 13:41:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32DfQgp080808; Tue, 2 Apr 2019 13:41:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201904021341.x32DfQgp080808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 2 Apr 2019 13:41:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345799 - head/sys/fs/tmpfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/tmpfs X-SVN-Commit-Revision: 345799 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E52678C8EA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:41:27 -0000 Author: kib Date: Tue Apr 2 13:41:26 2019 New Revision: 345799 URL: https://svnweb.freebsd.org/changeset/base/345799 Log: Block creation of the new nodes for read-only tmpfs mounts. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19737 Modified: head/sys/fs/tmpfs/tmpfs_subr.c Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Tue Apr 2 13:38:00 2019 (r345798) +++ head/sys/fs/tmpfs/tmpfs_subr.c Tue Apr 2 13:41:26 2019 (r345799) @@ -218,6 +218,8 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount */ return (EBUSY); } + if ((mp->mnt_kern_flag & MNT_RDONLY) != 0) + return (EROFS); nnode = (struct tmpfs_node *)uma_zalloc_arg(tmp->tm_node_pool, tmp, M_WAITOK); From owner-svn-src-head@freebsd.org Tue Apr 2 13:47:33 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FEF41567798; Tue, 2 Apr 2019 13:47:33 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from butcher-nb.yandex.net (unknown [IPv6:2a02:6b8:0:845::1:b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "butcher-nb.yandex.net", Issuer "butcher-nb.yandex.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9FEEF8CFDD; Tue, 2 Apr 2019 13:47:32 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from butcher-nb.yandex.net (localhost [127.0.0.1]) by butcher-nb.yandex.net (8.15.2/8.15.2) with ESMTP id x32DjRJu016482; Tue, 2 Apr 2019 16:45:27 +0300 (MSK) (envelope-from ae@FreeBSD.org) Subject: Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd To: Baptiste Daroussin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Hartmut Brandt References: <201904021250.x32Co13P053573@repo.freebsd.org> <20190402134019.j325zduvwstcgz3s@ivaldir.net> From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Autocrypt: addr=ae@FreeBSD.org; prefer-encrypt=mutual; keydata= mQENBEwBF1kBCADB9sXFhBEUy8qQ4X63Y8eBatYMHGEFWN9ypS5lI3RE6qQW2EYbxNk7qUC5 21YIIS1mMFVBEfvR7J9uc7yaYgFCEb6Sce1RSO4ULN2mRKGHP3/Sl0ijZEjWHV91hY1YTHEF ZW/0GYinDf56sYpDDehaBF5wkWIo1+QK5nmj3vl0DIDCMNd7QEiWpyLVwECgLX2eOAXByT8B bCqVhJGcG6iFP7/B9Ll6uX5gb8thM9LM+ibwErDBVDGiOgvfxqidab7fdkh893IBCXa82H9N CNwnEtcgzh+BSKK5BgvPohFMgRwjti37TSxwLu63QejRGbZWSz3OK3jMOoF63tCgn7FvABEB AAG0IkFuZHJleSBWLiBFbHN1a292IDxhZUBmcmVlYnNkLm9yZz6JATsEEwECACUCGwMGCwkI BwMCBhUIAgkKCwQWAgMBAh4BAheABQJMB/ruAhkBAAoJEAHF6gQQyKF6MLwH/3Ri/TZl9uo0 SepYWXOnxL6EaDVXDA+dLb1eLKC4PRBBjX29ttQ0KaWapiE6y5/AfzOPmRtHLrHYHjd/aiHX GMLHcYRXD+5GvdkK8iMALrZ28X0JXyuuZa8rAxWIWmCbYHNSBy2unqWgTI04Erodk90IALgM 9JeHN9sFqTM6zalrMnTzlcmel4kcjT3lyYw3vOKgoYLtsLhKZSbJoVVVlvRlGBpHFJI5AoYJ SyfXoN0rcX6k9X7Isp2K50YjqxV4v78xluh1puhwZyC0p8IShPrmrp9Oy9JkMX90o6UAXdGU KfdExJuGJfUZOFBTtNIMNIAKfMTjhpRhxONIr0emxxC5AQ0ETAEXWQEIAJ2p6l9LBoqdH/0J PEFDY2t2gTvAuzz+8zs3R03dFuHcNbOwjvWCG0aOmVpAzkRa8egn5JB4sZaFUtKPYJEQ1Iu+ LUBwgvtXf4vWpzC67zs2dDuiW4LamH5p6xkTD61aHR7mCB3bg2TUjrDWn2Jt44cvoYxj3dz4 S49U1rc9ZPgD5axCNv45j72tggWlZvpefThP7xT1OlNTUqye2gAwQravXpZkl5JG4eOqJVIU X316iE3qso0iXRUtO7OseBf0PiVmk+wCahdreHOeOxK5jMhYkPKVn7z1sZiB7W2H2TojbmcK HZC22sz7Z/H36Lhg1+/RCnGzdEcjGc8oFHXHCxUAEQEAAYkBHwQYAQIACQUCTAEXWQIbDAAK CRABxeoEEMihegkYCAC3ivGYNe2taNm/4Nx5GPdzuaAJGKWksV+w9mo7dQvU+NmI2az5w8vw 98OmX7G0OV9snxMW+6cyNqBrVFTu33VVNzz9pnqNCHxGvj5dL5ltP160JV2zw2bUwJBYsgYQ WfyJJIM7l3gv5ZS3DGqaGIm9gOK1ANxfrR5PgPzvI9VxDhlr2juEVMZYAqPLEJe+SSxbwLoz BcFCNdDAyXcaAzXsx/E02YWm1hIWNRxanAe7Vlg7OL+gvLpdtrYCMg28PNqKNyrQ87LQ49O9 50IIZDOtNFeR0FGucjcLPdS9PiEqCoH7/waJxWp6ydJ+g4OYRBYNM0EmMgy1N85JJrV1mi5i Message-ID: <2cf70b81-feff-7586-6763-caaa22aa5e85@FreeBSD.org> Date: Tue, 2 Apr 2019 16:45:27 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190402134019.j325zduvwstcgz3s@ivaldir.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="662CrSi7MzaczfMRC4m7axNfuRE9iDQBc" X-Rspamd-Queue-Id: 9FEEF8CFDD X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:47:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --662CrSi7MzaczfMRC4m7axNfuRE9iDQBc Content-Type: multipart/mixed; boundary="JCJ9hJXpqtvYoZii6NCrpIDJABu9cQlpH"; protected-headers="v1" From: "Andrey V. Elsukov" To: Baptiste Daroussin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Hartmut Brandt Message-ID: <2cf70b81-feff-7586-6763-caaa22aa5e85@FreeBSD.org> Subject: Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd References: <201904021250.x32Co13P053573@repo.freebsd.org> <20190402134019.j325zduvwstcgz3s@ivaldir.net> In-Reply-To: <20190402134019.j325zduvwstcgz3s@ivaldir.net> --JCJ9hJXpqtvYoZii6NCrpIDJABu9cQlpH Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 02.04.2019 16:40, Baptiste Daroussin wrote: >> URL: https://svnweb.freebsd.org/changeset/base/345797 >> >> Log: >> Add IPv6 transport for bsnmp. >> =20 >> This patch adds a new table begemotSnmpdTransInetTable that uses the= >> InetAddressType textual convention and can be used to create listeni= ng >> ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also sup= ports >> future extension beyond UDP by adding a protocol identifier to the t= able >> index. In order to support this gensnmptree had to be modified. >> =20 >> Submitted by: harti >> MFC after: 1 month >> Relnotes: yes >> Differential Revision: https://reviews.freebsd.org/D16654 >> > Jumping in this commit, maybe it is time to move bsnmpd out of contrib,= given > that all the dev appears to only be in our own source tree right? I think it is better to ask harti@ --=20 WBR, Andrey V. Elsukov --JCJ9hJXpqtvYoZii6NCrpIDJABu9cQlpH-- --662CrSi7MzaczfMRC4m7axNfuRE9iDQBc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlyjZ3cACgkQAcXqBBDI oXrchAgAv6nOdZCRU6M88LgKjZa+cTSy2SGROPLPiph4X17ibx8avNkWupAjCbwk 8DSDptRvvF1T1CwJj1mU//xilrcbUQjml9hwSvExgiAcYdF2dFAcQYw3OZzJn7Dk sO2ZSPuMs8dmYY9vPZzdqr/PueW5PPU5Fyy6etnbEnZslVikKYLl7LwvnHr/xmrt 0pwhg6OB7YO6FoWFHem0ZXdXRpNopBTqf9dL4tIoP0SsJ03s1Fd+dO2jBki+9zTA AD3WIU+FUYg/9L6m4y/KzdQpt8dIvwlztQsiYx2nmDMyE0Ij7tIc3376YImOCX56 XYrysvb2t21+Y8BVi8NATWypHoj42Q== =wTSb -----END PGP SIGNATURE----- --662CrSi7MzaczfMRC4m7axNfuRE9iDQBc-- From owner-svn-src-head@freebsd.org Tue Apr 2 13:49:34 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4441C15679B8; Tue, 2 Apr 2019 13:49:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D97FF8D2DF; Tue, 2 Apr 2019 13:49:33 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B052C26D6C; Tue, 2 Apr 2019 13:49:33 +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 x32DnXSq084934; Tue, 2 Apr 2019 13:49:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32DnWe0084928; Tue, 2 Apr 2019 13:49:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201904021349.x32DnWe0084928@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 2 Apr 2019 13:49:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345800 - head/sys/fs/tmpfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/tmpfs X-SVN-Commit-Revision: 345800 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D97FF8D2DF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:49:34 -0000 Author: kib Date: Tue Apr 2 13:49:32 2019 New Revision: 345800 URL: https://svnweb.freebsd.org/changeset/base/345800 Log: tmpfs: ignore tmpfs_set_status() if mount point is read-only. In particular, this fixes atimes still changing for ro tmpfs. tmpfs_set_status() gains tmpfs_mount * argument. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19737 Modified: head/sys/fs/tmpfs/tmpfs.h head/sys/fs/tmpfs/tmpfs_fifoops.c head/sys/fs/tmpfs/tmpfs_subr.c head/sys/fs/tmpfs/tmpfs_vnops.c Modified: head/sys/fs/tmpfs/tmpfs.h ============================================================================== --- head/sys/fs/tmpfs/tmpfs.h Tue Apr 2 13:41:26 2019 (r345799) +++ head/sys/fs/tmpfs/tmpfs.h Tue Apr 2 13:49:32 2019 (r345800) @@ -437,8 +437,8 @@ void tmpfs_dir_destroy(struct tmpfs_mount *, struct tm struct tmpfs_dirent * tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f, struct componentname *cnp); -int tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, int, - u_long *, int *); +int tmpfs_dir_getdents(struct tmpfs_mount *, struct tmpfs_node *, + struct uio *, int, u_long *, int *); int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *); void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *); int tmpfs_reg_resize(struct vnode *, off_t, boolean_t); @@ -452,7 +452,8 @@ int tmpfs_chtimes(struct vnode *, struct vattr *, stru void tmpfs_itimes(struct vnode *, const struct timespec *, const struct timespec *); -void tmpfs_set_status(struct tmpfs_node *node, int status); +void tmpfs_set_status(struct tmpfs_mount *tm, struct tmpfs_node *node, + int status); void tmpfs_update(struct vnode *); int tmpfs_truncate(struct vnode *, off_t); struct tmpfs_dirent *tmpfs_dir_first(struct tmpfs_node *dnode, Modified: head/sys/fs/tmpfs/tmpfs_fifoops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_fifoops.c Tue Apr 2 13:41:26 2019 (r345799) +++ head/sys/fs/tmpfs/tmpfs_fifoops.c Tue Apr 2 13:49:32 2019 (r345800) @@ -56,7 +56,8 @@ tmpfs_fifo_close(struct vop_close_args *v) struct tmpfs_node *node; node = VP_TO_TMPFS_NODE(v->a_vp); - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(VFS_TO_TMPFS(v->a_vp->v_mount), node, + TMPFS_NODE_ACCESSED); tmpfs_update(v->a_vp); return (fifo_specops.vop_close(v)); } Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Tue Apr 2 13:41:26 2019 (r345799) +++ head/sys/fs/tmpfs/tmpfs_subr.c Tue Apr 2 13:49:32 2019 (r345800) @@ -1110,7 +1110,8 @@ tmpfs_dir_destroy(struct tmpfs_mount *tmp, struct tmpf * error happens. */ static int -tmpfs_dir_getdotdent(struct tmpfs_node *node, struct uio *uio) +tmpfs_dir_getdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node, + struct uio *uio) { int error; struct dirent dent; @@ -1130,7 +1131,7 @@ tmpfs_dir_getdotdent(struct tmpfs_node *node, struct u else error = uiomove(&dent, dent.d_reclen, uio); - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(tm, node, TMPFS_NODE_ACCESSED); return (error); } @@ -1143,7 +1144,8 @@ tmpfs_dir_getdotdent(struct tmpfs_node *node, struct u * error happens. */ static int -tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struct uio *uio) +tmpfs_dir_getdotdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node, + struct uio *uio) { int error; struct dirent dent; @@ -1174,7 +1176,7 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struc else error = uiomove(&dent, dent.d_reclen, uio); - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(tm, node, TMPFS_NODE_ACCESSED); return (error); } @@ -1187,8 +1189,8 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struc * error code if another error happens. */ int -tmpfs_dir_getdents(struct tmpfs_node *node, struct uio *uio, int maxcookies, - u_long *cookies, int *ncookies) +tmpfs_dir_getdents(struct tmpfs_mount *tm, struct tmpfs_node *node, + struct uio *uio, int maxcookies, u_long *cookies, int *ncookies) { struct tmpfs_dir_cursor dc; struct tmpfs_dirent *de; @@ -1209,7 +1211,7 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio */ switch (uio->uio_offset) { case TMPFS_DIRCOOKIE_DOT: - error = tmpfs_dir_getdotdent(node, uio); + error = tmpfs_dir_getdotdent(tm, node, uio); if (error != 0) return (error); uio->uio_offset = TMPFS_DIRCOOKIE_DOTDOT; @@ -1217,7 +1219,7 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio cookies[(*ncookies)++] = off = uio->uio_offset; /* FALLTHROUGH */ case TMPFS_DIRCOOKIE_DOTDOT: - error = tmpfs_dir_getdotdotdent(node, uio); + error = tmpfs_dir_getdotdotdent(tm, node, uio); if (error != 0) return (error); de = tmpfs_dir_first(node, &dc); @@ -1319,7 +1321,7 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio node->tn_dir.tn_readdir_lastn = off; node->tn_dir.tn_readdir_lastp = de; - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(tm, node, TMPFS_NODE_ACCESSED); return error; } @@ -1774,10 +1776,10 @@ tmpfs_chtimes(struct vnode *vp, struct vattr *vap, } void -tmpfs_set_status(struct tmpfs_node *node, int status) +tmpfs_set_status(struct tmpfs_mount *tm, struct tmpfs_node *node, int status) { - if ((node->tn_status & status) == status) + if ((node->tn_status & status) == status || tm->tm_ronly) return; TMPFS_NODE_LOCK(node); node->tn_status |= status; Modified: head/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vnops.c Tue Apr 2 13:41:26 2019 (r345799) +++ head/sys/fs/tmpfs/tmpfs_vnops.c Tue Apr 2 13:49:32 2019 (r345800) @@ -481,7 +481,7 @@ tmpfs_read(struct vop_read_args *v) if (uio->uio_offset < 0) return (EINVAL); node = VP_TO_TMPFS_NODE(vp); - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(VFS_TO_TMPFS(vp->v_mount), node, TMPFS_NODE_ACCESSED); return (uiomove_object(node->tn_reg.tn_aobj, node->tn_size, uio)); } @@ -1188,25 +1188,30 @@ tmpfs_symlink(struct vop_symlink_args *v) } static int -tmpfs_readdir(struct vop_readdir_args *v) +tmpfs_readdir(struct vop_readdir_args *va) { - struct vnode *vp = v->a_vp; - struct uio *uio = v->a_uio; - int *eofflag = v->a_eofflag; - u_long **cookies = v->a_cookies; - int *ncookies = v->a_ncookies; - - int error; - ssize_t startresid; - int maxcookies; + struct vnode *vp; + struct uio *uio; + struct tmpfs_mount *tm; struct tmpfs_node *node; + u_long **cookies; + int *eofflag, *ncookies; + ssize_t startresid; + int error, maxcookies; + vp = va->a_vp; + uio = va->a_uio; + eofflag = va->a_eofflag; + cookies = va->a_cookies; + ncookies = va->a_ncookies; + /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) return ENOTDIR; maxcookies = 0; node = VP_TO_TMPFS_DIR(vp); + tm = VFS_TO_TMPFS(vp->v_mount); startresid = uio->uio_resid; @@ -1220,9 +1225,9 @@ tmpfs_readdir(struct vop_readdir_args *v) } if (cookies == NULL) - error = tmpfs_dir_getdents(node, uio, 0, NULL, NULL); + error = tmpfs_dir_getdents(tm, node, uio, 0, NULL, NULL); else - error = tmpfs_dir_getdents(node, uio, maxcookies, *cookies, + error = tmpfs_dir_getdents(tm, node, uio, maxcookies, *cookies, ncookies); /* Buffer was filled without hitting EOF. */ @@ -1258,7 +1263,7 @@ tmpfs_readlink(struct vop_readlink_args *v) error = uiomove(node->tn_link, MIN(node->tn_size, uio->uio_resid), uio); - tmpfs_set_status(node, TMPFS_NODE_ACCESSED); + tmpfs_set_status(VFS_TO_TMPFS(vp->v_mount), node, TMPFS_NODE_ACCESSED); return (error); } From owner-svn-src-head@freebsd.org Tue Apr 2 13:59:05 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E015156801C; Tue, 2 Apr 2019 13:59:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B64B48DCAC; Tue, 2 Apr 2019 13:59: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E63626F18; Tue, 2 Apr 2019 13:59: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 x32Dx4Qp090275; Tue, 2 Apr 2019 13:59:04 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Dx4RD090274; Tue, 2 Apr 2019 13:59:04 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201904021359.x32Dx4RD090274@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 2 Apr 2019 13:59:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345803 - head/sys/fs/tmpfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/tmpfs X-SVN-Commit-Revision: 345803 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B64B48DCAC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 13:59:05 -0000 Author: kib Date: Tue Apr 2 13:59:04 2019 New Revision: 345803 URL: https://svnweb.freebsd.org/changeset/base/345803 Log: tmpfs: plug holes on rw->ro mount update. In particular: - suspend the mount around vflush() to avoid new writes come after the vnode is processed; - flush pending metadata updates (mostly node times); - remap all rw mappings of files from the mount into ro. It is not clear to me how to handle writeable mappings on rw->ro for tmpfs best. Other filesystems, which use vnode vm object, call vgone() on vnodes with writers, which sets the vm object type to OBJT_DEAD, and keep the resident pages and installed ptes as is. In particular, the existing mappings continue to work as far as application only accesses resident pages, but changes are not flushed to file. For tmpfs the vm object of VREG vnodes also serves as the data pages container, giving single copy of the mapped pages, so it cannot be set to OBJT_DEAD. Alternatives for making rw mappings ro could be either invalidating them at all, or marking as CoW. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19737 Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vfsops.c Tue Apr 2 13:58:31 2019 (r345802) +++ head/sys/fs/tmpfs/tmpfs_vfsops.c Tue Apr 2 13:59:04 2019 (r345803) @@ -60,10 +60,15 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include +#include +#include +#include +#include #include #include @@ -137,14 +142,235 @@ tmpfs_node_fini(void *mem, int size) mtx_destroy(&node->tn_interlock); } +/* + * Handle updates of time from writes to mmaped regions. Use + * MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_ACTIVE, since + * unmap of the tmpfs-backed vnode does not call vinactive(), due to + * vm object type is OBJT_SWAP. + * If lazy, only handle delayed update of mtime due to the writes to + * mapped files. + */ +static void +tmpfs_update_mtime(struct mount *mp, bool lazy) +{ + struct vnode *vp, *mvp; + struct vm_object *obj; + + MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { + if (vp->v_type != VREG) { + VI_UNLOCK(vp); + continue; + } + obj = vp->v_object; + KASSERT((obj->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) == + (OBJ_TMPFS_NODE | OBJ_TMPFS), ("non-tmpfs obj")); + + /* + * In lazy case, do unlocked read, avoid taking vnode + * lock if not needed. Lost update will be handled on + * the next call. + * For non-lazy case, we must flush all pending + * metadata changes now. + */ + if (!lazy || (obj->flags & OBJ_TMPFS_DIRTY) != 0) { + if (vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, + curthread) != 0) + continue; + tmpfs_check_mtime(vp); + if (!lazy) + tmpfs_update(vp); + vput(vp); + } else { + VI_UNLOCK(vp); + continue; + } + } +} + +struct tmpfs_check_rw_maps_arg { + bool found; +}; + +static bool +tmpfs_check_rw_maps_cb(struct mount *mp __unused, vm_map_t map __unused, + vm_map_entry_t entry __unused, void *arg) +{ + struct tmpfs_check_rw_maps_arg *a; + + a = arg; + a->found = true; + return (true); +} + +/* + * Revoke write permissions from all mappings of regular files + * belonging to the specified tmpfs mount. + */ +static bool +tmpfs_revoke_rw_maps_cb(struct mount *mp __unused, vm_map_t map, + vm_map_entry_t entry, void *arg __unused) +{ + + /* + * XXXKIB: might be invalidate the mapping + * instead ? The process is not going to be + * happy in any case. + */ + entry->max_protection &= ~VM_PROT_WRITE; + if ((entry->protection & VM_PROT_WRITE) != 0) { + entry->protection &= ~VM_PROT_WRITE; + pmap_protect(map->pmap, entry->start, entry->end, + entry->protection); + } + return (false); +} + +static void +tmpfs_all_rw_maps(struct mount *mp, bool (*cb)(struct mount *mp, vm_map_t, + vm_map_entry_t, void *), void *cb_arg) +{ + struct proc *p; + struct vmspace *vm; + vm_map_t map; + vm_map_entry_t entry; + vm_object_t object; + struct vnode *vp; + int gen; + bool terminate; + + terminate = false; + sx_slock(&allproc_lock); +again: + gen = allproc_gen; + FOREACH_PROC_IN_SYSTEM(p) { + PROC_LOCK(p); + if (p->p_state != PRS_NORMAL || (p->p_flag & (P_INEXEC | + P_SYSTEM | P_WEXIT)) != 0) { + PROC_UNLOCK(p); + continue; + } + vm = vmspace_acquire_ref(p); + _PHOLD_LITE(p); + PROC_UNLOCK(p); + if (vm == NULL) { + PRELE(p); + continue; + } + sx_sunlock(&allproc_lock); + map = &vm->vm_map; + + vm_map_lock(map); + if (map->busy) + vm_map_wait_busy(map); + for (entry = map->header.next; entry != &map->header; + entry = entry->next) { + if ((entry->eflags & (MAP_ENTRY_GUARD | + MAP_ENTRY_IS_SUB_MAP | MAP_ENTRY_COW)) != 0 || + (entry->max_protection & VM_PROT_WRITE) == 0) + continue; + object = entry->object.vm_object; + if (object == NULL || object->type != OBJT_SWAP || + (object->flags & OBJ_TMPFS_NODE) == 0) + continue; + /* + * No need to dig into shadow chain, mapping + * of the object not at top is readonly. + */ + + VM_OBJECT_RLOCK(object); + if (object->type == OBJT_DEAD) { + VM_OBJECT_RUNLOCK(object); + continue; + } + MPASS(object->ref_count > 1); + if ((object->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) != + (OBJ_TMPFS_NODE | OBJ_TMPFS)) { + VM_OBJECT_RUNLOCK(object); + continue; + } + vp = object->un_pager.swp.swp_tmpfs; + if (vp->v_mount != mp) { + VM_OBJECT_RUNLOCK(object); + continue; + } + + terminate = cb(mp, map, entry, cb_arg); + VM_OBJECT_RUNLOCK(object); + if (terminate) + break; + } + vm_map_unlock(map); + + vmspace_free(vm); + sx_slock(&allproc_lock); + PRELE(p); + if (terminate) + break; + } + if (!terminate && gen != allproc_gen) + goto again; + sx_sunlock(&allproc_lock); +} + +static bool +tmpfs_check_rw_maps(struct mount *mp) +{ + struct tmpfs_check_rw_maps_arg ca; + + ca.found = false; + tmpfs_all_rw_maps(mp, tmpfs_check_rw_maps_cb, &ca); + return (ca.found); +} + static int +tmpfs_rw_to_ro(struct mount *mp) +{ + int error, flags; + bool forced; + + forced = (mp->mnt_flag & MNT_FORCE) != 0; + flags = WRITECLOSE | (forced ? FORCECLOSE : 0); + + if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) + return (error); + error = vfs_write_suspend_umnt(mp); + if (error != 0) + return (error); + if (!forced && tmpfs_check_rw_maps(mp)) { + error = EBUSY; + goto out; + } + VFS_TO_TMPFS(mp)->tm_ronly = 1; + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_RDONLY; + MNT_IUNLOCK(mp); + for (;;) { + tmpfs_all_rw_maps(mp, tmpfs_revoke_rw_maps_cb, NULL); + tmpfs_update_mtime(mp, false); + error = vflush(mp, 0, flags, curthread); + if (error != 0) { + VFS_TO_TMPFS(mp)->tm_ronly = 0; + MNT_ILOCK(mp); + mp->mnt_flag &= ~MNT_RDONLY; + MNT_IUNLOCK(mp); + goto out; + } + if (!tmpfs_check_rw_maps(mp)) + break; + } +out: + vfs_write_resume(mp, 0); + return (error); +} + +static int tmpfs_mount(struct mount *mp) { const size_t nodes_per_page = howmany(PAGE_SIZE, sizeof(struct tmpfs_dirent) + sizeof(struct tmpfs_node)); struct tmpfs_mount *tmp; struct tmpfs_node *root; - int error, flags; + int error; bool nonc; /* Size counters. */ u_quad_t pages; @@ -178,19 +404,7 @@ tmpfs_mount(struct mount *mp) if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && !(VFS_TO_TMPFS(mp)->tm_ronly)) { /* RW -> RO */ - error = VFS_SYNC(mp, MNT_WAIT); - if (error) - return (error); - flags = WRITECLOSE; - if (mp->mnt_flag & MNT_FORCE) - flags |= FORCECLOSE; - error = vflush(mp, 0, flags, curthread); - if (error) - return (error); - VFS_TO_TMPFS(mp)->tm_ronly = 1; - MNT_ILOCK(mp); - mp->mnt_flag |= MNT_RDONLY; - MNT_IUNLOCK(mp); + return (tmpfs_rw_to_ro(mp)); } else if (!vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && VFS_TO_TMPFS(mp)->tm_ronly) { /* RO -> RW */ @@ -469,45 +683,13 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp) static int tmpfs_sync(struct mount *mp, int waitfor) { - struct vnode *vp, *mvp; - struct vm_object *obj; if (waitfor == MNT_SUSPEND) { MNT_ILOCK(mp); mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED; MNT_IUNLOCK(mp); } else if (waitfor == MNT_LAZY) { - /* - * Handle lazy updates of mtime from writes to mmaped - * regions. Use MNT_VNODE_FOREACH_ALL instead of - * MNT_VNODE_FOREACH_ACTIVE, since unmap of the - * tmpfs-backed vnode does not call vinactive(), due - * to vm object type is OBJT_SWAP. - */ - MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { - if (vp->v_type != VREG) { - VI_UNLOCK(vp); - continue; - } - obj = vp->v_object; - KASSERT((obj->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) == - (OBJ_TMPFS_NODE | OBJ_TMPFS), ("non-tmpfs obj")); - - /* - * Unlocked read, avoid taking vnode lock if - * not needed. Lost update will be handled on - * the next call. - */ - if ((obj->flags & OBJ_TMPFS_DIRTY) == 0) { - VI_UNLOCK(vp); - continue; - } - if (vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, - curthread) != 0) - continue; - tmpfs_check_mtime(vp); - vput(vp); - } + tmpfs_update_mtime(mp, true); } return (0); } From owner-svn-src-head@freebsd.org Tue Apr 2 14:01:06 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA99115681F6; Tue, 2 Apr 2019 14:01:05 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 507A88E0FA; Tue, 2 Apr 2019 14:01:05 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12A6526F3A; Tue, 2 Apr 2019 14:01:05 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32E14NG092706; Tue, 2 Apr 2019 14:01:04 GMT (envelope-from mr@FreeBSD.org) Received: (from mr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32E13Fi092699; Tue, 2 Apr 2019 14:01:03 GMT (envelope-from mr@FreeBSD.org) Message-Id: <201904021401.x32E13Fi092699@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mr set sender to mr@FreeBSD.org using -f From: Michael Reifenberger Date: Tue, 2 Apr 2019 14:01:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345804 - head/usr.bin/systat X-SVN-Group: head X-SVN-Commit-Author: mr X-SVN-Commit-Paths: head/usr.bin/systat X-SVN-Commit-Revision: 345804 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 507A88E0FA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 14:01:06 -0000 Author: mr Date: Tue Apr 2 14:01:03 2019 New Revision: 345804 URL: https://svnweb.freebsd.org/changeset/base/345804 Log: systat -zarc to display disk activities like -vm PR: 213310 Submitted by: ota MFH: 4 weeks Differential Revision: https://reviews.freebsd.org/D18726 Modified: head/usr.bin/systat/devs.c head/usr.bin/systat/devs.h head/usr.bin/systat/iostat.c head/usr.bin/systat/swap.c head/usr.bin/systat/systat.h head/usr.bin/systat/vmstat.c head/usr.bin/systat/zarc.c Modified: head/usr.bin/systat/devs.c ============================================================================== --- head/usr.bin/systat/devs.c Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/devs.c Tue Apr 2 14:01:03 2019 (r345804) @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1998 Kenneth D. Merry. + * 2015 Yoshihiro Ota * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c 8.1 (Berkele #include #include -#include #include #include #include @@ -84,6 +84,8 @@ typedef enum { DS_MATCHTYPE_PATTERN } last_match_type; +struct statinfo cur_dev, last_dev, run_dev; + last_match_type last_type; struct device_selection *dev_select; long generation; @@ -101,10 +103,8 @@ static int dsselect(const char *args, devstat_select_m int maxshowdevs, struct statinfo *s1); int -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused, - struct statinfo *s3 __unused) +dsinit(int maxshowdevs) { - /* * Make sure that the userland devstat version matches the kernel * devstat version. If not, exit and print a message informing @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st if (devstat_checkversion(NULL) < 0) errx(1, "%s", devstat_errbuf); + if( cur_dev.dinfo ) // init was alreay ran + return(1); + + if ((num_devices = devstat_getnumdevs(NULL)) < 0) { + warnx("%s", devstat_errbuf); + return(0); + } + + cur_dev.dinfo = calloc(1, sizeof(struct devinfo)); + last_dev.dinfo = calloc(1, sizeof(struct devinfo)); + run_dev.dinfo = calloc(1, sizeof(struct devinfo)); + generation = 0; num_devices = 0; num_selected = 0; @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st select_generation = 0; last_type = DS_MATCHTYPE_NONE; - if (devstat_getdevs(NULL, s1) == -1) + if (devstat_getdevs(NULL, &cur_dev) == -1) errx(1, "%s", devstat_errbuf); - num_devices = s1->dinfo->numdevs; - generation = s1->dinfo->generation; + num_devices = cur_dev.dinfo->numdevs; + generation = cur_dev.dinfo->generation; dev_select = NULL; @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st * or 1. If we get back -1, though, there is an error. */ if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, - &select_generation, generation, s1->dinfo->devices, num_devices, + &select_generation, generation, cur_dev.dinfo->devices, num_devices, NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1) errx(1, "%d %s", __LINE__, devstat_errbuf); return(1); } + +void +dsgetinfo(struct statinfo* dev) +{ + switch (devstat_getdevs(NULL, dev)) { + case -1: + errx(1, "%s", devstat_errbuf); + break; + case 1: + num_devices = dev->dinfo->numdevs; + generation = dev->dinfo->generation; + cmdkre("refresh", NULL); + break; + default: + break; + } +} + int dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1) { @@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode select_ return(2); } return(1); +} + + +void +dslabel(int maxdrives, int diskcol, int diskrow) +{ + int i, j; + + mvprintw(diskrow, diskcol, "Disks"); + mvprintw(diskrow + 1, diskcol, "KB/t"); + mvprintw(diskrow + 2, diskcol, "tps"); + mvprintw(diskrow + 3, diskcol, "MB/s"); + mvprintw(diskrow + 4, diskcol, "%%busy"); + /* + * For now, we don't support a fourth disk statistic. So there's + * no point in providing a label for it. If someone can think of a + * fourth useful disk statistic, there is room to add it. + */ + /* mvprintw(diskrow + 4, diskcol, " msps"); */ + j = 0; + for (i = 0; i < num_devices && j < maxdrives; i++) + if (dev_select[i].selected) { + char tmpstr[80]; + sprintf(tmpstr, "%s%d", dev_select[i].device_name, + dev_select[i].unit_number); + mvprintw(diskrow, diskcol + 5 + 6 * j, + " %5.5s", tmpstr); + j++; + } +} + +static void +dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then) +{ + long double transfers_per_second; + long double kb_per_transfer, mb_per_second; + long double elapsed_time, device_busy; + int di; + + di = dev_select[dn].position; + + if (then != NULL) { + /* Calculate relative to previous sample */ + elapsed_time = now->snap_time - then->snap_time; + } else { + /* Calculate relative to device creation */ + elapsed_time = now->snap_time - devstat_compute_etime( + &now->dinfo->devices[di].creation_time, NULL); + } + + if (devstat_compute_statistics(&now->dinfo->devices[di], then ? + &then->dinfo->devices[di] : NULL, elapsed_time, + DSM_KB_PER_TRANSFER, &kb_per_transfer, + DSM_TRANSFERS_PER_SECOND, &transfers_per_second, + DSM_MB_PER_SECOND, &mb_per_second, + DSM_BUSY_PCT, &device_busy, + DSM_NONE) != 0) + errx(1, "%s", devstat_errbuf); + + lc = diskcol + lc * 6; + putlongdouble(kb_per_transfer, diskrow + 1, lc, 5, 2, 0); + putlongdouble(transfers_per_second, diskrow + 2, lc, 5, 0, 0); + putlongdouble(mb_per_second, diskrow + 3, lc, 5, 2, 0); + putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0); +} + +static void +dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then) +{ + dsshow2(diskcol, diskrow, dn, lc, now, then); +} + +void +dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct statinfo *then) +{ + int i, lc; + + for (i = 0, lc = 0; i < num_devices && lc < maxdrives; i++) + if (dev_select[i].selected) + dsshow3(diskcol, diskrow, i, ++lc, now, then); } Modified: head/usr.bin/systat/devs.h ============================================================================== --- head/usr.bin/systat/devs.h Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/devs.h Tue Apr 2 14:01:03 2019 (r345804) @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 1998 David E. O'Brien + * 2015 Yoshihiro Ota * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,5 +29,18 @@ * $FreeBSD$ */ -int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *); +#ifndef DEVS_H +#define DEVS_H + +#include + +int dsinit(int); +void dsgetinfo(struct statinfo *); int dscmd(const char *, const char *, int, struct statinfo *); + +void dslabel(int, int, int); +void dsshow(int, int, int, struct statinfo *, struct statinfo *); + +extern struct statinfo cur_dev, last_dev, run_dev; + +#endif Modified: head/usr.bin/systat/iostat.c ============================================================================== --- head/usr.bin/systat/iostat.c Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/iostat.c Tue Apr 2 14:01:03 2019 (r345804) @@ -79,8 +79,6 @@ static const char sccsid[] = "@(#)iostat.c 8.1 (Berkel #include "extern.h" #include "devs.h" -struct statinfo cur, last; - static int linesperregion; static double etime; static int numbers = 0; /* default display bar graphs */ @@ -111,17 +109,11 @@ closeiostat(WINDOW *w) int initiostat(void) { - if ((num_devices = devstat_getnumdevs(NULL)) < 0) - return(0); - - cur.dinfo = calloc(1, sizeof(struct devinfo)); - last.dinfo = calloc(1, sizeof(struct devinfo)); - /* * This value for maxshowdevs (100) is bogus. I'm not sure exactly * how to calculate it, though. */ - if (dsinit(100, &cur, &last, NULL) != 1) + if (dsinit(7) != 1) return(0); return(1); @@ -133,17 +125,17 @@ fetchiostat(void) struct devinfo *tmp_dinfo; size_t len; - len = sizeof(cur.cp_time); - if (sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0) - || len != sizeof(cur.cp_time)) { + len = sizeof(cur_dev.cp_time); + if (sysctlbyname("kern.cp_time", &cur_dev.cp_time, &len, NULL, 0) + || len != sizeof(cur_dev.cp_time)) { perror("kern.cp_time"); exit (1); } - tmp_dinfo = last.dinfo; - last.dinfo = cur.dinfo; - cur.dinfo = tmp_dinfo; + tmp_dinfo = last_dev.dinfo; + last_dev.dinfo = cur_dev.dinfo; + cur_dev.dinfo = tmp_dinfo; - last.snap_time = cur.snap_time; + last_dev.snap_time = cur_dev.snap_time; /* * Here what we want to do is refresh our device stats. @@ -152,7 +144,7 @@ fetchiostat(void) * the selection process again, in case a device that we * were previously displaying has gone away. */ - switch (devstat_getdevs(NULL, &cur)) { + switch (devstat_getdevs(NULL, &cur_dev)) { case -1: errx(1, "%s", devstat_errbuf); break; @@ -162,8 +154,8 @@ fetchiostat(void) default: break; } - num_devices = cur.dinfo->numdevs; - generation = cur.dinfo->generation; + num_devices = cur_dev.dinfo->numdevs; + generation = cur_dev.dinfo->generation; } @@ -260,11 +252,11 @@ showiostat(void) long t; int i, row, _col; -#define X(fld) t = cur.fld[i]; cur.fld[i] -= last.fld[i]; last.fld[i] = t +#define X(fld) t = cur_dev.fld[i]; cur_dev.fld[i] -= last_dev.fld[i]; last_dev.fld[i] = t etime = 0; for(i = 0; i < CPUSTATES; i++) { X(cp_time); - etime += cur.cp_time[i]; + etime += cur_dev.cp_time[i]; } if (etime == 0.0) etime = 1.0; @@ -313,10 +305,10 @@ devstats(int row, int _col, int dn) di = dev_select[dn].position; - busy_seconds = cur.snap_time - last.snap_time; + busy_seconds = cur_dev.snap_time - last_dev.snap_time; - if (devstat_compute_statistics(&cur.dinfo->devices[di], - &last.dinfo->devices[di], busy_seconds, + if (devstat_compute_statistics(&cur_dev.dinfo->devices[di], + &last_dev.dinfo->devices[di], busy_seconds, DSM_KB_PER_TRANSFER, &kb_per_transfer, DSM_TRANSFERS_PER_SECOND, &transfers_per_second, DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0) @@ -349,12 +341,12 @@ stat1(int row, int o) dtime = 0.0; for (i = 0; i < CPUSTATES; i++) - dtime += cur.cp_time[i]; + dtime += cur_dev.cp_time[i]; if (dtime == 0.0) dtime = 1.0; wmove(wnd, row, INSET); #define CPUSCALE 0.5 - histogram(100.0 * cur.cp_time[o] / dtime, 50, CPUSCALE); + histogram(100.0 * cur_dev.cp_time[o] / dtime, 50, CPUSCALE); } static void @@ -388,7 +380,7 @@ cmdiostat(const char *cmd, const char *args) numbers = 1; else if (prefix(cmd, "bars")) numbers = 0; - else if (!dscmd(cmd, args, 100, &cur)) + else if (!dscmd(cmd, args, 100, &cur_dev)) return (0); wclear(wnd); labeliostat(); Modified: head/usr.bin/systat/swap.c ============================================================================== --- head/usr.bin/systat/swap.c Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/swap.c Tue Apr 2 14:01:03 2019 (r345804) @@ -3,6 +3,7 @@ * * Copyright (c) 1980, 1992, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2017 Yoshihiro Ota * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,6 +56,7 @@ static const char sccsid[] = "@(#)swap.c 8.3 (Berkeley #include "systat.h" #include "extern.h" +#include "devs.h" kvm_t *kd; @@ -137,13 +139,15 @@ initswap(void) oulen = ulen; once = 1; + + dsinit(12); + return (1); } void fetchswap(void) { - okvnsw = kvnsw; if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) { error("systat: kvm_getswapinfo failed"); @@ -153,6 +157,15 @@ fetchswap(void) odlen = dlen; oulen = ulen; calclens(); + + struct devinfo *tmp_dinfo; + + tmp_dinfo = last_dev.dinfo; + last_dev.dinfo = cur_dev.dinfo; + cur_dev.dinfo = tmp_dinfo; + + last_dev.snap_time = cur_dev.snap_time; + dsgetinfo( &cur_dev ); } void @@ -178,6 +191,7 @@ labelswap(void) name = kvmsw[i].ksw_devname; mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name); } + dslabel(12, 0, 18); } void @@ -217,4 +231,5 @@ showswap(void) waddch(wnd, 'X'); wclrtoeol(wnd); } + dsshow(12, 0, 18, &cur_dev, &last_dev); } Modified: head/usr.bin/systat/systat.h ============================================================================== --- head/usr.bin/systat/systat.h Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/systat.h Tue Apr 2 14:01:03 2019 (r345804) @@ -68,3 +68,7 @@ extern int use_kvm; #define NVAL(indx) namelist[(indx)].n_value #define NPTR(indx) (void *)NVAL((indx)) #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) + +extern void putint(int, int, int, int); +extern void putfloat(double, int, int, int, int, int); +extern void putlongdouble(long double, int, int, int, int, int); Modified: head/usr.bin/systat/vmstat.c ============================================================================== --- head/usr.bin/systat/vmstat.c Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/vmstat.c Tue Apr 2 14:01:03 2019 (r345804) @@ -66,7 +66,6 @@ static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkel #include #include #include -#include #include "systat.h" #include "extern.h" #include "devs.h" @@ -125,7 +124,6 @@ static struct Info { static u_long kmem_size; static u_int v_page_count; -struct statinfo cur, last, run; #define total s.Total #define nchtotal s.nchstats @@ -137,13 +135,9 @@ enum divisor { IEC = 0, SI = HN_DIVISOR_1000 }; static void allocinfo(struct Info *); static void copyinfo(struct Info *, struct Info *); static float cputime(int); -static void dinfo(int, int, struct statinfo *, struct statinfo *); static void do_putuint64(uint64_t, int, int, int, int); static void getinfo(struct Info *); -static void putint(int, int, int, int); static void putuint64(uint64_t, int, int, int); -static void putfloat(double, int, int, int, int, int); -static void putlongdouble(long double, int, int, int, int, int); static int ucount(void); static int ncpu; @@ -209,18 +203,9 @@ initkre(void) int i; size_t sz; - if ((num_devices = devstat_getnumdevs(NULL)) < 0) { - warnx("%s", devstat_errbuf); + if (dsinit(MAXDRIVES) != 1) return(0); - } - cur.dinfo = calloc(1, sizeof(struct devinfo)); - last.dinfo = calloc(1, sizeof(struct devinfo)); - run.dinfo = calloc(1, sizeof(struct devinfo)); - - if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) - return(0); - if (nintr == 0) { if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { error("sysctl(hw.intrcnt...) failed: %s", @@ -371,27 +356,7 @@ labelkre(void) mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); mvprintw(NAMEIROW + 1, NAMEICOL, " Calls hits %% hits %%"); - mvprintw(DISKROW, DISKCOL, "Disks"); - mvprintw(DISKROW + 1, DISKCOL, "KB/t"); - mvprintw(DISKROW + 2, DISKCOL, "tps"); - mvprintw(DISKROW + 3, DISKCOL, "MB/s"); - mvprintw(DISKROW + 4, DISKCOL, "%%busy"); - /* - * For now, we don't support a fourth disk statistic. So there's - * no point in providing a label for it. If someone can think of a - * fourth useful disk statistic, there is room to add it. - */ - /* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ - j = 0; - for (i = 0; i < num_devices && j < MAXDRIVES; i++) - if (dev_select[i].selected) { - char tmpstr[80]; - sprintf(tmpstr, "%s%d", dev_select[i].device_name, - dev_select[i].unit_number); - mvprintw(DISKROW, DISKCOL + 5 + 6 * j, - " %5.5s", tmpstr); - j++; - } + dslabel(MAXDRIVES, DISKCOL, DISKROW); for (i = 0; i < nintr; i++) { if (intrloc[i] == 0) @@ -401,7 +366,7 @@ labelkre(void) } #define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} -#define Q(fld) {t=cur.fld[i]; cur.fld[i]-=last.fld[i]; if(state==TIME) last.fld[i]=t;} +#define Q(fld) {t=cur_dev.fld[i]; cur_dev.fld[i]-=last_dev.fld[i]; if(state==TIME) last_dev.fld[i]=t;} #define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} #define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ if(state == TIME) s1.nchstats.fld = t;} @@ -543,20 +508,17 @@ showkre(void) PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); - for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) - if (dev_select[i].selected) { - switch(state) { - case TIME: - dinfo(i, ++lc, &cur, &last); - break; - case RUN: - dinfo(i, ++lc, &cur, &run); - break; - case BOOT: - dinfo(i, ++lc, &cur, NULL); - break; - } - } + switch(state) { + case TIME: + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); + break; + case RUN: + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); + break; + case BOOT: + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); + break; + } putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); @@ -582,14 +544,14 @@ cmdkre(const char *cmd, const char *args) if (prefix(cmd, "run")) { retval = 1; copyinfo(&s2, &s1); - switch (devstat_getdevs(NULL, &run)) { + switch (devstat_getdevs(NULL, &run_dev)) { case -1: errx(1, "%s", devstat_errbuf); break; case 1: - num_devices = run.dinfo->numdevs; - generation = run.dinfo->generation; - retval = dscmd("refresh", NULL, MAXDRIVES, &cur); + num_devices = run_dev.dinfo->numdevs; + generation = run_dev.dinfo->generation; + retval = dscmd("refresh", NULL, MAXDRIVES, &cur_dev); if (retval == 2) labelkre(); break; @@ -612,14 +574,14 @@ cmdkre(const char *cmd, const char *args) retval = 1; if (state == RUN) { getinfo(&s1); - switch (devstat_getdevs(NULL, &run)) { + switch (devstat_getdevs(NULL, &run_dev)) { case -1: errx(1, "%s", devstat_errbuf); break; case 1: - num_devices = run.dinfo->numdevs; - generation = run.dinfo->generation; - retval = dscmd("refresh",NULL, MAXDRIVES, &cur); + num_devices = run_dev.dinfo->numdevs; + generation = run_dev.dinfo->generation; + retval = dscmd("refresh",NULL, MAXDRIVES, &cur_dev); if (retval == 2) labelkre(); break; @@ -629,7 +591,7 @@ cmdkre(const char *cmd, const char *args) } return (retval); } - retval = dscmd(cmd, args, MAXDRIVES, &cur); + retval = dscmd(cmd, args, MAXDRIVES, &cur_dev); if (retval == 2) labelkre(); @@ -667,7 +629,7 @@ cputime(int indx) return (s.time[indx] * 100.0 / lt); } -static void +void putint(int n, int l, int lc, int w) { @@ -713,7 +675,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div addstr(b); } -static void +void putfloat(double f, int l, int lc, int w, int d, int nz) { int snr; @@ -745,7 +707,7 @@ putfloat(double f, int l, int lc, int w, int d, int nz addstr(b); } -static void +void putlongdouble(long double f, int l, int lc, int w, int d, int nz) { int snr; @@ -785,7 +747,7 @@ getinfo(struct Info *ls) int mib[2]; GETSYSCTL("kern.cp_time", ls->time); - GETSYSCTL("kern.cp_time", cur.cp_time); + GETSYSCTL("kern.cp_time", cur_dev.cp_time); GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); @@ -838,23 +800,12 @@ getinfo(struct Info *ls) size != sizeof(ncpu)) ncpu = 1; - tmp_dinfo = last.dinfo; - last.dinfo = cur.dinfo; - cur.dinfo = tmp_dinfo; + tmp_dinfo = last_dev.dinfo; + last_dev.dinfo = cur_dev.dinfo; + cur_dev.dinfo = tmp_dinfo; - last.snap_time = cur.snap_time; - switch (devstat_getdevs(NULL, &cur)) { - case -1: - errx(1, "%s", devstat_errbuf); - break; - case 1: - num_devices = cur.dinfo->numdevs; - generation = cur.dinfo->generation; - cmdkre("refresh", NULL); - break; - default: - break; - } + last_dev.snap_time = cur_dev.snap_time; + dsgetinfo(&cur_dev); } static void @@ -880,39 +831,4 @@ copyinfo(struct Info *from, struct Info *to) *to = *from; bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); -} - -static void -dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) -{ - long double transfers_per_second; - long double kb_per_transfer, mb_per_second; - long double elapsed_time, device_busy; - int di; - - di = dev_select[dn].position; - - if (then != NULL) { - /* Calculate relative to previous sample */ - elapsed_time = now->snap_time - then->snap_time; - } else { - /* Calculate relative to device creation */ - elapsed_time = now->snap_time - devstat_compute_etime( - &now->dinfo->devices[di].creation_time, NULL); - } - - if (devstat_compute_statistics(&now->dinfo->devices[di], then ? - &then->dinfo->devices[di] : NULL, elapsed_time, - DSM_KB_PER_TRANSFER, &kb_per_transfer, - DSM_TRANSFERS_PER_SECOND, &transfers_per_second, - DSM_MB_PER_SECOND, &mb_per_second, - DSM_BUSY_PCT, &device_busy, - DSM_NONE) != 0) - errx(1, "%s", devstat_errbuf); - - lc = DISKCOL + lc * 6; - putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); - putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); - putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); - putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); } Modified: head/usr.bin/systat/zarc.c ============================================================================== --- head/usr.bin/systat/zarc.c Tue Apr 2 13:59:04 2019 (r345803) +++ head/usr.bin/systat/zarc.c Tue Apr 2 14:01:03 2019 (r345804) @@ -1,6 +1,5 @@ /*- - * Copyright (c) 2014 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 2014 - 2017 Yoshihiro Ota * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,11 +32,14 @@ __FBSDID("$FreeBSD$"); #include #include +/* #include */ #include #include +#include #include "systat.h" #include "extern.h" +#include "devs.h" struct zfield{ uint64_t arcstats; @@ -77,21 +79,23 @@ closezarc(WINDOW *w) void labelzarc(void) { + int row = 1; wmove(wnd, 0, 0); wclrtoeol(wnd); mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s", "rate", "hits", "misses", "total hits", "total misses"); -#define L(row, str) mvwprintw(wnd, row, 5, str); \ +#define L(str) mvwprintw(wnd, row, 5, #str); \ mvwprintw(wnd, row, 31, ":"); \ - mvwprintw(wnd, row, 31+4, "%%") - L(1, "arcstats"); - L(2, "arcstats.demand_data"); - L(3, "arcstats.demand_metadata"); - L(4, "arcstats.prefetch_data"); - L(5, "arcstats.prefetch_metadata"); - L(6, "zfetchstats"); - L(7, "arcstats.l2"); - L(8, "vdev_cache_stats"); + mvwprintw(wnd, row, 31+4, "%%"); ++row + L(arcstats); + L(arcstats.demand_data); + L(arcstats.demand_metadata); + L(arcstats.prefetch_data); + L(arcstats.prefetch_metadata); + L(zfetchstats); + L(arcstats.l2); + L(vdev_cache_stats); #undef L + dslabel(12, 0, 18); } static int calc(uint64_t hits, uint64_t misses) @@ -131,6 +135,7 @@ domode(struct zarcstats *delta, struct zarcstats *rate void showzarc(void) { + int row = 1; struct zarcstats delta, rate; memset(&delta, 0, sizeof delta); @@ -138,34 +143,37 @@ showzarc(void) domode(&delta, &rate); -#define DO(stat, row, col, fmt) \ +#define DO(stat, col, fmt) \ mvwprintw(wnd, row, col, fmt, stat) -#define R(row, stat) DO(rate.hits.stat, row, 31+1, "%3"PRIu64) -#define H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7"PRIu64); \ - DO(curstat.hits.stat, row, 31+1+5+8+8, "%12"PRIu64) -#define M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7"PRIu64); \ - DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12"PRIu64) -#define E(row, stat) R(row, stat); H(row, stat); M(row, stat); - E(1, arcstats); - E(2, arcstats_demand_data); - E(3, arcstats_demand_metadata); - E(4, arcstats_prefetch_data); - E(5, arcstats_prefetch_metadata); - E(6, zfetchstats); - E(7, arcstats_l2); - E(8, vdev_cache_stats); +#define R(stat) DO(rate.hits.stat, 31+1, "%3"PRIu64) +#define H(stat) DO(delta.hits.stat, 31+1+5, "%7"PRIu64); \ + DO(curstat.hits.stat, 31+1+5+8+8, "%12"PRIu64) +#define M(stat) DO(delta.misses.stat, 31+1+5+8, "%7"PRIu64); \ + DO(curstat.misses.stat, 31+1+5+8+8+13, "%12"PRIu64) +#define E(stat) R(stat); H(stat); M(stat); ++row + E(arcstats); + E(arcstats_demand_data); + E(arcstats_demand_metadata); + E(arcstats_prefetch_data); + E(arcstats_prefetch_metadata); + E(zfetchstats); + E(arcstats_l2); + E(vdev_cache_stats); #undef DO #undef E #undef M #undef H #undef R + dsshow(12, 0, 18, &cur_dev, &last_dev); } int initzarc(void) { + dsinit(12); getinfo(&initstat); curstat = oldstat = initstat; + return 1; } @@ -178,6 +186,15 @@ resetzarc(void) static void getinfo(struct zarcstats *ls) { + struct devinfo *tmp_dinfo; + + tmp_dinfo = last_dev.dinfo; + last_dev.dinfo = cur_dev.dinfo; + cur_dev.dinfo = tmp_dinfo; + + last_dev.snap_time = cur_dev.snap_time; + dsgetinfo( &cur_dev ); + size_t size = sizeof( ls->hits.arcstats ); if ( sysctlbyname("kstat.zfs.misc.arcstats.hits", &ls->hits.arcstats, &size, NULL, 0 ) != 0 ) From owner-svn-src-head@freebsd.org Tue Apr 2 14:08:21 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C01415685A6; Tue, 2 Apr 2019 14:08:21 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A5918E4F6; Tue, 2 Apr 2019 14:08:20 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x32E8IYu021668; Tue, 2 Apr 2019 07:08:18 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x32E8Ho9021667; Tue, 2 Apr 2019 07:08:17 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345804 - head/usr.bin/systat In-Reply-To: <201904021401.x32E13Fi092699@repo.freebsd.org> To: Michael Reifenberger Date: Tue, 2 Apr 2019 07:08:17 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4A5918E4F6 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 14:08:21 -0000 > Author: mr > Date: Tue Apr 2 14:01:03 2019 > New Revision: 345804 > URL: https://svnweb.freebsd.org/changeset/base/345804 > > Log: > systat -zarc to display disk activities like -vm > > PR: 213310 > Submitted by: ota > MFH: 4 weeks ? MFC: > Differential Revision: https://reviews.freebsd.org/D18726 > > Modified: > head/usr.bin/systat/devs.c > head/usr.bin/systat/devs.h > head/usr.bin/systat/iostat.c > head/usr.bin/systat/swap.c > head/usr.bin/systat/systat.h > head/usr.bin/systat/vmstat.c > head/usr.bin/systat/zarc.c > > Modified: head/usr.bin/systat/devs.c > ============================================================================== > --- head/usr.bin/systat/devs.c Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/devs.c Tue Apr 2 14:01:03 2019 (r345804) > @@ -2,6 +2,7 @@ > * SPDX-License-Identifier: BSD-3-Clause > * > * Copyright (c) 1998 Kenneth D. Merry. > + * 2015 Yoshihiro Ota > * All rights reserved. Can we get in contact with Yoshihiro Ota about his copyright statements, and correcting this to make it clear that it is Kenneth D. Merry that is asserting "All rights reserved" and if Ota does nor does not wish to assert "All rights reserved". As committed this makes a grey area on Kenneth's assertion, also leaving out the word copyright on Yoshihiro's line is a bit iffy. I am only commenting once, this issue appears several times. We can go back out to D18726 to discuss it if need be. > * > * Redistribution and use in source and binary forms, with or without > @@ -69,7 +70,6 @@ static const char sccsid[] = "@(#)disks.c 8.1 (Berkele > #include > > #include > -#include > #include > #include > #include > @@ -84,6 +84,8 @@ typedef enum { > DS_MATCHTYPE_PATTERN > } last_match_type; > > +struct statinfo cur_dev, last_dev, run_dev; > + > last_match_type last_type; > struct device_selection *dev_select; > long generation; > @@ -101,10 +103,8 @@ static int dsselect(const char *args, devstat_select_m > int maxshowdevs, struct statinfo *s1); > > int > -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused, > - struct statinfo *s3 __unused) > +dsinit(int maxshowdevs) > { > - > /* > * Make sure that the userland devstat version matches the kernel > * devstat version. If not, exit and print a message informing > @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st > if (devstat_checkversion(NULL) < 0) > errx(1, "%s", devstat_errbuf); > > + if( cur_dev.dinfo ) // init was alreay ran > + return(1); > + > + if ((num_devices = devstat_getnumdevs(NULL)) < 0) { > + warnx("%s", devstat_errbuf); > + return(0); > + } > + > + cur_dev.dinfo = calloc(1, sizeof(struct devinfo)); > + last_dev.dinfo = calloc(1, sizeof(struct devinfo)); > + run_dev.dinfo = calloc(1, sizeof(struct devinfo)); > + > generation = 0; > num_devices = 0; > num_selected = 0; > @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st > select_generation = 0; > last_type = DS_MATCHTYPE_NONE; > > - if (devstat_getdevs(NULL, s1) == -1) > + if (devstat_getdevs(NULL, &cur_dev) == -1) > errx(1, "%s", devstat_errbuf); > > - num_devices = s1->dinfo->numdevs; > - generation = s1->dinfo->generation; > + num_devices = cur_dev.dinfo->numdevs; > + generation = cur_dev.dinfo->generation; > > dev_select = NULL; > > @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct st > * or 1. If we get back -1, though, there is an error. > */ > if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, > - &select_generation, generation, s1->dinfo->devices, num_devices, > + &select_generation, generation, cur_dev.dinfo->devices, num_devices, > NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1) > errx(1, "%d %s", __LINE__, devstat_errbuf); > > return(1); > } > > + > +void > +dsgetinfo(struct statinfo* dev) > +{ > + switch (devstat_getdevs(NULL, dev)) { > + case -1: > + errx(1, "%s", devstat_errbuf); > + break; > + case 1: > + num_devices = dev->dinfo->numdevs; > + generation = dev->dinfo->generation; > + cmdkre("refresh", NULL); > + break; > + default: > + break; > + } > +} > + > int > dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1) > { > @@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode select_ > return(2); > } > return(1); > +} > + > + > +void > +dslabel(int maxdrives, int diskcol, int diskrow) > +{ > + int i, j; > + > + mvprintw(diskrow, diskcol, "Disks"); > + mvprintw(diskrow + 1, diskcol, "KB/t"); > + mvprintw(diskrow + 2, diskcol, "tps"); > + mvprintw(diskrow + 3, diskcol, "MB/s"); > + mvprintw(diskrow + 4, diskcol, "%%busy"); > + /* > + * For now, we don't support a fourth disk statistic. So there's > + * no point in providing a label for it. If someone can think of a > + * fourth useful disk statistic, there is room to add it. > + */ > + /* mvprintw(diskrow + 4, diskcol, " msps"); */ > + j = 0; > + for (i = 0; i < num_devices && j < maxdrives; i++) > + if (dev_select[i].selected) { > + char tmpstr[80]; > + sprintf(tmpstr, "%s%d", dev_select[i].device_name, > + dev_select[i].unit_number); > + mvprintw(diskrow, diskcol + 5 + 6 * j, > + " %5.5s", tmpstr); > + j++; > + } > +} > + > +static void > +dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then) > +{ > + long double transfers_per_second; > + long double kb_per_transfer, mb_per_second; > + long double elapsed_time, device_busy; > + int di; > + > + di = dev_select[dn].position; > + > + if (then != NULL) { > + /* Calculate relative to previous sample */ > + elapsed_time = now->snap_time - then->snap_time; > + } else { > + /* Calculate relative to device creation */ > + elapsed_time = now->snap_time - devstat_compute_etime( > + &now->dinfo->devices[di].creation_time, NULL); > + } > + > + if (devstat_compute_statistics(&now->dinfo->devices[di], then ? > + &then->dinfo->devices[di] : NULL, elapsed_time, > + DSM_KB_PER_TRANSFER, &kb_per_transfer, > + DSM_TRANSFERS_PER_SECOND, &transfers_per_second, > + DSM_MB_PER_SECOND, &mb_per_second, > + DSM_BUSY_PCT, &device_busy, > + DSM_NONE) != 0) > + errx(1, "%s", devstat_errbuf); > + > + lc = diskcol + lc * 6; > + putlongdouble(kb_per_transfer, diskrow + 1, lc, 5, 2, 0); > + putlongdouble(transfers_per_second, diskrow + 2, lc, 5, 0, 0); > + putlongdouble(mb_per_second, diskrow + 3, lc, 5, 2, 0); > + putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0); > +} > + > +static void > +dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then) > +{ > + dsshow2(diskcol, diskrow, dn, lc, now, then); > +} > + > +void > +dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct statinfo *then) > +{ > + int i, lc; > + > + for (i = 0, lc = 0; i < num_devices && lc < maxdrives; i++) > + if (dev_select[i].selected) > + dsshow3(diskcol, diskrow, i, ++lc, now, then); > } > > Modified: head/usr.bin/systat/devs.h > ============================================================================== > --- head/usr.bin/systat/devs.h Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/devs.h Tue Apr 2 14:01:03 2019 (r345804) > @@ -2,6 +2,7 @@ > * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > * > * Copyright (c) 1998 David E. O'Brien > + * 2015 Yoshihiro Ota > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -28,5 +29,18 @@ > * $FreeBSD$ > */ > > -int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *); > +#ifndef DEVS_H > +#define DEVS_H > + > +#include > + > +int dsinit(int); > +void dsgetinfo(struct statinfo *); > int dscmd(const char *, const char *, int, struct statinfo *); > + > +void dslabel(int, int, int); > +void dsshow(int, int, int, struct statinfo *, struct statinfo *); > + > +extern struct statinfo cur_dev, last_dev, run_dev; > + > +#endif > > Modified: head/usr.bin/systat/iostat.c > ============================================================================== > --- head/usr.bin/systat/iostat.c Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/iostat.c Tue Apr 2 14:01:03 2019 (r345804) > @@ -79,8 +79,6 @@ static const char sccsid[] = "@(#)iostat.c 8.1 (Berkel > #include "extern.h" > #include "devs.h" > > -struct statinfo cur, last; > - > static int linesperregion; > static double etime; > static int numbers = 0; /* default display bar graphs */ > @@ -111,17 +109,11 @@ closeiostat(WINDOW *w) > int > initiostat(void) > { > - if ((num_devices = devstat_getnumdevs(NULL)) < 0) > - return(0); > - > - cur.dinfo = calloc(1, sizeof(struct devinfo)); > - last.dinfo = calloc(1, sizeof(struct devinfo)); > - > /* > * This value for maxshowdevs (100) is bogus. I'm not sure exactly > * how to calculate it, though. > */ > - if (dsinit(100, &cur, &last, NULL) != 1) > + if (dsinit(7) != 1) > return(0); > > return(1); > @@ -133,17 +125,17 @@ fetchiostat(void) > struct devinfo *tmp_dinfo; > size_t len; > > - len = sizeof(cur.cp_time); > - if (sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0) > - || len != sizeof(cur.cp_time)) { > + len = sizeof(cur_dev.cp_time); > + if (sysctlbyname("kern.cp_time", &cur_dev.cp_time, &len, NULL, 0) > + || len != sizeof(cur_dev.cp_time)) { > perror("kern.cp_time"); > exit (1); > } > - tmp_dinfo = last.dinfo; > - last.dinfo = cur.dinfo; > - cur.dinfo = tmp_dinfo; > + tmp_dinfo = last_dev.dinfo; > + last_dev.dinfo = cur_dev.dinfo; > + cur_dev.dinfo = tmp_dinfo; > > - last.snap_time = cur.snap_time; > + last_dev.snap_time = cur_dev.snap_time; > > /* > * Here what we want to do is refresh our device stats. > @@ -152,7 +144,7 @@ fetchiostat(void) > * the selection process again, in case a device that we > * were previously displaying has gone away. > */ > - switch (devstat_getdevs(NULL, &cur)) { > + switch (devstat_getdevs(NULL, &cur_dev)) { > case -1: > errx(1, "%s", devstat_errbuf); > break; > @@ -162,8 +154,8 @@ fetchiostat(void) > default: > break; > } > - num_devices = cur.dinfo->numdevs; > - generation = cur.dinfo->generation; > + num_devices = cur_dev.dinfo->numdevs; > + generation = cur_dev.dinfo->generation; > > } > > @@ -260,11 +252,11 @@ showiostat(void) > long t; > int i, row, _col; > > -#define X(fld) t = cur.fld[i]; cur.fld[i] -= last.fld[i]; last.fld[i] = t > +#define X(fld) t = cur_dev.fld[i]; cur_dev.fld[i] -= last_dev.fld[i]; last_dev.fld[i] = t > etime = 0; > for(i = 0; i < CPUSTATES; i++) { > X(cp_time); > - etime += cur.cp_time[i]; > + etime += cur_dev.cp_time[i]; > } > if (etime == 0.0) > etime = 1.0; > @@ -313,10 +305,10 @@ devstats(int row, int _col, int dn) > > di = dev_select[dn].position; > > - busy_seconds = cur.snap_time - last.snap_time; > + busy_seconds = cur_dev.snap_time - last_dev.snap_time; > > - if (devstat_compute_statistics(&cur.dinfo->devices[di], > - &last.dinfo->devices[di], busy_seconds, > + if (devstat_compute_statistics(&cur_dev.dinfo->devices[di], > + &last_dev.dinfo->devices[di], busy_seconds, > DSM_KB_PER_TRANSFER, &kb_per_transfer, > DSM_TRANSFERS_PER_SECOND, &transfers_per_second, > DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0) > @@ -349,12 +341,12 @@ stat1(int row, int o) > > dtime = 0.0; > for (i = 0; i < CPUSTATES; i++) > - dtime += cur.cp_time[i]; > + dtime += cur_dev.cp_time[i]; > if (dtime == 0.0) > dtime = 1.0; > wmove(wnd, row, INSET); > #define CPUSCALE 0.5 > - histogram(100.0 * cur.cp_time[o] / dtime, 50, CPUSCALE); > + histogram(100.0 * cur_dev.cp_time[o] / dtime, 50, CPUSCALE); > } > > static void > @@ -388,7 +380,7 @@ cmdiostat(const char *cmd, const char *args) > numbers = 1; > else if (prefix(cmd, "bars")) > numbers = 0; > - else if (!dscmd(cmd, args, 100, &cur)) > + else if (!dscmd(cmd, args, 100, &cur_dev)) > return (0); > wclear(wnd); > labeliostat(); > > Modified: head/usr.bin/systat/swap.c > ============================================================================== > --- head/usr.bin/systat/swap.c Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/swap.c Tue Apr 2 14:01:03 2019 (r345804) > @@ -3,6 +3,7 @@ > * > * Copyright (c) 1980, 1992, 1993 > * The Regents of the University of California. All rights reserved. > + * Copyright (c) 2017 Yoshihiro Ota > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -55,6 +56,7 @@ static const char sccsid[] = "@(#)swap.c 8.3 (Berkeley > > #include "systat.h" > #include "extern.h" > +#include "devs.h" > > kvm_t *kd; > > @@ -137,13 +139,15 @@ initswap(void) > oulen = ulen; > > once = 1; > + > + dsinit(12); > + > return (1); > } > > void > fetchswap(void) > { > - > okvnsw = kvnsw; > if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) { > error("systat: kvm_getswapinfo failed"); > @@ -153,6 +157,15 @@ fetchswap(void) > odlen = dlen; > oulen = ulen; > calclens(); > + > + struct devinfo *tmp_dinfo; > + > + tmp_dinfo = last_dev.dinfo; > + last_dev.dinfo = cur_dev.dinfo; > + cur_dev.dinfo = tmp_dinfo; > + > + last_dev.snap_time = cur_dev.snap_time; > + dsgetinfo( &cur_dev ); > } > > void > @@ -178,6 +191,7 @@ labelswap(void) > name = kvmsw[i].ksw_devname; > mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name); > } > + dslabel(12, 0, 18); > } > > void > @@ -217,4 +231,5 @@ showswap(void) > waddch(wnd, 'X'); > wclrtoeol(wnd); > } > + dsshow(12, 0, 18, &cur_dev, &last_dev); > } > > Modified: head/usr.bin/systat/systat.h > ============================================================================== > --- head/usr.bin/systat/systat.h Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/systat.h Tue Apr 2 14:01:03 2019 (r345804) > @@ -68,3 +68,7 @@ extern int use_kvm; > #define NVAL(indx) namelist[(indx)].n_value > #define NPTR(indx) (void *)NVAL((indx)) > #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) > + > +extern void putint(int, int, int, int); > +extern void putfloat(double, int, int, int, int, int); > +extern void putlongdouble(long double, int, int, int, int, int); > > Modified: head/usr.bin/systat/vmstat.c > ============================================================================== > --- head/usr.bin/systat/vmstat.c Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/vmstat.c Tue Apr 2 14:01:03 2019 (r345804) > @@ -66,7 +66,6 @@ static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkel > #include > #include > #include > -#include > #include "systat.h" > #include "extern.h" > #include "devs.h" > @@ -125,7 +124,6 @@ static struct Info { > static u_long kmem_size; > static u_int v_page_count; > > -struct statinfo cur, last, run; > > #define total s.Total > #define nchtotal s.nchstats > @@ -137,13 +135,9 @@ enum divisor { IEC = 0, SI = HN_DIVISOR_1000 }; > static void allocinfo(struct Info *); > static void copyinfo(struct Info *, struct Info *); > static float cputime(int); > -static void dinfo(int, int, struct statinfo *, struct statinfo *); > static void do_putuint64(uint64_t, int, int, int, int); > static void getinfo(struct Info *); > -static void putint(int, int, int, int); > static void putuint64(uint64_t, int, int, int); > -static void putfloat(double, int, int, int, int, int); > -static void putlongdouble(long double, int, int, int, int, int); > static int ucount(void); > > static int ncpu; > @@ -209,18 +203,9 @@ initkre(void) > int i; > size_t sz; > > - if ((num_devices = devstat_getnumdevs(NULL)) < 0) { > - warnx("%s", devstat_errbuf); > + if (dsinit(MAXDRIVES) != 1) > return(0); > - } > > - cur.dinfo = calloc(1, sizeof(struct devinfo)); > - last.dinfo = calloc(1, sizeof(struct devinfo)); > - run.dinfo = calloc(1, sizeof(struct devinfo)); > - > - if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) > - return(0); > - > if (nintr == 0) { > if (sysctlbyname("hw.intrcnt", NULL, &sz, NULL, 0) == -1) { > error("sysctl(hw.intrcnt...) failed: %s", > @@ -371,27 +356,7 @@ labelkre(void) > mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); > mvprintw(NAMEIROW + 1, NAMEICOL, > " Calls hits %% hits %%"); > - mvprintw(DISKROW, DISKCOL, "Disks"); > - mvprintw(DISKROW + 1, DISKCOL, "KB/t"); > - mvprintw(DISKROW + 2, DISKCOL, "tps"); > - mvprintw(DISKROW + 3, DISKCOL, "MB/s"); > - mvprintw(DISKROW + 4, DISKCOL, "%%busy"); > - /* > - * For now, we don't support a fourth disk statistic. So there's > - * no point in providing a label for it. If someone can think of a > - * fourth useful disk statistic, there is room to add it. > - */ > - /* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ > - j = 0; > - for (i = 0; i < num_devices && j < MAXDRIVES; i++) > - if (dev_select[i].selected) { > - char tmpstr[80]; > - sprintf(tmpstr, "%s%d", dev_select[i].device_name, > - dev_select[i].unit_number); > - mvprintw(DISKROW, DISKCOL + 5 + 6 * j, > - " %5.5s", tmpstr); > - j++; > - } > + dslabel(MAXDRIVES, DISKCOL, DISKROW); > > for (i = 0; i < nintr; i++) { > if (intrloc[i] == 0) > @@ -401,7 +366,7 @@ labelkre(void) > } > > #define X(fld) {t=s.fld[i]; s.fld[i]-=s1.fld[i]; if(state==TIME) s1.fld[i]=t;} > -#define Q(fld) {t=cur.fld[i]; cur.fld[i]-=last.fld[i]; if(state==TIME) last.fld[i]=t;} > +#define Q(fld) {t=cur_dev.fld[i]; cur_dev.fld[i]-=last_dev.fld[i]; if(state==TIME) last_dev.fld[i]=t;} > #define Y(fld) {t = s.fld; s.fld -= s1.fld; if(state == TIME) s1.fld = t;} > #define Z(fld) {t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \ > if(state == TIME) s1.nchstats.fld = t;} > @@ -543,20 +508,17 @@ showkre(void) > PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); > PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); > PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); > - for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++) > - if (dev_select[i].selected) { > - switch(state) { > - case TIME: > - dinfo(i, ++lc, &cur, &last); > - break; > - case RUN: > - dinfo(i, ++lc, &cur, &run); > - break; > - case BOOT: > - dinfo(i, ++lc, &cur, NULL); > - break; > - } > - } > + switch(state) { > + case TIME: > + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); > + break; > + case RUN: > + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); > + break; > + case BOOT: > + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); > + break; > + } > putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7); > putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); > putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7); > @@ -582,14 +544,14 @@ cmdkre(const char *cmd, const char *args) > if (prefix(cmd, "run")) { > retval = 1; > copyinfo(&s2, &s1); > - switch (devstat_getdevs(NULL, &run)) { > + switch (devstat_getdevs(NULL, &run_dev)) { > case -1: > errx(1, "%s", devstat_errbuf); > break; > case 1: > - num_devices = run.dinfo->numdevs; > - generation = run.dinfo->generation; > - retval = dscmd("refresh", NULL, MAXDRIVES, &cur); > + num_devices = run_dev.dinfo->numdevs; > + generation = run_dev.dinfo->generation; > + retval = dscmd("refresh", NULL, MAXDRIVES, &cur_dev); > if (retval == 2) > labelkre(); > break; > @@ -612,14 +574,14 @@ cmdkre(const char *cmd, const char *args) > retval = 1; > if (state == RUN) { > getinfo(&s1); > - switch (devstat_getdevs(NULL, &run)) { > + switch (devstat_getdevs(NULL, &run_dev)) { > case -1: > errx(1, "%s", devstat_errbuf); > break; > case 1: > - num_devices = run.dinfo->numdevs; > - generation = run.dinfo->generation; > - retval = dscmd("refresh",NULL, MAXDRIVES, &cur); > + num_devices = run_dev.dinfo->numdevs; > + generation = run_dev.dinfo->generation; > + retval = dscmd("refresh",NULL, MAXDRIVES, &cur_dev); > if (retval == 2) > labelkre(); > break; > @@ -629,7 +591,7 @@ cmdkre(const char *cmd, const char *args) > } > return (retval); > } > - retval = dscmd(cmd, args, MAXDRIVES, &cur); > + retval = dscmd(cmd, args, MAXDRIVES, &cur_dev); > > if (retval == 2) > labelkre(); > @@ -667,7 +629,7 @@ cputime(int indx) > return (s.time[indx] * 100.0 / lt); > } > > -static void > +void > putint(int n, int l, int lc, int w) > { > > @@ -713,7 +675,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div > addstr(b); > } > > -static void > +void > putfloat(double f, int l, int lc, int w, int d, int nz) > { > int snr; > @@ -745,7 +707,7 @@ putfloat(double f, int l, int lc, int w, int d, int nz > addstr(b); > } > > -static void > +void > putlongdouble(long double f, int l, int lc, int w, int d, int nz) > { > int snr; > @@ -785,7 +747,7 @@ getinfo(struct Info *ls) > int mib[2]; > > GETSYSCTL("kern.cp_time", ls->time); > - GETSYSCTL("kern.cp_time", cur.cp_time); > + GETSYSCTL("kern.cp_time", cur_dev.cp_time); > GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch); > GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap); > GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall); > @@ -838,23 +800,12 @@ getinfo(struct Info *ls) > size != sizeof(ncpu)) > ncpu = 1; > > - tmp_dinfo = last.dinfo; > - last.dinfo = cur.dinfo; > - cur.dinfo = tmp_dinfo; > + tmp_dinfo = last_dev.dinfo; > + last_dev.dinfo = cur_dev.dinfo; > + cur_dev.dinfo = tmp_dinfo; > > - last.snap_time = cur.snap_time; > - switch (devstat_getdevs(NULL, &cur)) { > - case -1: > - errx(1, "%s", devstat_errbuf); > - break; > - case 1: > - num_devices = cur.dinfo->numdevs; > - generation = cur.dinfo->generation; > - cmdkre("refresh", NULL); > - break; > - default: > - break; > - } > + last_dev.snap_time = cur_dev.snap_time; > + dsgetinfo(&cur_dev); > } > > static void > @@ -880,39 +831,4 @@ copyinfo(struct Info *from, struct Info *to) > *to = *from; > > bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); > -} > - > -static void > -dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) > -{ > - long double transfers_per_second; > - long double kb_per_transfer, mb_per_second; > - long double elapsed_time, device_busy; > - int di; > - > - di = dev_select[dn].position; > - > - if (then != NULL) { > - /* Calculate relative to previous sample */ > - elapsed_time = now->snap_time - then->snap_time; > - } else { > - /* Calculate relative to device creation */ > - elapsed_time = now->snap_time - devstat_compute_etime( > - &now->dinfo->devices[di].creation_time, NULL); > - } > - > - if (devstat_compute_statistics(&now->dinfo->devices[di], then ? > - &then->dinfo->devices[di] : NULL, elapsed_time, > - DSM_KB_PER_TRANSFER, &kb_per_transfer, > - DSM_TRANSFERS_PER_SECOND, &transfers_per_second, > - DSM_MB_PER_SECOND, &mb_per_second, > - DSM_BUSY_PCT, &device_busy, > - DSM_NONE) != 0) > - errx(1, "%s", devstat_errbuf); > - > - lc = DISKCOL + lc * 6; > - putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); > - putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); > - putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); > - putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); > } > > Modified: head/usr.bin/systat/zarc.c > ============================================================================== > --- head/usr.bin/systat/zarc.c Tue Apr 2 13:59:04 2019 (r345803) > +++ head/usr.bin/systat/zarc.c Tue Apr 2 14:01:03 2019 (r345804) > @@ -1,6 +1,5 @@ > /*- > - * Copyright (c) 2014 > - * The Regents of the University of California. All rights reserved. > + * Copyright (c) 2014 - 2017 Yoshihiro Ota > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -33,11 +32,14 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +/* #include */ > #include > #include > +#include > > #include "systat.h" > #include "extern.h" > +#include "devs.h" > > struct zfield{ > uint64_t arcstats; > @@ -77,21 +79,23 @@ closezarc(WINDOW *w) > void > labelzarc(void) > { > + int row = 1; > wmove(wnd, 0, 0); wclrtoeol(wnd); > mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s", > "rate", "hits", "misses", "total hits", "total misses"); > -#define L(row, str) mvwprintw(wnd, row, 5, str); \ > +#define L(str) mvwprintw(wnd, row, 5, #str); \ > mvwprintw(wnd, row, 31, ":"); \ > - mvwprintw(wnd, row, 31+4, "%%") > - L(1, "arcstats"); > - L(2, "arcstats.demand_data"); > - L(3, "arcstats.demand_metadata"); > - L(4, "arcstats.prefetch_data"); > - L(5, "arcstats.prefetch_metadata"); > - L(6, "zfetchstats"); > - L(7, "arcstats.l2"); > - L(8, "vdev_cache_stats"); > + mvwprintw(wnd, row, 31+4, "%%"); ++row > + L(arcstats); > + L(arcstats.demand_data); > + L(arcstats.demand_metadata); > + L(arcstats.prefetch_data); > + L(arcstats.prefetch_metadata); > + L(zfetchstats); > + L(arcstats.l2); > + L(vdev_cache_stats); > #undef L > + dslabel(12, 0, 18); > } > > static int calc(uint64_t hits, uint64_t misses) > @@ -131,6 +135,7 @@ domode(struct zarcstats *delta, struct zarcstats *rate > void > showzarc(void) > { > + int row = 1; > struct zarcstats delta, rate; > > memset(&delta, 0, sizeof delta); > @@ -138,34 +143,37 @@ showzarc(void) > > domode(&delta, &rate); > > -#define DO(stat, row, col, fmt) \ > +#define DO(stat, col, fmt) \ > mvwprintw(wnd, row, col, fmt, stat) > -#define R(row, stat) DO(rate.hits.stat, row, 31+1, "%3"PRIu64) > -#define H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7"PRIu64); \ > - DO(curstat.hits.stat, row, 31+1+5+8+8, "%12"PRIu64) > -#define M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7"PRIu64); \ > - DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12"PRIu64) > -#define E(row, stat) R(row, stat); H(row, stat); M(row, stat); > - E(1, arcstats); > - E(2, arcstats_demand_data); > - E(3, arcstats_demand_metadata); > - E(4, arcstats_prefetch_data); > - E(5, arcstats_prefetch_metadata); > - E(6, zfetchstats); > - E(7, arcstats_l2); > - E(8, vdev_cache_stats); > +#define R(stat) DO(rate.hits.stat, 31+1, "%3"PRIu64) > +#define H(stat) DO(delta.hits.stat, 31+1+5, "%7"PRIu64); \ > + DO(curstat.hits.stat, 31+1+5+8+8, "%12"PRIu64) > +#define M(stat) DO(delta.misses.stat, 31+1+5+8, "%7"PRIu64); \ > + DO(curstat.misses.stat, 31+1+5+8+8+13, "%12"PRIu64) > +#define E(stat) R(stat); H(stat); M(stat); ++row > + E(arcstats); > + E(arcstats_demand_data); > + E(arcstats_demand_metadata); > + E(arcstats_prefetch_data); > + E(arcstats_prefetch_metadata); > + E(zfetchstats); > + E(arcstats_l2); > + E(vdev_cache_stats); > #undef DO > #undef E > #undef M > #undef H > #undef R > + dsshow(12, 0, 18, &cur_dev, &last_dev); > } > > int > initzarc(void) > { > + dsinit(12); > getinfo(&initstat); > curstat = oldstat = initstat; > + > return 1; > } > > @@ -178,6 +186,15 @@ resetzarc(void) > static void > getinfo(struct zarcstats *ls) > { > + struct devinfo *tmp_dinfo; > + > + tmp_dinfo = last_dev.dinfo; > + last_dev.dinfo = cur_dev.dinfo; > + cur_dev.dinfo = tmp_dinfo; > + > + last_dev.snap_time = cur_dev.snap_time; > + dsgetinfo( &cur_dev ); > + > size_t size = sizeof( ls->hits.arcstats ); > if ( sysctlbyname("kstat.zfs.misc.arcstats.hits", > &ls->hits.arcstats, &size, NULL, 0 ) != 0 ) > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-head@freebsd.org Tue Apr 2 14:25:28 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8A461568D2C; Tue, 2 Apr 2019 14:25:28 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from mailin.dlr.de (mailin.dlr.de [194.94.201.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailin.dlr.de", Issuer "DFN-Verein Global Issuing CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id C9FEE8EE34; Tue, 2 Apr 2019 14:25:27 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) IronPort-PHdr: =?us-ascii?q?9a23=3AwHJuaReRxIoDGSp1X+Ki7uT2lGMj4u6mDksu8p?= =?us-ascii?q?Mizoh2WeGdxc27bBeN2/xhgRfzUJnB7Loc0qyK6vmmATRLvMzJ8ChbNsAVD1?= =?us-ascii?q?ld0YRetjdjKfbNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHh?= =?us-ascii?q?LiKVg9fbytScbdgMutyu+95YDYbRlWizqhe7NyKwi9oRnMusUMjoZuN7s9xg?= =?us-ascii?q?HVrndUdOhbxX1kLk+Xkxrg+8u85pFu/zlMt/4768JMTaD2dLkkQLJFCzgrL3?= =?us-ascii?q?o779DxuxnZSguP6HocUmEInRdNHgPI8hL0UIrvvyXjruZy1zWUMsPwTbAvRD?= =?us-ascii?q?St9LxrRwPyiCcGLDE27mfagdFtga1BoRKhoxt/w5PIYIyQKfFzcL/Rcc8cSG?= =?us-ascii?q?FcRctaSTBPDZ2gYIsOF+oBPPhXr4/hp1sVsBCyARCgCP7zxjNUg3P727Ax3e?= =?us-ascii?q?Y8HgHcxAEuEdIAsG7KotvoNqgcUu61w6fHwjrfbvNbwiv95JTSfxw9vf2BR6?= =?us-ascii?q?x8fMzMwkcvDQPFiVCQpJTnMTyPzOQNr2mb5Pd9WOK1kWEnrRx+oiSyzcorio?= =?us-ascii?q?nGnJgVykzB9SVk3IY5P8a3SFRhbt6iDZRQqzqXOJZyQsM4WW1npTg1x6QAtJ?= =?us-ascii?q?WmciYKz5EnyATea/yBa4WI7AjjW/iPLjhjn3JqZaizhxGo8UivzOD3S8q60E?= =?us-ascii?q?5SoyZYjtXArG0B2h/c58SdV/dw8ESs1SyS2wzN8u1IPF44mK7BJ5I/zbM9lI?= =?us-ascii?q?AfvVnBEyL1gkn6kaGbe0Qi9+O18eroeK/mqYWZN4JsjwH+NbkhldKnDOQjNw?= =?us-ascii?q?gOQ3Cb+eOh1L3/5UH5QKtFjvkxkqTBvp7UI8oVqKG5DQFV1Ygt6BGxAS263N?= =?us-ascii?q?gGkncILUxIdAiGj4jvJ1HOOur3Ae2ijFSoijdn3e3JMaP5DpXMKHjMjqvhcK?= =?us-ascii?q?5g50JA0gY/0NNS6p1OBr0cLv/+WVX9uMHGAhMhNgy72efnCNFz1oMEXmKPB7?= =?us-ascii?q?eUPqHIvl+S+uIvJvSMZJMPtDvgMfgq/fjugmIlmVIGYKap2YEXZGqlEft4O0?= =?us-ascii?q?mZe2bjgs8dEWcWuQozVPfqiEOEUTJKfHayRb4z6ighB4KiCYfOXY6tgKaf0y?= =?us-ascii?q?ilBZJWfX1JBkqLEXfyeIWOQ+0MZz6KIs99jjwEUqCsS5Q/1RGorQP60KBnIf?= =?us-ascii?q?bN9i0Yq53szsV66vbdlREo6zN7Ed+S03qQQG1umWMIXTA21rhloUNh0leDzb?= =?us-ascii?q?R4g/tAGNxI/fNGTh42OoLbz+x/DtDyWx7BfsuXR1a8WdWrGj8xTsgvzNAQeE?= =?us-ascii?q?l9AMitggrE3yqwDL8fj6aLC4As8qLAw3jxIN5wxG3c26k5k1krWcVPNXe4ia?= =?us-ascii?q?Fh7AfTHJPGn1+el6aweqQWxDTN+3ubzWqSoEFYVxZ9Xr/bUn0EaEvWt8r26V?= =?us-ascii?q?3ZQL+1FLsrKAxBydSNKvgCVtq8p1xeWPb4JNmWT2urnHqrHheOjueGZZL2U0?= =?us-ascii?q?sH0Sj3M2RClBocqyW8OBA6Fxum9kLXFiBvXXj1akXg7aEqqHqhUk4cwRuHYk?= =?us-ascii?q?d62/yy4BFD1tKGTPZG/rsepCZpgS99Glqhl4bWAsCcohd9Oq9GaNUx/H9L0X?= =?us-ascii?q?ifuwErbc/oFLxrmlNLK1c/hEjpzRgiT9wYycU=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2FNAADzbqNc/wyKuAplGgEBAQEBAgE?= =?us-ascii?q?BAQEHAgEBAQGBZYJ5UWOZOCWYX4FbECMJAoQ+AoVfOBIBAQMBAQkBAwIBAQJ?= =?us-ascii?q?pHAyCOikBFE1rAQEBAQEBIwINZAMDOj8QCw4GJwtXBg6DKIF1D68thDEBCwF?= =?us-ascii?q?4hQEFCQGBJY1JgUSCXz6KJQOlVAcCgSiGTIQah3SLMw2IeINUjX0LjW5hgQM?= =?us-ascii?q?igVYzGiSCERiBE4I/iEyFQT2BAFuOEgGBHgEB?= X-IronPort-AV: E=Sophos;i="5.60,300,1549926000"; d="scan'208";a="15692344" Date: Tue, 2 Apr 2019 16:24:10 +0200 From: Harti Brandt X-X-Sender: brandt_h@KNOP-BEAGLE.kn.op.dlr.de Reply-To: Harti Brandt To: Baptiste Daroussin CC: "Andrey V. Elsukov" , , , Subject: Re: svn commit: r345797 - in head: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmpd lib/libbsnmp/libbsnmp usr.sbin/bsnmpd/bsnmpd In-Reply-To: <20190402134019.j325zduvwstcgz3s@ivaldir.net> Message-ID: References: <201904021250.x32Co13P053573@repo.freebsd.org> <20190402134019.j325zduvwstcgz3s@ivaldir.net> User-Agent: Alpine 2.21.9999 (BSF 287 2018-06-16) X-OpenPGP-Key: harti@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Rspamd-Queue-Id: C9FEE8EE34 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 14:25:29 -0000 On Tue, 2 Apr 2019, Baptiste Daroussin wrote: BD>On Tue, Apr 02, 2019 at 12:50:01PM +0000, Andrey V. Elsukov wrote: BD>> Author: ae BD>> Date: Tue Apr 2 12:50:01 2019 BD>> New Revision: 345797 BD>> URL: https://svnweb.freebsd.org/changeset/base/345797 BD>> BD>> Log: BD>> Add IPv6 transport for bsnmp. BD>> BD>> This patch adds a new table begemotSnmpdTransInetTable that uses the BD>> InetAddressType textual convention and can be used to create listening BD>> ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports BD>> future extension beyond UDP by adding a protocol identifier to the table BD>> index. In order to support this gensnmptree had to be modified. BD>> BD>> Submitted by: harti BD>> MFC after: 1 month BD>> Relnotes: yes BD>> Differential Revision: https://reviews.freebsd.org/D16654 BD>> BD>Jumping in this commit, maybe it is time to move bsnmpd out of contrib, given BD>that all the dev appears to only be in our own source tree right? Actually I have a private tree that has some more stuff in it than there is in the contrib tree in FreeBSD. I usually do modifications first in that tree, then I bring it to FreeBSD. If somebody commits modifications to FreeBSD I feed that back. One day I intend to put this into a public place. harti From owner-svn-src-head@freebsd.org Tue Apr 2 14:46:11 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D07E11569379; Tue, 2 Apr 2019 14:46:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BDC38F78A; Tue, 2 Apr 2019 14:46:11 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 67BE7277CE; Tue, 2 Apr 2019 14:46:11 +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 x32EkB19016546; Tue, 2 Apr 2019 14:46:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32EkBM7016545; Tue, 2 Apr 2019 14:46:11 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201904021446.x32EkBM7016545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 2 Apr 2019 14:46:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345805 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 345805 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8BDC38F78A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 14:46:12 -0000 Author: mav Date: Tue Apr 2 14:46:10 2019 New Revision: 345805 URL: https://svnweb.freebsd.org/changeset/base/345805 Log: Unify SCSI_STATUS_BUSY retry handling with other cases. - Do not retry if periph was invalidated. - Do not decrement retry_count if already zero. - Report action_string when applicable. MFC after: 2 weeks Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Tue Apr 2 14:01:03 2019 (r345804) +++ head/sys/cam/cam_periph.c Tue Apr 2 14:46:10 2019 (r345805) @@ -1513,6 +1513,7 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o int *openings, u_int32_t *relsim_flags, u_int32_t *timeout, u_int32_t *action, const char **action_string) { + struct cam_periph *periph; int error; switch (ccb->csio.scsi_status) { @@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o * Restart the queue after either another * command completes or a 1 second timeout. */ - if ((sense_flags & SF_RETRY_BUSY) != 0 || - (ccb->ccb_h.retry_count--) > 0) { + periph = xpt_path_periph(ccb->ccb_h.path); + if (periph->flags & CAM_PERIPH_INVALID) { + error = EIO; + *action_string = "Periph was invalidated"; + } else if ((sense_flags & SF_RETRY_BUSY) != 0 || + ccb->ccb_h.retry_count > 0) { + if ((sense_flags & SF_RETRY_BUSY) == 0) + ccb->ccb_h.retry_count--; error = ERESTART; *relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT | RELSIM_RELEASE_AFTER_CMDCMPLT; *timeout = 1000; } else { error = EIO; + *action_string = "Retries exhausted"; } break; case SCSI_STATUS_RESERV_CONFLICT: From owner-svn-src-head@freebsd.org Tue Apr 2 16:09:07 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84343156B82C; Tue, 2 Apr 2019 16:09:07 +0000 (UTC) (envelope-from mike@reifenberger.com) Received: from app.eeeit.de (app.eeeit.de [188.68.43.176]) (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 024CE6B9AF; Tue, 2 Apr 2019 16:09:07 +0000 (UTC) (envelope-from mike@reifenberger.com) Received: from [100.92.110.33] (ip-109-41-195-17.web.vodafone.de [109.41.195.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mike@reifenberger.com) by app.eeeit.de (Postfix) with ESMTPSA id 8778C597A9; Tue, 2 Apr 2019 18:09:05 +0200 (CEST) Date: Tue, 02 Apr 2019 18:09:10 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> References: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: svn commit: r345804 - head/usr.bin/systat To: rgrimes@freebsd.org, "Rodney W. Grimes" , Michael Reifenberger CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Michael Message-ID: X-Rspamd-Queue-Id: 024CE6B9AF X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.92 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.92)[-0.921,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 16:09:07 -0000 Hi, Am 2=2E April 2019 16:08:17 MESZ schrieb "Rodney W=2E Grimes" : >> Author: mr >> Date: Tue Apr 2 14:01:03 2019 >> New Revision: 345804 >> URL: https://svnweb=2Efreebsd=2Eorg/changeset/base/345804 >>=20 >> Log: >> systat -zarc to display disk activities like -vm >> =20 >> PR: 213310 >> Submitted by: ota >> MFH: 4 weeks > >? MFC: Yes, indeed=2E > >> Differential Revision: https://reviews=2Efreebsd=2Eorg/D18726 >>=20 >> Modified: >> head/usr=2Ebin/systat/devs=2Ec >> head/usr=2Ebin/systat/devs=2Eh >> head/usr=2Ebin/systat/iostat=2Ec >> head/usr=2Ebin/systat/swap=2Ec >> head/usr=2Ebin/systat/systat=2Eh >> head/usr=2Ebin/systat/vmstat=2Ec >> head/usr=2Ebin/systat/zarc=2Ec >>=20 >> Modified: head/usr=2Ebin/systat/devs=2Ec >> >=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/usr=2Ebin/systat/devs=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/devs=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -2,6 +2,7 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> * >> * Copyright (c) 1998 Kenneth D=2E Merry=2E >> + * 2015 Yoshihiro Ota >> * All rights reserved=2E > > >Can we get in contact with Yoshihiro Ota about his >copyright statements, and correcting this to make >it clear that it is Kenneth D=2E Merry that is asserting >"All rights reserved" and if Ota does nor does not wish to assert >"All rights reserved"=2E > >As committed this makes a grey area on Kenneth's assertion, >also leaving out the word copyright on Yoshihiro's line is a bit iffy=2E > >I am only commenting once, this issue appears several times=2E >We can go back out to D18726 to discuss it if need be=2E > You could add a comment in the PR too, I intended to keep it open until MF= C >> * >> * Redistribution and use in source and binary forms, with or >without >> @@ -69,7 +70,6 @@ static const char sccsid[] =3D "@(#)disks=2Ec 8=2E1 >(Berkele >> #include >> =20 >> #include >> -#include >> #include >> #include >> #include >> @@ -84,6 +84,8 @@ typedef enum { >> DS_MATCHTYPE_PATTERN >> } last_match_type; >> =20 >> +struct statinfo cur_dev, last_dev, run_dev; >> + >> last_match_type last_type; >> struct device_selection *dev_select; >> long generation; >> @@ -101,10 +103,8 @@ static int dsselect(const char *args, >devstat_select_m >> int maxshowdevs, struct statinfo *s1); >> =20 >> int >> -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 >__unused, >> - struct statinfo *s3 __unused) >> +dsinit(int maxshowdevs) >> { >> - >> /* >> * Make sure that the userland devstat version matches the kernel >> * devstat version=2E If not, exit and print a message informing >> @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> if (devstat_checkversion(NULL) < 0) >> errx(1, "%s", devstat_errbuf); >> =20 >> + if( cur_dev=2Edinfo ) // init was alreay ran >> + return(1); >> + >> + if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) { >> + warnx("%s", devstat_errbuf); >> + return(0); >> + } >> + >> + cur_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + last_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + run_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + >> generation =3D 0; >> num_devices =3D 0; >> num_selected =3D 0; >> @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> select_generation =3D 0; >> last_type =3D DS_MATCHTYPE_NONE; >> =20 >> - if (devstat_getdevs(NULL, s1) =3D=3D -1) >> + if (devstat_getdevs(NULL, &cur_dev) =3D=3D -1) >> errx(1, "%s", devstat_errbuf); >> =20 >> - num_devices =3D s1->dinfo->numdevs; >> - generation =3D s1->dinfo->generation; >> + num_devices =3D cur_dev=2Edinfo->numdevs; >> + generation =3D cur_dev=2Edinfo->generation; >> =20 >> dev_select =3D NULL; >> =20 >> @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> * or 1=2E If we get back -1, though, there is an error=2E >> */ >> if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, >> - &select_generation, generation, s1->dinfo->devices, >num_devices, >> + &select_generation, generation, cur_dev=2Edinfo->devices, >num_devices, >> NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) =3D=3D -1) >> errx(1, "%d %s", __LINE__, devstat_errbuf); >> =20 >> return(1); >> } >> =20 >> + >> +void >> +dsgetinfo(struct statinfo* dev) >> +{ >> + switch (devstat_getdevs(NULL, dev)) { >> + case -1: >> + errx(1, "%s", devstat_errbuf); >> + break; >> + case 1: >> + num_devices =3D dev->dinfo->numdevs; >> + generation =3D dev->dinfo->generation; >> + cmdkre("refresh", NULL); >> + break; >> + default: >> + break; >> + } >> +} >> + >> int >> dscmd(const char *cmd, const char *args, int maxshowdevs, struct >statinfo *s1) >> { >> @@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode >select_ >> return(2); >> } >> return(1); >> +} >> + >> + >> +void >> +dslabel(int maxdrives, int diskcol, int diskrow) >> +{ >> + int i, j; >> + >> + mvprintw(diskrow, diskcol, "Disks"); >> + mvprintw(diskrow + 1, diskcol, "KB/t"); >> + mvprintw(diskrow + 2, diskcol, "tps"); >> + mvprintw(diskrow + 3, diskcol, "MB/s"); >> + mvprintw(diskrow + 4, diskcol, "%%busy"); >> + /* >> + * For now, we don't support a fourth disk statistic=2E So there's >> + * no point in providing a label for it=2E If someone can think of a >> + * fourth useful disk statistic, there is room to add it=2E >> + */ >> + /* mvprintw(diskrow + 4, diskcol, " msps"); */ >> + j =3D 0; >> + for (i =3D 0; i < num_devices && j < maxdrives; i++) >> + if (dev_select[i]=2Eselected) { >> + char tmpstr[80]; >> + sprintf(tmpstr, "%s%d", dev_select[i]=2Edevice_name, >> + dev_select[i]=2Eunit_number); >> + mvprintw(diskrow, diskcol + 5 + 6 * j, >> + " %5=2E5s", tmpstr); >> + j++; >> + } >> +} >> + >> +static void >> +dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo >*now, struct statinfo *then) >> +{ >> + long double transfers_per_second; >> + long double kb_per_transfer, mb_per_second; >> + long double elapsed_time, device_busy; >> + int di; >> + >> + di =3D dev_select[dn]=2Eposition; >> + >> + if (then !=3D NULL) { >> + /* Calculate relative to previous sample */ >> + elapsed_time =3D now->snap_time - then->snap_time; >> + } else { >> + /* Calculate relative to device creation */ >> + elapsed_time =3D now->snap_time - devstat_compute_etime( >> + &now->dinfo->devices[di]=2Ecreation_time, NULL); >> + } >> + >> + if (devstat_compute_statistics(&now->dinfo->devices[di], then ? >> + &then->dinfo->devices[di] : NULL, elapsed_time, >> + DSM_KB_PER_TRANSFER, &kb_per_transfer, >> + DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> + DSM_MB_PER_SECOND, &mb_per_second, >> + DSM_BUSY_PCT, &device_busy, >> + DSM_NONE) !=3D 0) >> + errx(1, "%s", devstat_errbuf); >> + >> + lc =3D diskcol + lc * 6; >> + putlongdouble(kb_per_transfer, diskrow + 1, lc, 5, 2, 0); >> + putlongdouble(transfers_per_second, diskrow + 2, lc, 5, 0, 0); >> + putlongdouble(mb_per_second, diskrow + 3, lc, 5, 2, 0); >> + putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0); >> +} >> + >> +static void >> +dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo >*now, struct statinfo *then) >> +{ >> + dsshow2(diskcol, diskrow, dn, lc, now, then); >> +} >> + >> +void >> +dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo >*now, struct statinfo *then) >> +{ >> + int i, lc; >> + >> + for (i =3D 0, lc =3D 0; i < num_devices && lc < maxdrives; i++) >> + if (dev_select[i]=2Eselected) >> + dsshow3(diskcol, diskrow, i, ++lc, now, then); >> } >>=20 >> Modified: head/usr=2Ebin/systat/devs=2Eh >> >=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/usr=2Ebin/systat/devs=2Eh Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/devs=2Eh Tue Apr 2 14:01:03 2019 (r345804) >> @@ -2,6 +2,7 @@ >> * SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> * >> * Copyright (c) 1998 David E=2E O'Brien >> + * 2015 Yoshihiro Ota >> * All rights reserved=2E >> * >> * Redistribution and use in source and binary forms, with or >without >> @@ -28,5 +29,18 @@ >> * $FreeBSD$ >> */ >> =20 >> -int dsinit(int, struct statinfo *, struct statinfo *, struct >statinfo *); >> +#ifndef DEVS_H >> +#define DEVS_H >> + >> +#include >> + >> +int dsinit(int); >> +void dsgetinfo(struct statinfo *); >> int dscmd(const char *, const char *, int, struct statinfo *); >> + >> +void dslabel(int, int, int); >> +void dsshow(int, int, int, struct statinfo *, struct statinfo *); >> + >> +extern struct statinfo cur_dev, last_dev, run_dev; >> + >> +#endif >>=20 >> Modified: head/usr=2Ebin/systat/iostat=2Ec >> >=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/usr=2Ebin/systat/iostat=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/iostat=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -79,8 +79,6 @@ static const char sccsid[] =3D "@(#)iostat=2Ec 8=2E1 >(Berkel >> #include "extern=2Eh" >> #include "devs=2Eh" >> =20 >> -struct statinfo cur, last; >> - >> static int linesperregion; >> static double etime; >> static int numbers =3D 0; /* default display bar graphs */ >> @@ -111,17 +109,11 @@ closeiostat(WINDOW *w) >> int >> initiostat(void) >> { >> - if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) >> - return(0); >> - >> - cur=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - last=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - >> /* >> * This value for maxshowdevs (100) is bogus=2E I'm not sure exactly >> * how to calculate it, though=2E >> */ >> - if (dsinit(100, &cur, &last, NULL) !=3D 1) >> + if (dsinit(7) !=3D 1) >> return(0); >> =20 >> return(1); >> @@ -133,17 +125,17 @@ fetchiostat(void) >> struct devinfo *tmp_dinfo; >> size_t len; >> =20 >> - len =3D sizeof(cur=2Ecp_time); >> - if (sysctlbyname("kern=2Ecp_time", &cur=2Ecp_time, &len, NULL, 0) >> - || len !=3D sizeof(cur=2Ecp_time)) { >> + len =3D sizeof(cur_dev=2Ecp_time); >> + if (sysctlbyname("kern=2Ecp_time", &cur_dev=2Ecp_time, &len, NULL, 0) >> + || len !=3D sizeof(cur_dev=2Ecp_time)) { >> perror("kern=2Ecp_time"); >> exit (1); >> } >> - tmp_dinfo =3D last=2Edinfo; >> - last=2Edinfo =3D cur=2Edinfo; >> - cur=2Edinfo =3D tmp_dinfo; >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> =20 >> - last=2Esnap_time =3D cur=2Esnap_time; >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> =20 >> /* >> * Here what we want to do is refresh our device stats=2E >> @@ -152,7 +144,7 @@ fetchiostat(void) >> * the selection process again, in case a device that we >> * were previously displaying has gone away=2E >> */ >> - switch (devstat_getdevs(NULL, &cur)) { >> + switch (devstat_getdevs(NULL, &cur_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> @@ -162,8 +154,8 @@ fetchiostat(void) >> default: >> break; >> } >> - num_devices =3D cur=2Edinfo->numdevs; >> - generation =3D cur=2Edinfo->generation; >> + num_devices =3D cur_dev=2Edinfo->numdevs; >> + generation =3D cur_dev=2Edinfo->generation; >> =20 >> } >> =20 >> @@ -260,11 +252,11 @@ showiostat(void) >> long t; >> int i, row, _col; >> =20 >> -#define X(fld) t =3D cur=2Efld[i]; cur=2Efld[i] -=3D last=2Efld[i]; >last=2Efld[i] =3D t >> +#define X(fld) t =3D cur_dev=2Efld[i]; cur_dev=2Efld[i] -=3D >last_dev=2Efld[i]; last_dev=2Efld[i] =3D t >> etime =3D 0; >> for(i =3D 0; i < CPUSTATES; i++) { >> X(cp_time); >> - etime +=3D cur=2Ecp_time[i]; >> + etime +=3D cur_dev=2Ecp_time[i]; >> } >> if (etime =3D=3D 0=2E0) >> etime =3D 1=2E0; >> @@ -313,10 +305,10 @@ devstats(int row, int _col, int dn) >> =20 >> di =3D dev_select[dn]=2Eposition; >> =20 >> - busy_seconds =3D cur=2Esnap_time - last=2Esnap_time; >> + busy_seconds =3D cur_dev=2Esnap_time - last_dev=2Esnap_time; >> =20 >> - if (devstat_compute_statistics(&cur=2Edinfo->devices[di], >> - &last=2Edinfo->devices[di], busy_seconds, >> + if (devstat_compute_statistics(&cur_dev=2Edinfo->devices[di], >> + &last_dev=2Edinfo->devices[di], busy_seconds, >> DSM_KB_PER_TRANSFER, &kb_per_transfer, >> DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) !=3D 0) >> @@ -349,12 +341,12 @@ stat1(int row, int o) >> =20 >> dtime =3D 0=2E0; >> for (i =3D 0; i < CPUSTATES; i++) >> - dtime +=3D cur=2Ecp_time[i]; >> + dtime +=3D cur_dev=2Ecp_time[i]; >> if (dtime =3D=3D 0=2E0) >> dtime =3D 1=2E0; >> wmove(wnd, row, INSET); >> #define CPUSCALE 0=2E5 >> - histogram(100=2E0 * cur=2Ecp_time[o] / dtime, 50, CPUSCALE); >> + histogram(100=2E0 * cur_dev=2Ecp_time[o] / dtime, 50, CPUSCALE); >> } >> =20 >> static void >> @@ -388,7 +380,7 @@ cmdiostat(const char *cmd, const char *args) >> numbers =3D 1; >> else if (prefix(cmd, "bars")) >> numbers =3D 0; >> - else if (!dscmd(cmd, args, 100, &cur)) >> + else if (!dscmd(cmd, args, 100, &cur_dev)) >> return (0); >> wclear(wnd); >> labeliostat(); >>=20 >> Modified: head/usr=2Ebin/systat/swap=2Ec >> >=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/usr=2Ebin/systat/swap=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/swap=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -3,6 +3,7 @@ >> * >> * Copyright (c) 1980, 1992, 1993 >> * The Regents of the University of California=2E All rights >reserved=2E >> + * Copyright (c) 2017 Yoshihiro Ota >> * >> * Redistribution and use in source and binary forms, with or >without >> * modification, are permitted provided that the following >conditions >> @@ -55,6 +56,7 @@ static const char sccsid[] =3D "@(#)swap=2Ec 8=2E3 >(Berkeley >> =20 >> #include "systat=2Eh" >> #include "extern=2Eh" >> +#include "devs=2Eh" >> =20 >> kvm_t *kd; >> =20 >> @@ -137,13 +139,15 @@ initswap(void) >> oulen =3D ulen; >> =20 >> once =3D 1; >> + >> + dsinit(12); >> + >> return (1); >> } >> =20 >> void >> fetchswap(void) >> { >> - >> okvnsw =3D kvnsw; >> if ((kvnsw =3D kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) { >> error("systat: kvm_getswapinfo failed"); >> @@ -153,6 +157,15 @@ fetchswap(void) >> odlen =3D dlen; >> oulen =3D ulen; >> calclens(); >> + >> + struct devinfo *tmp_dinfo; >> + >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> + >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo( &cur_dev ); >> } >> =20 >> void >> @@ -178,6 +191,7 @@ labelswap(void) >> name =3D kvmsw[i]=2Eksw_devname; >> mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name); >> } >> + dslabel(12, 0, 18); >> } >> =20 >> void >> @@ -217,4 +231,5 @@ showswap(void) >> waddch(wnd, 'X'); >> wclrtoeol(wnd); >> } >> + dsshow(12, 0, 18, &cur_dev, &last_dev); >> } >>=20 >> Modified: head/usr=2Ebin/systat/systat=2Eh >> >=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/usr=2Ebin/systat/systat=2Eh Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/systat=2Eh Tue Apr 2 14:01:03 2019 (r345804) >> @@ -68,3 +68,7 @@ extern int use_kvm; >> #define NVAL(indx) namelist[(indx)]=2En_value >> #define NPTR(indx) (void *)NVAL((indx)) >> #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) >> + >> +extern void putint(int, int, int, int); >> +extern void putfloat(double, int, int, int, int, int); >> +extern void putlongdouble(long double, int, int, int, int, int); >>=20 >> Modified: head/usr=2Ebin/systat/vmstat=2Ec >> >=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/usr=2Ebin/systat/vmstat=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/vmstat=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -66,7 +66,6 @@ static const char sccsid[] =3D "@(#)vmstat=2Ec 8=2E2 >(Berkel >> #include >> #include >> #include >> -#include >> #include "systat=2Eh" >> #include "extern=2Eh" >> #include "devs=2Eh" >> @@ -125,7 +124,6 @@ static struct Info { >> static u_long kmem_size; >> static u_int v_page_count; >> =20 >> -struct statinfo cur, last, run; >> =20 >> #define total s=2ETotal >> #define nchtotal s=2Enchstats >> @@ -137,13 +135,9 @@ enum divisor { IEC =3D 0, SI =3D HN_DIVISOR_1000 }= ; >> static void allocinfo(struct Info *); >> static void copyinfo(struct Info *, struct Info *); >> static float cputime(int); >> -static void dinfo(int, int, struct statinfo *, struct statinfo *); >> static void do_putuint64(uint64_t, int, int, int, int); >> static void getinfo(struct Info *); >> -static void putint(int, int, int, int); >> static void putuint64(uint64_t, int, int, int); >> -static void putfloat(double, int, int, int, int, int); >> -static void putlongdouble(long double, int, int, int, int, int); >> static int ucount(void); >> =20 >> static int ncpu; >> @@ -209,18 +203,9 @@ initkre(void) >> int i; >> size_t sz; >> =20 >> - if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) { >> - warnx("%s", devstat_errbuf); >> + if (dsinit(MAXDRIVES) !=3D 1) >> return(0); >> - } >> =20 >> - cur=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - last=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - run=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - >> - if (dsinit(MAXDRIVES, &cur, &last, &run) !=3D 1) >> - return(0); >> - >> if (nintr =3D=3D 0) { >> if (sysctlbyname("hw=2Eintrcnt", NULL, &sz, NULL, 0) =3D=3D -1) { >> error("sysctl(hw=2Eintrcnt=2E=2E=2E) failed: %s", >> @@ -371,27 +356,7 @@ labelkre(void) >> mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); >> mvprintw(NAMEIROW + 1, NAMEICOL, >> " Calls hits %% hits %%"); >> - mvprintw(DISKROW, DISKCOL, "Disks"); >> - mvprintw(DISKROW + 1, DISKCOL, "KB/t"); >> - mvprintw(DISKROW + 2, DISKCOL, "tps"); >> - mvprintw(DISKROW + 3, DISKCOL, "MB/s"); >> - mvprintw(DISKROW + 4, DISKCOL, "%%busy"); >> - /* >> - * For now, we don't support a fourth disk statistic=2E So there's >> - * no point in providing a label for it=2E If someone can think of a >> - * fourth useful disk statistic, there is room to add it=2E >> - */ >> - /* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ >> - j =3D 0; >> - for (i =3D 0; i < num_devices && j < MAXDRIVES; i++) >> - if (dev_select[i]=2Eselected) { >> - char tmpstr[80]; >> - sprintf(tmpstr, "%s%d", dev_select[i]=2Edevice_name, >> - dev_select[i]=2Eunit_number); >> - mvprintw(DISKROW, DISKCOL + 5 + 6 * j, >> - " %5=2E5s", tmpstr); >> - j++; >> - } >> + dslabel(MAXDRIVES, DISKCOL, DISKROW); >> =20 >> for (i =3D 0; i < nintr; i++) { >> if (intrloc[i] =3D=3D 0) >> @@ -401,7 +366,7 @@ labelkre(void) >> } >> =20 >> #define X(fld) {t=3Ds=2Efld[i]; s=2Efld[i]-=3Ds1=2Efld[i]; if(state=3D= =3DTIME) >s1=2Efld[i]=3Dt;} >> -#define Q(fld) {t=3Dcur=2Efld[i]; cur=2Efld[i]-=3Dlast=2Efld[i]; >if(state=3D=3DTIME) last=2Efld[i]=3Dt;} >> +#define Q(fld) {t=3Dcur_dev=2Efld[i]; cur_dev=2Efld[i]-=3Dlast_dev=2Ef= ld[i]; >if(state=3D=3DTIME) last_dev=2Efld[i]=3Dt;} >> #define Y(fld) {t =3D s=2Efld; s=2Efld -=3D s1=2Efld; if(state =3D=3D = TIME) s1=2Efld >=3D t;} >> #define Z(fld) {t =3D s=2Enchstats=2Efld; s=2Enchstats=2Efld -=3D >s1=2Enchstats=2Efld; \ >> if(state =3D=3D TIME) s1=2Enchstats=2Efld =3D t;} >> @@ -543,20 +508,17 @@ showkre(void) >> PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); >> PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); >> PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); >> - for (i =3D 0, lc =3D 0; i < num_devices && lc < MAXDRIVES; i++) >> - if (dev_select[i]=2Eselected) { >> - switch(state) { >> - case TIME: >> - dinfo(i, ++lc, &cur, &last); >> - break; >> - case RUN: >> - dinfo(i, ++lc, &cur, &run); >> - break; >> - case BOOT: >> - dinfo(i, ++lc, &cur, NULL); >> - break; >> - } >> - } >> + switch(state) { >> + case TIME: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); >> + break; >> + case RUN: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); >> + break; >> + case BOOT: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); >> + break; >> + } >> putint(s=2Enumdirtybuffers, VNSTATROW, VNSTATCOL, 7); >> putint(s=2Edesiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); >> putint(s=2Enumvnodes, VNSTATROW + 2, VNSTATCOL, 7); >> @@ -582,14 +544,14 @@ cmdkre(const char *cmd, const char *args) >> if (prefix(cmd, "run")) { >> retval =3D 1; >> copyinfo(&s2, &s1); >> - switch (devstat_getdevs(NULL, &run)) { >> + switch (devstat_getdevs(NULL, &run_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> case 1: >> - num_devices =3D run=2Edinfo->numdevs; >> - generation =3D run=2Edinfo->generation; >> - retval =3D dscmd("refresh", NULL, MAXDRIVES, &cur); >> + num_devices =3D run_dev=2Edinfo->numdevs; >> + generation =3D run_dev=2Edinfo->generation; >> + retval =3D dscmd("refresh", NULL, MAXDRIVES, &cur_dev); >> if (retval =3D=3D 2) >> labelkre(); >> break; >> @@ -612,14 +574,14 @@ cmdkre(const char *cmd, const char *args) >> retval =3D 1; >> if (state =3D=3D RUN) { >> getinfo(&s1); >> - switch (devstat_getdevs(NULL, &run)) { >> + switch (devstat_getdevs(NULL, &run_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> case 1: >> - num_devices =3D run=2Edinfo->numdevs; >> - generation =3D run=2Edinfo->generation; >> - retval =3D dscmd("refresh",NULL, MAXDRIVES, &cur); >> + num_devices =3D run_dev=2Edinfo->numdevs; >> + generation =3D run_dev=2Edinfo->generation; >> + retval =3D dscmd("refresh",NULL, MAXDRIVES, &cur_dev); >> if (retval =3D=3D 2) >> labelkre(); >> break; >> @@ -629,7 +591,7 @@ cmdkre(const char *cmd, const char *args) >> } >> return (retval); >> } >> - retval =3D dscmd(cmd, args, MAXDRIVES, &cur); >> + retval =3D dscmd(cmd, args, MAXDRIVES, &cur_dev); >> =20 >> if (retval =3D=3D 2) >> labelkre(); >> @@ -667,7 +629,7 @@ cputime(int indx) >> return (s=2Etime[indx] * 100=2E0 / lt); >> } >> =20 >> -static void >> +void >> putint(int n, int l, int lc, int w) >> { >> =20 >> @@ -713,7 +675,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, >int div >> addstr(b); >> } >> =20 >> -static void >> +void >> putfloat(double f, int l, int lc, int w, int d, int nz) >> { >> int snr; >> @@ -745,7 +707,7 @@ putfloat(double f, int l, int lc, int w, int d, >int nz >> addstr(b); >> } >> =20 >> -static void >> +void >> putlongdouble(long double f, int l, int lc, int w, int d, int nz) >> { >> int snr; >> @@ -785,7 +747,7 @@ getinfo(struct Info *ls) >> int mib[2]; >> =20 >> GETSYSCTL("kern=2Ecp_time", ls->time); >> - GETSYSCTL("kern=2Ecp_time", cur=2Ecp_time); >> + GETSYSCTL("kern=2Ecp_time", cur_dev=2Ecp_time); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_swtch", ls->v_swtch); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_trap", ls->v_trap); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_syscall", ls->v_syscall); >> @@ -838,23 +800,12 @@ getinfo(struct Info *ls) >> size !=3D sizeof(ncpu)) >> ncpu =3D 1; >> =20 >> - tmp_dinfo =3D last=2Edinfo; >> - last=2Edinfo =3D cur=2Edinfo; >> - cur=2Edinfo =3D tmp_dinfo; >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> =20 >> - last=2Esnap_time =3D cur=2Esnap_time; >> - switch (devstat_getdevs(NULL, &cur)) { >> - case -1: >> - errx(1, "%s", devstat_errbuf); >> - break; >> - case 1: >> - num_devices =3D cur=2Edinfo->numdevs; >> - generation =3D cur=2Edinfo->generation; >> - cmdkre("refresh", NULL); >> - break; >> - default: >> - break; >> - } >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo(&cur_dev); >> } >> =20 >> static void >> @@ -880,39 +831,4 @@ copyinfo(struct Info *from, struct Info *to) >> *to =3D *from; >> =20 >> bcopy(from->intrcnt, to->intrcnt =3D intrcnt, nintr * sizeof (int)); >> -} >> - >> -static void >> -dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) >> -{ >> - long double transfers_per_second; >> - long double kb_per_transfer, mb_per_second; >> - long double elapsed_time, device_busy; >> - int di; >> - >> - di =3D dev_select[dn]=2Eposition; >> - >> - if (then !=3D NULL) { >> - /* Calculate relative to previous sample */ >> - elapsed_time =3D now->snap_time - then->snap_time; >> - } else { >> - /* Calculate relative to device creation */ >> - elapsed_time =3D now->snap_time - devstat_compute_etime( >> - &now->dinfo->devices[di]=2Ecreation_time, NULL); >> - } >> - >> - if (devstat_compute_statistics(&now->dinfo->devices[di], then ? >> - &then->dinfo->devices[di] : NULL, elapsed_time, >> - DSM_KB_PER_TRANSFER, &kb_per_transfer, >> - DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> - DSM_MB_PER_SECOND, &mb_per_second, >> - DSM_BUSY_PCT, &device_busy, >> - DSM_NONE) !=3D 0) >> - errx(1, "%s", devstat_errbuf); >> - >> - lc =3D DISKCOL + lc * 6; >> - putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); >> - putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); >> - putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); >> - putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); >> } >>=20 >> Modified: head/usr=2Ebin/systat/zarc=2Ec >> >=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/usr=2Ebin/systat/zarc=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/zarc=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -1,6 +1,5 @@ >> /*- >> - * Copyright (c) 2014 >> - * The Regents of the University of California=2E All rights >reserved=2E >> + * Copyright (c) 2014 - 2017 Yoshihiro Ota >> * >> * Redistribution and use in source and binary forms, with or >without >> * modification, are permitted provided that the following >conditions >> @@ -33,11 +32,14 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> =20 >> +/* #include */ >> #include >> #include >> +#include >> =20 >> #include "systat=2Eh" >> #include "extern=2Eh" >> +#include "devs=2Eh" >> =20 >> struct zfield{ >> uint64_t arcstats; >> @@ -77,21 +79,23 @@ closezarc(WINDOW *w) >> void >> labelzarc(void) >> { >> + int row =3D 1; >> wmove(wnd, 0, 0); wclrtoeol(wnd); >> mvwprintw(wnd, 0, 31+1, "%4=2E4s %7=2E7s %7=2E7s %12=2E12s %12=2E12s"= , >> "rate", "hits", "misses", "total hits", "total misses"); >> -#define L(row, str) mvwprintw(wnd, row, 5, str); \ >> +#define L(str) mvwprintw(wnd, row, 5, #str); \ >> mvwprintw(wnd, row, 31, ":"); \ >> - mvwprintw(wnd, row, 31+4, "%%") >> - L(1, "arcstats"); >> - L(2, "arcstats=2Edemand_data"); >> - L(3, "arcstats=2Edemand_metadata"); >> - L(4, "arcstats=2Eprefetch_data"); >> - L(5, "arcstats=2Eprefetch_metadata"); >> - L(6, "zfetchstats"); >> - L(7, "arcstats=2El2"); >> - L(8, "vdev_cache_stats"); >> + mvwprintw(wnd, row, 31+4, "%%"); ++row >> + L(arcstats); >> + L(arcstats=2Edemand_data); >> + L(arcstats=2Edemand_metadata); >> + L(arcstats=2Eprefetch_data); >> + L(arcstats=2Eprefetch_metadata); >> + L(zfetchstats); >> + L(arcstats=2El2); >> + L(vdev_cache_stats); >> #undef L >> + dslabel(12, 0, 18); >> } >> =20 >> static int calc(uint64_t hits, uint64_t misses) >> @@ -131,6 +135,7 @@ domode(struct zarcstats *delta, struct zarcstats >*rate >> void >> showzarc(void) >> { >> + int row =3D 1; >> struct zarcstats delta, rate; >> =20 >> memset(&delta, 0, sizeof delta); >> @@ -138,34 +143,37 @@ showzarc(void) >> =20 >> domode(&delta, &rate); >> =20 >> -#define DO(stat, row, col, fmt) \ >> +#define DO(stat, col, fmt) \ >> mvwprintw(wnd, row, col, fmt, stat) >> -#define R(row, stat) DO(rate=2Ehits=2Estat, row, 31+1, "%3"PRIu64) >> -#define H(row, stat) DO(delta=2Ehits=2Estat, row, 31+1+5, "%7"PRIu64);= \ >> - DO(curstat=2Ehits=2Estat, row, 31+1+5+8+8, "%12"PRIu64) >> -#define M(row, stat) DO(delta=2Emisses=2Estat, row, 31+1+5+8, >"%7"PRIu64); \ >> - DO(curstat=2Emisses=2Estat, row, 31+1+5+8+8+13, "%12"PRIu64) >> -#define E(row, stat) R(row, stat); H(row, stat); M(row, stat);=20 >> - E(1, arcstats); >> - E(2, arcstats_demand_data); >> - E(3, arcstats_demand_metadata); >> - E(4, arcstats_prefetch_data); >> - E(5, arcstats_prefetch_metadata); >> - E(6, zfetchstats); >> - E(7, arcstats_l2); >> - E(8, vdev_cache_stats); >> +#define R(stat) DO(rate=2Ehits=2Estat, 31+1, "%3"PRIu64) >> +#define H(stat) DO(delta=2Ehits=2Estat, 31+1+5, "%7"PRIu64); \ >> + DO(curstat=2Ehits=2Estat, 31+1+5+8+8, "%12"PRIu64) >> +#define M(stat) DO(delta=2Emisses=2Estat, 31+1+5+8, "%7"PRIu64); \ >> + DO(curstat=2Emisses=2Estat, 31+1+5+8+8+13, "%12"PRIu64) >> +#define E(stat) R(stat); H(stat); M(stat); ++row >> + E(arcstats); >> + E(arcstats_demand_data); >> + E(arcstats_demand_metadata); >> + E(arcstats_prefetch_data); >> + E(arcstats_prefetch_metadata); >> + E(zfetchstats); >> + E(arcstats_l2); >> + E(vdev_cache_stats); >> #undef DO >> #undef E >> #undef M >> #undef H >> #undef R >> + dsshow(12, 0, 18, &cur_dev, &last_dev); >> } >> =20 >> int >> initzarc(void) >> { >> + dsinit(12); >> getinfo(&initstat); >> curstat =3D oldstat =3D initstat; >> + >> return 1; >> } >> =20 >> @@ -178,6 +186,15 @@ resetzarc(void) >> static void >> getinfo(struct zarcstats *ls) >> { >> + struct devinfo *tmp_dinfo; >> + >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> + >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo( &cur_dev ); >> + >> size_t size =3D sizeof( ls->hits=2Earcstats ); >> if ( sysctlbyname("kstat=2Ezfs=2Emisc=2Earcstats=2Ehits", >> &ls->hits=2Earcstats, &size, NULL, 0 ) !=3D 0 ) >>=20 >>=20 Gru=C3=9F ---=20 Michael From owner-svn-src-head@freebsd.org Tue Apr 2 16:43:45 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8879A156C5F9; Tue, 2 Apr 2019 16:43:45 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3C4A6CDF8; Tue, 2 Apr 2019 16:43:44 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x62e.google.com with SMTP id b65so6545229plb.6; Tue, 02 Apr 2019 09:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FwFRc1sFMTLcvAX8/iIRPvWp8m8kbm8OLl/pgECRbHY=; b=iUEoSJEwSNIGia+36XL1KpMBKJPU9vO2gKtNuncvW4JRtZ4fH31oMcGke4iFjdFPd/ SHlzB87BnMAac+KxWlnZxf4UrKM1MACl6apOVxrQevWQX8hKWAFTILs80401k/tdDese +yzcKM/Q2ge/wwulO1UItUJi83vsXR9ptDwE7LGkQou1Hi4NILnDkxrF6VhAcEmpvYNs T1pd/8wKVUT50HmB1Guws2ZjZXNrqryTBb4yQCiVLoT8c8zWcm9qqIIGRdGILMqxFOif D3ZFfFDxqPZD6BZ29mgTxEzO9TI7ZYB1ykHge9o33W5MbpB6UsV8PYRRJFnxRSLyMwIj j0Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FwFRc1sFMTLcvAX8/iIRPvWp8m8kbm8OLl/pgECRbHY=; b=qbyA+hnZUA5mTYyS5hJ1D4MSb6+zi3a1T0TcE40oWgMzpXzeRu5c5IqUaPT6CMqpYY mZvApExUH25XzvNVmadL0bH+co3jaCTmptHMEJuIJYTb8Dhg9mqSiCnTQI9yra3BkWi1 j8VAvD/Xe1bYiC//73bZnUBFlVGoFDoTVlBu0rQVNBtUJe37/H5FcOEbq9aM6fzO9YGg jcM+iUSVUWAddIuIGUlgFd2UYdrv05dtXJAaleyu5PXUWQBWcJWmdEBKA0J26CAn7PCH Ff8Gfy2VInbg5FbL2oCN6HHgGvKz09pwwB0cTNRMFuvBnsX2a9MZAGuqCUCmzo2Ta/Ub z+Rw== X-Gm-Message-State: APjAAAUJK3I6lHC8AclED9mDOtRJEsdeobpXrAxfV9Jq+vihuz5/PY93 cGGQpYd2qSQBFd1Uz4r8qCxOdCSY X-Google-Smtp-Source: APXvYqzXg8Q79LGNiFkW0QlNvrvgPKwbPk28JclRnfK1Eiw9FdRDpcUfjfC0XxAhSwjI0jYWc+niHw== X-Received: by 2002:a17:902:e391:: with SMTP id ch17mr12235729plb.196.1554223423451; Tue, 02 Apr 2019 09:43:43 -0700 (PDT) Received: from ?IPv6:2607:fb90:837c:f605:f5ef:10c5:4773:983b? ([2607:fb90:837c:f605:f5ef:10c5:4773:983b]) by smtp.gmail.com with ESMTPSA id k131sm22742165pfc.183.2019.04.02.09.43.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 09:43:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: svn commit: r345805 - head/sys/cam From: Enji Cooper X-Mailer: iPhone Mail (16E227) In-Reply-To: <201904021446.x32EkBM7016545@repo.freebsd.org> Date: Tue, 2 Apr 2019 09:43:40 -0700 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <201904021446.x32EkBM7016545@repo.freebsd.org> To: Alexander Motin X-Rspamd-Queue-Id: F3C4A6CDF8 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.946,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 16:43:45 -0000 Hi Alexander, > On Apr 2, 2019, at 07:46, Alexander Motin wrote: >=20 > Author: mav > Date: Tue Apr 2 14:46:10 2019 > New Revision: 345805 > URL: https://svnweb.freebsd.org/changeset/base/345805 >=20 > Log: > Unify SCSI_STATUS_BUSY retry handling with other cases. >=20 > - Do not retry if periph was invalidated. > - Do not decrement retry_count if already zero. > - Report action_string when applicable. >=20 > MFC after: 2 weeks >=20 > Modified: > head/sys/cam/cam_periph.c >=20 > Modified: head/sys/cam/cam_periph.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/cam_periph.c Tue Apr 2 14:01:03 2019 (r345804) > +++ head/sys/cam/cam_periph.c Tue Apr 2 14:46:10 2019 (r345805) > @@ -1513,6 +1513,7 @@ camperiphscsistatuserror(union ccb *ccb, union ccb *= *o > int *openings, u_int32_t *relsim_flags, > u_int32_t *timeout, u_int32_t *action, const char **action_string) > { > + struct cam_periph *periph; > int error; >=20 > switch (ccb->csio.scsi_status) { > @@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb= **o > * Restart the queue after either another > * command completes or a 1 second timeout. > */ > - if ((sense_flags & SF_RETRY_BUSY) !=3D 0 || > - (ccb->ccb_h.retry_count--) > 0) { > + periph =3D xpt_path_periph(ccb->ccb_h.path); > + if (periph->flags & CAM_PERIPH_INVALID) { Is there a reason why this style is inconsistent with the other part of the c= hange by not explicitly testing for =E2=80=9C!=3D 0=E2=80=9D? Thanks! -Enji= From owner-svn-src-head@freebsd.org Tue Apr 2 17:10:18 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAB25156D233; Tue, 2 Apr 2019 17:10:17 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A1AA6DCB1; Tue, 2 Apr 2019 17:10:17 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-yb1-xb2a.google.com with SMTP id c15so3051166ybk.8; Tue, 02 Apr 2019 10:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:openpgp:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QAVznllPxUJaoHMesKMsb51jVykyFZ/zJQC818DhIHw=; b=hNMQV6q0hUoO1vstKnrfEZBfeKYfEYp0fxlH5FZ8842CVCIsjmP0fS6iyMuBc4FuvE wq8Yg9Bg8Zw87sT7NwHAMWBD8nETd5PVbDUl0iuF6oZczbgs9z5VUtBdoKDBzGFhvnY+ fnYGdlbIiDwm0J9w1F39g//t8uXjbpZv2mBGHQKJrKMtXz0/YkZCn8tRPDrOpiYS0r6N uqhfokUaOe2IEsdqmSyoUeKR64uIMYd7zl7aUHdRymswt4lvw1C+UmO9ejtkJkJq4e3T 9TNjPF6GAJg6CUcp8Y+bYFw9XK3W0ZI4dRSozna1raqCXqr63CXZ45zyKC9ILLjnY3XA l1XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:openpgp :autocrypt:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=QAVznllPxUJaoHMesKMsb51jVykyFZ/zJQC818DhIHw=; b=qXXHtm6OSHJURryBqakV3IHycXTHkZQuECQ9oII3dYnaLwx9cxQl3AxZUBMhbQZvls /x4ANyekMCK3w7PVErcHRsgndiuys/HghDkApEUvGl+hxS/jjRcFCnMVh8q/6gidgg1i 7DW/0xMgcWHRkVBd91EHt3H3+/16Chne2B4OX4VPUsip07e4Vtprmp9OW+O6SOVzAn+W fK0BqZzykPtxwiSB1LRb8kgtqTKoqdAyPzzMqL8hv32ZqkiIJxrvOU+zdot7bIo2lIG4 FNh0uVNv8O5DnnizuoE4ajIDhX5YbCHIxjmDGI6w19FhU2U7t3jjMv/rnBKwAy5Jb52e KJbg== X-Gm-Message-State: APjAAAWNjI5sFHbpdd6L+EYb8vswBud50oiTvL7sfEoOgHjCQGMlvqr7 0NTWheSxrmjQ4eCeatuHUKL3pOSs X-Google-Smtp-Source: APXvYqylUlwz3p8fNqWCjxOpLWT5I0cq6EQLbF261gZ44022cEEJsaZ1uUrBVpBUXl1OeFnZFAW65w== X-Received: by 2002:a25:1643:: with SMTP id 64mr3030423ybw.363.1554225016401; Tue, 02 Apr 2019 10:10:16 -0700 (PDT) Received: from mavoffice.ixsystems.com ([12.189.233.129]) by smtp.gmail.com with ESMTPSA id 193sm5431062ywf.22.2019.04.02.10.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 10:10:15 -0700 (PDT) Sender: Alexander Motin Subject: Re: svn commit: r345805 - head/sys/cam To: Enji Cooper Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201904021446.x32EkBM7016545@repo.freebsd.org> From: Alexander Motin Openpgp: preference=signencrypt Autocrypt: addr=mav@FreeBSD.org; prefer-encrypt=mutual; keydata= xsBNBFOzxAwBCADkPrax0pI2W/ig0CK9nRJJwsHitAGEZ2HZiFEuti+6/4UVxj81yr4ak/4g 9bKUyC7rMEAp/ZHNhd+MFCPAAcHPvtovnfykqE/vuosCS3wlSLloix2iKVLks0CwbLHGAyne 46lTQW74Xl/33c3W1Z6d8jD9gVFT/xaVzZ0U9xdzOmsYAZaAj4ki0tuxO9F7L+ct9grRe7iP g8t9hai7BL4ee3VRwk2JXnKb7UvBiVITKYWKz1jRvZIrjPokgEcCLOSlv7x/1kjuFnj3xWZU 7HSFFT8J93epBbrSSCsYsppIk2fZH41kaaFXsMQfTPH8wkeM6qwrvOh4HiQM08R+9tThABEB AAHNIUFsZXhhbmRlciBNb3RpbiA8bWF2QEZyZWVCU0Qub3JnPsLAlwQTAQoAQQIbAwULCQgH AwUVCgkICwUWAwIBAAIeAQIXgAIZARYhBOmM88TmnMPNDledVYMYw5VbqyJ/BQJZYMKuBQkN McyiAAoJEIMYw5VbqyJ/tuUIAOG3ONOSNYqjK4eTZ1TVh9jdUBAhWk5nhDFnODN49Wj0AbYm 7aIqy8O1hnCDSZG5LttjSAo3UfXJZDKQM0BLb0gpRMBnAYqO6tdolLNqAbPGJBnGoPjsh24y 6KcbDaNnis+lD4GwPXwQM+92wZGhCUFElPV9NciZGVS65TNIgk7X+yEjjhD1MSWKKijZ1r9Z zIt4OzUTxxNOvzdlABZS88nNRdJkatOQJPmFdd1mpP6UzTNCiLUo1pIqOEtJgvVVDYq5WHY6 tciWWYdmZG/tIBexJmv2mV2OLVjXR6ZeKmntVH14H72/wRHJuYHQC+r5SVRcWWayrThsY6jZ Yr4+raTOwE0EU7PEDAEIAOZgWf2cJIu+58IzP2dkXE/urj3tr4OqrB/yHGWUf71Lz6D0Fi6Z AXgDtmcFLGPfMyWuLAvSM+xmoguk7zC4hRBYvQycmIhuqBq1jO1Wp/Z+lpoPM/1cDYLn8Flv mI/c40MhUZh345DA4jYWWaZNjQHUWVQ1fPf595vdVVMPT/abE8E5DaF6fSkRmqFTmfYRkfbt 3ytU8NdUapDcJVY7cEP2nJBVNZPnOIObR/ZIgSxjjrG5o34yXoqeup8JvwEv+/NylzzuyXEZ R1EdEIzQ/a1nh/0j4NXtzZEqKW4aTWlmSqb6wN8jh1OSOOqkYsfnE3nfxcZbxi4IRoNQYlm5 9R8AEQEAAcLAZQQYAQoADwUCU7PEDAIbDAUJBaOagAAKCRCDGMOVW6sif7FRB/4k9y/GaGqU fcJiXdQHRAKHCUvbKMFgeEDHOg33qx+POS2Ah85/PXVa2jYBldCZDmYc+zl48aEMd163a7s3 0gJaB7CYElwxlKUk6c+5gwoYIJuJJzSzW0JzSD5ch7RIRxbfxrKdsiHrUW8AeduZWzlK6VaW RmWILgLmxfLdhEVFWxbr99GSeVFZaZwn6tl/8CvBcgYoARvJvl0V5zS1akQfEISYkwL9EfUI W44EOHranL5qUXkedXBYp6fRsooGrIimfwYxaC8FbXhk3FMgMjDMRiVq4POHo1iGeYETsUrL NM6184E25gPVtX2fb3RhM8Xh6BkwCZ6ZYbQ+AcD4F/cKwsB8BBgBCgAmAhsMFiEE6YzzxOac w80OV51VgxjDlVurIn8FAllgwtgFCQ0xzMwACgkQgxjDlVurIn9OqAf9FAcKWS95wTTbraXA qg/+bQyHgjlMtGCgkmfxLsbUGeqiFgmSIuoDrF7q6sYPs6p00CXXZRuuNZt0lX7O95re8mgz gxm5iJisZpdbHMVepYlw/AxT2wCHwxGCEe64Lm+A9vjlOd+3D3/6fSLwZ9WFCE6p6lQZ1CDg 09xe+JKSgC+KDqmn0tzGKyfSCuhRAq3XkZyxL1hxBaDeP0eeKlzoy7jXodf3wVvXXc0cmpza B5McuRHK4EU6jIioHo30YqPM4AjPHGxV2X1N6/Aayungzj9EXNZtKCxs6dsTvjniWa5VkZ9F 4SOdSbxEen1DZRYpeWnd7GVmO86n+5USkKCXPg== Message-ID: <56a5de69-fa77-8d34-6743-b74d0db05eec@FreeBSD.org> Date: Tue, 2 Apr 2019 13:10:15 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6A1AA6DCB1 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 17:10:18 -0000 Hi. On 02.04.2019 12:43, Enji Cooper wrote: >> On Apr 2, 2019, at 07:46, Alexander Motin wrote: >> @@ -1595,14 +1596,21 @@ camperiphscsistatuserror(union ccb *ccb, union ccb **o >> * Restart the queue after either another >> * command completes or a 1 second timeout. >> */ >> - if ((sense_flags & SF_RETRY_BUSY) != 0 || >> - (ccb->ccb_h.retry_count--) > 0) { >> + periph = xpt_path_periph(ccb->ccb_h.path); >> + if (periph->flags & CAM_PERIPH_INVALID) { > > Is there a reason why this style is inconsistent with the other part of the change by not explicitly testing for “!= 0”? Not really, I've just copied this chunk from other place where it was this way. Bug I generally prefer more compact code where possible, and I don't see style(9) saying it is bad to do so here. But if it hurts somebody, I see no problem to change it. -- Alexander Motin From owner-svn-src-head@freebsd.org Tue Apr 2 17:51:29 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78211156E35F; Tue, 2 Apr 2019 17:51:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 184716F756; Tue, 2 Apr 2019 17:51:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E78B21784; Tue, 2 Apr 2019 17:51:28 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32HpSIb014695; Tue, 2 Apr 2019 17:51:28 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32HpS8T014694; Tue, 2 Apr 2019 17:51:28 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201904021751.x32HpS8T014694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 2 Apr 2019 17:51:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345806 - head/contrib/llvm/tools/clang/lib/CodeGen X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/contrib/llvm/tools/clang/lib/CodeGen X-SVN-Commit-Revision: 345806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 184716F756 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 17:51:29 -0000 Author: dim Date: Tue Apr 2 17:51:28 2019 New Revision: 345806 URL: https://svnweb.freebsd.org/changeset/base/345806 Log: Pull in r357362 from upstream clang trunk (by David Chisnall): [objc-gnustep] Use .init_array not .ctors when requested. This doesn't make a difference most of the time but FreeBSD/ARM doesn't run anything in the .ctors array. This should help with updating the libobjc2 port for armv7. Requested by: theraven Upstream PR: https://github.com/gnustep/libobjc2/issues/83 MFC after: 3 days Modified: head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp Modified: head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp ============================================================================== --- head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp Tue Apr 2 14:46:10 2019 (r345805) +++ head/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp Tue Apr 2 17:51:28 2019 (r345806) @@ -1519,7 +1519,12 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { if (CGM.getTriple().isOSBinFormatCOFF()) InitVar->setSection(".CRT$XCLz"); else - InitVar->setSection(".ctors"); + { + if (CGM.getCodeGenOpts().UseInitArray) + InitVar->setSection(".init_array"); + else + InitVar->setSection(".ctors"); + } InitVar->setVisibility(llvm::GlobalValue::HiddenVisibility); InitVar->setComdat(TheModule.getOrInsertComdat(".objc_ctor")); CGM.addUsedGlobal(InitVar); From owner-svn-src-head@freebsd.org Tue Apr 2 18:01:55 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DF08156E881; Tue, 2 Apr 2019 18:01:55 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C17A56FF04; Tue, 2 Apr 2019 18:01:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B8E91A7D; Tue, 2 Apr 2019 18:01:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32I1su1019440; Tue, 2 Apr 2019 18:01:54 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32I1sxX019439; Tue, 2 Apr 2019 18:01:54 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201904021801.x32I1sxX019439@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 2 Apr 2019 18:01:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345807 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 345807 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C17A56FF04 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:01:55 -0000 Author: dim Date: Tue Apr 2 18:01:54 2019 New Revision: 345807 URL: https://svnweb.freebsd.org/changeset/base/345807 Log: Fix regression in top(1) after r344381, causing informational messages to no longer be displayed. This was because the reimplementation of setup_buffer() did not copy the previous contents into any reallocated buffer. Reported by: James Wright PR: 236947 MFC after: 3 days Modified: head/usr.bin/top/display.c Modified: head/usr.bin/top/display.c ============================================================================== --- head/usr.bin/top/display.c Tue Apr 2 17:51:28 2019 (r345806) +++ head/usr.bin/top/display.c Tue Apr 2 18:01:54 2019 (r345807) @@ -1347,7 +1347,8 @@ i_uptime(struct timeval *bt, time_t *tod) static char * setup_buffer(char *buffer, int addlen) { - size_t len; + size_t len, old_len; + char *new_buffer; setup_buffer_bufsiz = screen_width; if (setup_buffer_bufsiz < SETUPBUFFER_MIN_SCREENWIDTH) @@ -1355,13 +1356,18 @@ setup_buffer(char *buffer, int addlen) setup_buffer_bufsiz = SETUPBUFFER_MIN_SCREENWIDTH; } - free(buffer); len = setup_buffer_bufsiz + addlen + SETUPBUFFER_REQUIRED_ADDBUFSIZ; - buffer = calloc(len, sizeof(char)); - if (buffer == NULL) + new_buffer = calloc(len, sizeof(char)); + if (new_buffer == NULL) { errx(4, "can't allocate sufficient memory"); } + if (buffer != NULL) + { + old_len = strlen(buffer); + memcpy(new_buffer, buffer, old_len < len - 1 ? old_len : len - 1); + free(buffer); + } - return buffer; + return new_buffer; } From owner-svn-src-head@freebsd.org Tue Apr 2 18:50:37 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20A4D156FF44; Tue, 2 Apr 2019 18:50:37 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BCA9371F56; Tue, 2 Apr 2019 18:50:36 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F78721D8; Tue, 2 Apr 2019 18:50:33 +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 x32IoXEm041898; Tue, 2 Apr 2019 18:50:33 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32IoXKC041897; Tue, 2 Apr 2019 18:50:33 GMT (envelope-from np@FreeBSD.org) Message-Id: <201904021850.x32IoXKC041897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 2 Apr 2019 18:50:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345810 - head/sys/dev/cxgbe/common X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe/common X-SVN-Commit-Revision: 345810 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BCA9371F56 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.985,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:50:37 -0000 Author: np Date: Tue Apr 2 18:50:33 2019 New Revision: 345810 URL: https://svnweb.freebsd.org/changeset/base/345810 Log: cxgbe(4): Add a flag to indicate that bits in interrupt cause but not in interrupt enable are not fatal. The firmware sets up all the interrupt enables based on run time configuration, which means the information in the enables is more accurate than what's compiled into the driver. This change also allows the fatal bits to be updated without any changes in the driver in some cases. MFC after: 1 week Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/common/t4_hw.c Modified: head/sys/dev/cxgbe/common/t4_hw.c ============================================================================== --- head/sys/dev/cxgbe/common/t4_hw.c Tue Apr 2 18:44:01 2019 (r345809) +++ head/sys/dev/cxgbe/common/t4_hw.c Tue Apr 2 18:50:33 2019 (r345810) @@ -3960,11 +3960,13 @@ struct intr_action { bool (*action)(struct adapter *, int, bool); }; +#define NONFATAL_IF_DISABLED 1 struct intr_info { const char *name; /* name of the INT_CAUSE register */ int cause_reg; /* INT_CAUSE register */ int enable_reg; /* INT_ENABLE register */ u32 fatal; /* bits that are fatal */ + int flags; /* hints */ const struct intr_details *details; const struct intr_action *actions; }; @@ -3983,14 +3985,18 @@ intr_alert_char(u32 cause, u32 enable, u32 fatal) static void t4_show_intr_info(struct adapter *adap, const struct intr_info *ii, u32 cause) { - u32 enable, leftover; + u32 enable, fatal, leftover; const struct intr_details *details; char alert; enable = t4_read_reg(adap, ii->enable_reg); - alert = intr_alert_char(cause, enable, ii->fatal); + if (ii->flags & NONFATAL_IF_DISABLED) + fatal = ii->fatal & t4_read_reg(adap, ii->enable_reg); + else + fatal = ii->fatal; + alert = intr_alert_char(cause, enable, fatal); CH_ALERT(adap, "%c %s 0x%x = 0x%08x, E 0x%08x, F 0x%08x\n", - alert, ii->name, ii->cause_reg, cause, enable, ii->fatal); + alert, ii->name, ii->cause_reg, cause, enable, fatal); leftover = cause; for (details = ii->details; details && details->mask != 0; details++) { @@ -4013,30 +4019,40 @@ static bool t4_handle_intr(struct adapter *adap, const struct intr_info *ii, u32 additional_cause, bool verbose) { - u32 cause; - bool fatal; + u32 cause, fatal; + bool rc; const struct intr_action *action; /* read and display cause. */ cause = t4_read_reg(adap, ii->cause_reg); if (verbose || cause != 0) t4_show_intr_info(adap, ii, cause); - fatal = (cause & ii->fatal) != 0; + /* + * The top level interrupt cause is a bit special and we need to ignore + * the bits that are not in the enable. Note that we did display them + * above in t4_show_intr_info but will not clear them. + */ + if (ii->cause_reg == A_PL_INT_CAUSE) + cause &= t4_read_reg(adap, ii->enable_reg); + fatal = cause & ii->fatal; + if (fatal != 0 && ii->flags & NONFATAL_IF_DISABLED) + fatal &= t4_read_reg(adap, ii->enable_reg); cause |= additional_cause; if (cause == 0) return (false); + rc = fatal != 0; for (action = ii->actions; action && action->mask != 0; action++) { if (!(action->mask & cause)) continue; - fatal |= (action->action)(adap, action->arg, verbose); + rc |= (action->action)(adap, action->arg, verbose); } /* clear */ t4_write_reg(adap, ii->cause_reg, cause); (void)t4_read_reg(adap, ii->cause_reg); - return (fatal); + return (rc); } /* @@ -4057,6 +4073,7 @@ static bool pcie_intr_handler(struct adapter *adap, in .cause_reg = A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS, .enable_reg = A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_INTERRUPT_ENABLE, .fatal = F_RFTP | F_RCCP | F_RCIP | F_RPCP | F_RNPP, + .flags = 0, .details = sysbus_intr_details, .actions = NULL, }; @@ -4078,6 +4095,7 @@ static bool pcie_intr_handler(struct adapter *adap, in .enable_reg = A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_INTERRUPT_ENABLE, .fatal = F_TPCP | F_TNPP | F_TFTP | F_TCAP | F_TCIP | F_RCAP | F_OTDD | F_RDPE | F_TDUE, + .flags = 0, .details = pcie_port_intr_details, .actions = NULL, }; @@ -4152,7 +4170,8 @@ static bool pcie_intr_handler(struct adapter *adap, in .name = "PCIE_INT_CAUSE", .cause_reg = A_PCIE_INT_CAUSE, .enable_reg = A_PCIE_INT_ENABLE, - .fatal = 0, + .fatal = 0xffffffff, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; @@ -4162,10 +4181,8 @@ static bool pcie_intr_handler(struct adapter *adap, in fatal |= t4_handle_intr(adap, &sysbus_intr_info, 0, verbose); fatal |= t4_handle_intr(adap, &pcie_port_intr_info, 0, verbose); - pcie_intr_info.fatal = 0x3fffffc0; pcie_intr_info.details = pcie_intr_details; } else { - pcie_intr_info.fatal = is_t5(adap) ? 0xbfffff40 : 0x9fffff40; pcie_intr_info.details = t5_pcie_intr_details; } fatal |= t4_handle_intr(adap, &pcie_intr_info, 0, verbose); @@ -4188,6 +4205,7 @@ static bool tp_intr_handler(struct adapter *adap, int .cause_reg = A_TP_INT_CAUSE, .enable_reg = A_TP_INT_ENABLE, .fatal = 0x7fffffff, + .flags = NONFATAL_IF_DISABLED, .details = tp_intr_details, .actions = NULL, }; @@ -4205,6 +4223,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE1, .enable_reg = A_SGE_INT_ENABLE1, .fatal = 0xffffffff, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; @@ -4213,6 +4232,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE2, .enable_reg = A_SGE_INT_ENABLE2, .fatal = 0xffffffff, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; @@ -4292,6 +4312,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE3, .enable_reg = A_SGE_INT_ENABLE3, .fatal = F_ERR_CPL_EXCEED_IQE_SIZE, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -4300,6 +4321,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE4, .enable_reg = A_SGE_INT_ENABLE4, .fatal = 0, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -4308,6 +4330,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE5, .enable_reg = A_SGE_INT_ENABLE5, .fatal = 0xffffffff, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; @@ -4316,6 +4339,7 @@ static bool sge_intr_handler(struct adapter *adap, int .cause_reg = A_SGE_INT_CAUSE6, .enable_reg = A_SGE_INT_ENABLE6, .fatal = 0, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -4398,11 +4422,12 @@ static bool cim_intr_handler(struct adapter *adap, int { F_PREFDROPINT, "CIM control register prefetch drop" }, { 0} }; - struct intr_info cim_host_intr_info = { + static const struct intr_info cim_host_intr_info = { .name = "CIM_HOST_INT_CAUSE", .cause_reg = A_CIM_HOST_INT_CAUSE, .enable_reg = A_CIM_HOST_INT_ENABLE, - .fatal = 0, + .fatal = 0x007fffe6, + .flags = NONFATAL_IF_DISABLED, .details = cim_host_intr_details, .actions = cim_host_intr_actions, }; @@ -4453,6 +4478,7 @@ static bool cim_intr_handler(struct adapter *adap, int .cause_reg = A_CIM_HOST_UPACC_INT_CAUSE, .enable_reg = A_CIM_HOST_UPACC_INT_ENABLE, .fatal = 0x3fffeeff, + .flags = NONFATAL_IF_DISABLED, .details = cim_host_upacc_intr_details, .actions = NULL, }; @@ -4461,6 +4487,7 @@ static bool cim_intr_handler(struct adapter *adap, int .cause_reg = MYPF_REG(A_CIM_PF_HOST_INT_CAUSE), .enable_reg = MYPF_REG(A_CIM_PF_HOST_INT_ENABLE), .fatal = 0, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -4485,12 +4512,6 @@ static bool cim_intr_handler(struct adapter *adap, int } fatal = false; - if (is_t4(adap)) - cim_host_intr_info.fatal = 0x001fffe2; - else if (is_t5(adap)) - cim_host_intr_info.fatal = 0x007dffe2; - else - cim_host_intr_info.fatal = 0x007dffe6; fatal |= t4_handle_intr(adap, &cim_host_intr_info, 0, verbose); fatal |= t4_handle_intr(adap, &cim_host_upacc_intr_info, 0, verbose); fatal |= t4_handle_intr(adap, &cim_pf_host_intr_info, 0, verbose); @@ -4519,6 +4540,7 @@ static bool ulprx_intr_handler(struct adapter *adap, i .cause_reg = A_ULP_RX_INT_CAUSE, .enable_reg = A_ULP_RX_INT_ENABLE, .fatal = 0x07ffffff, + .flags = NONFATAL_IF_DISABLED, .details = ulprx_intr_details, .actions = NULL, }; @@ -4527,6 +4549,7 @@ static bool ulprx_intr_handler(struct adapter *adap, i .cause_reg = A_ULP_RX_INT_CAUSE_2, .enable_reg = A_ULP_RX_INT_ENABLE_2, .fatal = 0, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -4556,6 +4579,7 @@ static bool ulptx_intr_handler(struct adapter *adap, i .cause_reg = A_ULP_TX_INT_CAUSE, .enable_reg = A_ULP_TX_INT_ENABLE, .fatal = 0x0fffffff, + .flags = NONFATAL_IF_DISABLED, .details = ulptx_intr_details, .actions = NULL, }; @@ -4563,7 +4587,8 @@ static bool ulptx_intr_handler(struct adapter *adap, i .name = "ULP_TX_INT_CAUSE_2", .cause_reg = A_ULP_TX_INT_CAUSE_2, .enable_reg = A_ULP_TX_INT_ENABLE_2, - .fatal = 0, + .fatal = 0xf0, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; @@ -4621,6 +4646,7 @@ static bool pmtx_intr_handler(struct adapter *adap, in .cause_reg = A_PM_TX_INT_CAUSE, .enable_reg = A_PM_TX_INT_ENABLE, .fatal = 0xffffffff, + .flags = 0, .details = pmtx_intr_details, .actions = pmtx_intr_actions, }; @@ -4660,6 +4686,7 @@ static bool pmrx_intr_handler(struct adapter *adap, in .cause_reg = A_PM_RX_INT_CAUSE, .enable_reg = A_PM_RX_INT_ENABLE, .fatal = 0x1fffffff, + .flags = NONFATAL_IF_DISABLED, .details = pmrx_intr_details, .actions = NULL, }; @@ -4686,26 +4713,21 @@ static bool cplsw_intr_handler(struct adapter *adap, i { F_ZERO_SWITCH_ERROR, "CPLSW no-switch error" }, { 0 } }; - struct intr_info cplsw_intr_info = { + static const struct intr_info cplsw_intr_info = { .name = "CPL_INTR_CAUSE", .cause_reg = A_CPL_INTR_CAUSE, .enable_reg = A_CPL_INTR_ENABLE, - .fatal = 0, + .fatal = 0xff, + .flags = NONFATAL_IF_DISABLED, .details = cplsw_intr_details, .actions = NULL, }; - if (is_t4(adap)) - cplsw_intr_info.fatal = 0x2f; - else if (is_t5(adap)) - cplsw_intr_info.fatal = 0xef; - else - cplsw_intr_info.fatal = 0xff; - return (t4_handle_intr(adap, &cplsw_intr_info, 0, verbose)); } #define T4_LE_FATAL_MASK (F_PARITYERR | F_UNKNOWNCMD | F_REQQPARERR) +#define T5_LE_FATAL_MASK (T4_LE_FATAL_MASK | F_VFPARERR) #define T6_LE_PERRCRC_MASK (F_PIPELINEERR | F_CLIPTCAMACCFAIL | \ F_SRVSRAMACCFAIL | F_CLCAMCRCPARERR | F_CLCAMINTPERR | F_SSRAMINTPERR | \ F_SRVSRAMPERR | F_VFSRAMPERR | F_TCAMINTPERR | F_TCAMCRCERR | \ @@ -4754,15 +4776,14 @@ static bool le_intr_handler(struct adapter *adap, int .cause_reg = A_LE_DB_INT_CAUSE, .enable_reg = A_LE_DB_INT_ENABLE, .fatal = 0, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = NULL, }; if (chip_id(adap) <= CHELSIO_T5) { le_intr_info.details = le_intr_details; - le_intr_info.fatal = T4_LE_FATAL_MASK; - if (is_t5(adap)) - le_intr_info.fatal |= F_VFPARERR; + le_intr_info.fatal = T5_LE_FATAL_MASK; } else { le_intr_info.details = t6_le_intr_details; le_intr_info.fatal = T6_LE_FATAL_MASK; @@ -4785,6 +4806,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_RX_PERR_INT_CAUSE, .enable_reg = A_MPS_RX_PERR_INT_ENABLE, .fatal = 0xffffffff, + .flags = NONFATAL_IF_DISABLED, .details = mps_rx_perr_intr_details, .actions = NULL, }; @@ -4799,11 +4821,12 @@ static bool mps_intr_handler(struct adapter *adap, int { V_TPFIFO(M_TPFIFO), "MPS Tx TP FIFO parity error" }, { 0 } }; - struct intr_info mps_tx_intr_info = { + static const struct intr_info mps_tx_intr_info = { .name = "MPS_TX_INT_CAUSE", .cause_reg = A_MPS_TX_INT_CAUSE, .enable_reg = A_MPS_TX_INT_ENABLE, .fatal = 0x1ffff, + .flags = NONFATAL_IF_DISABLED, .details = mps_tx_intr_details, .actions = NULL, }; @@ -4818,6 +4841,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_TRC_INT_CAUSE, .enable_reg = A_MPS_TRC_INT_ENABLE, .fatal = F_MISCPERR | V_PKTFIFO(M_PKTFIFO) | V_FILTMEM(M_FILTMEM), + .flags = 0, .details = mps_trc_intr_details, .actions = NULL, }; @@ -4830,6 +4854,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_STAT_PERR_INT_CAUSE_SRAM, .enable_reg = A_MPS_STAT_PERR_INT_ENABLE_SRAM, .fatal = 0x1fffffff, + .flags = NONFATAL_IF_DISABLED, .details = mps_stat_sram_intr_details, .actions = NULL, }; @@ -4842,6 +4867,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_STAT_PERR_INT_CAUSE_TX_FIFO, .enable_reg = A_MPS_STAT_PERR_INT_ENABLE_TX_FIFO, .fatal = 0xffffff, + .flags = NONFATAL_IF_DISABLED, .details = mps_stat_tx_intr_details, .actions = NULL, }; @@ -4854,6 +4880,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_STAT_PERR_INT_CAUSE_RX_FIFO, .enable_reg = A_MPS_STAT_PERR_INT_ENABLE_RX_FIFO, .fatal = 0xffffff, + .flags = 0, .details = mps_stat_rx_intr_details, .actions = NULL, }; @@ -4868,6 +4895,7 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_CLS_INT_CAUSE, .enable_reg = A_MPS_CLS_INT_ENABLE, .fatal = F_MATCHSRAM | F_MATCHTCAM | F_HASHSRAM, + .flags = 0, .details = mps_cls_intr_details, .actions = NULL, }; @@ -4880,15 +4908,13 @@ static bool mps_intr_handler(struct adapter *adap, int .cause_reg = A_MPS_STAT_PERR_INT_CAUSE_SRAM1, .enable_reg = A_MPS_STAT_PERR_INT_ENABLE_SRAM1, .fatal = 0xff, + .flags = 0, .details = mps_stat_sram1_intr_details, .actions = NULL, }; bool fatal; - if (chip_id(adap) == CHELSIO_T6) - mps_tx_intr_info.fatal &= ~F_BUBBLE; - fatal = false; fatal |= t4_handle_intr(adap, &mps_rx_perr_intr_info, 0, verbose); fatal |= t4_handle_intr(adap, &mps_tx_intr_info, 0, verbose); @@ -4925,6 +4951,7 @@ static bool mem_intr_handler(struct adapter *adap, int struct intr_info ii = { .fatal = F_PERR_INT_CAUSE | F_ECC_UE_INT_CAUSE, .details = mem_intr_details, + .flags = 0, .actions = NULL, }; bool fatal; @@ -5011,8 +5038,8 @@ static bool ma_intr_handler(struct adapter *adap, int .name = "MA_INT_CAUSE", .cause_reg = A_MA_INT_CAUSE, .enable_reg = A_MA_INT_ENABLE, - .fatal = F_MEM_WRAP_INT_CAUSE | F_MEM_PERR_INT_CAUSE | - F_MEM_TO_INT_CAUSE, + .fatal = F_MEM_PERR_INT_CAUSE | F_MEM_TO_INT_CAUSE, + .flags = NONFATAL_IF_DISABLED, .details = NULL, .actions = ma_intr_actions, }; @@ -5021,6 +5048,7 @@ static bool ma_intr_handler(struct adapter *adap, int .cause_reg = A_MA_PARITY_ERROR_STATUS1, .enable_reg = A_MA_PARITY_ERROR_ENABLE1, .fatal = 0xffffffff, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -5029,6 +5057,7 @@ static bool ma_intr_handler(struct adapter *adap, int .cause_reg = A_MA_PARITY_ERROR_STATUS2, .enable_reg = A_MA_PARITY_ERROR_ENABLE2, .fatal = 0xffffffff, + .flags = 0, .details = NULL, .actions = NULL, }; @@ -5059,6 +5088,7 @@ static bool smb_intr_handler(struct adapter *adap, int .cause_reg = A_SMB_INT_CAUSE, .enable_reg = A_SMB_INT_ENABLE, .fatal = F_SLVFIFOPARINT | F_MSTRXFIFOPARINT | F_MSTTXFIFOPARINT, + .flags = 0, .details = smb_intr_details, .actions = NULL, }; @@ -5084,6 +5114,7 @@ static bool ncsi_intr_handler(struct adapter *adap, in .enable_reg = A_NCSI_INT_ENABLE, .fatal = F_RXFIFO_PRTY_ERR | F_TXFIFO_PRTY_ERR | F_MPS_DM_PRTY_ERR | F_CIM_DM_PRTY_ERR, + .flags = 0, .details = ncsi_intr_details, .actions = NULL, }; @@ -5110,16 +5141,18 @@ static bool mac_intr_handler(struct adapter *adap, int ii.name = &name[0]; ii.cause_reg = PORT_REG(port, A_XGMAC_PORT_INT_CAUSE); ii.enable_reg = PORT_REG(port, A_XGMAC_PORT_INT_EN); - ii.fatal = F_TXFIFO_PRTY_ERR | F_RXFIFO_PRTY_ERR, - ii.details = mac_intr_details, + ii.fatal = F_TXFIFO_PRTY_ERR | F_RXFIFO_PRTY_ERR; + ii.flags = 0; + ii.details = mac_intr_details; ii.actions = NULL; } else { snprintf(name, sizeof(name), "MAC_PORT%u_INT_CAUSE", port); ii.name = &name[0]; ii.cause_reg = T5_PORT_REG(port, A_MAC_PORT_INT_CAUSE); ii.enable_reg = T5_PORT_REG(port, A_MAC_PORT_INT_EN); - ii.fatal = F_TXFIFO_PRTY_ERR | F_RXFIFO_PRTY_ERR, - ii.details = mac_intr_details, + ii.fatal = F_TXFIFO_PRTY_ERR | F_RXFIFO_PRTY_ERR; + ii.flags = 0; + ii.details = mac_intr_details; ii.actions = NULL; } fatal |= t4_handle_intr(adap, &ii, 0, verbose); @@ -5130,6 +5163,7 @@ static bool mac_intr_handler(struct adapter *adap, int ii.cause_reg = T5_PORT_REG(port, A_MAC_PORT_PERR_INT_CAUSE); ii.enable_reg = T5_PORT_REG(port, A_MAC_PORT_PERR_INT_EN); ii.fatal = 0; + ii.flags = 0; ii.details = NULL; ii.actions = NULL; fatal |= t4_handle_intr(adap, &ii, 0, verbose); @@ -5141,6 +5175,7 @@ static bool mac_intr_handler(struct adapter *adap, int ii.cause_reg = T5_PORT_REG(port, A_MAC_PORT_PERR_INT_CAUSE_100G); ii.enable_reg = T5_PORT_REG(port, A_MAC_PORT_PERR_INT_EN_100G); ii.fatal = 0; + ii.flags = 0; ii.details = NULL; ii.actions = NULL; fatal |= t4_handle_intr(adap, &ii, 0, verbose); @@ -5156,18 +5191,16 @@ static bool plpl_intr_handler(struct adapter *adap, in { F_PERRVFID, "VFID_MAP parity error" }, { 0 } }; - struct intr_info plpl_intr_info = { + static const struct intr_info plpl_intr_info = { .name = "PL_PL_INT_CAUSE", .cause_reg = A_PL_PL_INT_CAUSE, .enable_reg = A_PL_PL_INT_ENABLE, - .fatal = F_FATALPERR, + .fatal = F_FATALPERR | F_PERRVFID, + .flags = NONFATAL_IF_DISABLED, .details = plpl_intr_details, .actions = NULL, }; - if (is_t4(adap)) - plpl_intr_info.fatal |= F_PERRVFID; - return (t4_handle_intr(adap, &plpl_intr_info, 0, verbose)); } @@ -5220,6 +5253,7 @@ int t4_slow_intr_handler(struct adapter *adap, bool ve .cause_reg = A_PL_PERR_CAUSE, .enable_reg = A_PL_PERR_ENABLE, .fatal = 0xffffffff, + .flags = 0, .details = pl_intr_details, .actions = NULL, }; @@ -5254,6 +5288,7 @@ int t4_slow_intr_handler(struct adapter *adap, bool ve .cause_reg = A_PL_INT_CAUSE, .enable_reg = A_PL_INT_ENABLE, .fatal = 0, + .flags = 0, .details = pl_intr_details, .actions = pl_intr_action, }; From owner-svn-src-head@freebsd.org Tue Apr 2 18:50:53 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BCAF156FF90; Tue, 2 Apr 2019 18:50:53 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF077720E7; Tue, 2 Apr 2019 18:50:52 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB48121F0; Tue, 2 Apr 2019 18:50:49 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32IonAV041954; Tue, 2 Apr 2019 18:50:49 GMT (envelope-from tychon@FreeBSD.org) Received: (from tychon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Iondm041953; Tue, 2 Apr 2019 18:50:49 GMT (envelope-from tychon@FreeBSD.org) Message-Id: <201904021850.x32Iondm041953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tychon set sender to tychon@FreeBSD.org using -f From: Tycho Nightingale Date: Tue, 2 Apr 2019 18:50:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345811 - head/sys/x86/iommu X-SVN-Group: head X-SVN-Commit-Author: tychon X-SVN-Commit-Paths: head/sys/x86/iommu X-SVN-Commit-Revision: 345811 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EF077720E7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.984,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:50:53 -0000 Author: tychon Date: Tue Apr 2 18:50:49 2019 New Revision: 345811 URL: https://svnweb.freebsd.org/changeset/base/345811 Log: DMAR driver assumes all physical addresses are backed by a fully initialized struct vm_page. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19753 Modified: head/sys/x86/iommu/busdma_dmar.c Modified: head/sys/x86/iommu/busdma_dmar.c ============================================================================== --- head/sys/x86/iommu/busdma_dmar.c Tue Apr 2 18:50:33 2019 (r345810) +++ head/sys/x86/iommu/busdma_dmar.c Tue Apr 2 18:50:49 2019 (r345811) @@ -665,9 +665,9 @@ dmar_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmam { struct bus_dma_tag_dmar *tag; struct bus_dmamap_dmar *map; - vm_page_t *ma; - vm_paddr_t pstart, pend; - int error, i, ma_cnt, offset; + vm_page_t *ma, fma; + vm_paddr_t pstart, pend, paddr; + int error, i, ma_cnt, mflags, offset; tag = (struct bus_dma_tag_dmar *)dmat; map = (struct bus_dmamap_dmar *)map1; @@ -675,14 +675,36 @@ dmar_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmam pend = round_page(buf + buflen); offset = buf & PAGE_MASK; ma_cnt = OFF_TO_IDX(pend - pstart); - ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, map->cansleep ? - M_WAITOK : M_NOWAIT); + mflags = map->cansleep ? M_WAITOK : M_NOWAIT; + ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, mflags); if (ma == NULL) return (ENOMEM); - for (i = 0; i < ma_cnt; i++) - ma[i] = PHYS_TO_VM_PAGE(pstart + i * PAGE_SIZE); + fma = NULL; + for (i = 0; i < ma_cnt; i++) { + paddr = pstart + i * PAGE_SIZE; + ma[i] = PHYS_TO_VM_PAGE(paddr); + if (ma[i] == NULL || VM_PAGE_TO_PHYS(ma[i]) != paddr) { + /* + * If PHYS_TO_VM_PAGE() returned NULL or the + * vm_page was not initialized we'll use a + * fake page. + */ + if (fma == NULL) { + fma = malloc(sizeof(struct vm_page) * ma_cnt, + M_DEVBUF, mflags); + if (fma == NULL) { + free(ma, M_DEVBUF); + return (ENOMEM); + } + } + vm_page_initfake(&fma[i], pstart + i * PAGE_SIZE, + VM_MEMATTR_DEFAULT); + ma[i] = &fma[i]; + } + } error = dmar_bus_dmamap_load_something(tag, map, ma, offset, buflen, flags, segs, segp); + free(fma, M_DEVBUF); free(ma, M_DEVBUF); return (error); } @@ -696,7 +718,7 @@ dmar_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dm struct bus_dmamap_dmar *map; vm_page_t *ma, fma; vm_paddr_t pstart, pend, paddr; - int error, i, ma_cnt, offset; + int error, i, ma_cnt, mflags, offset; tag = (struct bus_dma_tag_dmar *)dmat; map = (struct bus_dmamap_dmar *)map1; @@ -704,41 +726,33 @@ dmar_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dm pend = round_page((vm_offset_t)buf + buflen); offset = (vm_offset_t)buf & PAGE_MASK; ma_cnt = OFF_TO_IDX(pend - pstart); - ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, map->cansleep ? - M_WAITOK : M_NOWAIT); + mflags = map->cansleep ? M_WAITOK : M_NOWAIT; + ma = malloc(sizeof(vm_page_t) * ma_cnt, M_DEVBUF, mflags); if (ma == NULL) return (ENOMEM); - if (dumping) { - /* - * If dumping, do not attempt to call - * PHYS_TO_VM_PAGE() at all. It may return non-NULL - * but the vm_page returned might be not initialized, - * e.g. for the kernel itself. - */ - KASSERT(pmap == kernel_pmap, ("non-kernel address write")); - fma = malloc(sizeof(struct vm_page) * ma_cnt, M_DEVBUF, - M_ZERO | (map->cansleep ? M_WAITOK : M_NOWAIT)); - if (fma == NULL) { - free(ma, M_DEVBUF); - return (ENOMEM); - } - for (i = 0; i < ma_cnt; i++, pstart += PAGE_SIZE) { + fma = NULL; + for (i = 0; i < ma_cnt; i++, pstart += PAGE_SIZE) { + if (pmap == kernel_pmap) paddr = pmap_kextract(pstart); + else + paddr = pmap_extract(pmap, pstart); + ma[i] = PHYS_TO_VM_PAGE(paddr); + if (ma[i] == NULL || VM_PAGE_TO_PHYS(ma[i]) != paddr) { + /* + * If PHYS_TO_VM_PAGE() returned NULL or the + * vm_page was not initialized we'll use a + * fake page. + */ + if (fma == NULL) { + fma = malloc(sizeof(struct vm_page) * ma_cnt, + M_DEVBUF, mflags); + if (fma == NULL) { + free(ma, M_DEVBUF); + return (ENOMEM); + } + } vm_page_initfake(&fma[i], paddr, VM_MEMATTR_DEFAULT); ma[i] = &fma[i]; - } - } else { - fma = NULL; - for (i = 0; i < ma_cnt; i++, pstart += PAGE_SIZE) { - if (pmap == kernel_pmap) - paddr = pmap_kextract(pstart); - else - paddr = pmap_extract(pmap, pstart); - ma[i] = PHYS_TO_VM_PAGE(paddr); - KASSERT(VM_PAGE_TO_PHYS(ma[i]) == paddr, - ("PHYS_TO_VM_PAGE failed %jx %jx m %p", - (uintmax_t)paddr, (uintmax_t)VM_PAGE_TO_PHYS(ma[i]), - ma[i])); } } error = dmar_bus_dmamap_load_something(tag, map, ma, offset, buflen, From owner-svn-src-head@freebsd.org Tue Apr 2 19:06:27 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CAE51570676; Tue, 2 Apr 2019 19:06:27 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C379272C25; Tue, 2 Apr 2019 19:06:26 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 930462544; Tue, 2 Apr 2019 19:06:26 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32J6Qc2052303; Tue, 2 Apr 2019 19:06:26 GMT (envelope-from tychon@FreeBSD.org) Received: (from tychon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32J6PJW052299; Tue, 2 Apr 2019 19:06:25 GMT (envelope-from tychon@FreeBSD.org) Message-Id: <201904021906.x32J6PJW052299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tychon set sender to tychon@FreeBSD.org using -f From: Tycho Nightingale Date: Tue, 2 Apr 2019 19:06:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345812 - in head: sys/dev/ioat tools/tools/ioat X-SVN-Group: head X-SVN-Commit-Author: tychon X-SVN-Commit-Paths: in head: sys/dev/ioat tools/tools/ioat X-SVN-Commit-Revision: 345812 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C379272C25 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 19:06:27 -0000 Author: tychon Date: Tue Apr 2 19:06:25 2019 New Revision: 345812 URL: https://svnweb.freebsd.org/changeset/base/345812 Log: ioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and crc-copy modes. Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19780 Modified: head/sys/dev/ioat/ioat_test.c head/sys/dev/ioat/ioat_test.h head/tools/tools/ioat/ioatcontrol.8 head/tools/tools/ioat/ioatcontrol.c Modified: head/sys/dev/ioat/ioat_test.c ============================================================================== --- head/sys/dev/ioat/ioat_test.c Tue Apr 2 18:50:49 2019 (r345811) +++ head/sys/dev/ioat/ioat_test.c Tue Apr 2 19:06:25 2019 (r345812) @@ -65,6 +65,7 @@ struct test_transaction { void *buf[IOAT_MAX_BUFS]; uint32_t length; uint32_t depth; + uint32_t crc[IOAT_MAX_BUFS]; struct ioat_test *test; TAILQ_ENTRY(test_transaction) entry; }; @@ -312,6 +313,28 @@ ioat_test_submit_1_tx(struct ioat_test *test, bus_dmae desc = ioat_copy_8k_aligned(dma, dest, dst2, src, src2, cb, tx, flags); + } else if (test->testkind == IOAT_TEST_DMA_8K_PB) { + bus_addr_t src2, dst2; + + src2 = vtophys((vm_offset_t)tx->buf[2*i+1] + PAGE_SIZE); + dst2 = vtophys((vm_offset_t)tx->buf[2*i] + PAGE_SIZE); + + desc = ioat_copy_8k_aligned(dma, dest, dst2, src, src2, + cb, tx, flags); + } else if (test->testkind == IOAT_TEST_DMA_CRC) { + bus_addr_t crc; + + tx->crc[i] = 0; + crc = vtophys((vm_offset_t)&tx->crc[i]); + desc = ioat_crc(dma, src, tx->length, + NULL, crc, cb, tx, flags | DMA_CRC_STORE); + } else if (test->testkind == IOAT_TEST_DMA_CRC_COPY) { + bus_addr_t crc; + + tx->crc[i] = 0; + crc = vtophys((vm_offset_t)&tx->crc[i]); + desc = ioat_copy_crc(dma, dest, src, tx->length, + NULL, crc, cb, tx, flags | DMA_CRC_STORE); } if (desc == NULL) break; @@ -346,7 +369,8 @@ ioat_dma_test(void *arg) test = arg; memset(__DEVOLATILE(void *, test->status), 0, sizeof(test->status)); - if (test->testkind == IOAT_TEST_DMA_8K && + if ((test->testkind == IOAT_TEST_DMA_8K || + test->testkind == IOAT_TEST_DMA_8K_PB) && test->buffer_size != 2 * PAGE_SIZE) { ioat_test_log(0, "Asked for 8k test and buffer size isn't 8k\n"); test->status[IOAT_TEST_INVALID_INPUT]++; Modified: head/sys/dev/ioat/ioat_test.h ============================================================================== --- head/sys/dev/ioat/ioat_test.h Tue Apr 2 18:50:49 2019 (r345811) +++ head/sys/dev/ioat/ioat_test.h Tue Apr 2 19:06:25 2019 (r345812) @@ -44,6 +44,9 @@ enum ioat_test_kind { IOAT_TEST_RAW_DMA, IOAT_TEST_DMA_8K, IOAT_TEST_MEMCPY, + IOAT_TEST_DMA_8K_PB, + IOAT_TEST_DMA_CRC, + IOAT_TEST_DMA_CRC_COPY, IOAT_NUM_TESTKINDS }; Modified: head/tools/tools/ioat/ioatcontrol.8 ============================================================================== --- head/tools/tools/ioat/ioatcontrol.8 Tue Apr 2 18:50:49 2019 (r345811) +++ head/tools/tools/ioat/ioatcontrol.8 Tue Apr 2 19:06:25 2019 (r345812) @@ -35,9 +35,12 @@ .Nm .Op Fl c Ar period .Op Fl E +.Op Fl e .Op Fl f .Op Fl m .Op Fl V +.Op Fl x +.Op Fl X .Op Fl z .Ar channel_number .Ar num_txns @@ -65,6 +68,8 @@ The arguments are as follows: Configure the channel's interrupt coalescing period, in microseconds (defaults to 0). .It Fl E +Test contiguous 8k copy. +.It Fl e Test non-contiguous 8k copy. .It Fl f Test block fill (by default, @@ -74,6 +79,10 @@ tests copy) Test memcpy instead of DMA. .It Fl V Verify copies/fills for accuracy +.It Fl x +Test DMA CRC. +.It Fl X +Test DMA copy with CRC. .It Fl z Zero device statistics before running test. .El Modified: head/tools/tools/ioat/ioatcontrol.c ============================================================================== --- head/tools/tools/ioat/ioatcontrol.c Tue Apr 2 18:50:49 2019 (r345811) +++ head/tools/tools/ioat/ioatcontrol.c Tue Apr 2 19:06:25 2019 (r345812) @@ -54,13 +54,16 @@ usage(void) printf(" %s -r [-c period] [-vVwz] channel-number address []\n\n", getprogname()); printf(" -c period - Enable interrupt coalescing (us) (default: 0)\n"); - printf(" -E - Test non-contiguous 8k copy.\n"); - printf(" -f - Test block fill (default: DMA copy).\n"); + printf(" -E - Test contiguous 8k copy.\n"); + printf(" -e - Test non-contiguous 8k copy.\n"); + printf(" -f - Test block fill.\n"); printf(" -m - Test memcpy instead of DMA.\n"); printf(" -r - Issue DMA to or from a specific address.\n"); printf(" -V - Enable verification\n"); printf(" -v -
is a kernel virtual address\n"); printf(" -w - Write to the specified address\n"); + printf(" -x - Test DMA CRC.\n"); + printf(" -X - Test DMA CRC copy.\n"); printf(" -z - Zero device stats before test\n"); exit(EX_USAGE); } @@ -107,15 +110,15 @@ main(int argc, char **argv) { struct ioat_test t; int fd, ch; - bool fflag, rflag, Eflag, mflag; + bool fflag, rflag, Eflag, eflag, mflag, xflag, Xflag; unsigned modeflags; memset(&t, 0, sizeof(t)); - fflag = rflag = Eflag = mflag = false; + fflag = rflag = Eflag = eflag = mflag = xflag = Xflag = false; modeflags = 0; - while ((ch = getopt(argc, argv, "c:EfmrvVwz")) != -1) { + while ((ch = getopt(argc, argv, "c:EefmrvVwxXz")) != -1) { switch (ch) { case 'c': t.coalesce_period = atoi(optarg); @@ -124,6 +127,10 @@ main(int argc, char **argv) Eflag = true; modeflags++; break; + case 'e': + eflag = true; + modeflags++; + break; case 'f': fflag = true; modeflags++; @@ -145,6 +152,12 @@ main(int argc, char **argv) case 'w': t.raw_write = true; break; + case 'x': + xflag = true; + break; + case 'X': + Xflag = true; + break; case 'z': t.zero_stats = true; break; @@ -171,11 +184,15 @@ main(int argc, char **argv) if (fflag) t.testkind = IOAT_TEST_FILL; - else if (Eflag) { + else if (Eflag || eflag) { t.testkind = IOAT_TEST_DMA_8K; t.buffer_size = 8 * 1024; } else if (mflag) t.testkind = IOAT_TEST_MEMCPY; + else if (xflag) + t.testkind = IOAT_TEST_DMA_CRC; + else if (xflag) + t.testkind = IOAT_TEST_DMA_CRC_COPY; t.channel_index = atoi(argv[0]); if (t.channel_index > 8) { From owner-svn-src-head@freebsd.org Tue Apr 2 19:08:08 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA85E1570796; Tue, 2 Apr 2019 19:08:07 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7BDB072E8E; Tue, 2 Apr 2019 19:08:07 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 668422559; Tue, 2 Apr 2019 19:08:07 +0000 (UTC) (envelope-from tychon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32J87SC052414; Tue, 2 Apr 2019 19:08:07 GMT (envelope-from tychon@FreeBSD.org) Received: (from tychon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32J87f5052412; Tue, 2 Apr 2019 19:08:07 GMT (envelope-from tychon@FreeBSD.org) Message-Id: <201904021908.x32J87f5052412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tychon set sender to tychon@FreeBSD.org using -f From: Tycho Nightingale Date: Tue, 2 Apr 2019 19:08:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345813 - head/sys/dev/ioat X-SVN-Group: head X-SVN-Commit-Author: tychon X-SVN-Commit-Paths: head/sys/dev/ioat X-SVN-Commit-Revision: 345813 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7BDB072E8E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 19:08:08 -0000 Author: tychon Date: Tue Apr 2 19:08:06 2019 New Revision: 345813 URL: https://svnweb.freebsd.org/changeset/base/345813 Log: ioat(4) should use bus_dma(9) for the operation source and destination addresses Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19725 Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Tue Apr 2 19:06:25 2019 (r345812) +++ head/sys/dev/ioat/ioat.c Tue Apr 2 19:08:06 2019 (r345813) @@ -320,10 +320,26 @@ err: return (error); } +static inline int +ioat_bus_dmamap_destroy(struct ioat_softc *ioat, const char *func, + bus_dma_tag_t dmat, bus_dmamap_t map) +{ + int error; + + error = bus_dmamap_destroy(dmat, map); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_destroy failed %d\n", func, error); + } + + return (error); +} + static int ioat_detach(device_t device) { struct ioat_softc *ioat; + int i, error; ioat = DEVICE2SOFTC(device); @@ -359,6 +375,47 @@ ioat_detach(device_t device) bus_release_resource(device, SYS_RES_MEMORY, ioat->pci_resource_id, ioat->pci_resource); + if (ioat->data_tag != NULL) { + for (i = 0; i < 1 << ioat->ring_size_order; i++) { + error = ioat_bus_dmamap_destroy(ioat, __func__, + ioat->data_tag, ioat->ring[i].src_dmamap); + if (error != 0) + return (error); + } + for (i = 0; i < 1 << ioat->ring_size_order; i++) { + error = ioat_bus_dmamap_destroy(ioat, __func__, + ioat->data_tag, ioat->ring[i].dst_dmamap); + if (error != 0) + return (error); + } + + for (i = 0; i < 1 << ioat->ring_size_order; i++) { + error = ioat_bus_dmamap_destroy(ioat, __func__, + ioat->data_tag, ioat->ring[i].src2_dmamap); + if (error != 0) + return (error); + } + for (i = 0; i < 1 << ioat->ring_size_order; i++) { + error = ioat_bus_dmamap_destroy(ioat, __func__, + ioat->data_tag, ioat->ring[i].dst2_dmamap); + if (error != 0) + return (error); + } + + bus_dma_tag_destroy(ioat->data_tag); + } + + if (ioat->data_crc_tag != NULL) { + for (i = 0; i < 1 << ioat->ring_size_order; i++) { + error = ioat_bus_dmamap_destroy(ioat, __func__, + ioat->data_crc_tag, ioat->ring[i].crc_dmamap); + if (error != 0) + return (error); + } + + bus_dma_tag_destroy(ioat->data_crc_tag); + } + if (ioat->ring != NULL) ioat_free_ring(ioat, 1 << ioat->ring_size_order, ioat->ring); @@ -523,6 +580,25 @@ ioat3_attach(device_t device) ioat->hw_desc_ring = hw_desc; + error = bus_dma_tag_create(bus_get_dma_tag(ioat->device), + 1, 0, BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, NULL, NULL, + ioat->max_xfer_size, 1, ioat->max_xfer_size, 0, NULL, NULL, + &ioat->data_crc_tag); + if (error != 0) { + ioat_log_message(0, "%s: bus_dma_tag_create failed %d\n", + __func__, error); + return (error); + } + + error = bus_dma_tag_create(bus_get_dma_tag(ioat->device), + 1, 0, BUS_SPACE_MAXADDR_48BIT, BUS_SPACE_MAXADDR, NULL, NULL, + ioat->max_xfer_size, 1, ioat->max_xfer_size, 0, NULL, NULL, + &ioat->data_tag); + if (error != 0) { + ioat_log_message(0, "%s: bus_dma_tag_create failed %d\n", + __func__, error); + return (error); + } ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT, M_ZERO | M_WAITOK); @@ -530,6 +606,46 @@ ioat3_attach(device_t device) for (i = 0; i < num_descriptors; i++) { memset(&ring[i].bus_dmadesc, 0, sizeof(ring[i].bus_dmadesc)); ring[i].id = i; + error = bus_dmamap_create(ioat->data_tag, 0, + &ring[i].src_dmamap); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_create failed %d\n", __func__, + error); + return (error); + } + error = bus_dmamap_create(ioat->data_tag, 0, + &ring[i].dst_dmamap); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_create failed %d\n", __func__, + error); + return (error); + } + error = bus_dmamap_create(ioat->data_tag, 0, + &ring[i].src2_dmamap); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_create failed %d\n", __func__, + error); + return (error); + } + error = bus_dmamap_create(ioat->data_tag, 0, + &ring[i].dst2_dmamap); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_create failed %d\n", __func__, + error); + return (error); + } + error = bus_dmamap_create(ioat->data_crc_tag, 0, + &ring[i].crc_dmamap); + if (error != 0) { + ioat_log_message(0, + "%s: bus_dmamap_create failed %d\n", __func__, + error); + return (error); + } } for (i = 0; i < num_descriptors; i++) { @@ -724,6 +840,12 @@ ioat_process_events(struct ioat_softc *ioat, boolean_t ioat->chan_idx, ioat->tail, dmadesc, dmadesc->callback_fn, dmadesc->callback_arg); + bus_dmamap_unload(ioat->data_tag, desc->src_dmamap); + bus_dmamap_unload(ioat->data_tag, desc->dst_dmamap); + bus_dmamap_unload(ioat->data_tag, desc->src2_dmamap); + bus_dmamap_unload(ioat->data_tag, desc->dst2_dmamap); + bus_dmamap_unload(ioat->data_crc_tag, desc->crc_dmamap); + if (dmadesc->callback_fn != NULL) dmadesc->callback_fn(dmadesc->callback_arg, 0); @@ -999,7 +1121,8 @@ ioat_op_generic(struct ioat_softc *ioat, uint8_t op, { struct ioat_generic_hw_descriptor *hw_desc; struct ioat_descriptor *desc; - int mflags; + bus_dma_segment_t seg; + int mflags, nseg, error; mtx_assert(&ioat->submit_lock, MA_OWNED); @@ -1032,9 +1155,31 @@ ioat_op_generic(struct ioat_softc *ioat, uint8_t op, hw_desc->u.control_generic.fence = 1; hw_desc->size = size; - hw_desc->src_addr = src; - hw_desc->dest_addr = dst; + if (src != 0) { + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, desc->src_dmamap, + src, size, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->src_addr = seg.ds_addr; + } + + if (dst != 0) { + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, desc->dst_dmamap, + dst, size, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->dest_addr = seg.ds_addr; + } + desc->bus_dmadesc.callback_fn = callback_fn; desc->bus_dmadesc.callback_arg = callback_arg; return (desc); @@ -1102,6 +1247,9 @@ ioat_copy_8k_aligned(bus_dmaengine_t dmaengine, bus_ad struct ioat_dma_hw_descriptor *hw_desc; struct ioat_descriptor *desc; struct ioat_softc *ioat; + bus_size_t src1_len, dst1_len; + bus_dma_segment_t seg; + int nseg, error; ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); @@ -1117,19 +1265,57 @@ ioat_copy_8k_aligned(bus_dmaengine_t dmaengine, bus_ad return (NULL); } - desc = ioat_op_generic(ioat, IOAT_OP_COPY, 2 * PAGE_SIZE, src1, dst1, + desc = ioat_op_generic(ioat, IOAT_OP_COPY, 2 * PAGE_SIZE, 0, 0, callback_fn, callback_arg, flags); if (desc == NULL) return (NULL); hw_desc = &ioat_get_descriptor(ioat, desc->id)->dma; - if (src2 != src1 + PAGE_SIZE) { + + src1_len = (src2 != src1 + PAGE_SIZE) ? PAGE_SIZE : 2 * PAGE_SIZE; + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, + desc->src_dmamap, src1, src1_len, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->src_addr = seg.ds_addr; + if (src1_len != 2 * PAGE_SIZE) { hw_desc->u.control.src_page_break = 1; - hw_desc->next_src_addr = src2; + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, + desc->src2_dmamap, src2, PAGE_SIZE, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->next_src_addr = seg.ds_addr; } - if (dst2 != dst1 + PAGE_SIZE) { + + dst1_len = (dst2 != dst1 + PAGE_SIZE) ? PAGE_SIZE : 2 * PAGE_SIZE; + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, + desc->dst_dmamap, dst1, dst1_len, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->dest_addr = seg.ds_addr; + if (dst1_len != 2 * PAGE_SIZE) { hw_desc->u.control.dest_page_break = 1; - hw_desc->next_dest_addr = dst2; + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_tag, + desc->dst2_dmamap, dst2, PAGE_SIZE, 0, &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->next_dest_addr = seg.ds_addr; } if (g_ioat_debug_level >= 3) @@ -1149,6 +1335,8 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, bus_addr_t ds struct ioat_softc *ioat; uint32_t teststore; uint8_t op; + bus_dma_segment_t seg; + int nseg, error; ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); @@ -1201,9 +1389,18 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, bus_addr_t ds hw_desc = &ioat_get_descriptor(ioat, desc->id)->crc32; - if ((flags & DMA_CRC_INLINE) == 0) - hw_desc->crc_address = crcptr; - else + if ((flags & DMA_CRC_INLINE) == 0) { + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_crc_tag, + desc->crc_dmamap, crcptr, sizeof(uint32_t), 0, + &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->crc_address = seg.ds_addr; + } else hw_desc->u.control.crc_location = 1; if (initialseed != NULL) { @@ -1228,6 +1425,8 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_addr_t src, bu struct ioat_softc *ioat; uint32_t teststore; uint8_t op; + bus_dma_segment_t seg; + int nseg, error; ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); @@ -1280,9 +1479,18 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_addr_t src, bu hw_desc = &ioat_get_descriptor(ioat, desc->id)->crc32; - if ((flags & DMA_CRC_INLINE) == 0) - hw_desc->crc_address = crcptr; - else + if ((flags & DMA_CRC_INLINE) == 0) { + nseg = -1; + error = _bus_dmamap_load_phys(ioat->data_crc_tag, + desc->crc_dmamap, crcptr, sizeof(uint32_t), 0, + &seg, &nseg); + if (error != 0) { + ioat_log_message(0, "%s: _bus_dmamap_load_phys" + " failed %d\n", __func__, error); + return (NULL); + } + hw_desc->crc_address = seg.ds_addr; + } else hw_desc->u.control.crc_location = 1; if (initialseed != NULL) { @@ -1321,12 +1529,13 @@ ioat_blockfill(bus_dmaengine_t dmaengine, bus_addr_t d return (NULL); } - desc = ioat_op_generic(ioat, IOAT_OP_FILL, len, fillpattern, dst, + desc = ioat_op_generic(ioat, IOAT_OP_FILL, len, 0, dst, callback_fn, callback_arg, flags); if (desc == NULL) return (NULL); hw_desc = &ioat_get_descriptor(ioat, desc->id)->fill; + hw_desc->src_data = fillpattern; if (g_ioat_debug_level >= 3) dump_descriptor(hw_desc); Modified: head/sys/dev/ioat/ioat_internal.h ============================================================================== --- head/sys/dev/ioat/ioat_internal.h Tue Apr 2 19:06:25 2019 (r345812) +++ head/sys/dev/ioat/ioat_internal.h Tue Apr 2 19:08:06 2019 (r345813) @@ -414,6 +414,11 @@ struct bus_dmadesc { struct ioat_descriptor { struct bus_dmadesc bus_dmadesc; uint32_t id; + bus_dmamap_t src_dmamap; + bus_dmamap_t dst_dmamap; + bus_dmamap_t src2_dmamap; + bus_dmamap_t dst2_dmamap; + bus_dmamap_t crc_dmamap; }; /* Unused by this driver at this time. */ @@ -456,6 +461,9 @@ struct ioat_softc { bus_dma_tag_t hw_desc_tag; bus_dmamap_t hw_desc_map; + + bus_dma_tag_t data_tag; + bus_dma_tag_t data_crc_tag; bus_dma_tag_t comp_update_tag; bus_dmamap_t comp_update_map; From owner-svn-src-head@freebsd.org Tue Apr 2 19:37:54 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FA66157145E; Tue, 2 Apr 2019 19:37:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30FC6745A8; Tue, 2 Apr 2019 19:37:54 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A9BF2A79; Tue, 2 Apr 2019 19:37:54 +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 x32JbrFY067925; Tue, 2 Apr 2019 19:37:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32JbrRk067921; Tue, 2 Apr 2019 19:37:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201904021937.x32JbrRk067921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 2 Apr 2019 19:37:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345815 - in head: lib/libcam sys/cam sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head: lib/libcam sys/cam sys/cam/nvme X-SVN-Commit-Revision: 345815 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 30FC6745A8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 19:37:54 -0000 Author: mav Date: Tue Apr 2 19:37:52 2019 New Revision: 345815 URL: https://svnweb.freebsd.org/changeset/base/345815 Log: Make cam_error_print() decode NVMe commands. MFC after: 2 weeks Modified: head/lib/libcam/Makefile head/sys/cam/cam.c head/sys/cam/nvme/nvme_all.c head/sys/cam/nvme/nvme_all.h head/sys/cam/nvme/nvme_xpt.c Modified: head/lib/libcam/Makefile ============================================================================== --- head/lib/libcam/Makefile Tue Apr 2 19:20:55 2019 (r345814) +++ head/lib/libcam/Makefile Tue Apr 2 19:37:52 2019 (r345815) @@ -4,7 +4,7 @@ PACKAGE= lib${LIB} LIB= cam SHLIBDIR?= /lib SRCS= camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c \ - ata_all.c smp_all.c + ata_all.c nvme_all.c smp_all.c INCS= camlib.h LIBADD= sbuf @@ -38,6 +38,7 @@ MLINKS+= cam.3 cam_open_device.3 \ .PATH: ${SRCTOP}/sys/cam \ ${SRCTOP}/sys/cam/ata \ + ${SRCTOP}/sys/cam/nvme \ ${SRCTOP}/sys/cam/mmc \ ${SRCTOP}/sys/cam/scsi Modified: head/sys/cam/cam.c ============================================================================== --- head/sys/cam/cam.c Tue Apr 2 19:20:55 2019 (r345814) +++ head/sys/cam/cam.c Tue Apr 2 19:37:52 2019 (r345815) @@ -415,7 +415,6 @@ cam_error_string(struct cam_device *device, union ccb switch (ccb->ccb_h.func_code) { case XPT_ATA_IO: ata_command_sbuf(&ccb->ataio, &sb); - sbuf_printf(&sb, "\n"); break; case XPT_SCSI_IO: #ifdef _KERNEL @@ -423,17 +422,22 @@ cam_error_string(struct cam_device *device, union ccb #else /* !_KERNEL */ scsi_command_string(device, &ccb->csio, &sb); #endif /* _KERNEL/!_KERNEL */ - sbuf_printf(&sb, "\n"); break; case XPT_SMP_IO: smp_command_sbuf(&ccb->smpio, &sb, path_str, 79 - strlen(path_str), (proto_flags & CAM_ESMF_PRINT_FULL_CMD) ? 79 : 0); - sbuf_printf(&sb, "\n"); break; + case XPT_NVME_IO: + case XPT_NVME_ADMIN: + nvme_command_sbuf(&ccb->nvmeio, &sb); + break; default: + sbuf_printf(&sb, "CAM func %#x", + ccb->ccb_h.func_code); break; } + sbuf_printf(&sb, "\n"); } if (flags & CAM_ESF_CAM_STATUS) { Modified: head/sys/cam/nvme/nvme_all.c ============================================================================== --- head/sys/cam/nvme/nvme_all.c Tue Apr 2 19:20:55 2019 (r345814) +++ head/sys/cam/nvme/nvme_all.c Tue Apr 2 19:37:52 2019 (r345815) @@ -111,37 +111,84 @@ nvme_opc2str[] = { "COMPARE", "RSVD-6", "RSVD-7", - "DATASET_MANAGEMENT" + "WRITE_ZEROES", + "DATASET_MANAGEMENT", + "RSVD-a", + "RSVD-b", + "RSVD-c", + "RESERVATION_REGISTER", + "RESERVATION_REPORT", + "RSVD-f", + "RSVD-10", + "RESERVATION_ACQUIRE", + "RSVD-12", + "RSVD-13", + "RSVD-14", + "RESERVATION_RELEASE", }; const char * -nvme_op_string(const struct nvme_command *cmd) +nvme_op_string(const struct nvme_command *cmd, int admin) { - if (cmd->opc >= nitems(nvme_opc2str)) - return "UNKNOWN"; - - return nvme_opc2str[cmd->opc]; + if (admin) { + return "ADMIN"; + } else { + if (cmd->opc >= nitems(nvme_opc2str)) + return "UNKNOWN"; + return nvme_opc2str[cmd->opc]; + } } const char * nvme_cmd_string(const struct nvme_command *cmd, char *cmd_string, size_t len) { + struct sbuf sb; + int error; + if (len == 0) + return (""); + + sbuf_new(&sb, cmd_string, len, SBUF_FIXEDLEN); + nvme_cmd_sbuf(cmd, &sb); + + error = sbuf_finish(&sb); + if (error != 0 && error != ENOMEM) + return (""); + + return(sbuf_data(&sb)); +} + +void +nvme_cmd_sbuf(const struct nvme_command *cmd, struct sbuf *sb) +{ + /* * cid, rsvd areas and mptr not printed, since they are used * only internally by the SIM. */ - snprintf(cmd_string, len, + sbuf_printf(sb, "opc=%x fuse=%x nsid=%x prp1=%llx prp2=%llx cdw=%x %x %x %x %x %x", cmd->opc, cmd->fuse, cmd->nsid, (unsigned long long)cmd->prp1, (unsigned long long)cmd->prp2, cmd->cdw10, cmd->cdw11, cmd->cdw12, cmd->cdw13, cmd->cdw14, cmd->cdw15); +} - return cmd_string; +/* + * nvme_command_sbuf() returns 0 for success and -1 for failure. + */ +int +nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb) +{ + + sbuf_printf(sb, "%s. NCB: ", nvme_op_string(&nvmeio->cmd, + nvmeio->ccb_h.func_code == XPT_NVME_ADMIN)); + nvme_cmd_sbuf(&nvmeio->cmd, sb); + return(0); } +#ifdef _KERNEL const void * nvme_get_identify_cntrl(struct cam_periph *periph) { @@ -161,3 +208,4 @@ nvme_get_identify_ns(struct cam_periph *periph) return device->nvme_data; } +#endif Modified: head/sys/cam/nvme/nvme_all.h ============================================================================== --- head/sys/cam/nvme/nvme_all.h Tue Apr 2 19:20:55 2019 (r345814) +++ head/sys/cam/nvme/nvme_all.h Tue Apr 2 19:37:52 2019 (r345815) @@ -42,8 +42,10 @@ int nvme_identify_match(caddr_t identbuffer, caddr_t t struct sbuf; void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); -const char *nvme_op_string(const struct nvme_command *); +const char *nvme_op_string(const struct nvme_command *, int admin); const char *nvme_cmd_string(const struct nvme_command *, char *, size_t); +void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb); +int nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb); const void *nvme_get_identify_cntrl(struct cam_periph *); const void *nvme_get_identify_ns(struct cam_periph *); Modified: head/sys/cam/nvme/nvme_xpt.c ============================================================================== --- head/sys/cam/nvme/nvme_xpt.c Tue Apr 2 19:20:55 2019 (r345814) +++ head/sys/cam/nvme/nvme_xpt.c Tue Apr 2 19:37:52 2019 (r345815) @@ -769,11 +769,13 @@ nvme_proto_debug_out(union ccb *ccb) { char cdb_str[(sizeof(struct nvme_command) * 3) + 1]; - if (ccb->ccb_h.func_code != XPT_NVME_IO) + if (ccb->ccb_h.func_code != XPT_NVME_IO || + ccb->ccb_h.func_code != XPT_NVME_ADMIN) return; CAM_DEBUG(ccb->ccb_h.path, - CAM_DEBUG_CDB,("%s. NCB: %s\n", nvme_op_string(&ccb->nvmeio.cmd), + CAM_DEBUG_CDB,("%s. NCB: %s\n", nvme_op_string(&ccb->nvmeio.cmd, + ccb->ccb_h.func_code == XPT_NVME_ADMIN), nvme_cmd_string(&ccb->nvmeio.cmd, cdb_str, sizeof(cdb_str)))); } From owner-svn-src-head@freebsd.org Tue Apr 2 20:03:04 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EFCD1571DF3; Tue, 2 Apr 2019 20:03:04 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 162E6759FB; Tue, 2 Apr 2019 20:03:04 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F0CFB3039; Tue, 2 Apr 2019 20:03:03 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32K33Fn084419; Tue, 2 Apr 2019 20:03:03 GMT (envelope-from ygy@FreeBSD.org) Received: (from ygy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32K33KB084418; Tue, 2 Apr 2019 20:03:03 GMT (envelope-from ygy@FreeBSD.org) Message-Id: <201904022003.x32K33KB084418@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ygy set sender to ygy@FreeBSD.org using -f From: Guangyuan Yang Date: Tue, 2 Apr 2019 20:03:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345816 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: ygy X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 345816 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 162E6759FB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 20:03:04 -0000 Author: ygy (doc committer) Date: Tue Apr 2 20:03:03 2019 New Revision: 345816 URL: https://svnweb.freebsd.org/changeset/base/345816 Log: Correct SMC definition in asmc(4) man page. MFC after: 3 days PR: 236954 Submitted by: fbsdbugs4@sentry.org Modified: head/share/man/man4/asmc.4 Modified: head/share/man/man4/asmc.4 ============================================================================== --- head/share/man/man4/asmc.4 Tue Apr 2 19:37:52 2019 (r345815) +++ head/share/man/man4/asmc.4 Tue Apr 2 20:03:03 2019 (r345816) @@ -25,12 +25,12 @@ .\" .\" $FreeBSD$ .\" -.Dd July 27, 2009 +.Dd April 2, 2019 .Dt ASMC 4 .Os .Sh NAME .Nm asmc -.Nd device driver for the Apple System Management Console (SMC) +.Nd device driver for the Apple System Management Controller (SMC) .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your kernel configuration file: @@ -47,7 +47,7 @@ asmc_load="YES" .Sh DESCRIPTION The .Nm -driver controls the Apple System Management Console (SMC for short) +driver controls the Apple System Management Controller (SMC for short) found on Intel Apple systems. .Pp The SMC is known to be found on the following systems: From owner-svn-src-head@freebsd.org Tue Apr 2 20:27:57 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A668C1572A63; Tue, 2 Apr 2019 20:27:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 45BEC76CDB; Tue, 2 Apr 2019 20:27:57 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3476333FB; Tue, 2 Apr 2019 20:27:57 +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 x32KRv1w095866; Tue, 2 Apr 2019 20:27:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32KRua0095865; Tue, 2 Apr 2019 20:27:56 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201904022027.x32KRua0095865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 2 Apr 2019 20:27:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345817 - in head/sys: cam/nvme conf X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys: cam/nvme conf X-SVN-Commit-Revision: 345817 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 45BEC76CDB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 20:27:57 -0000 Author: mav Date: Tue Apr 2 20:27:56 2019 New Revision: 345817 URL: https://svnweb.freebsd.org/changeset/base/345817 Log: Build NVMe CAM transport unrelated to NVMe SIM. Before this I suppose it was impossible load CAM-based NVMe as module. Plus this appeared to be needed to build r345815 without NVMe driver. MFC after: 2 weeks Modified: head/sys/cam/nvme/nvme_da.c head/sys/conf/files Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Tue Apr 2 20:03:03 2019 (r345816) +++ head/sys/cam/nvme/nvme_da.c Tue Apr 2 20:27:56 2019 (r345817) @@ -770,10 +770,6 @@ ndaregister(struct cam_periph *periph, void *arg) softc->quirks = quirks; cam_iosched_set_sort_queue(softc->cam_iosched, 0); softc->disk = disk = disk_alloc(); - strlcpy(softc->disk->d_descr, cd->mn, - MIN(sizeof(softc->disk->d_descr), sizeof(cd->mn))); - strlcpy(softc->disk->d_ident, cd->sn, - MIN(sizeof(softc->disk->d_ident), sizeof(cd->sn))); disk->d_rotation_rate = DISK_RR_NON_ROTATING; disk->d_open = ndaopen; disk->d_close = ndaclose; @@ -812,9 +808,9 @@ ndaregister(struct cam_periph *periph, void *arg) * d_ident and d_descr are both far bigger than the length of either * the serial or model number strings. */ - nvme_strvis(disk->d_descr, cd->mn, + cam_strvis(disk->d_descr, cd->mn, sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH); - nvme_strvis(disk->d_ident, cd->sn, + cam_strvis(disk->d_ident, cd->sn, sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH); disk->d_hba_vendor = cpi.hba_vendor; disk->d_hba_device = cpi.hba_device; Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Apr 2 20:03:03 2019 (r345816) +++ head/sys/conf/files Tue Apr 2 20:27:56 2019 (r345817) @@ -86,9 +86,9 @@ cam/cam_xpt.c optional scbus cam/ata/ata_all.c optional scbus cam/ata/ata_xpt.c optional scbus cam/ata/ata_pmp.c optional scbus -cam/nvme/nvme_all.c optional scbus nvme -cam/nvme/nvme_da.c optional scbus nvme da -cam/nvme/nvme_xpt.c optional scbus nvme +cam/nvme/nvme_all.c optional scbus +cam/nvme/nvme_da.c optional nda | da +cam/nvme/nvme_xpt.c optional scbus cam/scsi/scsi_xpt.c optional scbus cam/scsi/scsi_all.c optional scbus cam/scsi/scsi_cd.c optional cd From owner-svn-src-head@freebsd.org Tue Apr 2 23:51:10 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 080A81553124; Tue, 2 Apr 2019 23:51:10 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A303D85A8D; Tue, 2 Apr 2019 23:51:09 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7AD4A5AB5; Tue, 2 Apr 2019 23:51:09 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32Np9FB002429; Tue, 2 Apr 2019 23:51:09 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Np9Lh002428; Tue, 2 Apr 2019 23:51:09 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201904022351.x32Np9Lh002428@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 2 Apr 2019 23:51:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345818 - head/sys/rpc/rpcsec_gss X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/rpc/rpcsec_gss X-SVN-Commit-Revision: 345818 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A303D85A8D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 23:51:10 -0000 Author: rmacklem Date: Tue Apr 2 23:51:08 2019 New Revision: 345818 URL: https://svnweb.freebsd.org/changeset/base/345818 Log: Fix a race in the RPCSEC_GSS server code that caused crashes. When a new client structure was allocated, it was added to the list so that it was visible to other threads before the expiry time was initialized, with only a single reference count. The caller would increment the reference count, but it was possible for another thread to decrement the reference count to zero and free the structure before the caller incremented the reference count. This could occur because the expiry time was still set to zero when the new client structure was inserted in the list and the list was unlocked. This patch fixes the race by initializing the reference count to two and initializing all fields, including the expiry time, before inserting it in the list. Tested by: peter@ifm.liu.se PR: 235582 MFC after: 2 weeks Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c ============================================================================== --- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Tue Apr 2 20:27:56 2019 (r345817) +++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Tue Apr 2 23:51:08 2019 (r345818) @@ -568,19 +568,13 @@ svc_rpc_gss_create_client(void) client = mem_alloc(sizeof(struct svc_rpc_gss_client)); memset(client, 0, sizeof(struct svc_rpc_gss_client)); - refcount_init(&client->cl_refs, 1); + refcount_init(&client->cl_refs, 2); 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 % svc_rpc_gss_client_hash_size]; - sx_xlock(&svc_rpc_gss_lock); - TAILQ_INSERT_HEAD(list, client, cl_link); - TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink); - svc_rpc_gss_client_count++; - sx_xunlock(&svc_rpc_gss_lock); /* * Start the client off with a short expiration time. We will @@ -590,6 +584,12 @@ svc_rpc_gss_create_client(void) client->cl_locked = FALSE; client->cl_expiration = time_uptime + 5*60; + list = &svc_rpc_gss_client_hash[client->cl_id.ci_id % svc_rpc_gss_client_hash_size]; + sx_xlock(&svc_rpc_gss_lock); + TAILQ_INSERT_HEAD(list, client, cl_link); + TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink); + svc_rpc_gss_client_count++; + sx_xunlock(&svc_rpc_gss_lock); return (client); } @@ -1287,7 +1287,6 @@ svc_rpc_gss(struct svc_req *rqst, struct rpc_msg *msg) goto out; } client = svc_rpc_gss_create_client(); - refcount_acquire(&client->cl_refs); } else { struct svc_rpc_gss_clientid *p; if (gc.gc_handle.length != sizeof(*p)) { From owner-svn-src-head@freebsd.org Wed Apr 3 01:00:33 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA39415554A3; Wed, 3 Apr 2019 01:00:33 +0000 (UTC) (envelope-from ota@j.email.ne.jp) Received: from mail03.asahi-net.or.jp (mail03.asahi-net.or.jp [202.224.55.15]) by mx1.freebsd.org (Postfix) with ESMTP id 249678895B; Wed, 3 Apr 2019 01:00:32 +0000 (UTC) (envelope-from ota@j.email.ne.jp) Received: from rv515.advok.com (pool-72-76-119-135.nwrknj.fios.verizon.net [72.76.119.135]) (Authenticated sender: NR2Y-OOT) by mail03.asahi-net.or.jp (Postfix) with ESMTPSA id 8F4BB39474; Wed, 3 Apr 2019 10:00:19 +0900 (JST) Date: Tue, 2 Apr 2019 21:00:01 -0400 From: Yoshihiro Ota To: rgrimes@freebsd.org Cc: "Rodney W. Grimes" , Michael Reifenberger , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r345804 - head/usr.bin/systat Message-Id: <20190402210001.3cd9b434a2f521e2dea80009@j.email.ne.jp> In-Reply-To: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> References: <201904021401.x32E13Fi092699@repo.freebsd.org> <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i386-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 249678895B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.961,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 01:00:34 -0000 Hi, On Tue, 2 Apr 2019 07:08:17 -0700 (PDT) "Rodney W. Grimes" wrote: > > Author: mr > > Date: Tue Apr 2 14:01:03 2019 > > New Revision: 345804 > > URL: https://svnweb.freebsd.org/changeset/base/345804 > > > > Log: > > systat -zarc to display disk activities like -vm > > > > PR: 213310 > > Submitted by: ota > > MFH: 4 weeks > > ? MFC: > > > Differential Revision: https://reviews.freebsd.org/D18726 > > > > Modified: > > head/usr.bin/systat/devs.c > > head/usr.bin/systat/devs.h > > head/usr.bin/systat/iostat.c > > head/usr.bin/systat/swap.c > > head/usr.bin/systat/systat.h > > head/usr.bin/systat/vmstat.c > > head/usr.bin/systat/zarc.c > > > > Modified: head/usr.bin/systat/devs.c > > ============================================================================== > > --- head/usr.bin/systat/devs.c Tue Apr 2 13:59:04 2019 (r345803) > > +++ head/usr.bin/systat/devs.c Tue Apr 2 14:01:03 2019 (r345804) > > @@ -2,6 +2,7 @@ > > * SPDX-License-Identifier: BSD-3-Clause > > * > > * Copyright (c) 1998 Kenneth D. Merry. > > + * 2015 Yoshihiro Ota > > * All rights reserved. > > > Can we get in contact with Yoshihiro Ota about his > copyright statements, and correcting this to make > it clear that it is Kenneth D. Merry that is asserting > "All rights reserved" and if Ota does nor does not wish to assert > "All rights reserved". > > As committed this makes a grey area on Kenneth's assertion, > also leaving out the word copyright on Yoshihiro's line is a bit iffy. > > I am only commenting once, this issue appears several times. > We can go back out to D18726 to discuss it if need be. I've fully written zarc.c (and copied copy-right section from another file) but all other changes in other files are refactoring and adjustments. I don't know the policy/procedure of how to update copy right section of FreeBSD. Please adjust them according the project. Regards, Hiro From owner-svn-src-head@freebsd.org Wed Apr 3 01:09:45 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BAD115557EB; Wed, 3 Apr 2019 01:09:45 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F92788E24; Wed, 3 Apr 2019 01:09:44 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x3319f5n024051; Tue, 2 Apr 2019 18:09:41 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x3319f25024050; Tue, 2 Apr 2019 18:09:41 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904030109.x3319f25024050@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345804 - head/usr.bin/systat In-Reply-To: <20190402210001.3cd9b434a2f521e2dea80009@j.email.ne.jp> To: Yoshihiro Ota Date: Tue, 2 Apr 2019 18:09:41 -0700 (PDT) CC: rgrimes@freebsd.org, "Rodney W. Grimes" , Michael Reifenberger , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 7F92788E24 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.948,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 01:09:45 -0000 > Hi, > > On Tue, 2 Apr 2019 07:08:17 -0700 (PDT) > "Rodney W. Grimes" wrote: > > > > Author: mr > > > Date: Tue Apr 2 14:01:03 2019 > > > New Revision: 345804 > > > URL: https://svnweb.freebsd.org/changeset/base/345804 > > > > > > Log: > > > systat -zarc to display disk activities like -vm > > > > > > PR: 213310 > > > Submitted by: ota > > > MFH: 4 weeks > > > > ? MFC: > > > > > Differential Revision: https://reviews.freebsd.org/D18726 > > > > > > Modified: > > > head/usr.bin/systat/devs.c > > > head/usr.bin/systat/devs.h > > > head/usr.bin/systat/iostat.c > > > head/usr.bin/systat/swap.c > > > head/usr.bin/systat/systat.h > > > head/usr.bin/systat/vmstat.c > > > head/usr.bin/systat/zarc.c > > > > > > Modified: head/usr.bin/systat/devs.c > > > ============================================================================== > > > --- head/usr.bin/systat/devs.c Tue Apr 2 13:59:04 2019 (r345803) > > > +++ head/usr.bin/systat/devs.c Tue Apr 2 14:01:03 2019 (r345804) > > > @@ -2,6 +2,7 @@ > > > * SPDX-License-Identifier: BSD-3-Clause > > > * > > > * Copyright (c) 1998 Kenneth D. Merry. > > > + * 2015 Yoshihiro Ota > > > * All rights reserved. > > > > > > Can we get in contact with Yoshihiro Ota about his > > copyright statements, and correcting this to make > > it clear that it is Kenneth D. Merry that is asserting > > "All rights reserved" and if Ota does nor does not wish to assert > > "All rights reserved". > > > > As committed this makes a grey area on Kenneth's assertion, > > also leaving out the word copyright on Yoshihiro's line is a bit iffy. > > > > I am only commenting once, this issue appears several times. > > We can go back out to D18726 to discuss it if need be. > > I've fully written zarc.c (and copied copy-right section from another file) > but all other changes in other files are refactoring and adjustments. > > I don't know the policy/procedure of how to update copy right section of FreeBSD. > Please adjust them according the project. > > Regards, > Hiro > I'll create a review with you as a reviewer that takes what I believe is the appropriate steps, and seek your approval for changes to your copyright statements. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-head@freebsd.org Wed Apr 3 03:50:17 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23A85155A722; Wed, 3 Apr 2019 03:50:17 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B77848E744; Wed, 3 Apr 2019 03:50:16 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 944F582CB; Wed, 3 Apr 2019 03:50:16 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x333oGa1030064; Wed, 3 Apr 2019 03:50:16 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x333oG3X030063; Wed, 3 Apr 2019 03:50:16 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201904030350.x333oG3X030063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 3 Apr 2019 03:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345828 - head/sys/rpc/rpcsec_gss X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/rpc/rpcsec_gss X-SVN-Commit-Revision: 345828 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B77848E744 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 03:50:17 -0000 Author: rmacklem Date: Wed Apr 3 03:50:16 2019 New Revision: 345828 URL: https://svnweb.freebsd.org/changeset/base/345828 Log: Add a comment to the r345818 patch to explain why cl_refs is initialized to 2. PR: 235582 MFC after: 2 weeks Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c ============================================================================== --- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Wed Apr 3 03:30:57 2019 (r345827) +++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Wed Apr 3 03:50:16 2019 (r345828) @@ -568,6 +568,11 @@ svc_rpc_gss_create_client(void) client = mem_alloc(sizeof(struct svc_rpc_gss_client)); memset(client, 0, sizeof(struct svc_rpc_gss_client)); + + /* + * Set the initial value of cl_refs to two. One for the caller + * and the other to hold onto the client structure until it expires. + */ refcount_init(&client->cl_refs, 2); sx_init(&client->cl_lock, "GSS-client"); getcredhostid(curthread->td_ucred, &hostid); From owner-svn-src-head@freebsd.org Wed Apr 3 03:54:32 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3D84155AAA7; Wed, 3 Apr 2019 03:54:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 814B98EBC2; Wed, 3 Apr 2019 03:54:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A70D8474; Wed, 3 Apr 2019 03:54:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x333sVoa035042; Wed, 3 Apr 2019 03:54:31 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x333sVS1035041; Wed, 3 Apr 2019 03:54:31 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904030354.x333sVS1035041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 3 Apr 2019 03:54:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345829 - head/sys/powerpc/fpu X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/fpu X-SVN-Commit-Revision: 345829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 814B98EBC2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 03:54:32 -0000 Author: jhibbits Date: Wed Apr 3 03:54:30 2019 New Revision: 345829 URL: https://svnweb.freebsd.org/changeset/base/345829 Log: powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt This fix was committed less than 2 months after the code was forked into the powerpc kernel. Though powerpc doesn't use quad-precision floating point, or need it for emulation, the changes do look like correctness fixes overall. This was found while trying to get fsqrt emulation working on e5500, which does have a real FPU, but lacks the fsqrt instruction. This is not the complete fix, the rest is to be committed separately. MFC after: 1 week Modified: head/sys/powerpc/fpu/fpu_sqrt.c Modified: head/sys/powerpc/fpu/fpu_sqrt.c ============================================================================== --- head/sys/powerpc/fpu/fpu_sqrt.c Wed Apr 3 03:50:16 2019 (r345828) +++ head/sys/powerpc/fpu/fpu_sqrt.c Wed Apr 3 03:54:30 2019 (r345829) @@ -353,7 +353,7 @@ fpu_sqrt(struct fpemu *fe) FPU_SUBC(d0, x0, t0); if ((int)d0 >= 0) { x0 = d0, x1 = d1, x2 = d2; - q |= bit; + q = bit; y1 |= 1; /* now t1, y1 are set in concrete */ } ODD_DOUBLE; @@ -385,12 +385,12 @@ fpu_sqrt(struct fpemu *fe) FPU_SUBCS(d2, x2, t2); FPU_SUBCS(d1, x1, t1); FPU_SUBC(d0, x0, t0); - ODD_DOUBLE; if ((int)d0 >= 0) { - x0 = d0, x1 = d1, x2 = d2; - q |= bit; + x0 = d0, x1 = d1, x2 = d2; x3 = d3; + q = bit; y2 |= 1; } + ODD_DOUBLE; while ((bit >>= 1) != 0) { EVEN_DOUBLE; t3 = y3 | bit; @@ -399,7 +399,7 @@ fpu_sqrt(struct fpemu *fe) FPU_SUBCS(d1, x1, t1); FPU_SUBC(d0, x0, t0); if ((int)d0 >= 0) { - x0 = d0, x1 = d1, x2 = d2; + x0 = d0, x1 = d1, x2 = d2; x3 = d3; q |= bit; y3 |= bit << 1; } From owner-svn-src-head@freebsd.org Wed Apr 3 03:57:40 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FEF3155AB4C; Wed, 3 Apr 2019 03:57:40 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EA86A8ED6A; Wed, 3 Apr 2019 03:57:39 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7C36847D; Wed, 3 Apr 2019 03:57:39 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x333vd5J035255; Wed, 3 Apr 2019 03:57:39 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x333vblZ035243; Wed, 3 Apr 2019 03:57:37 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201904030357.x333vblZ035243@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 3 Apr 2019 03:57:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345830 - in head: lib/libsecureboot lib/libsecureboot/h share/mk stand stand/common sys/conf sys/security/mac_veriexec_parser tools/build/options X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head: lib/libsecureboot lib/libsecureboot/h share/mk stand stand/common sys/conf sys/security/mac_veriexec_parser tools/build/options X-SVN-Commit-Revision: 345830 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EA86A8ED6A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 03:57:40 -0000 Author: mw Date: Wed Apr 3 03:57:37 2019 New Revision: 345830 URL: https://svnweb.freebsd.org/changeset/base/345830 Log: Create kernel module to parse Veriexec manifest based on envs The current approach of injecting manifest into mac_veriexec is to verify the integrity of it in userspace (veriexec (8)) and pass its entries into kernel using a char device (/dev/veriexec). This requires verifying root partition integrity in loader, for example by using memory disk and checking its hash. Otherwise if rootfs is compromised an attacker could inject their own data. This patch introduces an option to parse manifest in kernel based on envs. The loader sets manifest path and digest. EVENTHANDLER is used to launch the module right after the rootfs is mounted. It has to be done this way, since one might want to verify integrity of the init file. This means that manifest is required to be present on the root partition. Note that the envs have to be set right before boot to make sure that no one can spoof them. Submitted by: Kornel Duleba Reviewed by: sjg Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D19281 Added: head/lib/libsecureboot/pass_manifest.c (contents, props changed) head/sys/security/mac_veriexec_parser/ head/sys/security/mac_veriexec_parser/mac_veriexec_parser.c (contents, props changed) head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST (contents, props changed) Modified: head/lib/libsecureboot/Makefile.libsa.inc head/lib/libsecureboot/h/verify_file.h head/lib/libsecureboot/libsecureboot-priv.h head/lib/libsecureboot/verify_file.c head/share/mk/src.opts.mk head/stand/common/boot.c head/stand/common/module.c head/stand/loader.mk head/sys/conf/files Modified: head/lib/libsecureboot/Makefile.libsa.inc ============================================================================== --- head/lib/libsecureboot/Makefile.libsa.inc Wed Apr 3 03:54:30 2019 (r345829) +++ head/lib/libsecureboot/Makefile.libsa.inc Wed Apr 3 03:57:37 2019 (r345830) @@ -29,6 +29,11 @@ CFLAGS+= \ -I${SRCTOP}/stand/efi/include/${MACHINE} .endif +.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} == "yes" +SRCS+= \ + pass_manifest.c +.endif + # this is the list of paths (relative to a file # that we need to verify) used to find a signed manifest. # the signature extensions in VE_SIGNATURE_EXT_LIST Modified: head/lib/libsecureboot/h/verify_file.h ============================================================================== --- head/lib/libsecureboot/h/verify_file.h Wed Apr 3 03:54:30 2019 (r345829) +++ head/lib/libsecureboot/h/verify_file.h Wed Apr 3 03:57:37 2019 (r345830) @@ -32,6 +32,7 @@ #define VE_WANT 1 /* we want this verified */ #define VE_MUST 2 /* this must be verified */ +#define VE_NOT_CHECKED -42 #define VE_VERIFIED 1 /* all good */ #define VE_UNVERIFIED_OK 0 /* not verified but that's ok */ #define VE_NOT_VERIFYING 2 /* we are not verifying */ @@ -42,6 +43,8 @@ void ve_debug_set(int); int ve_status_get(int); void ve_efi_init(void); int load_manifest(const char *, const char *, const char *, struct stat *); +int pass_manifest(const char *, const char *); +int pass_manifest_export_envs(void); int verify_file(int, const char *, off_t, int); void verify_pcr_export(void); Modified: head/lib/libsecureboot/libsecureboot-priv.h ============================================================================== --- head/lib/libsecureboot/libsecureboot-priv.h Wed Apr 3 03:54:30 2019 (r345829) +++ head/lib/libsecureboot/libsecureboot-priv.h Wed Apr 3 03:57:37 2019 (r345830) @@ -31,6 +31,8 @@ /* public api */ #include "libsecureboot.h" +struct stat; + typedef struct { unsigned char *data; size_t hash_size; @@ -49,6 +51,9 @@ int verify_rsa_digest(br_rsa_public_key *pkey, const unsigned char *hash_oid, unsigned char *mdata, size_t mlen, unsigned char *sdata, size_t slen); + +int is_verified(struct stat *stp); +void add_verify_status(struct stat *stp, int status); int openpgp_self_tests(void); Added: head/lib/libsecureboot/pass_manifest.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libsecureboot/pass_manifest.c Wed Apr 3 03:57:37 2019 (r345830) @@ -0,0 +1,152 @@ +/*- + * Copyright (c) 2019 Stormshield. + * Copyright (c) 2019 Semihalf. + * + * 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 ``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 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$ + */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "libsecureboot-priv.h" +#include + +/* + * Values to pass to kernel by envs. + */ +static char manifest_path[MAXPATHLEN]; +static char manifest_prefix[MAXPATHLEN]; +static char manifest_hash[2 * br_sha256_SIZE + 2]; +static int manifest_present = 0; + +/* + * Verify and pass manifest path and digest to kernel through envs. + * The paths in manifest can be either absolute, + * or "prefix", if exists will be added to the ones that are not. + */ +int +pass_manifest(const char *path, const char *prefix) +{ + char *content; + struct stat st; + unsigned char digest[br_sha256_SIZE]; + const br_hash_class *md; + br_hash_compat_context ctx; + int rc; + + content = NULL; + md = &br_sha256_vtable; + + if (strnlen(path, MAXPATHLEN) == MAXPATHLEN || + strnlen(prefix, MAXPATHLEN) == MAXPATHLEN) + return (EINVAL); + + rc = stat(path, &st); + if (rc != 0) + goto out; + + if (!S_ISREG(st.st_mode)) { + rc = EINVAL; + goto out; + } + + rc = is_verified(&st); + + if (rc != VE_NOT_CHECKED && rc != VE_VERIFIED) { + rc = EPERM; + goto out; + } + + if (rc == VE_VERIFIED) + content = read_file(path, NULL); + else + content = (char *)verify_signed(path, VEF_VERBOSE); + + if (content == NULL) { + add_verify_status(&st, VE_FINGERPRINT_WRONG); + rc = EIO; + goto out; + } + + add_verify_status(&st, VE_VERIFIED); + + md->init(&ctx.vtable); + md->update(&ctx.vtable, content, st.st_size); + md->out(&ctx.vtable, digest); + + if (prefix == NULL) + manifest_prefix[0] = '\0'; + else + strcpy(manifest_prefix, prefix); + + strcpy(manifest_path, path); + + hexdigest(manifest_hash, 2 * br_sha256_SIZE + 2, + digest, br_sha256_SIZE); + manifest_hash[2*br_sha256_SIZE] = '\0'; + + manifest_present = 1; + rc = 0; + +out: + if (content != NULL) + free(content); + + return (rc); +} + +/* + * Set appropriate envs to inform kernel about manifest location and digest. + * This should be called right before boot so that envs can't be replaced. + */ +int +pass_manifest_export_envs() +{ + int rc; + + /* If we have nothing to pass make sure that envs are empty. */ + if (!manifest_present) { + unsetenv("veriexec.manifest_path"); + unsetenv("veriexec.manifest_hash"); + unsetenv("veriexec.manifest_prefix"); + return (0); + } + + rc = setenv("veriexec.manifest_path", manifest_path, 1); + if (rc != 0) + return (rc); + + rc = setenv("veriexec.manifest_hash", manifest_hash, 1); + if (rc != 0) { + unsetenv("veriexec.manifest_path"); + return (rc); + } + + if (manifest_prefix[0] != '\0') + rc = setenv("veriexec.manifest_prefix", manifest_prefix, 1); + + return (rc); +} + Modified: head/lib/libsecureboot/verify_file.c ============================================================================== --- head/lib/libsecureboot/verify_file.c Wed Apr 3 03:54:30 2019 (r345829) +++ head/lib/libsecureboot/verify_file.c Wed Apr 3 03:57:37 2019 (r345830) @@ -36,8 +36,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define VE_NOT_CHECKED -42 - #ifdef UNIT_TEST # include # define panic warn @@ -112,7 +110,7 @@ struct verify_status { struct verify_status *vs_next; }; -static int +int is_verified(struct stat *stp) { struct verify_status *vsp; @@ -126,7 +124,7 @@ is_verified(struct stat *stp) } /* most recent first, since most likely to see repeated calls. */ -static void +void add_verify_status(struct stat *stp, int status) { struct verify_status *vsp; Modified: head/share/mk/src.opts.mk ============================================================================== --- head/share/mk/src.opts.mk Wed Apr 3 03:54:30 2019 (r345829) +++ head/share/mk/src.opts.mk Wed Apr 3 03:57:37 2019 (r345830) @@ -205,6 +205,7 @@ __DEFAULT_NO_OPTIONS = \ LOADER_FIREWIRE \ LOADER_FORCE_LE \ LOADER_VERBOSE \ + LOADER_VERIEXEC_PASS_MANIFEST \ NAND \ OFED_EXTRA \ OPENLDAP \ @@ -545,6 +546,10 @@ MK_LLDB:= no MK_CLANG_EXTRAS:= no MK_CLANG_FULL:= no MK_LLVM_COV:= no +.endif + +.if ${MK_LOADER_VERIEXEC} == "no" +MK_LOADER_VERIEXEC_PASS_MANIFEST := no .endif # Modified: head/stand/common/boot.c ============================================================================== --- head/stand/common/boot.c Wed Apr 3 03:54:30 2019 (r345829) +++ head/stand/common/boot.c Wed Apr 3 03:57:37 2019 (r345830) @@ -108,6 +108,9 @@ command_boot(int argc, char *argv[]) #ifdef LOADER_VERIEXEC verify_pcr_export(); /* for measured boot */ +#ifdef LOADER_VERIEXEC_PASS_MANIFEST + pass_manifest_export_envs(); +#endif #endif /* Call the exec handler from the loader matching the kernel */ Modified: head/stand/common/module.c ============================================================================== --- head/stand/common/module.c Wed Apr 3 03:54:30 2019 (r345829) +++ head/stand/common/module.c Wed Apr 3 03:57:37 2019 (r345830) @@ -159,6 +159,13 @@ command_load(int argc, char *argv[]) ve_debug_set(dflag); return (load_manifest(argv[1], prefix, skip, NULL)); } +#ifdef LOADER_VERIEXEC_PASS_MANIFEST + if (strncmp(typestr, "pass_manifest", 13) == 0) { + if (dflag > 0) + ve_debug_set(dflag); + return (pass_manifest(argv[1], prefix)); + } +#endif #endif fp = file_findfile(argv[1], typestr); Modified: head/stand/loader.mk ============================================================================== --- head/stand/loader.mk Wed Apr 3 03:54:30 2019 (r345829) +++ head/stand/loader.mk Wed Apr 3 03:57:37 2019 (r345830) @@ -77,6 +77,10 @@ SRCS+= interp_simple.c CFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h .endif +.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} != "no" +CFLAGS+= -DLOADER_VERIEXEC_PASS_MANIFEST -I${SRCTOP}/lib/libsecureboot/h +.endif + .if defined(BOOT_PROMPT_123) CFLAGS+= -DBOOT_PROMPT_123 .endif Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Apr 3 03:54:30 2019 (r345829) +++ head/sys/conf/files Wed Apr 3 03:57:37 2019 (r345830) @@ -4890,14 +4890,15 @@ security/mac_portacl/mac_portacl.c optional mac_portac security/mac_seeotheruids/mac_seeotheruids.c optional mac_seeotheruids security/mac_stub/mac_stub.c optional mac_stub security/mac_test/mac_test.c optional mac_test -security/mac_veriexec/mac_veriexec.c optional mac_veriexec -security/mac_veriexec/veriexec_fingerprint.c optional mac_veriexec -security/mac_veriexec/veriexec_metadata.c optional mac_veriexec -security/mac_veriexec/mac_veriexec_rmd160.c optional mac_veriexec_rmd160 -security/mac_veriexec/mac_veriexec_sha1.c optional mac_veriexec_sha1 -security/mac_veriexec/mac_veriexec_sha256.c optional mac_veriexec_sha256 -security/mac_veriexec/mac_veriexec_sha384.c optional mac_veriexec_sha384 -security/mac_veriexec/mac_veriexec_sha512.c optional mac_veriexec_sha512 +security/mac_veriexec/mac_veriexec.c optional mac_veriexec +security/mac_veriexec/veriexec_fingerprint.c optional mac_veriexec +security/mac_veriexec/veriexec_metadata.c optional mac_veriexec +security/mac_veriexec_parser/mac_veriexec_parser.c optional mac_veriexec mac_veriexec_parser +security/mac_veriexec/mac_veriexec_rmd160.c optional mac_veriexec_rmd160 +security/mac_veriexec/mac_veriexec_sha1.c optional mac_veriexec_sha1 +security/mac_veriexec/mac_veriexec_sha256.c optional mac_veriexec_sha256 +security/mac_veriexec/mac_veriexec_sha384.c optional mac_veriexec_sha384 +security/mac_veriexec/mac_veriexec_sha512.c optional mac_veriexec_sha512 teken/teken.c optional sc !SC_NO_TERM_TEKEN | vt ufs/ffs/ffs_alloc.c optional ffs ufs/ffs/ffs_balloc.c optional ffs Added: head/sys/security/mac_veriexec_parser/mac_veriexec_parser.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/security/mac_veriexec_parser/mac_veriexec_parser.c Wed Apr 3 03:57:37 2019 (r345830) @@ -0,0 +1,474 @@ +/*- + * Copyright (c) 2019 Stormshield. + * Copyright (c) 2019 Semihalf. + * + * 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 ``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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +/* The following are based on sbin/veriexec */ +struct fingerprint_type { + const char *fp_type; + int fp_size; +}; + +struct fp_flag { + const char *flag_name; + int flag; +}; + +static const struct fingerprint_type fp_table[] = { + {"sha256=", SHA256_DIGEST_LENGTH}, +#if MAXFINGERPRINTLEN >= SHA384_DIGEST_LENGTH + {"sha384=", SHA384_DIGEST_LENGTH}, +#endif +#if MAXFINGERPRINTLEN >= SHA512_DIGEST_LENGTH + {"sha512=", SHA512_DIGEST_LENGTH}, +#endif + {NULL, 0} +}; + +static const struct fp_flag flags_table[] = { + {"indirect", VERIEXEC_INDIRECT}, + {"no_ptrace", VERIEXEC_NOTRACE}, + {"trusted", VERIEXEC_TRUSTED}, + {"no_fips", VERIEXEC_NOFIPS}, + {NULL, 0} +}; + +extern struct mtx ve_mutex; + +static unsigned char hexchar_to_byte(unsigned char c); +static int hexstring_to_bin(unsigned char *buf); + +static int get_flags(const char *entry); +static int get_fp(const char *entry, char **type, + unsigned char **digest, int *flags); +static int verify_digest(const char *data, size_t len, + const unsigned char *expected_hash); + +static int open_file(const char *path, struct nameidata *nid); +static char *read_manifest(char *path, unsigned char *digest); +static int parse_entry(char *entry, char *prefix); +static int parse_manifest(char *path, unsigned char *hash, char *prefix); + +static unsigned char +hexchar_to_byte(unsigned char c) +{ + + if (isdigit(c)) + return (c - '0'); + + return (isupper(c) ? c - 'A' + 10 : c - 'a' + 10); +} + +static int +hexstring_to_bin(unsigned char *buf) +{ + size_t i, len; + unsigned char byte; + + len = strlen(buf); + for (i = 0; i < len / 2; i++) { + if (!isxdigit(buf[2 * i]) || !isxdigit(buf[2 * i + 1])) + return (EINVAL); + + byte = hexchar_to_byte(buf[2 * i]) << 4; + byte += hexchar_to_byte(buf[2 * i + 1]); + buf[i] = byte; + } + return (0); +} + +static int +get_flags(const char *entry) +{ + int i; + int result = 0; + + for (i = 0; flags_table[i].flag_name != NULL; i++) + if (strstr(entry, flags_table[i].flag_name) != NULL) + result |= flags_table[i].flag; + + return (result); +} + +/* + * Parse a single line of manifest looking for a digest and its type. + * We expect it to be in form of "path shaX=hash". + * The line will be split into path, hash type and hash value. + */ +static int +get_fp(const char *entry, char **type, unsigned char **digest, int *flags) +{ + char *delimiter; + char *local_digest; + char *fp_type; + char *prev_fp_type; + size_t min_len; + int i; + + delimiter = NULL; + fp_type = NULL; + prev_fp_type = NULL; + + for (i = 0; fp_table[i].fp_type != NULL; i++) { + fp_type = strstr(entry, fp_table[i].fp_type); + /* Look for the last "shaX=hash" in line */ + while (fp_type != NULL) { + prev_fp_type = fp_type; + fp_type++; + fp_type = strstr(fp_type, fp_table[i].fp_type); + } + fp_type = prev_fp_type; + if (fp_type != NULL) { + if (fp_type == entry || fp_type[-1] != ' ') + return (EINVAL); + + /* + * The entry should contain at least + * fp_type and digest in hexadecimal form. + */ + min_len = strlen(fp_table[i].fp_type) + + 2 * fp_table[i].fp_size; + + if (strnlen(fp_type, min_len) < min_len) + return (EINVAL); + + local_digest = &fp_type[strlen(fp_table[i].fp_type)]; + delimiter = &local_digest[2 * fp_table[i].fp_size]; + + /* + * Make sure that digest is followed by + * some kind of delimiter. + */ + if (*delimiter != '\n' && + *delimiter != '\0' && + *delimiter != ' ') + return (EINVAL); + + /* + * Does the entry contain flags we need to parse? + */ + if (*delimiter == ' ' && flags != NULL) + *flags = get_flags(delimiter); + + /* + * Split entry into three parts: + * path, fp_type and digest. + */ + local_digest[-1] = '\0'; + *delimiter = '\0'; + fp_type[-1] = '\0'; + break; + } + } + + if (fp_type == NULL) + return (EINVAL); + + if (type != NULL) + *type = fp_type; + + if (digest != NULL) + *digest = local_digest; + + return (0); +} + +/* + * Currently we verify manifest using sha256. + * In future another env with hash type could be introduced. + */ +static int +verify_digest(const char *data, size_t len, const unsigned char *expected_hash) +{ + SHA256_CTX ctx; + unsigned char hash[SHA256_DIGEST_LENGTH]; + + SHA256_Init(&ctx); + SHA256_Update(&ctx, data, len); + SHA256_Final(hash, &ctx); + + return (memcmp(expected_hash, hash, SHA256_DIGEST_LENGTH)); +} + + +static int +open_file(const char *path, struct nameidata *nid) +{ + int flags, rc; + + flags = FREAD; + + pwd_ensure_dirs(); + + NDINIT(nid, LOOKUP, 0, UIO_SYSSPACE, path, curthread); + rc = vn_open(nid, &flags, 0, NULL); + NDFREE(nid, NDF_ONLY_PNBUF); + if (rc != 0) + return (rc); + + return (0); +} + +/* + * Read the manifest from location specified in path and verify its digest. + */ +static char* +read_manifest(char *path, unsigned char *digest) +{ + struct nameidata nid; + struct vattr va; + char *data; + ssize_t bytes_read, resid; + int rc; + + data = NULL; + bytes_read = 0; + + rc = open_file(path, &nid); + if (rc != 0) + goto fail; + + rc = VOP_GETATTR(nid.ni_vp, &va, curthread->td_ucred); + if (rc != 0) + goto fail; + + data = (char *)malloc(va.va_size + 1, M_VERIEXEC, M_WAITOK); + + while (bytes_read < va.va_size) { + rc = vn_rdwr( + UIO_READ, nid.ni_vp, data, + va.va_size - bytes_read, bytes_read, + UIO_SYSSPACE, IO_NODELOCKED, + curthread->td_ucred, NOCRED, &resid, curthread); + if (rc != 0) + goto fail; + + bytes_read = va.va_size - resid; + } + + data[bytes_read] = '\0'; + + VOP_UNLOCK(nid.ni_vp, 0); + (void)vn_close(nid.ni_vp, FREAD, curthread->td_ucred, curthread); + + /* + * If digest is wrong someone might be trying to fool us. + */ + if (verify_digest(data, va.va_size, digest)) + panic("Manifest hash doesn't match expected value!"); + + return (data); + +fail: + if (data != NULL) + free(data, M_VERIEXEC); + + return (NULL); +} + +/* + * Process single line. + * First split it into path, digest_type and digest. + * Then try to open the file and insert its fingerprint into metadata store. + */ +static int +parse_entry(char *entry, char *prefix) +{ + struct nameidata nid; + struct vattr va; + char path[MAXPATHLEN]; + char *fp_type; + unsigned char *digest; + int rc, is_exec, flags; + + fp_type = NULL; + digest = NULL; + flags = 0; + + rc = get_fp(entry, &fp_type, &digest, &flags); + if (rc != 0) + return (rc); + + rc = hexstring_to_bin(digest); + if (rc != 0) + return (rc); + + if (strnlen(entry, MAXPATHLEN) == MAXPATHLEN) + return (EINVAL); + + /* If the path is not absolute prepend it with a prefix */ + if (prefix != NULL && entry[0] != '/') { + rc = snprintf(path, MAXPATHLEN, "%s/%s", + prefix, entry); + if (rc < 0) + return (-rc); + } else { + strcpy(path, entry); + } + + rc = open_file(path, &nid); + NDFREE(&nid, NDF_ONLY_PNBUF); + if (rc != 0) + return (rc); + + rc = VOP_GETATTR(nid.ni_vp, &va, curthread->td_ucred); + if (rc != 0) + goto out; + + is_exec = (va.va_mode & VEXEC); + + mtx_lock(&ve_mutex); + rc = mac_veriexec_metadata_add_file( + is_exec == 0, + va.va_fsid, va.va_fileid, va.va_gen, + digest, flags, fp_type, 1); + mtx_unlock(&ve_mutex); + +out: + VOP_UNLOCK(nid.ni_vp, 0); + vn_close(nid.ni_vp, FREAD, curthread->td_ucred, curthread); + return (rc); +} + +/* + * Look for manifest in env that have beed passed by loader. + * This routine should be called right after the rootfs is mounted. + */ +static int +parse_manifest(char *path, unsigned char *hash, char *prefix) +{ + char *data; + char *entry; + char *next_entry; + int rc, success_count; + + data = NULL; + success_count = 0; + rc = 0; + + data = read_manifest(path, hash); + if (data == NULL) { + rc = EIO; + goto out; + } + + entry = data; + while (entry != NULL) { + next_entry = strchr(entry, '\n'); + if (next_entry != NULL) { + *next_entry = '\0'; + next_entry++; + } + if (entry[0] == '\n' || entry[0] == '\0') { + entry = next_entry; + continue; + } + if ((rc = parse_entry(entry, prefix))) + printf("mac_veriexec_parser: Warning: Failed to parse" + " entry with rc:%d, entry:\"%s\"\n", rc, entry); + else + success_count++; + + entry = next_entry; + } + rc = 0; + +out: + if (data != NULL) + free(data, M_VERIEXEC); + + if (success_count == 0) + rc = EINVAL; + + return (rc); +} + +static void +parse_manifest_event(void *dummy) +{ + char *manifest_path; + char *manifest_prefix; + unsigned char *manifest_hash; + int rc; + + /* If the envs are not set fail silently */ + manifest_path = kern_getenv("veriexec.manifest_path"); + if (manifest_path == NULL) + return; + + manifest_hash = kern_getenv("veriexec.manifest_hash"); + if (manifest_hash == NULL) { + freeenv(manifest_path); + return; + } + + manifest_prefix = kern_getenv("veriexec.manifest_prefix"); + + if (strlen(manifest_hash) != 2 * SHA256_DIGEST_LENGTH) + panic("veriexec.manifest_hash has incorrect size"); + + rc = hexstring_to_bin(manifest_hash); + if (rc != 0) + panic("mac_veriexec: veriexec.loader.manifest_hash" + " doesn't contain a hash in hexadecimal form"); + + rc = parse_manifest(manifest_path, manifest_hash, manifest_prefix); + if (rc != 0) + panic("mac_veriexec: Failed to parse manifest err=%d", rc); + + mtx_lock(&ve_mutex); + mac_veriexec_set_state( + VERIEXEC_STATE_LOADED | VERIEXEC_STATE_ACTIVE | + VERIEXEC_STATE_LOCKED | VERIEXEC_STATE_ENFORCE); + mtx_unlock(&ve_mutex); + + freeenv(manifest_path); + freeenv(manifest_hash); + if (manifest_prefix != NULL) + freeenv(manifest_prefix); +} + +EVENTHANDLER_DEFINE(mountroot, parse_manifest_event, NULL, 0); Added: head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST Wed Apr 3 03:57:37 2019 (r345830) @@ -0,0 +1,8 @@ +.\" $FreeBSD$ +Enable building +.Xr loader 8 +with support to pass a verified manifest to kernel. +Kernel has to be build with a module to parse the manfiest. +.Pp +It depends on +.Va WITH_LOADER_VERIEXEC From owner-svn-src-head@freebsd.org Wed Apr 3 04:01:10 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33B32155ADEF; Wed, 3 Apr 2019 04:01:10 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB45A8F0BD; Wed, 3 Apr 2019 04:01:09 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8BB6184BD; Wed, 3 Apr 2019 04:01:09 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33419Ow036255; Wed, 3 Apr 2019 04:01:09 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33418h0036251; Wed, 3 Apr 2019 04:01:08 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904030401.x33418h0036251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 3 Apr 2019 04:01:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345831 - in head/sys/powerpc: include powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys/powerpc: include powerpc X-SVN-Commit-Revision: 345831 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CB45A8F0BD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 04:01:10 -0000 Author: jhibbits Date: Wed Apr 3 04:01:08 2019 New Revision: 345831 URL: https://svnweb.freebsd.org/changeset/base/345831 Log: powerpc: Allow emulating optional FPU instructions on CPUs with an FPU The e5500 has an FPU, but lacks the optional fsqrt instruction. This instruction gets emulated in the kernel, but the emulation uses stale data, from the last switch out, and does not return the result of the operation immediately. Fix both of these conditions by saving and restoring the FPRs around the emulation point. MFC after: 1 week MFC with: r345829 Modified: head/sys/powerpc/include/trap.h head/sys/powerpc/powerpc/exec_machdep.c head/sys/powerpc/powerpc/trap.c Modified: head/sys/powerpc/include/trap.h ============================================================================== --- head/sys/powerpc/include/trap.h Wed Apr 3 03:57:37 2019 (r345830) +++ head/sys/powerpc/include/trap.h Wed Apr 3 04:01:08 2019 (r345831) @@ -152,10 +152,10 @@ #ifndef LOCORE struct trapframe; -struct pcb; +struct thread; extern int (*hmi_handler)(struct trapframe *); void trap(struct trapframe *); -int ppc_instr_emulate(struct trapframe *, struct pcb *); +int ppc_instr_emulate(struct trapframe *, struct thread *); #endif #endif /* _POWERPC_TRAP_H_ */ Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Wed Apr 3 03:57:37 2019 (r345830) +++ head/sys/powerpc/powerpc/exec_machdep.c Wed Apr 3 04:01:08 2019 (r345831) @@ -1081,8 +1081,9 @@ emulate_mtspr(int spr, int reg, struct trapframe *fram #define XFX 0xFC0007FF int -ppc_instr_emulate(struct trapframe *frame, struct pcb *pcb) +ppc_instr_emulate(struct trapframe *frame, struct thread *td) { + struct pcb *pcb; uint32_t instr; int reg, sig; int rs, spr; @@ -1109,12 +1110,16 @@ ppc_instr_emulate(struct trapframe *frame, struct pcb return (0); } + pcb = td->td_pcb; #ifdef FPU_EMU if (!(pcb->pcb_flags & PCB_FPREGS)) { bzero(&pcb->pcb_fpu, sizeof(pcb->pcb_fpu)); pcb->pcb_flags |= PCB_FPREGS; - } + } else if (pcb->pcb_flags & PCB_FPU) + save_fpu(td); sig = fpu_emulate(frame, &pcb->pcb_fpu); + if ((sig == 0 || sig == SIGFPE) && pcb->pcb_flags & PCB_FPU) + enable_fpu(td); #endif if (sig == SIGILL) { if (pcb->pcb_lastill != frame->srr0) { Modified: head/sys/powerpc/powerpc/trap.c ============================================================================== --- head/sys/powerpc/powerpc/trap.c Wed Apr 3 03:57:37 2019 (r345830) +++ head/sys/powerpc/powerpc/trap.c Wed Apr 3 04:01:08 2019 (r345831) @@ -363,7 +363,7 @@ trap(struct trapframe *frame) sig = SIGTRAP; ucode = TRAP_BRKPT; } else { - sig = ppc_instr_emulate(frame, td->td_pcb); + sig = ppc_instr_emulate(frame, td); if (sig == SIGILL) { if (frame->srr1 & EXC_PGM_PRIV) ucode = ILL_PRVOPC; From owner-svn-src-head@freebsd.org Wed Apr 3 07:09:29 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D99D01560F9E; Wed, 3 Apr 2019 07:09:29 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7DE9B96C0E; Wed, 3 Apr 2019 07:09:29 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 59F54A541; Wed, 3 Apr 2019 07:09:29 +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 x3379TGF038960; Wed, 3 Apr 2019 07:09:29 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3379T7E038959; Wed, 3 Apr 2019 07:09:29 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201904030709.x3379T7E038959@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Wed, 3 Apr 2019 07:09:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345839 - head/sbin/fsck_msdosfs X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: head/sbin/fsck_msdosfs X-SVN-Commit-Revision: 345839 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7DE9B96C0E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 07:09:30 -0000 Author: delphij Date: Wed Apr 3 07:09:28 2019 New Revision: 345839 URL: https://svnweb.freebsd.org/changeset/base/345839 Log: Assert that q can't be NULL. 'empty' is always non-NULL when DIREMPTY is set earlier. MFC after: 1 month Modified: head/sbin/fsck_msdosfs/dir.c Modified: head/sbin/fsck_msdosfs/dir.c ============================================================================== --- head/sbin/fsck_msdosfs/dir.c Wed Apr 3 06:37:25 2019 (r345838) +++ head/sbin/fsck_msdosfs/dir.c Wed Apr 3 07:09:28 2019 (r345839) @@ -35,6 +35,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include @@ -520,7 +521,8 @@ readDosDirSection(int f, struct bootblock *boot, struc empcl, empty - buffer, cl, p - buffer, 1) == FSFATAL) return FSFATAL; - q = empcl == cl ? empty : buffer; + q = ((empcl == cl) ? empty : buffer); + assert(q != NULL); for (; q < p; q += 32) *q = SLOT_DELETED; mod |= THISMOD|FSDIRMOD; From owner-svn-src-head@freebsd.org Wed Apr 3 08:22:59 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C9561563B66; Wed, 3 Apr 2019 08:22:59 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 20E0A6B751; Wed, 3 Apr 2019 08:22:59 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F0A71B2E6; Wed, 3 Apr 2019 08:22:58 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x338MwAv081431; Wed, 3 Apr 2019 08:22:58 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x338Mwqe081430; Wed, 3 Apr 2019 08:22:58 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201904030822.x338Mwqe081430@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 3 Apr 2019 08:22:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345842 - head/sys/dev/tpm X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/tpm X-SVN-Commit-Revision: 345842 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 20E0A6B751 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 08:22:59 -0000 Author: mw Date: Wed Apr 3 08:22:58 2019 New Revision: 345842 URL: https://svnweb.freebsd.org/changeset/base/345842 Log: Add a cv_wait to the TPM2.0 harvesting function Harvesting has to compete for the TPM chip with userspace. Before this change the callout could hijack an unread buffer causing a userspace call to the TPM to fail. Submitted by: Kornel Duleba Reviewed by: delphij Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D19712 Modified: head/sys/dev/tpm/tpm20.c Modified: head/sys/dev/tpm/tpm20.c ============================================================================== --- head/sys/dev/tpm/tpm20.c Wed Apr 3 08:18:18 2019 (r345841) +++ head/sys/dev/tpm/tpm20.c Wed Apr 3 08:22:58 2019 (r345842) @@ -263,6 +263,8 @@ tpm20_harvest(void *arg) sc = arg; sx_xlock(&sc->dev_lock); + while (sc->pending_data_length != 0) + cv_wait(&sc->buf_cv, &sc->dev_lock); memcpy(sc->buf, cmd, sizeof(cmd)); result = sc->transmit(sc, sizeof(cmd)); From owner-svn-src-head@freebsd.org Wed Apr 3 12:47:50 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FB5D156D0B9; Wed, 3 Apr 2019 12:47:50 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DC544778F5; Wed, 3 Apr 2019 12:47:49 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8B97E15D; Wed, 3 Apr 2019 12:47:49 +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 x33ClnAI021098; Wed, 3 Apr 2019 12:47:49 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33ClnkS021097; Wed, 3 Apr 2019 12:47:49 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201904031247.x33ClnkS021097@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 3 Apr 2019 12:47:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345843 - head/contrib/bsnmp/lib X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/contrib/bsnmp/lib X-SVN-Commit-Revision: 345843 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DC544778F5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 12:47:50 -0000 Author: ae Date: Wed Apr 3 12:47:49 2019 New Revision: 345843 URL: https://svnweb.freebsd.org/changeset/base/345843 Log: Follow the declared behaviour that specifies server string format in bsnmpclient(3). snmp_parse_server() function accepts string where some fields can be omitted: [trans::][community@][server][:port] "trans" field can be "udp", "udp6", "dgram" and "stream". "community" can be empty string, if it is omitted, the default value will be used. For read_community it is "public", for write_comminity it is "private". "server" field can be hostname, IPv4 address or IPv6 address. IPv6 address should be specified in brackets "[]". If port is omitted, the default value "snmp" will be used for "udp" and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is not required to specify all fields in argument of '-s' option. E.g. # bsnmpget -s 127.1 sysName.0 # bsnmpget -s "udp::127.1" sysName.0 # bsnmpget -s "udp::public@127.1" sysName.0 # bsnmpget -s "udp::public@127.1:161" sysName.0 # bsnmpget -s "udp::[::1]" sysName.0 # bsnmpget -s "udp6::[::1]" sysName.0 # bsnmpget -s "[fe80::1%lo0]" sysName.0 PR: 236664 Reported by: olivier MFC after: 1 month Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- head/contrib/bsnmp/lib/snmpclient.c Wed Apr 3 08:22:58 2019 (r345842) +++ head/contrib/bsnmp/lib/snmpclient.c Wed Apr 3 12:47:49 2019 (r345843) @@ -1874,38 +1874,47 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } +static const char *const trans_list[] = { + [SNMP_TRANS_UDP] = "udp::", + [SNMP_TRANS_LOC_DGRAM] = "dgram::", + [SNMP_TRANS_LOC_STREAM] = "stream::", + [SNMP_TRANS_UDP6] = "udp6::", +}; + /** * Try to get a transport identifier which is a leading alphanumeric string - * (starting with '_' or a letter and including also '_') terminated by - * a double colon. The string may not be empty. The transport identifier - * is optional. + * terminated by a double colon. The string may not be empty. The transport + * identifier is optional. * * \param sc client struct to set errors * \param strp possible start of transport; updated to point to * the next character to parse * - * \return end of transport; equals *strp if there is none; NULL if there - * was an error + * \return transport identifier */ -static inline const char * +static inline int get_transp(struct snmp_client *sc, const char **strp) { - const char *p = *strp; + const char *p; + size_t i; - if (isascii(*p) && (isalpha(*p) || *p == '_')) { - p++; - while (isascii(*p) && (isalnum(*p) || *p == '_')) - p++; - if (p[0] == ':' && p[1] == ':') { - *strp = p + 2; - return (p); + for (i = 0; i < nitems(trans_list); i++) { + if (trans_list[i] == NULL || *trans_list[i] == '\0') + continue; + p = strstr(*strp, trans_list[i]); + if (p == *strp) { + *strp += strlen(trans_list[i]); + return ((int)i); } } + + p = *strp; if (p[0] == ':' && p[1] == ':') { seterr(sc, "empty transport specifier"); - return (NULL); + return (-1); } - return (*strp); + /* by default assume UDP */ + return (SNMP_TRANS_UDP); } /** @@ -2143,24 +2152,13 @@ save_str(struct snmp_client *sc, const char *const s[2 int snmp_parse_server(struct snmp_client *sc, const char *str) { -#if DEBUG_PARSE const char *const orig = str; -#endif - - const char *const trans_list[] = { - [SNMP_TRANS_UDP] = "udp", - [SNMP_TRANS_LOC_DGRAM] = "dgram", - [SNMP_TRANS_LOC_STREAM] = "stream", - [SNMP_TRANS_UDP6] = "udp6", - }; - /* parse input */ - const char *const transp[2] = { - str, - get_transp(sc, &str), - }; - if (transp[1] == NULL) + int i, trans = get_transp(sc, &str); + if (trans < 0) return (-1); + /* choose automatically */ + i = orig == str ? -1: trans; const char *const comm[2] = { str, @@ -2206,7 +2204,7 @@ snmp_parse_server(struct snmp_client *sc, const char * } #if DEBUG_PARSE - printf("transp: %zu %zu\n", transp[0] - orig, transp[1] - orig); + printf("transp: %u\n", trans); printf("comm: %zu %zu\n", comm[0] - orig, comm[1] - orig); printf("ipv6: %zu %zu\n", ipv6[0] - orig, ipv6[1] - orig); printf("ipv4: %zu %zu\n", ipv4[0] - orig, ipv4[1] - orig); @@ -2215,69 +2213,73 @@ snmp_parse_server(struct snmp_client *sc, const char * #endif /* analyse and allocate */ - int i = -1; - if (transp[0] != transp[1]) { - for (i = 0; i < (int)nitems(trans_list); i++) { - if (trans_list[i] != NULL && - strlen(trans_list[i]) == (size_t)(transp[1] - - transp[0]) && !strncmp(trans_list[i], transp[0], - transp[1] - transp[0])) - break; - } - - if (i == (int)nitems(trans_list)) { - seterr(sc, "unknown transport specifier '%.*s'", - transp[1] - transp[0], transp[0]); - return (-1); - } - } - char *chost; if (ipv6[0] != ipv6[1]) { if ((chost = save_str(sc, ipv6)) == NULL) return (-1); - if (i == -1) - i = SNMP_TRANS_UDP6; + if (i == -1 || trans == SNMP_TRANS_UDP) + trans = SNMP_TRANS_UDP6; } else if (ipv4[0] != ipv4[1]) { if ((chost = save_str(sc, ipv4)) == NULL) return (-1); if (i == -1) - i = SNMP_TRANS_UDP; + trans = SNMP_TRANS_UDP; } else { if ((chost = save_str(sc, host)) == NULL) return (-1); if (i == -1) { - /* Default transport is UDP unless the host contains - * a slash in which case we default to DGRAM. */ - i = SNMP_TRANS_UDP; + /* + * Default transport is UDP unless the host contains + * a slash in which case we default to DGRAM. + */ for (const char *p = host[0]; p < host[1]; p++) if (*p == '/') { - i = SNMP_TRANS_LOC_DGRAM; + trans = SNMP_TRANS_LOC_DGRAM; break; } } } - char *cport = save_str(sc, port); + char *cport; + + if (port[0] == port[1] && ( + trans == SNMP_TRANS_UDP || trans == SNMP_TRANS_UDP6)) { + /* If port was not specified, use "snmp" name by default */ + cport = strdup("snmp"); + } else + cport = save_str(sc, port); + if (cport == NULL) { free(chost); return (-1); } /* commit */ - sc->trans = i; + sc->trans = trans; + /* + * If community string was specified and it is empty, overwrite it. + * If it was not specified, use default. + */ + if (comm[0] != comm[1] || strrchr(comm[0], '@') != NULL) { + strncpy(sc->read_community, comm[0], comm[1] - comm[0]); + sc->read_community[comm[1] - comm[0]] = '\0'; + strncpy(sc->write_community, comm[0], comm[1] - comm[0]); + sc->write_community[comm[1] - comm[0]] = '\0'; + } - strncpy(sc->read_community, comm[0], comm[1] - comm[0]); - sc->read_community[comm[1] - comm[0]] = '\0'; - strncpy(sc->write_community, comm[0], comm[1] - comm[0]); - sc->write_community[comm[1] - comm[0]] = '\0'; - free(sc->chost); sc->chost = chost; free(sc->cport); sc->cport = cport; +#if DEBUG_PARSE + printf("Committed values:\n"); + printf("trans: %u\n", sc->trans); + printf("comm: '%s'/'%s'\n", sc->read_community, sc->write_community); + printf("host: '%s'\n", sc->chost); + printf("port: '%s'\n", sc->cport); +#endif return (0); } From owner-svn-src-head@freebsd.org Wed Apr 3 13:17:12 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91DC4156DC72; Wed, 3 Apr 2019 13:17:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id F2FE780AA7; Wed, 3 Apr 2019 13:17:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 801DF4388E1; Thu, 4 Apr 2019 00:17:00 +1100 (AEDT) Date: Thu, 4 Apr 2019 00:16:58 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dimitry Andric cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r345807 - head/usr.bin/top In-Reply-To: <201904021801.x32I1sxX019439@repo.freebsd.org> Message-ID: <20190403234558.X1970@besplex.bde.org> References: <201904021801.x32I1sxX019439@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.2 cv=FNpr/6gs c=1 sm=1 tr=0 cx=a_idp_d a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=qgxEQ-H3AAAA:8 a=ilqspKNxh9cREQBrOfMA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=p3XWM3U2PI-Bt-EJryuK:22 X-Rspamd-Queue-Id: F2FE780AA7 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.96)[-0.958,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 13:17:12 -0000 On Tue, 2 Apr 2019, Dimitry Andric wrote: > Author: dim > Date: Tue Apr 2 18:01:54 2019 > New Revision: 345807 > URL: https://svnweb.freebsd.org/changeset/base/345807 > > Log: > Fix regression in top(1) after r344381, causing informational messages > to no longer be displayed. This was because the reimplementation of > setup_buffer() did not copy the previous contents into any reallocated > buffer. > > Reported by: James Wright > PR: 236947 > MFC after: 3 days > > Modified: > head/usr.bin/top/display.c > > Modified: head/usr.bin/top/display.c > ============================================================================== > --- head/usr.bin/top/display.c Tue Apr 2 17:51:28 2019 (r345806) > +++ head/usr.bin/top/display.c Tue Apr 2 18:01:54 2019 (r345807) > @@ -1347,7 +1347,8 @@ i_uptime(struct timeval *bt, time_t *tod) > static char * > setup_buffer(char *buffer, int addlen) > { > - size_t len; > + size_t len, old_len; > + char *new_buffer; > > setup_buffer_bufsiz = screen_width; > if (setup_buffer_bufsiz < SETUPBUFFER_MIN_SCREENWIDTH) > @@ -1355,13 +1356,18 @@ setup_buffer(char *buffer, int addlen) > setup_buffer_bufsiz = SETUPBUFFER_MIN_SCREENWIDTH; > } > > - free(buffer); > len = setup_buffer_bufsiz + addlen + SETUPBUFFER_REQUIRED_ADDBUFSIZ; > - buffer = calloc(len, sizeof(char)); > - if (buffer == NULL) > + new_buffer = calloc(len, sizeof(char)); > + if (new_buffer == NULL) > { > errx(4, "can't allocate sufficient memory"); > } > + if (buffer != NULL) > + { > + old_len = strlen(buffer); > + memcpy(new_buffer, buffer, old_len < len - 1 ? old_len : len - 1); > + free(buffer); > + } > > - return buffer; > + return new_buffer; > } Looks like realloc() hasn't been invented yet. realloc() wouldn't clear the new part of the buffer, so a memset() or at least setting the first byte in a new buffer (starting with buffer == NULL might be needed). The above has some bugs when the new buffer is smaller the old buffer: - when old_len < len - 1, the new buffer has no space for the old buffer including its NUL terminator, so the new buffer is left unterminated after blind truncation - when old_len == len - 1, the new buffer has no space for the NUL terminator, so the new buffer is left unterminated after not overrunning it by copying the NUL terminator - when old_len > len - 1, the new buffer is NUL terminated in an obfuscated way (calloc() has filled it with NULs and the memcpy() doesn't overwrite them all). Bruce From owner-svn-src-head@freebsd.org Wed Apr 3 13:46:44 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BCD4156EB72; Wed, 3 Apr 2019 13:46:44 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3399D81F22; Wed, 3 Apr 2019 13:46:44 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 03916EBCE; Wed, 3 Apr 2019 13:46:44 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33Dkhve052472; Wed, 3 Apr 2019 13:46:43 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33DkhH3052471; Wed, 3 Apr 2019 13:46:43 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <201904031346.x33DkhH3052471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Wed, 3 Apr 2019 13:46:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345845 - head/sbin/bectl X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/sbin/bectl X-SVN-Commit-Revision: 345845 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3399D81F22 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 13:46:44 -0000 Author: 0mp (ports committer) Date: Wed Apr 3 13:46:43 2019 New Revision: 345845 URL: https://svnweb.freebsd.org/changeset/base/345845 Log: bectl.8: Clean up & clarify the create subcommand - Improve formatting - Use consistent variable names - Improve the description of the create subcommand (1) PR: 235850 (1) Submitted by: kevans (1) Reported by: ler (1) Reviewed by: kevans Approved by: src (kevans) Differential Revision: https://reviews.freebsd.org/D19666 Modified: head/sbin/bectl/bectl.8 Modified: head/sbin/bectl/bectl.8 ============================================================================== --- head/sbin/bectl/bectl.8 Wed Apr 3 13:19:47 2019 (r345844) +++ head/sbin/bectl/bectl.8 Wed Apr 3 13:46:43 2019 (r345845) @@ -18,12 +18,12 @@ .\" .\" $FreeBSD$ .\" -.Dd February 10, 2019 +.Dd March 21, 2019 .Dt BECTL 8 .Os .Sh NAME .Nm bectl -.Nd Utility to manage Boot Environments on ZFS +.Nd Utility to manage boot environments on ZFS .Sh SYNOPSIS .Nm .Cm activate @@ -32,16 +32,12 @@ .Nm .Cm create .Op Fl r -.Op Fl e Brq Ar nonActiveBe | beName@snapshot -.Ar beName +.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot +.Ar newBeName .Nm -.Cm create -.Op Fl r -.Ar beName@snapshot -.Nm .Cm destroy .Op Fl \&Fo -.Brq Ar beName | beName@snapshot +.Ar beName Ns Op Cm @ Ns Ar snapshot .Nm .Cm export .Ar sourceBe @@ -50,39 +46,42 @@ .Ar targetBe .Nm .Cm jail -.Brq Fl b | Fl U -.Oo Bro Fl o Ar key Ns = Ns Ar value | Fl u Ar key Brc Oc Ns ... -.Ar bootenv +.Op Fl bU +.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ... +.Ar beName .Op Ar utility Op Ar argument ... .Nm .Cm list -.Op Fl DHas +.Op Fl aDHs .Nm .Cm mount .Ar beName -.Op mountpoint +.Op Ar mountpoint .Nm .Cm rename .Ar origBeName .Ar newBeName .Nm .Brq Cm ujail | unjail -.Brq Ar jailID | jailName -.Ar bootenv +.Brq Ar jailId | jailName +.Ar beName .Nm .Brq Cm umount | unmount .Op Fl f .Ar beName +.Pp +.Nm +.Op Fl h\&? .Sh DESCRIPTION The .Nm command is used to setup and interact with ZFS boot environments, which are bootable clones of datasets. .Pp -.Em Boot Environments -allows the system to be upgraded, while preserving the old system environment in +Boot environments +allow the system to be upgraded, while preserving the old system environment in a separate ZFS dataset. -.Sh COMMANDS +.Pp The following commands are supported by .Nm : .Bl -tag -width activate @@ -100,39 +99,38 @@ flag is given, this takes effect only for the next boo .It Xo .Cm create .Op Fl r -.Op Fl e Brq Ar nonActiveBe | beName@snapshot -.Ar beName +.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot +.Ar newBeName .Xc -Creates a new boot environment named -.Ar beName . +Create a new boot environment named +.Ar newBeName . +.Pp If the -.Fl e -argument is specified, the new environment will be cloned from the given -.Brq Ar nonActiveBe | Ar beName@snapshot . -If the .Fl r flag is given, a recursive boot environment will be made. -.It Xo -.Cm create -.Op Fl r -.Ar beName@snapshot -.Xc -Creates a snapshot of the existing boot environment named -.Ar beName . +.Pp If the -.Fl r -flag is given, a recursive boot environment will be made. +.Fl e +flag is specified, the new environment will be cloned from the given +.Ar nonActiveBe +or +.Ar beName Ns Cm @ Ns Ar snapshot . +Otherwise, the new environment will be created from the currently booted environment. +.Pp +If +.Nm +is creating from another boot environment, a snapshot of that boot environment will be created to clone from. .It Xo .Cm destroy .Op Fl \&Fo -.Brq Ar beName | beName@snapshot +.Ar beName Ns Op Cm @ Ns Ar snapshot .Xc -Destroys the given +Destroy the given .Ar beName boot environment or -.Ar beName@snapshot +.Ar beName Ns Cm @ Ns Ar snapshot snapshot without confirmation, unlike in -.Nm beadm . +.Xr beadm 1 . Specifying .Fl F will automatically unmount without confirmation. @@ -148,22 +146,22 @@ flag may be specified to destroy the origin as well. Export .Ar sourceBe to -.Dv stdout . -.Dv stdout +.Xr stdout 4 . +.Xr stdout 4 must be piped or redirected to a file. .It Cm import Ar targetBe Import .Ar targetBe from -.Dv stdin . +.Xr stdin 4 . .It Xo .Cm jail -.Brq Fl b | Fl U -.Oo Bro Fl o Ar key Ns = Ns Ar value | Fl u Ar key Brc Oc Ns ... -.Ao Ar bootenv Ac +.Op Fl bU +.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ... +.Ar beName .Op Ar utility Op Ar argument ... .Xc -Creates a jail of the given boot environment. +Create a jail of the given boot environment. Multiple .Fl o and @@ -202,7 +200,7 @@ and must be set, the default values are specified below. .Pp All -.Ar key Ns = Ns Ar value +.Ar key Ns Cm = Ns Ar value pairs are interpreted as jail parameters as described in .Xr jail 8 . The following default parameters are provided: @@ -210,17 +208,24 @@ The following default parameters are provided: .It Va allow.mount Ta Cm true .It Va allow.mount.devfs Ta Cm true .It Va enforce_statfs Ta Cm 1 -.It Va name Ta jail id +.It Va name Ta Set to jail ID. .It Va host.hostname Ta Va bootenv -.It Va path Ta Set to a path in /tmp generated by +.It Va path Ta Set to a path in Pa /tmp +generated by .Xr libbe 3 . .El .Pp All default parameters may be overwritten. -.It Cm list Op Fl DHas -Displays all boot environments. -The Active field indicates whether the boot environment is active now (N); -active on reboot (R); or both (NR). +.It Cm list Op Fl aDHs +Display all boot environments. +The +.Em Active +field indicates whether the boot environment is active now +.Pq Em \&N ; +active on reboot +.Pq Em \&R ; +or both +.Pq Em \&NR . .Pp If .Fl a @@ -243,14 +248,20 @@ Mount at the specified .Ar mountpoint if provided. .It Cm rename Ar origBeName newBeName -Renames the given +Rename the given .Ar origBeName to the given .Ar newBeName . The boot environment will not be unmounted in order for this rename to occur. -.It Cm unjail Brq Ar jailID | jailName | beName -Destroys the jail created from the given boot environment. +.It Cm ujail Bro Ar jailId | jailName Brc Ar beName +.It Cm unjail Bro Ar jailId | jailName Brc Ar beName +Destroy the jail created from the given boot environment. .It Xo +.Cm umount +.Op Fl f +.Ar beName +.Xc +.It Xo .Cm unmount .Op Fl f .Ar beName @@ -260,12 +271,20 @@ Specifying .Fl f will force the unmount if busy. .El +.Pp +.Nm +prints usage information if +.Fl h +or +.Fl \&? +is specified. .Sh EXAMPLES .Bl -bullet .It To fill in with jail upgrade example when behavior is firm. .El .Sh SEE ALSO +.Xr beinstall.sh 1 , .Xr libbe 3 , .Xr jail 8 , .Xr zfs 8 , @@ -273,7 +292,7 @@ To fill in with jail upgrade example when behavior is .Sh HISTORY .Nm is based on -.Nm beadm +.Xr beadm 1 and was implemented as a project for the 2017 Summer of Code, along with .Xr libbe 3 . .Sh AUTHORS @@ -281,11 +300,11 @@ and was implemented as a project for the 2017 Summer o was written by .An Kyle Kneitinger (kneitinger) Aq Mt kyle@kneit.in . .Pp -.Nm beadm +.Xr beadm 1 was written and is maintained by .An Slawomir Wojciech Wojtczak (vermaden) Aq Mt vermaden@interia.pl . .Pp .An Bryan Drewery (bdrewery) Aq Mt bryan@shatow.net wrote the original -.Nm beadm +.Xr beadm 1 manual page that this one is derived from. From owner-svn-src-head@freebsd.org Wed Apr 3 13:59:36 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A682F156F104; Wed, 3 Apr 2019 13:59:36 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49589827AC; Wed, 3 Apr 2019 13:59:36 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F8CBED9C; Wed, 3 Apr 2019 13:59:36 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33DxZD8057779; Wed, 3 Apr 2019 13:59:35 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33DxZ12057778; Wed, 3 Apr 2019 13:59:35 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <201904031359.x33DxZ12057778@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Wed, 3 Apr 2019 13:59:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345846 - head/sbin/bectl X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/sbin/bectl X-SVN-Commit-Revision: 345846 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 49589827AC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 13:59:36 -0000 Author: 0mp (ports committer) Date: Wed Apr 3 13:59:35 2019 New Revision: 345846 URL: https://svnweb.freebsd.org/changeset/base/345846 Log: bectl.8: Bump date after r345845 Approved by: kevans Modified: head/sbin/bectl/bectl.8 Modified: head/sbin/bectl/bectl.8 ============================================================================== --- head/sbin/bectl/bectl.8 Wed Apr 3 13:46:43 2019 (r345845) +++ head/sbin/bectl/bectl.8 Wed Apr 3 13:59:35 2019 (r345846) @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2019 +.Dd April 3, 2019 .Dt BECTL 8 .Os .Sh NAME From owner-svn-src-head@freebsd.org Wed Apr 3 17:02:19 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8C5C1573A8F; Wed, 3 Apr 2019 17:02:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6AB1A8AE19; Wed, 3 Apr 2019 17:02: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 341F418D09; Wed, 3 Apr 2019 17:02:19 +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 x33H2Ix8056775; Wed, 3 Apr 2019 17:02:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33H2IC9056774; Wed, 3 Apr 2019 17:02:18 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201904031702.x33H2IC9056774@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 3 Apr 2019 17:02:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345847 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 345847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6AB1A8AE19 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 17:02:20 -0000 Author: kib Date: Wed Apr 3 17:02:18 2019 New Revision: 345847 URL: https://svnweb.freebsd.org/changeset/base/345847 Log: msdosfs: zero tail of the last block on truncation for VREG vnodes as well. Despite the call to vtruncbuf() from detrunc(), which results in zeroing part of the partial page after EOF, there still is a possibility to retain the stale data which is revived on file enlargement. If the filesystem block size is greater than the page size, partial block might keep other after-EOF pages wired and they get reused then. Fix it by zeroing whole part of the partial buffer after EOF, not relying on vnode_pager_setsize(). PR: 236977 Reported by: asomers Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/fs/msdosfs/msdosfs_denode.c Modified: head/sys/fs/msdosfs/msdosfs_denode.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 13:59:35 2019 (r345846) +++ head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 17:02:18 2019 (r345847) @@ -405,19 +405,21 @@ detrunc(struct denode *dep, u_long length, int flags, bn = cntobn(pmp, eofentry); error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp); - if (error) { - brelse(bp); + } else { + error = bread(DETOV(dep), de_cluster(pmp, length), + pmp->pm_bpcluster, cred, &bp); + } + if (error) { #ifdef MSDOSFS_DEBUG - printf("detrunc(): bread fails %d\n", error); + printf("detrunc(): bread fails %d\n", error); #endif - return (error); - } - memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff); - if (flags & IO_SYNC) - bwrite(bp); - else - bdwrite(bp); + return (error); } + memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff); + if ((flags & IO_SYNC) != 0) + bwrite(bp); + else + bdwrite(bp); } /* From owner-svn-src-head@freebsd.org Wed Apr 3 17:04:39 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0665C1573CD9; Wed, 3 Apr 2019 17:04:39 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9E5C38B0C2; Wed, 3 Apr 2019 17:04:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7481018E25; Wed, 3 Apr 2019 17:04:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33H4cpX056935; Wed, 3 Apr 2019 17:04:38 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33H4c0n056934; Wed, 3 Apr 2019 17:04:38 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201904031704.x33H4c0n056934@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 3 Apr 2019 17:04:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345848 - head/lib/libbe X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/lib/libbe X-SVN-Commit-Revision: 345848 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9E5C38B0C2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 17:04:39 -0000 Author: kevans Date: Wed Apr 3 17:04:38 2019 New Revision: 345848 URL: https://svnweb.freebsd.org/changeset/base/345848 Log: libbe(3): Add a serial to the generated snapshot names To use bectl in an example, when one creates a new boot environment with either `bectl create ` or `bectl create -e `, libbe will take a snapshot of the original boot environment to clone. Previously, this used %F-%T date format as the snapshot name, but this has some limitations- attempting to create multiple boot environments in quick succession may collide if done within the same second. Tack a serial onto it to reduce the chances of a collision... we could still collide if multiple processes/threads are creating boot environments at the same time, but this is likely not a big concern as this has only been reported as occurring in freebsd-ci setup. MFC after: 3 days Modified: head/lib/libbe/be.c Modified: head/lib/libbe/be.c ============================================================================== --- head/lib/libbe/be.c Wed Apr 3 17:02:18 2019 (r345847) +++ head/lib/libbe/be.c Wed Apr 3 17:04:38 2019 (r345848) @@ -56,6 +56,9 @@ static int be_create_child_noent(libbe_handle_t *lbh, static int be_create_child_cloned(libbe_handle_t *lbh, const char *active); #endif +/* Arbitrary... should tune */ +#define BE_SNAP_SERIAL_MAX 1024 + /* * Iterator function for locating the rootfs amongst the children of the * zfs_be_root set by loader(8). data is expected to be a libbe_handle_t *. @@ -320,13 +323,32 @@ be_destroy(libbe_handle_t *lbh, const char *name, int options & ~BE_DESTROY_ORIGIN)); } +static void +be_setup_snapshot_name(libbe_handle_t *lbh, char *buf, size_t buflen) +{ + time_t rawtime; + int len, serial; + + time(&rawtime); + len = strlen(buf); + len += strftime(buf + len, buflen - len, "@%F-%T", localtime(&rawtime)); + /* No room for serial... caller will do its best */ + if (buflen - len < 2) + return; + + for (serial = 0; serial < BE_SNAP_SERIAL_MAX; ++serial) { + snprintf(buf + len, buflen - len, "-%d", serial); + if (!zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) + return; + } +} + int be_snapshot(libbe_handle_t *lbh, const char *source, const char *snap_name, bool recursive, char *result) { char buf[BE_MAXPATHLEN]; - time_t rawtime; - int len, err; + int err; be_root_concat(lbh, source, buf); @@ -344,10 +366,8 @@ be_snapshot(libbe_handle_t *lbh, const char *source, c snprintf(result, BE_MAXPATHLEN, "%s@%s", source, snap_name); } else { - time(&rawtime); - len = strlen(buf); - strftime(buf + len, sizeof(buf) - len, - "@%F-%T", localtime(&rawtime)); + be_setup_snapshot_name(lbh, buf, sizeof(buf)); + if (result != NULL && strlcpy(result, strrchr(buf, '/') + 1, sizeof(buf)) >= sizeof(buf)) return (set_error(lbh, BE_ERR_INVALIDNAME)); From owner-svn-src-head@freebsd.org Wed Apr 3 18:27:56 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F77B1531C82; Wed, 3 Apr 2019 18:27:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0EC08DC1A; Wed, 3 Apr 2019 18:27:55 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A1E019BE5; Wed, 3 Apr 2019 18:27:55 +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 x33IRtXm099122; Wed, 3 Apr 2019 18:27:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33IRtT7099120; Wed, 3 Apr 2019 18:27:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201904031827.x33IRtT7099120@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 3 Apr 2019 18:27:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345849 - in head/sys: cam/ata sys X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys: cam/ata sys X-SVN-Commit-Revision: 345849 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B0EC08DC1A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 18:27:56 -0000 Author: mav Date: Wed Apr 3 18:27:54 2019 New Revision: 345849 URL: https://svnweb.freebsd.org/changeset/base/345849 Log: List few more ATA commands. MFC after: 1 week Modified: head/sys/cam/ata/ata_all.c head/sys/sys/ata.h Modified: head/sys/cam/ata/ata_all.c ============================================================================== --- head/sys/cam/ata/ata_all.c Wed Apr 3 17:04:38 2019 (r345848) +++ head/sys/cam/ata/ata_all.c Wed Apr 3 18:27:54 2019 (r345849) @@ -215,8 +215,10 @@ ata_op_string(struct ata_cmd *cmd) case 0xe5: return ("CHECK_POWER_MODE"); case 0xe6: return ("SLEEP"); case 0xe7: return ("FLUSHCACHE"); - case 0xe8: return ("WRITE_PM"); + case 0xe8: return ("WRITE_BUFFER/PM"); + case 0xe9: return ("READ_BUFFER_DMA"); case 0xea: return ("FLUSHCACHE48"); + case 0xeb: return ("WRITE_BUFFER_DMA"); case 0xec: return ("ATA_IDENTIFY"); case 0xed: return ("MEDIA_EJECT"); case 0xef: @@ -581,7 +583,12 @@ ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, ui if (cmd == ATA_READ_DMA || cmd == ATA_READ_DMA_QUEUED || cmd == ATA_WRITE_DMA || - cmd == ATA_WRITE_DMA_QUEUED) + cmd == ATA_WRITE_DMA_QUEUED || + cmd == ATA_TRUSTED_RECEIVE_DMA || + cmd == ATA_TRUSTED_SEND_DMA || + cmd == ATA_DOWNLOAD_MICROCODE_DMA || + cmd == ATA_READ_BUFFER_DMA || + cmd == ATA_WRITE_BUFFER_DMA) ataio->cmd.flags |= CAM_ATAIO_DMA; ataio->cmd.command = cmd; ataio->cmd.features = features; @@ -607,7 +614,8 @@ ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, ui cmd == ATA_WRITE_DMA_QUEUED_FUA48 || cmd == ATA_WRITE_STREAM_DMA48 || cmd == ATA_DATA_SET_MANAGEMENT || - cmd == ATA_READ_LOG_DMA_EXT) + cmd == ATA_READ_LOG_DMA_EXT || + cmd == ATA_WRITE_LOG_DMA_EXT) ataio->cmd.flags |= CAM_ATAIO_DMA; ataio->cmd.command = cmd; ataio->cmd.features = features; Modified: head/sys/sys/ata.h ============================================================================== --- head/sys/sys/ata.h Wed Apr 3 17:04:38 2019 (r345848) +++ head/sys/sys/ata.h Wed Apr 3 18:27:54 2019 (r345849) @@ -393,6 +393,12 @@ struct ata_params { #define ATA_READ_LOG_DMA_EXT 0x47 /* read log DMA ext - PIO Data-In */ #define ATA_ZAC_MANAGEMENT_IN 0x4a /* ZAC management in */ #define ATA_ZM_REPORT_ZONES 0x00 /* report zones */ +#define ATA_WRITE_LOG_DMA_EXT 0x57 /* WRITE LOG DMA EXT */ +#define ATA_TRUSTED_NON_DATA 0x5b /* TRUSTED NON-DATA */ +#define ATA_TRUSTED_RECEIVE 0x5c /* TRUSTED RECEIVE */ +#define ATA_TRUSTED_RECEIVE_DMA 0x5d /* TRUSTED RECEIVE DMA */ +#define ATA_TRUSTED_SEND 0x5c /* TRUSTED SEND */ +#define ATA_TRUSTED_SEND_DMA 0x5d /* TRUSTED SEND DMA */ #define ATA_READ_FPDMA_QUEUED 0x60 /* read DMA NCQ */ #define ATA_WRITE_FPDMA_QUEUED 0x61 /* write DMA NCQ */ #define ATA_NCQ_NON_DATA 0x63 /* NCQ non-data command */ @@ -417,6 +423,8 @@ struct ata_params { #define ATA_ZM_FINISH_ZONE 0x02 /* finish zone */ #define ATA_ZM_OPEN_ZONE 0x03 /* open zone */ #define ATA_ZM_RWP 0x04 /* reset write pointer */ +#define ATA_DOWNLOAD_MICROCODE 0x92 /* DOWNLOAD MICROCODE */ +#define ATA_DOWNLOAD_MICROCODE_DMA 0x93 /* DOWNLOAD MICROCODE DMA */ #define ATA_PACKET_CMD 0xa0 /* packet command */ #define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ #define ATA_SERVICE 0xa2 /* service command */ @@ -439,8 +447,11 @@ struct ata_params { #define ATA_CHECK_POWER_MODE 0xe5 /* device power mode */ #define ATA_SLEEP 0xe6 /* sleep */ #define ATA_FLUSHCACHE 0xe7 /* flush cache to disk */ +#define ATA_WRITE_BUFFER 0xe8 /* write buffer */ #define ATA_WRITE_PM 0xe8 /* write portmultiplier */ +#define ATA_READ_BUFFER_DMA 0xe9 /* read buffer DMA */ #define ATA_FLUSHCACHE48 0xea /* flush cache to disk */ +#define ATA_WRITE_BUFFER_DMA 0xeb /* write buffer DMA */ #define ATA_ATA_IDENTIFY 0xec /* get ATA params */ #define ATA_SETFEATURES 0xef /* features command */ #define ATA_SF_ENAB_WCACHE 0x02 /* enable write cache */ From owner-svn-src-head@freebsd.org Wed Apr 3 18:35:14 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33E8A154F08A; Wed, 3 Apr 2019 18:35:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C63E38E1CC; Wed, 3 Apr 2019 18:35:13 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A0C3119D9D; Wed, 3 Apr 2019 18:35:13 +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 x33IZDb2004358; Wed, 3 Apr 2019 18:35:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33IZD0k004357; Wed, 3 Apr 2019 18:35:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201904031835.x33IZD0k004357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 3 Apr 2019 18:35:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345850 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 345850 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C63E38E1CC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 18:35:14 -0000 Author: mav Date: Wed Apr 3 18:35:13 2019 New Revision: 345850 URL: https://svnweb.freebsd.org/changeset/base/345850 Log: Fix typos in r345849. MFC after: 1 week Modified: head/sys/sys/ata.h Modified: head/sys/sys/ata.h ============================================================================== --- head/sys/sys/ata.h Wed Apr 3 18:27:54 2019 (r345849) +++ head/sys/sys/ata.h Wed Apr 3 18:35:13 2019 (r345850) @@ -397,8 +397,8 @@ struct ata_params { #define ATA_TRUSTED_NON_DATA 0x5b /* TRUSTED NON-DATA */ #define ATA_TRUSTED_RECEIVE 0x5c /* TRUSTED RECEIVE */ #define ATA_TRUSTED_RECEIVE_DMA 0x5d /* TRUSTED RECEIVE DMA */ -#define ATA_TRUSTED_SEND 0x5c /* TRUSTED SEND */ -#define ATA_TRUSTED_SEND_DMA 0x5d /* TRUSTED SEND DMA */ +#define ATA_TRUSTED_SEND 0x5e /* TRUSTED SEND */ +#define ATA_TRUSTED_SEND_DMA 0x5f /* TRUSTED SEND DMA */ #define ATA_READ_FPDMA_QUEUED 0x60 /* read DMA NCQ */ #define ATA_WRITE_FPDMA_QUEUED 0x61 /* write DMA NCQ */ #define ATA_NCQ_NON_DATA 0x63 /* NCQ non-data command */ From owner-svn-src-head@freebsd.org Wed Apr 3 19:35:08 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5D25B155081B; Wed, 3 Apr 2019 19:35:08 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF85B69D89; Wed, 3 Apr 2019 19:35:07 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C384F1A877; Wed, 3 Apr 2019 19:35:07 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33JZ72V037625; Wed, 3 Apr 2019 19:35:07 GMT (envelope-from rrs@FreeBSD.org) Received: (from rrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33JZ7N6037624; Wed, 3 Apr 2019 19:35:07 GMT (envelope-from rrs@FreeBSD.org) Message-Id: <201904031935.x33JZ7N6037624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rrs set sender to rrs@FreeBSD.org using -f From: Randall Stewart Date: Wed, 3 Apr 2019 19:35:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345851 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: rrs X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 345851 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EF85B69D89 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 19:35:08 -0000 Author: rrs Date: Wed Apr 3 19:35:07 2019 New Revision: 345851 URL: https://svnweb.freebsd.org/changeset/base/345851 Log: Undo my previous erroneous commit changing the tcp_output kassert. Hmm now the question is where did the tcp_log_id change go :o Modified: head/sys/netinet/tcp_output.c Modified: head/sys/netinet/tcp_output.c ============================================================================== --- head/sys/netinet/tcp_output.c Wed Apr 3 18:35:13 2019 (r345850) +++ head/sys/netinet/tcp_output.c Wed Apr 3 19:35:07 2019 (r345851) @@ -138,8 +138,7 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_auto_lowat * non-ACK. */ #define TCP_XMIT_TIMER_ASSERT(tp, len, th_flags) \ - KASSERT(((len) == 0 && ((th_flags) & \ - (TH_SYN | TH_FIN | TH_RST)) != 0) || \ + KASSERT(((len) == 0 && ((th_flags) & (TH_SYN | TH_FIN)) == 0) ||\ tcp_timer_active((tp), TT_REXMT) || \ tcp_timer_active((tp), TT_PERSIST), \ ("neither rexmt nor persist timer is set")) From owner-svn-src-head@freebsd.org Wed Apr 3 19:43:10 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6451515510BA; Wed, 3 Apr 2019 19:43:10 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3A7A6A656; Wed, 3 Apr 2019 19:43:09 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::7c78:2711:3f37:8a5d] (unknown [IPv6:2001:470:7a58:0:7c78:2711:3f37:8a5d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id D05CB3F6D0; Wed, 3 Apr 2019 21:42:59 +0200 (CEST) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_5733E18B-193D-4A27-B386-DDD252477B54"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: svn commit: r345807 - head/usr.bin/top Date: Wed, 3 Apr 2019 21:42:59 +0200 In-Reply-To: <20190403234558.X1970@besplex.bde.org> Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org To: Bruce Evans References: <201904021801.x32I1sxX019439@repo.freebsd.org> <20190403234558.X1970@besplex.bde.org> X-Mailer: Apple Mail (2.3445.104.8) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 19:43:10 -0000 --Apple-Mail=_5733E18B-193D-4A27-B386-DDD252477B54 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 3 Apr 2019, at 15:16, Bruce Evans wrote: > > On Tue, 2 Apr 2019, Dimitry Andric wrote: >> Author: dim >> Date: Tue Apr 2 18:01:54 2019 >> New Revision: 345807 >> URL: https://svnweb.freebsd.org/changeset/base/345807 >> >> Log: >> Fix regression in top(1) after r344381, causing informational messages >> to no longer be displayed. This was because the reimplementation of >> setup_buffer() did not copy the previous contents into any reallocated >> buffer. ... > Looks like realloc() hasn't been invented yet. > > realloc() wouldn't clear the new part of the buffer, so a memset() or at > least setting the first byte in a new buffer (starting with buffer == NULL > might be needed). Yeah, I found that a bit ugly, so just using calloc (like the previous implementation of setup_buffer did) and copying only the old contents seemed nicer. I never liked realloc's interface. > The above has some bugs when the new buffer is smaller the old buffer: > - when old_len < len - 1, the new buffer has no space for the old buffer > including its NUL terminator, so the new buffer is left unterminated > after blind truncation No, in this case the old buffer can be copied entirely, and the new buffer will already be NUL terminated, because calloc has filled the entirety of it with zeroes. This is also expected in the rest of the display.c code. > - when old_len == len - 1, the new buffer has no space for the NUL > terminator, so the new buffer is left unterminated after not overrunning > it by copying the NUL terminator No, in this case the old buffer can be copied entirely, and the new buffer will have exactly one zero byte at the end. > - when old_len > len - 1, the new buffer is NUL terminated in an obfuscated > way (calloc() has filled it with NULs and the memcpy() doesn't overwrite > them all). Indeed, that is exactly the intent. -Dimitry --Apple-Mail=_5733E18B-193D-4A27-B386-DDD252477B54 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXKUMwwAKCRCwXqMKLiCW o5KgAJsHYRWGvsFCC9jmrS4ylTKqCR7Z8gCdGcjmXMW6sJIuQMwjUD0KPg0y9BY= =+1zd -----END PGP SIGNATURE----- --Apple-Mail=_5733E18B-193D-4A27-B386-DDD252477B54-- From owner-svn-src-head@freebsd.org Wed Apr 3 20:37:15 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7902B15529FD; Wed, 3 Apr 2019 20:37:15 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 16EB36CBA2; Wed, 3 Apr 2019 20:37:15 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E51AD1B31F; Wed, 3 Apr 2019 20:37:14 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33KbEkX070605; Wed, 3 Apr 2019 20:37:14 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33KbEjq070604; Wed, 3 Apr 2019 20:37:14 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201904032037.x33KbEjq070604@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 3 Apr 2019 20:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345853 - head/usr.bin/rctl X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/usr.bin/rctl X-SVN-Commit-Revision: 345853 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 16EB36CBA2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 20:37:15 -0000 Author: mjg Date: Wed Apr 3 20:37:14 2019 New Revision: 345853 URL: https://svnweb.freebsd.org/changeset/base/345853 Log: rctl: fix sysctl kern.racct.enable use after r341182 The value was changed from int to bool. Since the new type is smaller, the rest of the variable in the caller was left unitialized. PR: 236714 Reported by: trasz Diagnosed by: markj Sponsored by: The FreeBSD Foundation Modified: head/usr.bin/rctl/rctl.c Modified: head/usr.bin/rctl/rctl.c ============================================================================== --- head/usr.bin/rctl/rctl.c Wed Apr 3 19:59:45 2019 (r345852) +++ head/usr.bin/rctl/rctl.c Wed Apr 3 20:37:14 2019 (r345853) @@ -378,8 +378,9 @@ print_rules(char *rules, int hflag, int nflag) static void enosys(void) { - int error, racct_enable; size_t racct_enable_len; + int error; + bool racct_enable; racct_enable_len = sizeof(racct_enable); error = sysctlbyname("kern.racct.enable", @@ -392,7 +393,7 @@ enosys(void) err(1, "sysctlbyname"); } - if (racct_enable == 0) + if (!racct_enable) errx(1, "RACCT/RCTL present, but disabled; enable using kern.racct.enable=1 tunable"); } From owner-svn-src-head@freebsd.org Wed Apr 3 21:01:55 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14F0C15535C8; Wed, 3 Apr 2019 21:01:55 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AD19D6DA84; Wed, 3 Apr 2019 21:01:54 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 80B411B81E; Wed, 3 Apr 2019 21:01:54 +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 x33L1sOV084636; Wed, 3 Apr 2019 21:01:54 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33L1sAI084634; Wed, 3 Apr 2019 21:01:54 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201904032101.x33L1sAI084634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 3 Apr 2019 21:01:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345855 - in head/sys: arm/ti/cpsw dev/fdt X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head/sys: arm/ti/cpsw dev/fdt X-SVN-Commit-Revision: 345855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AD19D6DA84 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 21:01:55 -0000 Author: emaste Date: Wed Apr 3 21:01:53 2019 New Revision: 345855 URL: https://svnweb.freebsd.org/changeset/base/345855 Log: cpsw: use `phy-handle` in FDT to find PHY address In r337703 DTS files were updated to Linux 4.18, including Linux commit 4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id` property from am335x-bone-common (as the property was deprecated). Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a fallback for old DTBs. PR: 236624 Submitted by: manu, Gerald Aryeetey Reported by: Gerald Aryeetey Reviewed by: manu MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19814 Modified: head/sys/arm/ti/cpsw/if_cpsw.c head/sys/dev/fdt/fdt_common.c Modified: head/sys/arm/ti/cpsw/if_cpsw.c ============================================================================== --- head/sys/arm/ti/cpsw/if_cpsw.c Wed Apr 3 20:57:43 2019 (r345854) +++ head/sys/arm/ti/cpsw/if_cpsw.c Wed Apr 3 21:01:53 2019 (r345855) @@ -82,6 +82,8 @@ __FBSDID("$FreeBSD$"); #include #include + +#include #ifdef CPSW_ETHERSWITCH #include @@ -742,7 +744,7 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port) phandle_t child; unsigned long mdio_child_addr; - /* Find any slave with phy_id */ + /* Find any slave with phy-handle/phy_id */ phy = -1; vlan = -1; for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) { @@ -756,11 +758,15 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port) if (mdio_child_addr != slave_mdio_addr[port]) continue; - len = OF_getproplen(child, "phy_id"); - if (len / sizeof(pcell_t) == 2) { - /* Get phy address from fdt */ - if (OF_getencprop(child, "phy_id", phy_id, len) > 0) - phy = phy_id[1]; + if (fdt_get_phyaddr(child, NULL, &phy, NULL) != 0){ + /* Users with old DTB will have phy_id instead */ + phy = -1; + len = OF_getproplen(child, "phy_id"); + if (len / sizeof(pcell_t) == 2) { + /* Get phy address from fdt */ + if (OF_getencprop(child, "phy_id", phy_id, len) > 0) + phy = phy_id[1]; + } } len = OF_getproplen(child, "dual_emac_res_vlan"); Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Wed Apr 3 20:57:43 2019 (r345854) +++ head/sys/dev/fdt/fdt_common.c Wed Apr 3 21:01:53 2019 (r345855) @@ -399,6 +399,9 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy *phy_addr = phy_reg; + if (phy_sc == NULL) + return (0); + /* * Search for softc used to communicate with phy. */ From owner-svn-src-head@freebsd.org Wed Apr 3 21:54:48 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A44B615549A8; Wed, 3 Apr 2019 21:54:48 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4AD7D6F6AC; Wed, 3 Apr 2019 21:54:48 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 245011C0EE; Wed, 3 Apr 2019 21:54:48 +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 x33LsmNr013078; Wed, 3 Apr 2019 21:54:48 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33LslFs013075; Wed, 3 Apr 2019 21:54:47 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201904032154.x33LslFs013075@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Wed, 3 Apr 2019 21:54:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345858 - in head/release: . tools X-SVN-Group: head X-SVN-Commit-Author: cperciva X-SVN-Commit-Paths: in head/release: . tools X-SVN-Commit-Revision: 345858 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4AD7D6F6AC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 21:54:48 -0000 Author: cperciva Date: Wed Apr 3 21:54:47 2019 New Revision: 345858 URL: https://svnweb.freebsd.org/changeset/base/345858 Log: Add support for cross-building cloudware images. If MACHINE_ARCH doesn't match TARGET_ARCH, and we're not in the special case of building i386 images on an amd64 host, we need to pull in the qemu-user-static package; this allows us to run some commands inside the VM disk image chroot, most notably to install packages. Reviewed by: gjb MFC after: 2 weeks Sponsored by: FreeBSD/EC2 patreon (https://www.patreon.com/cperciva) Modified: head/release/Makefile.vm head/release/tools/ec2.conf head/release/tools/vmimage.subr Modified: head/release/Makefile.vm ============================================================================== --- head/release/Makefile.vm Wed Apr 3 21:48:09 2019 (r345857) +++ head/release/Makefile.vm Wed Apr 3 21:54:47 2019 (r345858) @@ -39,6 +39,24 @@ VAGRANT-VMWARE_FORMAT= vmdk VAGRANT-VMWARE_DESC= Vagrant Image for VMWare VAGRANT-VMWARE_DISK= ${OSRELEASE}.vmware.${VAGRANT_FORMAT} +emulator-portinstall: +.if ${TARGET_ARCH} != ${MACHINE_ARCH} +.if ( ${TARGET_ARCH} != "i386" ) || ( ${MACHINE_ARCH} != "amd64" ) +.if !exists(/usr/local/bin/qemu-${TARGET_ARCH}-static) +.if exists(${PORTSDIR}/emulators/qemu-user-static/Makefile) + env - PATH=$$PATH make -C ${PORTSDIR}/emulators/qemu-user-static BATCH=1 all install clean +.else +.if !exists(/usr/local/sbin/pkg-static) + env ASSUME_ALWAYS_YES=yes pkg bootstrap -y +.endif + env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-user-static +.endif +.endif + +QEMUSTATIC=/usr/local/bin/qemu-${TARGET_ARCH}-static +.endif +.endif + .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE) . for _CW in ${CLOUDWARE} CLOUDTARGETS+= cw-${_CW:tl} @@ -53,9 +71,10 @@ ${_CW:tu}IMAGE= ${_CW:tl}.${${_CW:tu}_FORMAT} ${_CW:tu}CONF?= ${.CURDIR}/tools/${_CW:tl}.conf . endif -cw-${_CW:tl}: +cw-${_CW:tl}: emulator-portinstall mkdir -p ${.OBJDIR}/${.TARGET} env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \ + QEMUSTATIC=${QEMUSTATIC} \ ${.CURDIR}/scripts/mk-vmimage.sh \ -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \ -i ${.OBJDIR}/${_CW:tl}.img -s ${VMSIZE} -f ${${_CW:tu}_FORMAT} \ Modified: head/release/tools/ec2.conf ============================================================================== --- head/release/tools/ec2.conf Wed Apr 3 21:48:09 2019 (r345857) +++ head/release/tools/ec2.conf Wed Apr 3 21:54:47 2019 (r345858) @@ -40,7 +40,7 @@ vm_extra_pre_umount() { # catalogue and install or update pkg when the instance first # launches, so these files would just be replaced anyway; removing # them from the image allows it to boot faster. - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg delete -f -y pkg rm ${DESTDIR}/var/db/pkg/repo-*.sqlite Modified: head/release/tools/vmimage.subr ============================================================================== --- head/release/tools/vmimage.subr Wed Apr 3 21:48:09 2019 (r345857) +++ head/release/tools/vmimage.subr Wed Apr 3 21:54:47 2019 (r345858) @@ -148,10 +148,15 @@ vm_install_base() { hostname="$(echo $(uname -o) | tr '[:upper:]' '[:lower:]')" echo "hostname=\"${hostname}\"" >> ${DESTDIR}/etc/rc.conf + if ! [ -z "${QEMUSTATIC}" ]; then + export EMULATOR=/qemu + cp ${QEMUSTATIC} ${DESTDIR}/${EMULATOR} + fi + mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} /usr/bin/newaliases - chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart + chroot ${DESTDIR} ${EMULATOR} /usr/bin/newaliases + chroot ${DESTDIR} ${EMULATOR} /bin/sh /etc/rc.d/ldconfig forcestart umount_loop ${DESTDIR}/dev cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf @@ -188,9 +193,9 @@ vm_extra_install_packages() { fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} umount_loop ${DESTDIR}/dev @@ -210,13 +215,16 @@ vm_extra_pre_umount() { # Note: When overriding this function, removing resolv.conf in the # disk image must be included. + if ! [ -z "${QEMUSTATIC}" ]; then + rm -f ${DESTDIR}/${EMULATOR} + fi rm -f ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_pkg_rmcache() { if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/local/sbin/pkg clean -y -a fi From owner-svn-src-head@freebsd.org Wed Apr 3 21:55:42 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E7CF1554ABF; Wed, 3 Apr 2019 21:55:42 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 165846F85B; Wed, 3 Apr 2019 21:55:42 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E463B1C0EF; Wed, 3 Apr 2019 21:55:41 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33LtfIR013208; Wed, 3 Apr 2019 21:55:41 GMT (envelope-from phil@FreeBSD.org) Received: (from phil@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33LteXp013200; Wed, 3 Apr 2019 21:55:40 GMT (envelope-from phil@FreeBSD.org) Message-Id: <201904032155.x33LteXp013200@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phil set sender to phil@FreeBSD.org using -f From: Phil Shafer Date: Wed, 3 Apr 2019 21:55:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345859 - in head: contrib/libxo contrib/libxo/doc contrib/libxo/libxo contrib/libxo/tests/core contrib/libxo/tests/core/saved contrib/libxo/tests/gettext/po/pig_latin contrib/libxo/tes... X-SVN-Group: head X-SVN-Commit-Author: phil X-SVN-Commit-Paths: in head: contrib/libxo contrib/libxo/doc contrib/libxo/libxo contrib/libxo/tests/core contrib/libxo/tests/core/saved contrib/libxo/tests/gettext/po/pig_latin contrib/libxo/tests/gettext/saved contrib/... X-SVN-Commit-Revision: 345859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 165846F85B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.989,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 21:55:43 -0000 Author: phil Date: Wed Apr 3 21:55:39 2019 New Revision: 345859 URL: https://svnweb.freebsd.org/changeset/base/345859 Log: Import libxo-1.0.2 from 1.0.0: Add "continuation" flag, to allow multiple "xo" invocations in a single line of output (#58) Add --top-wrap to make top-level JSON wrappers Add --{open,close}-{list,instace} options Add xo_xml_leader(), to detect use of some bogus XML tags. It's still bad form, but it's a little safer now Avoid call to xo_write before xo_flush, since the latter calls the former Check return code from xo_flush_h properly (<0) (FreeBSD Bug 236935) For JSON output, avoid newline before a container's close brace (#62) Merge branch 'text_only' of https://github.com/zvr/libxo into zvr-text_only Use XO_USE_INT_RETURN_CODES, not USE_INT_RETURN_CODES add docs for --continuation add docs for --not-first call xo_state_set_flags before values and close containers; add XOIF_MADE_OUTPUT flag to track state; make proper empty JSON objects in xo_finish color_map code has to be #ifdef'd out, since the struct definition correct xo_flush_func_t (doesn't use xo_ssize_t) make depth change for --top-wrap only for JSON fix to handle --top-wrap in "xo" by being more consistent with handling trailing newlines fix to handle text-only version #64 (from zvr) fix xo_buf_has_room for round up to the next XO_BUFSIZ, not just add XO_BUFSIZ to the size (FreeBSD Bug 236937) update docs for new "xo" options update functions to use xo_ssize_t update test cases from 1.0.1: Add EINTEGRITY to .pot files under test/gettext/ (fix from FreeBSD) from 1.0.2: handle failure from xo_vnsprintf; don't add -1 to "rc" PR: 236937, 236935 Submitted by: phil Reported by: Alfonso S. Siciliano MFC after: 2 weeks Added: head/contrib/libxo/libxo/xo_explicit.h - copied unchanged from r345857, vendor/Juniper/libxo/dist/libxo/xo_explicit.h head/contrib/libxo/tests/xo/saved/xo_02.H.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.H.err head/contrib/libxo/tests/xo/saved/xo_02.H.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.H.out head/contrib/libxo/tests/xo/saved/xo_02.HIPx.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.HIPx.err head/contrib/libxo/tests/xo/saved/xo_02.HIPx.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.HIPx.out head/contrib/libxo/tests/xo/saved/xo_02.HP.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.HP.err head/contrib/libxo/tests/xo/saved/xo_02.HP.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.HP.out head/contrib/libxo/tests/xo/saved/xo_02.J.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.J.err head/contrib/libxo/tests/xo/saved/xo_02.J.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.J.out head/contrib/libxo/tests/xo/saved/xo_02.JP.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.JP.err head/contrib/libxo/tests/xo/saved/xo_02.JP.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.JP.out head/contrib/libxo/tests/xo/saved/xo_02.T.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.T.err head/contrib/libxo/tests/xo/saved/xo_02.T.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.T.out head/contrib/libxo/tests/xo/saved/xo_02.X.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.X.err head/contrib/libxo/tests/xo/saved/xo_02.X.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.X.out head/contrib/libxo/tests/xo/saved/xo_02.XP.err - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.XP.err head/contrib/libxo/tests/xo/saved/xo_02.XP.out - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/saved/xo_02.XP.out head/contrib/libxo/tests/xo/xo_02.sh - copied unchanged from r345857, vendor/Juniper/libxo/dist/tests/xo/xo_02.sh Modified: head/contrib/libxo/configure.ac head/contrib/libxo/doc/api.rst head/contrib/libxo/doc/libxo-manual.html head/contrib/libxo/doc/xo.rst head/contrib/libxo/libxo/Makefile.am head/contrib/libxo/libxo/libxo.c head/contrib/libxo/libxo/xo.h head/contrib/libxo/libxo/xo_attr.3 head/contrib/libxo/libxo/xo_buf.h head/contrib/libxo/libxo/xo_emit.3 head/contrib/libxo/libxo/xo_emit_f.3 head/contrib/libxo/libxo/xo_finish.3 head/contrib/libxo/libxo/xo_flush.3 head/contrib/libxo/libxo/xo_open_container.3 head/contrib/libxo/libxo/xo_open_list.3 head/contrib/libxo/libxo/xo_open_marker.3 head/contrib/libxo/libxo/xo_set_writer.3 head/contrib/libxo/tests/core/saved/test_01.J.out head/contrib/libxo/tests/core/saved/test_02.J.out head/contrib/libxo/tests/core/saved/test_03.J.out head/contrib/libxo/tests/core/saved/test_04.J.out head/contrib/libxo/tests/core/saved/test_05.J.out head/contrib/libxo/tests/core/saved/test_05.JP.out head/contrib/libxo/tests/core/saved/test_06.J.out head/contrib/libxo/tests/core/saved/test_07.J.out head/contrib/libxo/tests/core/saved/test_08.J.out head/contrib/libxo/tests/core/saved/test_09.J.out head/contrib/libxo/tests/core/saved/test_10.J.out head/contrib/libxo/tests/core/saved/test_11.J.out head/contrib/libxo/tests/core/saved/test_12.E.err head/contrib/libxo/tests/core/saved/test_12.E.out head/contrib/libxo/tests/core/saved/test_12.H.err head/contrib/libxo/tests/core/saved/test_12.H.out head/contrib/libxo/tests/core/saved/test_12.HIPx.err head/contrib/libxo/tests/core/saved/test_12.HIPx.out head/contrib/libxo/tests/core/saved/test_12.HP.err head/contrib/libxo/tests/core/saved/test_12.HP.out head/contrib/libxo/tests/core/saved/test_12.J.err head/contrib/libxo/tests/core/saved/test_12.J.out head/contrib/libxo/tests/core/saved/test_12.JP.err head/contrib/libxo/tests/core/saved/test_12.JP.out head/contrib/libxo/tests/core/saved/test_12.T.err head/contrib/libxo/tests/core/saved/test_12.T.out head/contrib/libxo/tests/core/saved/test_12.X.err head/contrib/libxo/tests/core/saved/test_12.X.out head/contrib/libxo/tests/core/saved/test_12.XP.err head/contrib/libxo/tests/core/saved/test_12.XP.out head/contrib/libxo/tests/core/test_12.c head/contrib/libxo/tests/gettext/po/pig_latin/strerror.po head/contrib/libxo/tests/gettext/saved/gt_01.J.out head/contrib/libxo/tests/xo/Makefile.am head/contrib/libxo/tests/xo/saved/xo_01.H.out head/contrib/libxo/tests/xo/saved/xo_01.HIPx.out head/contrib/libxo/tests/xo/saved/xo_01.HP.out head/contrib/libxo/tests/xo/saved/xo_01.J.out head/contrib/libxo/tests/xo/saved/xo_01.JP.out head/contrib/libxo/tests/xo/saved/xo_01.T.out head/contrib/libxo/tests/xo/xo_01.sh head/contrib/libxo/xo/xo.1 head/contrib/libxo/xo/xo.c head/lib/libxo/xo_config.h head/usr.bin/xohtml/xohtml.sh Directory Properties: head/contrib/libxo/ (props changed) Modified: head/contrib/libxo/configure.ac ============================================================================== --- head/contrib/libxo/configure.ac Wed Apr 3 21:54:47 2019 (r345858) +++ head/contrib/libxo/configure.ac Wed Apr 3 21:55:39 2019 (r345859) @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [0.9.0], [phil@juniper.net]) +AC_INIT([libxo], [1.0.2], [phil@juniper.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability]) # Support silent build rules. Requires at least automake-1.11. Modified: head/contrib/libxo/doc/api.rst ============================================================================== --- head/contrib/libxo/doc/api.rst Wed Apr 3 21:54:47 2019 (r345858) +++ head/contrib/libxo/doc/api.rst Wed Apr 3 21:55:39 2019 (r345859) @@ -400,28 +400,28 @@ string, since an inappropriate cast can ruin your day. argument to `xo_emit_hv` points to a variable argument list that can be used to retrieve arguments via `va_arg`. -.. c:function:: int xo_emit (const char *fmt, ...) +.. c:function:: xo_ssize_t xo_emit (const char *fmt, ...) :param fmt: The format string, followed by zero or more arguments :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t -.. c:function:: int xo_emit_h (xo_handle_t *xop, const char *fmt, ...) +.. c:function:: xo_ssize_t xo_emit_h (xo_handle_t *xop, const char *fmt, ...) :param xop: Handle for modify (or NULL for default handle) :type xop: xo_handle_t \* :param fmt: The format string, followed by zero or more arguments :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t -.. c:function:: int xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap) +.. c:function:: xo_ssize_t xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap) :param xop: Handle for modify (or NULL for default handle) :type xop: xo_handle_t \* :param fmt: The format string :param va_list vap: A set of variadic arguments :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t .. index:: xo_emit_field @@ -434,7 +434,7 @@ scenario where one would otherwise need to compose a f descriptors using `snprintf`. The individual parts of the format descriptor are passed in distinctly. -.. c:function:: int xo_emit_field (const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...) +.. c:function:: xo_ssize_t xo_emit_field (const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...) :param rolmod: A comma-separated list of field roles and field modifiers :type rolmod: const char * @@ -445,7 +445,7 @@ descriptor are passed in distinctly. :param efmt: Encoding format string, followed by additional arguments :type efmt: const char * :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t :: @@ -453,7 +453,7 @@ descriptor are passed in distinctly. xo_emit_field("T", "Host name is ", NULL, NULL); xo_emit_field("V", "host-name", NULL, NULL, host-name); -.. c:function:: int xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...) +.. c:function:: xo_ssize_t xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...) :param xop: Handle for modify (or NULL for default handle) :type xop: xo_handle_t \* @@ -466,9 +466,9 @@ descriptor are passed in distinctly. :param efmt: Encoding format string, followed by additional arguments :type efmt: const char * :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t -.. c:function:: int xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents, const char *fmt, const char *efmt, va_list vap) +.. c:function:: xo_ssize_t xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents, const char *fmt, const char *efmt, va_list vap) :param xop: Handle for modify (or NULL for default handle) :type xop: xo_handle_t \* @@ -482,7 +482,7 @@ descriptor are passed in distinctly. :type efmt: const char * :param va_list vap: A set of variadic arguments :returns: If XOF_COLUMNS is set, the number of columns used; otherwise the number of bytes emitted - :rtype: int + :rtype: xo_ssize_t .. index:: xo_attr .. _xo_attr: @@ -505,14 +505,14 @@ Since attributes are only emitted in XML, their use sh to meta-data and additional or redundant representations of data already emitted in other form. -.. c:function:: int xo_attr (const char *name, const char *fmt, ...) +.. c:function:: xo_ssize_t xo_attr (const char *name, const char *fmt, ...) :param name: Attribute name :type name: const char * :param fmt: Attribute value, as variadic arguments :type fmt: const char * :returns: -1 for error, or the number of bytes in the formatted attribute value - :rtype: int + :rtype: xo_ssize_t :: @@ -525,7 +525,7 @@ already emitted in other form. 00:14 -.. c:function:: int xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...) +.. c:function:: xo_ssize_t xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...) :param xop: Handle for modify (or NULL for default handle) :type xop: xo_handle_t \* @@ -533,7 +533,7 @@ already emitted in other form. The `xo_attr_h` function follows the conventions of `xo_attr` but adds an explicit libxo handle. -.. c:function:: int xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap) +.. c:function:: xo_ssize_t xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap) The `xo_attr_h` function follows the conventions of `xo_attr_h` but replaced the variadic list with a variadic pointer. Modified: head/contrib/libxo/doc/libxo-manual.html ============================================================================== --- head/contrib/libxo/doc/libxo-manual.html Wed Apr 3 21:54:47 2019 (r345858) +++ head/contrib/libxo/doc/libxo-manual.html Wed Apr 3 21:55:39 2019 (r345859) @@ -515,7 +515,7 @@ li.indline1 { } @top-right { - content: "May 2018"; + content: "April 2019"; } @top-center { @@ -22011,7 +22011,7 @@ jQuery(function ($) { -May 21, 2018 +April 2, 2019

libxo: The Easy Way to Generate text, XML, JSON, and HTML output
libxo-manual

Modified: head/contrib/libxo/doc/xo.rst ============================================================================== --- head/contrib/libxo/doc/xo.rst Wed Apr 3 21:54:47 2019 (r345858) +++ head/contrib/libxo/doc/xo.rst Wed Apr 3 21:55:39 2019 (r345859) @@ -75,7 +75,7 @@ prepend data to the XPath values used for HTML output EXAMPLE; #!/bin/sh xo --open top/data - xo --depth 2 '{tag}' value + xo --depth 2 '{:tag}' value xo --close top/data XML: @@ -90,6 +90,84 @@ prepend data to the XPath values used for HTML output } } +When making partial lines of output (where the format string does not +include a newline), use the `--continuation` option to let secondary +invocations know they are adding data to an existing line. + +When emitting a series of objects, use the `--not-first` option to +ensure that any details from the previous object (e.g. commas in JSON) +are handled correctly. + +Use the `--top-wrap` option to ensure any top-level object details are +handled correctly, e.g. wrap the entire output in a top-level set of +braces for JSON output. + + EXAMPLE; + #!/bin/sh + xo --top-wrap --open top/data + xo --depth 2 'First {:tag} ' value1 + xo --depth 2 --continuation 'and then {:tag}\n' value2 + xo --top-wrap --close top/data + TEXT: + First value1 and then value2 + HTML: +
+
First
+
value1
+
+
and then
+
value2
+
+ XML: + + + value1 + value2 + + + JSON: + { + "top": { + "data": { + "tag": "value1", + "tag": "value2" + } + } + } + +Lists and Instances +------------------- + +A "*list*" is set of one or more instances that appear under the same +parent. The instances contain details about a specific object. One +can think of instances as objects or records. A call is needed to +open and close the list, while a distinct call is needed to open and +close each instance of the list. + +Use the `--open-list` and `--open-instances` to open lists and +instances. Use the `--close-list` and `--close-instances` to close +them. Each of these options take a `name` parameter, providing the +name of the list and instance. + +In the following example, a list named "machine" is created with three +instances: + + opts="--json" + xo $opts --open-list machine + NF= + for name in red green blue; do + xo $opts --depth 1 $NF --open-instance machine + xo $opts --depth 2 "Machine {k:name} has {:memory}\n" $name 55 + xo $opts --depth 1 --close-instance machine + NF=--not-first + done + xo $opts $NF --close-list machine + +The normal `libxo` functions use a state machine to help these +transitions, but since each `xo` command is invoked independent of the +previous calls, the state must be passed in explicitly via these +command line options. + Command Line Options -------------------- @@ -97,15 +175,23 @@ Command Line Options Usage: xo [options] format [fields] --close Close tags for the given path + --close-instance Close an open instance name + --close-list Close an open list name + --continuation OR -C Output belongs on same line as previous output --depth Set the depth for pretty printing --help Display this help text --html OR -H Generate HTML output --json OR -J Generate JSON output --leading-xpath Add a prefix to generated XPaths (HTML) + --not-first Indicate this object is not the first (JSON) --open Open tags for the given path + --open-instance Open an instance given by name + --open-list Open a list given by name + --option -or -O Give formatting options --pretty OR -p Make 'pretty' output (add indent, newlines) --style