From owner-svn-src-all@freebsd.org Sun Jan 12 04:00:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F31652222BC; Sun, 12 Jan 2020 04:00:58 +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 47wNLL5hgmz3Pcl; Sun, 12 Jan 2020 04:00:58 +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 B9096DCA5; Sun, 12 Jan 2020 04:00:58 +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 00C40w7n073125; Sun, 12 Jan 2020 04:00:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C40wZd073124; Sun, 12 Jan 2020 04:00:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120400.00C40wZd073124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:00:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356646 - in stable: 11/share/man/man4 12/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/share/man/man4 12/share/man/man4 X-SVN-Commit-Revision: 356646 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:00:59 -0000 Author: kevans Date: Sun Jan 12 04:00:58 2020 New Revision: 356646 URL: https://svnweb.freebsd.org/changeset/base/356646 Log: MFC r356539: md(4): improve documentation of preloading It's not immediately clear by what mechanism loader(8) will be loading the preloaded file. Specifically name-drop loader.conf(5) with a pointer to the module loading section and a description of what the 'name' should look like, because that certainly isn't clear from the loader.conf(5) standpoint. The default loader.conf already has a pointer to md(4) where it appears and the reference to loader.conf in the new version of this manpage should make it more clear that this is where one should look for information. Modified: stable/11/share/man/man4/md.4 Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/share/man/man4/md.4 Directory Properties: stable/12/ (props changed) Modified: stable/11/share/man/man4/md.4 ============================================================================== --- stable/11/share/man/man4/md.4 Sat Jan 11 23:00:57 2020 (r356645) +++ stable/11/share/man/man4/md.4 Sun Jan 12 04:00:58 2020 (r356646) @@ -7,7 +7,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 26, 2017 +.Dd January 8, 2020 .Dt MD 4 .Os .Sh NAME @@ -46,7 +46,7 @@ system. The exact value can be determined with .Xr vmstat 8 . .It Cm preload -A file loaded by +A module loaded by .Xr loader 8 with type .Sq md_image @@ -54,6 +54,12 @@ is used for backing store. For backwards compatibility the type .Sq mfs_root is also recognized. +See the description of module loading directives in +.Xr loader.conf 5 +and note that the module name will either be an absolute path to the image file +or the name of a file in the +.Va module_path . +.Pp If the kernel is created with option .Dv MD_ROOT the first preloaded image found will become the root file system. From owner-svn-src-all@freebsd.org Sun Jan 12 04:00:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 854BB2223DF; Sun, 12 Jan 2020 04:00:59 +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 47wNLM1kqMz3Pcp; Sun, 12 Jan 2020 04:00:59 +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 31468DCA7; Sun, 12 Jan 2020 04:00:59 +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 00C40wE1073131; Sun, 12 Jan 2020 04:00:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C40wd7073130; Sun, 12 Jan 2020 04:00:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120400.00C40wd7073130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:00:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356646 - in stable: 11/share/man/man4 12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/share/man/man4 12/share/man/man4 X-SVN-Commit-Revision: 356646 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:00:59 -0000 Author: kevans Date: Sun Jan 12 04:00:58 2020 New Revision: 356646 URL: https://svnweb.freebsd.org/changeset/base/356646 Log: MFC r356539: md(4): improve documentation of preloading It's not immediately clear by what mechanism loader(8) will be loading the preloaded file. Specifically name-drop loader.conf(5) with a pointer to the module loading section and a description of what the 'name' should look like, because that certainly isn't clear from the loader.conf(5) standpoint. The default loader.conf already has a pointer to md(4) where it appears and the reference to loader.conf in the new version of this manpage should make it more clear that this is where one should look for information. Modified: stable/12/share/man/man4/md.4 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/share/man/man4/md.4 Directory Properties: stable/11/ (props changed) Modified: stable/12/share/man/man4/md.4 ============================================================================== --- stable/12/share/man/man4/md.4 Sat Jan 11 23:00:57 2020 (r356645) +++ stable/12/share/man/man4/md.4 Sun Jan 12 04:00:58 2020 (r356646) @@ -7,7 +7,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 26, 2017 +.Dd January 8, 2020 .Dt MD 4 .Os .Sh NAME @@ -46,7 +46,7 @@ system. The exact value can be determined with .Xr vmstat 8 . .It Cm preload -A file loaded by +A module loaded by .Xr loader 8 with type .Sq md_image @@ -54,6 +54,12 @@ is used for backing store. For backwards compatibility the type .Sq mfs_root is also recognized. +See the description of module loading directives in +.Xr loader.conf 5 +and note that the module name will either be an absolute path to the image file +or the name of a file in the +.Va module_path . +.Pp If the kernel is created with option .Dv MD_ROOT the first preloaded image found will become the root file system. From owner-svn-src-all@freebsd.org Sun Jan 12 04:02:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD46E222587; Sun, 12 Jan 2020 04:02:53 +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 47wNNY4vClz3Q4t; Sun, 12 Jan 2020 04:02:53 +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 978BFDE42; Sun, 12 Jan 2020 04:02:53 +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 00C42rns077716; Sun, 12 Jan 2020 04:02:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C42rdQ077715; Sun, 12 Jan 2020 04:02:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120402.00C42rdQ077715@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:02:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356647 - stable/12/sys/arm/broadcom/bcm2835 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/sys/arm/broadcom/bcm2835 X-SVN-Commit-Revision: 356647 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:02:53 -0000 Author: kevans Date: Sun Jan 12 04:02:53 2020 New Revision: 356647 URL: https://svnweb.freebsd.org/changeset/base/356647 Log: MFC r356562: bcm2835_vcbus: hide 'checking root' messages under bootverbose Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c ============================================================================== --- stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c Sun Jan 12 04:00:58 2020 (r356646) +++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c Sun Jan 12 04:02:53 2020 (r356647) @@ -219,8 +219,9 @@ bcm283x_get_current_memcfg(void) root = OF_finddevice("/"); for (i = 0; i < nitems(bcm283x_memory_configs); ++i) { booted_soc_memcfg = &bcm283x_memory_configs[i]; - printf("Checking root against %s\n", - booted_soc_memcfg->soc_compat); + if (bootverbose) + printf("Checking root against %s\n", + booted_soc_memcfg->soc_compat); if (ofw_bus_node_is_compatible(root, booted_soc_memcfg->soc_compat)) return (booted_soc_memcfg); From owner-svn-src-all@freebsd.org Sun Jan 12 04:05:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9087022265E; Sun, 12 Jan 2020 04:05:20 +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 47wNRN1BTPz3QCT; Sun, 12 Jan 2020 04:05:20 +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 F0B10DE46; Sun, 12 Jan 2020 04:05:19 +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 00C45JCC077914; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C45J0R077913; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120405.00C45J0R077913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356648 - in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Commit-Revision: 356648 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:05:20 -0000 Author: kevans Date: Sun Jan 12 04:05:18 2020 New Revision: 356648 URL: https://svnweb.freebsd.org/changeset/base/356648 Log: MFC r356564: dwc_otg: fix fdt attachment for newer bcm2708-usb nodes The newer versions of RPi FDT flipped the order of the interrupts specification and added an 'interrupt-names' property for driver aide in finding the correct interrupt, rather than assuming the positions. Use it if it's available, or fallback to the old method if there is no interrupt-names property with a usb value. This has been tested with both old RPi3B FDT and new RPi3B FDT, USB again works on the latter. Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:02:53 2020 (r356647) +++ stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:05:18 2020 (r356648) @@ -80,6 +80,20 @@ dwc_otg_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static int +dwc_otg_irq_index(device_t dev, int *rid) +{ + int idx, rv; + phandle_t node; + + node = ofw_bus_get_node(dev); + rv = ofw_bus_find_string_index(node, "interrupt-names", "usb", &idx); + if (rv != 0) + return (rv); + *rid = idx; + return (0); +} + int dwc_otg_attach(device_t dev) { @@ -130,10 +144,16 @@ dwc_otg_attach(device_t dev) /* - * brcm,bcm2708-usb FDT provides two interrupts, - * we need only second one (VC_USB) + * brcm,bcm2708-usb FDT provides two interrupts, we need only the USB + * interrupt (VC_USB). The latest FDT for it provides an + * interrupt-names property and swapped them around, while older ones + * did not have interrupt-names and put the usb interrupt in the second + * position. We'll attempt to use interrupt-names first with a fallback + * to the old method of assuming the index based on the compatible + * string. */ - rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; + if (dwc_otg_irq_index(dev, &rid) != 0) + rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_otg.sc_irq_res == NULL) From owner-svn-src-all@freebsd.org Sun Jan 12 04:05:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 908CD22265F; Sun, 12 Jan 2020 04:05:20 +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 47wNRN153kz3QCS; Sun, 12 Jan 2020 04:05:20 +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 CB189DE45; Sun, 12 Jan 2020 04:05:19 +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 00C45Jvu077908; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C45JL6077907; Sun, 12 Jan 2020 04:05:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120405.00C45JL6077907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356648 - in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/usb/controller 12/sys/dev/usb/controller X-SVN-Commit-Revision: 356648 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:05:20 -0000 Author: kevans Date: Sun Jan 12 04:05:18 2020 New Revision: 356648 URL: https://svnweb.freebsd.org/changeset/base/356648 Log: MFC r356564: dwc_otg: fix fdt attachment for newer bcm2708-usb nodes The newer versions of RPi FDT flipped the order of the interrupts specification and added an 'interrupt-names' property for driver aide in finding the correct interrupt, rather than assuming the positions. Use it if it's available, or fallback to the old method if there is no interrupt-names property with a usb value. This has been tested with both old RPi3B FDT and new RPi3B FDT, USB again works on the latter. Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/dev/usb/controller/dwc_otg_fdt.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:02:53 2020 (r356647) +++ stable/11/sys/dev/usb/controller/dwc_otg_fdt.c Sun Jan 12 04:05:18 2020 (r356648) @@ -73,6 +73,20 @@ dwc_otg_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static int +dwc_otg_irq_index(device_t dev, int *rid) +{ + int idx, rv; + phandle_t node; + + node = ofw_bus_get_node(dev); + rv = ofw_bus_find_string_index(node, "interrupt-names", "usb", &idx); + if (rv != 0) + return (rv); + *rid = idx; + return (0); +} + int dwc_otg_attach(device_t dev) { @@ -123,10 +137,16 @@ dwc_otg_attach(device_t dev) /* - * brcm,bcm2708-usb FDT provides two interrupts, - * we need only second one (VC_USB) + * brcm,bcm2708-usb FDT provides two interrupts, we need only the USB + * interrupt (VC_USB). The latest FDT for it provides an + * interrupt-names property and swapped them around, while older ones + * did not have interrupt-names and put the usb interrupt in the second + * position. We'll attempt to use interrupt-names first with a fallback + * to the old method of assuming the index based on the compatible + * string. */ - rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; + if (dwc_otg_irq_index(dev, &rid) != 0) + rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_otg.sc_irq_res == NULL) From owner-svn-src-all@freebsd.org Sun Jan 12 04:07:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 014E322277B; Sun, 12 Jan 2020 04:07:05 +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 47wNTN5W4hz3QS6; Sun, 12 Jan 2020 04:07:04 +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 859B1DE4A; Sun, 12 Jan 2020 04:07:04 +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 00C473Zj078053; Sun, 12 Jan 2020 04:07:03 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C473ea078052; Sun, 12 Jan 2020 04:07:03 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120407.00C473ea078052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356649 - head/sys/dev/extres/regulator X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/dev/extres/regulator X-SVN-Commit-Revision: 356649 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:07:05 -0000 Author: kevans Date: Sun Jan 12 04:07:03 2020 New Revision: 356649 URL: https://svnweb.freebsd.org/changeset/base/356649 Log: regulator: small enhancements to regulator_shutdown Highlights: - Exit early if we're not disabling unused regulators; there's no need to take the regulator topology lock and re-evaluate this every iteration, as it's not going to change. - Don't emit a notice that we're shutting down a regulator if it's not enabled, to reduce noise. - Mention the outcome of the shutdown, to aide debugging and easily let developer/user collect list of regulators we actually shutdown to determine problematic one. Reviewed by: manu MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D22213 Modified: head/sys/dev/extres/regulator/regulator.c Modified: head/sys/dev/extres/regulator/regulator.c ============================================================================== --- head/sys/dev/extres/regulator/regulator.c Sun Jan 12 04:05:18 2020 (r356648) +++ head/sys/dev/extres/regulator/regulator.c Sun Jan 12 04:07:03 2020 (r356649) @@ -191,16 +191,36 @@ regulator_shutdown(void *dummy) int status, ret; int disable = 1; - REG_TOPO_SLOCK(); TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable); + if (!disable) + return; + REG_TOPO_SLOCK(); + + if (bootverbose) + printf("regulator: shutting down unused regulators\n"); TAILQ_FOREACH(entry, ®node_list, reglist_link) { - if (!entry->std_param.always_on && disable) { - if (bootverbose) - printf("regulator: shutting down %s\n", - entry->name); + if (!entry->std_param.always_on) { ret = regnode_status(entry, &status); - if (ret == 0 && status == REGULATOR_STATUS_ENABLED) - regnode_stop(entry, 0); + if (ret == 0 && status == REGULATOR_STATUS_ENABLED) { + if (bootverbose) + printf("regulator: shutting down %s... ", + entry->name); + ret = regnode_stop(entry, 0); + if (bootverbose) { + /* + * Call out busy in particular, here, + * because it's not unexpected to fail + * shutdown if the regulator is simply + * in-use. + */ + if (ret == EBUSY) + printf("busy\n"); + else if (ret != 0) + printf("error (%d)\n", ret); + else + printf("ok\n"); + } + } } } REG_TOPO_UNLOCK(); From owner-svn-src-all@freebsd.org Sun Jan 12 04:18:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79A48222BB6; Sun, 12 Jan 2020 04:18:37 +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 47wNkj2Pnzz3QwH; Sun, 12 Jan 2020 04:18:37 +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 4595CE01E; Sun, 12 Jan 2020 04:18:37 +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 00C4Ibim084111; Sun, 12 Jan 2020 04:18:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C4Iapw084109; Sun, 12 Jan 2020 04:18:36 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120418.00C4Iapw084109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:18:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356650 - in head: . tools/build X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: . tools/build X-SVN-Commit-Revision: 356650 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:18:37 -0000 Author: kevans Date: Sun Jan 12 04:18:36 2020 New Revision: 356650 URL: https://svnweb.freebsd.org/changeset/base/356650 Log: Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH ${WORLDTMP}/legacy/usr/libexec will only have libexec/ bits that we've pushed as bootstrap tools, so this is generally safe to include prior to PATH. The following are the ramifications of this change: - BPATH addition gets us at least bootstrap flua in WMAKEENV path for buildenv, for those earlier systems where it's bootstrapped still - Reworked the sysent target to just set PATH and let it get worked out in src.lua.mk or individual sysent makefiles -- this gives us back the ability to overwrite LUA_CMD and use a different/external lua for these targets. sysent can also now work cleanly in buildenv. - tools/build/Makefile will now symlink the host flua into build's host tools so that the above can work without needing to add the host's /usr/libexec explicitly into TMPPATH. Reviewed by: arichardson, brooks, imp (all slightly earlier version) Differential Revision: https://reviews.freebsd.org/D22464 Modified: head/Makefile.inc1 head/tools/build/Makefile Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Sun Jan 12 04:07:03 2020 (r356649) +++ head/Makefile.inc1 Sun Jan 12 04:18:36 2020 (r356650) @@ -590,7 +590,7 @@ BUILD_ARCH!= uname -p .endif .endif WORLDTMP?= ${OBJTOP}/tmp -BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin +BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin # When building we want to find the cross tools before the host tools in ${BPATH}. @@ -1500,11 +1500,11 @@ makeman: .PHONY ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \ ${.CURDIR}/share/man/man5/src.conf.5 -.if make(sysent) -.include -.endif - -_sysent_PATH= ${WORLDTMP}/legacy/usr/libexec:/usr/libexec:${PATH} +# We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec +# because we may be building with a STRICTTMPPATH, so we explicitly include +# /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else +# we may need to function. +_sysent_PATH= ${TMPPATH}:/usr/libexec _sysent_dirs= sys/kern _sysent_dirs+= sys/compat/freebsd32 _sysent_dirs+= sys/compat/cloudabi32 \ @@ -1517,8 +1517,7 @@ _sysent_dirs+= sys/amd64/linux \ sysent: .PHONY .for _dir in ${_sysent_dirs} @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent" - ${_+_}@env PATH=${_sysent_PATH} LUA=${LUA_CMD} \ - ${MAKE} -C ${.CURDIR}/${_dir} sysent + ${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent .endfor # Modified: head/tools/build/Makefile ============================================================================== --- head/tools/build/Makefile Sun Jan 12 04:07:03 2020 (r356649) +++ head/tools/build/Makefile Sun Jan 12 04:18:36 2020 (r356650) @@ -116,6 +116,9 @@ host-symlinks: ln -sfnv "$${source_path}" "$${target_path}"; \ fi .endfor +.if exists(/usr/libexec/flua) + ln -sf /usr/libexec/flua ${DESTDIR}/usr/libexec/flua +.endif # Create all the directories that are needed during the legacy, bootstrap-tools # and cross-tools stages. We do this here using mkdir since mtree may not exist From owner-svn-src-all@freebsd.org Sun Jan 12 04:53:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EC1F4223857; Sun, 12 Jan 2020 04:53:01 +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 47wPVP5wzBz3xg3; Sun, 12 Jan 2020 04:53:01 +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 C6B29E75D; Sun, 12 Jan 2020 04:53:01 +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 00C4r1GE008224; Sun, 12 Jan 2020 04:53:01 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C4r1nX008222; Sun, 12 Jan 2020 04:53:01 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120453.00C4r1nX008222@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 04:53:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356651 - in head/sys/cddl: compat/opensolaris/kern contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys/cddl: compat/opensolaris/kern contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 356651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:53:02 -0000 Author: mjg Date: Sun Jan 12 04:53:01 2020 New Revision: 356651 URL: https://svnweb.freebsd.org/changeset/base/356651 Log: zfs: add missing CLTFLAG_MPSAFE annotations Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c ============================================================================== --- head/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Sun Jan 12 04:18:36 2020 (r356650) +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Sun Jan 12 04:53:01 2020 (r356651) @@ -117,8 +117,8 @@ kstat_install(kstat_t *ksp) ("data_type=%d", ksent->data_type)); SYSCTL_ADD_PROC(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(ksp->ks_sysctl_root), OID_AUTO, ksent->name, - CTLTYPE_U64 | CTLFLAG_RD, ksent, sizeof(*ksent), - kstat_sysctl, "QU", ksent->desc); + CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RD, ksent, + sizeof(*ksent), kstat_sysctl, "QU", ksent->desc); } } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sun Jan 12 04:18:36 2020 (r356650) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sun Jan 12 04:53:01 2020 (r356651) @@ -435,11 +435,14 @@ TUNABLE_INT("vfs.zfs.arc_shrink_shift", &zfs_arc_shrin TUNABLE_INT("vfs.zfs.arc_grow_retry", &zfs_arc_grow_retry); TUNABLE_INT("vfs.zfs.arc_no_grow_shift", &zfs_arc_no_grow_shift); SYSCTL_DECL(_vfs_zfs); -SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, CTLTYPE_U64 | CTLFLAG_RWTUN, +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, + CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(uint64_t), sysctl_vfs_zfs_arc_max, "QU", "Maximum ARC size"); -SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, CTLTYPE_U64 | CTLFLAG_RWTUN, +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, + CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(uint64_t), sysctl_vfs_zfs_arc_min, "QU", "Minimum ARC size"); -SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift, CTLTYPE_U32 | CTLFLAG_RWTUN, +SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift, + CTLTYPE_U32 | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(uint32_t), sysctl_vfs_zfs_arc_no_grow_shift, "U", "log2(fraction of ARC which must be free to allow growing)"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN, From owner-svn-src-all@freebsd.org Sun Jan 12 04:53:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B999F2238B6; Sun, 12 Jan 2020 04:53:22 +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 47wPVp4WF9z3xnP; Sun, 12 Jan 2020 04:53:22 +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 96243E75E; Sun, 12 Jan 2020 04:53:22 +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 00C4rMKm008292; Sun, 12 Jan 2020 04:53:22 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C4rMti008291; Sun, 12 Jan 2020 04:53:22 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120453.00C4rMti008291@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 04:53:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356652 - head/sys/cddl/dev/dtrace X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/cddl/dev/dtrace X-SVN-Commit-Revision: 356652 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:53:22 -0000 Author: mjg Date: Sun Jan 12 04:53:22 2020 New Revision: 356652 URL: https://svnweb.freebsd.org/changeset/base/356652 Log: dtrace: add missing CLTFLAG_MPSAFE annotations Modified: head/sys/cddl/dev/dtrace/dtrace_sysctl.c head/sys/cddl/dev/dtrace/dtrace_test.c Modified: head/sys/cddl/dev/dtrace/dtrace_sysctl.c ============================================================================== --- head/sys/cddl/dev/dtrace/dtrace_sysctl.c Sun Jan 12 04:53:01 2020 (r356651) +++ head/sys/cddl/dev/dtrace/dtrace_sysctl.c Sun Jan 12 04:53:22 2020 (r356652) @@ -75,8 +75,9 @@ sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); -SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, - 0, 0, sysctl_dtrace_providers, "A", "available DTrace providers"); +SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, + CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers, + "A", "available DTrace providers"); SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters"); Modified: head/sys/cddl/dev/dtrace/dtrace_test.c ============================================================================== --- head/sys/cddl/dev/dtrace/dtrace_test.c Sun Jan 12 04:53:01 2020 (r356651) +++ head/sys/cddl/dev/dtrace/dtrace_test.c Sun Jan 12 04:53:22 2020 (r356652) @@ -77,8 +77,9 @@ dtrace_test_sdttest(SYSCTL_HANDLER_ARGS) static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, CTLFLAG_RD, 0, ""); -SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, CTLTYPE_INT | CTLFLAG_RW, - NULL, 0, dtrace_test_sdttest, "I", "Trigger the SDT test probe"); +SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, dtrace_test_sdttest, + "I", "Trigger the SDT test probe"); static int dtrace_test_modevent(module_t mod, int type, void *data) From owner-svn-src-all@freebsd.org Sun Jan 12 05:08:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FA65223C4F; Sun, 12 Jan 2020 05:08:59 +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 47wPrq0Wznz3yDs; Sun, 12 Jan 2020 05:08:59 +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 0D662E939; Sun, 12 Jan 2020 05:08:59 +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 00C58wOP014632; Sun, 12 Jan 2020 05:08:58 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C58v07014627; Sun, 12 Jan 2020 05:08:57 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120508.00C58v07014627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 05:08:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356653 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 356653 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 05:08:59 -0000 Author: mjg Date: Sun Jan 12 05:08:57 2020 New Revision: 356653 URL: https://svnweb.freebsd.org/changeset/base/356653 Log: vm: add missing CLTFLAG_MPSAFE annotations This covers all vm/* files. Modified: head/sys/vm/memguard.c head/sys/vm/uma_core.c head/sys/vm/vm_glue.c head/sys/vm/vm_kern.c head/sys/vm/vm_reserv.c head/sys/vm/vnode_pager.c Modified: head/sys/vm/memguard.c ============================================================================== --- head/sys/vm/memguard.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/memguard.c Sun Jan 12 05:08:57 2020 (r356653) @@ -237,7 +237,7 @@ memguard_sysinit(void) CTLFLAG_RD, &memguard_mapsize, "MemGuard KVA size"); SYSCTL_ADD_PROC(NULL, parent, OID_AUTO, "mapused", - CTLFLAG_RD | CTLTYPE_ULONG, NULL, 0, memguard_sysctl_mapused, "LU", + CTLFLAG_RD | CTLFLAG_MPSAFE | CTLTYPE_ULONG, NULL, 0, memguard_sysctl_mapused, "LU", "MemGuard KVA used"); } SYSINIT(memguard, SI_SUB_KLD, SI_ORDER_ANY, memguard_sysinit, NULL); Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/uma_core.c Sun Jan 12 05:08:57 2020 (r356653) @@ -330,10 +330,10 @@ SYSINIT(uma_startup3, SI_SUB_VM_CONF, SI_ORDER_SECOND, SYSCTL_NODE(_vm, OID_AUTO, uma, CTLFLAG_RW, 0, "Universal Memory Allocator"); -SYSCTL_PROC(_vm, OID_AUTO, zone_count, CTLFLAG_RD|CTLTYPE_INT, +SYSCTL_PROC(_vm, OID_AUTO, zone_count, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLTYPE_INT, 0, 0, sysctl_vm_zone_count, "I", "Number of UMA zones"); -SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT, +SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLTYPE_STRUCT, 0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats"); static int zone_warnings = 1; Modified: head/sys/vm/vm_glue.c ============================================================================== --- head/sys/vm/vm_glue.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/vm_glue.c Sun Jan 12 05:08:57 2020 (r356653) @@ -281,9 +281,9 @@ sysctl_kstack_cache_size(SYSCTL_HANDLER_ARGS) uma_zone_set_maxcache(kstack_cache, kstack_cache_size); return (error); } -SYSCTL_PROC(_vm, OID_AUTO, kstack_cache_size, CTLTYPE_INT|CTLFLAG_RW, - &kstack_cache_size, 0, sysctl_kstack_cache_size, "IU", - "Maximum number of cached kernel stacks"); +SYSCTL_PROC(_vm, OID_AUTO, kstack_cache_size, + CTLTYPE_INT|CTLFLAG_MPSAFE|CTLFLAG_RW, &kstack_cache_size, 0, + sysctl_kstack_cache_size, "IU", "Maximum number of cached kernel stacks"); /* * Create the kernel stack (including pcb for i386) for a new thread. Modified: head/sys/vm/vm_kern.c ============================================================================== --- head/sys/vm/vm_kern.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/vm_kern.c Sun Jan 12 05:08:57 2020 (r356653) @@ -880,5 +880,5 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) return (0); } -SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_RW, 0, 0, +SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, 0, debug_vm_lowmem, "I", "set to trigger vm_lowmem event with given flags"); Modified: head/sys/vm/vm_reserv.c ============================================================================== --- head/sys/vm/vm_reserv.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/vm_reserv.c Sun Jan 12 05:08:57 2020 (r356653) @@ -273,8 +273,8 @@ SYSCTL_COUNTER_U64(_vm_reserv, OID_AUTO, freed, CTLFLA static int sysctl_vm_reserv_fullpop(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_vm_reserv, OID_AUTO, fullpop, CTLTYPE_INT | CTLFLAG_RD, NULL, 0, - sysctl_vm_reserv_fullpop, "I", "Current number of full reservations"); +SYSCTL_PROC(_vm_reserv, OID_AUTO, fullpop, CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD, + NULL, 0, sysctl_vm_reserv_fullpop, "I", "Current number of full reservations"); static int sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS); Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Sun Jan 12 04:53:22 2020 (r356652) +++ head/sys/vm/vnode_pager.c Sun Jan 12 05:08:57 2020 (r356653) @@ -119,9 +119,9 @@ struct pagerops vnodepagerops = { static struct domainset *vnode_domainset = NULL; -SYSCTL_PROC(_debug, OID_AUTO, vnode_domainset, CTLTYPE_STRING | CTLFLAG_RW, - &vnode_domainset, 0, sysctl_handle_domainset, "A", - "Default vnode NUMA policy"); +SYSCTL_PROC(_debug, OID_AUTO, vnode_domainset, + CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RW, &vnode_domainset, 0, + sysctl_handle_domainset, "A", "Default vnode NUMA policy"); static int nvnpbufs; SYSCTL_INT(_vm, OID_AUTO, vnode_pbufs, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, From owner-svn-src-all@freebsd.org Sun Jan 12 05:25:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 926F22240BA; Sun, 12 Jan 2020 05:25:06 +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 47wQCQ3NqCz3ywd; Sun, 12 Jan 2020 05:25:06 +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 6E465ECF2; Sun, 12 Jan 2020 05:25:06 +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 00C5P6Wd026455; Sun, 12 Jan 2020 05:25:06 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C5P6rh026454; Sun, 12 Jan 2020 05:25:06 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120525.00C5P6rh026454@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 05:25:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356654 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 356654 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 05:25:06 -0000 Author: mjg Date: Sun Jan 12 05:25:06 2020 New Revision: 356654 URL: https://svnweb.freebsd.org/changeset/base/356654 Log: sysctl: add missing CLTFLAG_MPSAFE annotation to CONST_STRING Modified: head/sys/sys/sysctl.h Modified: head/sys/sys/sysctl.h ============================================================================== --- head/sys/sys/sysctl.h Sun Jan 12 05:08:57 2020 (r356653) +++ head/sys/sys/sysctl.h Sun Jan 12 05:25:06 2020 (r356654) @@ -357,7 +357,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); /* Oid for a constant '\0' terminated string. */ #define SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\ __DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \ CTASSERT(!(access & CTLFLAG_WR)); \ CTASSERT(((access) & CTLTYPE) == 0 || \ @@ -369,9 +369,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(!(access & CTLFLAG_WR)); \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ - __arg, 0, sysctl_handle_string, "A", __DESCR(descr), \ - NULL); \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING | \ + CTLFLAG_MPSAFE | (access), __arg, 0, sysctl_handle_string, "A",\ + __DESCR(descr), NULL); \ }) /* Oid for a bool. If ptr is NULL, val is returned. */ From owner-svn-src-all@freebsd.org Sun Jan 12 06:08:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D30D6225367; Sun, 12 Jan 2020 06:08:01 +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 47wR8x633Xz41vP; Sun, 12 Jan 2020 06:08:01 +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 C6162F49B; Sun, 12 Jan 2020 06:08:01 +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 00C681c2050719; Sun, 12 Jan 2020 06:08:01 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C67sW0050677; Sun, 12 Jan 2020 06:07:54 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120607.00C67sW0050677@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 06:07:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356655 - in head/sys: arm/samsung/exynos arm/versatile cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs/zfs cddl/contrib/opensolaris/uts/common/os ddb dev/acpica dev/... X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: arm/samsung/exynos arm/versatile cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs/zfs cddl/contrib/opensolaris/uts/common/os ddb dev/acpica dev/drm2 dev/iscsi dev/mrsas ... X-SVN-Commit-Revision: 356655 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 06:08:01 -0000 Author: mjg Date: Sun Jan 12 06:07:54 2020 New Revision: 356655 URL: https://svnweb.freebsd.org/changeset/base/356655 Log: Add KERNEL_PANICKED macro for use in place of direct panicstr tests Modified: head/sys/arm/samsung/exynos/chrome_kb.c head/sys/arm/versatile/pl050.c head/sys/cddl/compat/opensolaris/sys/mutex.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c head/sys/cddl/contrib/opensolaris/uts/common/os/fm.c head/sys/ddb/db_textdump.c head/sys/dev/acpica/acpi.c head/sys/dev/drm2/drm_fb_helper.c head/sys/dev/iscsi/iscsi.c head/sys/dev/mrsas/mrsas.c head/sys/dev/syscons/syscons.c head/sys/dev/vt/vt_core.c head/sys/dev/xen/console/xen_console.c head/sys/gdb/netgdb.c head/sys/geom/journal/g_journal.c head/sys/geom/mirror/g_mirror.c head/sys/kern/kern_ktr.c head/sys/kern/kern_lock.c head/sys/kern/kern_mutex.c head/sys/kern/kern_switch.c head/sys/kern/kern_synch.c head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c head/sys/kern/subr_csan.c head/sys/kern/subr_prf.c head/sys/kern/subr_smp.c head/sys/kern/subr_witness.c head/sys/kern/tty_info.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_subr.c head/sys/netinet/netdump/netdump_client.c head/sys/sparc64/sparc64/mp_machdep.c head/sys/sys/systm.h head/sys/x86/x86/local_apic.c head/sys/x86/x86/mp_x86.c Modified: head/sys/arm/samsung/exynos/chrome_kb.c ============================================================================== --- head/sys/arm/samsung/exynos/chrome_kb.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/arm/samsung/exynos/chrome_kb.c Sun Jan 12 06:07:54 2020 (r356655) @@ -81,7 +81,7 @@ __FBSDID("$FreeBSD$"); */ #define CKB_CTX_LOCK_ASSERT() \ do { \ - if (!kdb_active && panicstr == NULL) \ + if (!kdb_active && !KERNEL_PANICKED()) \ mtx_assert(&Giant, MA_OWNED); \ } while (0) #else Modified: head/sys/arm/versatile/pl050.c ============================================================================== --- head/sys/arm/versatile/pl050.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/arm/versatile/pl050.c Sun Jan 12 06:07:54 2020 (r356655) @@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$"); */ #define KMI_CTX_LOCK_ASSERT() \ do { \ - if (!kdb_active && panicstr == NULL) \ + if (!kdb_active && !KERNEL_PANICKED()) \ mtx_assert(&Giant, MA_OWNED); \ } while (0) #else Modified: head/sys/cddl/compat/opensolaris/sys/mutex.h ============================================================================== --- head/sys/cddl/compat/opensolaris/sys/mutex.h Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/cddl/compat/opensolaris/sys/mutex.h Sun Jan 12 06:07:54 2020 (r356655) @@ -42,7 +42,7 @@ typedef enum { } kmutex_type_t; #define MUTEX_HELD(x) (mutex_owned(x)) -#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr) +#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || KERNEL_PANICKED()) typedef struct sx kmutex_t; Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Jan 12 06:07:54 2020 (r356655) @@ -7296,7 +7296,7 @@ zfs_shutdown(void *arg __unused, int howto __unused) /* * ZFS fini routines can not properly work in a panic-ed system. */ - if (panicstr == NULL) + if (!KERNEL_PANICKED()) (void)zfs__fini(); } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sun Jan 12 06:07:54 2020 (r356655) @@ -293,7 +293,7 @@ zfs_sync(vfs_t *vfsp, int waitfor) * Data integrity is job one. We don't want a compromised kernel * writing to the storage pool, so we never sync during panic. */ - if (panicstr) + if (KERNEL_PANICKED()) return (0); /* Modified: head/sys/cddl/contrib/opensolaris/uts/common/os/fm.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/os/fm.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/cddl/contrib/opensolaris/uts/common/os/fm.c Sun Jan 12 06:07:54 2020 (r356655) @@ -119,7 +119,7 @@ fm_drain(void *private, void *data, errorq_elem_t *eep { nvlist_t *nvl = errorq_elem_nvl(ereport_errorq, eep); - if (!panicstr) + if (!KERNEL_PANICKED()) (void) fm_ereport_post(nvl, EVCH_TRYHARD); else fm_nvprint(nvl); @@ -420,7 +420,7 @@ fm_banner(void) if (!fm_panicstr) return; /* panic was not initiated by fm_panic(); do nothing */ - if (panicstr) { + if (KERNEL_PANICKED()) { tod = panic_hrestime; now = panic_hrtime; } else { @@ -472,7 +472,7 @@ fm_ereport_dump(void) char *buf; size_t len; - if (panicstr) { + if (KERNEL_PANICKED()) { tod = panic_hrestime; now = panic_hrtime; } else { @@ -486,7 +486,7 @@ fm_ereport_dump(void) * In the panic case, sysevent_evc_walk_init() will return NULL. */ if ((chq = sysevent_evc_walk_init(ereport_chan, NULL)) == NULL && - !panicstr) + !KERNEL_PANICKED()) return; /* event channel isn't initialized yet */ while ((sep = sysevent_evc_walk_step(chq)) != NULL) { Modified: head/sys/ddb/db_textdump.c ============================================================================== --- head/sys/ddb/db_textdump.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/ddb/db_textdump.c Sun Jan 12 06:07:54 2020 (r356655) @@ -479,7 +479,7 @@ textdump_dumpsys(struct dumperinfo *di) #endif if (textdump_do_msgbuf) textdump_dump_msgbuf(di); - if (textdump_do_panic && panicstr != NULL) + if (textdump_do_panic && KERNEL_PANICKED()) textdump_dump_panic(di); if (textdump_do_version) textdump_dump_version(di); Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/acpica/acpi.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2166,7 +2166,7 @@ acpi_shutdown_final(void *arg, int howto) } else if (status != AE_NOT_EXIST) device_printf(sc->acpi_dev, "reset failed - %s\n", AcpiFormatException(status)); - } else if (sc->acpi_do_disable && panicstr == NULL) { + } else if (sc->acpi_do_disable && !KERNEL_PANICKED()) { /* * Only disable ACPI if the user requested. On some systems, writing * the disable value to SMI_CMD hangs the system. Modified: head/sys/dev/drm2/drm_fb_helper.c ============================================================================== --- head/sys/dev/drm2/drm_fb_helper.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/drm2/drm_fb_helper.c Sun Jan 12 06:07:54 2020 (r356655) @@ -74,7 +74,7 @@ vt_kms_postswitch(void *arg) sc = (struct vt_kms_softc *)arg; - if (!kdb_active && panicstr == NULL) + if (!kdb_active && !KERNEL_PANICKED()) taskqueue_enqueue(taskqueue_thread, &sc->fb_mode_task); else drm_fb_helper_restore_fbdev_mode(sc->fb_helper); Modified: head/sys/dev/iscsi/iscsi.c ============================================================================== --- head/sys/dev/iscsi/iscsi.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/iscsi/iscsi.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2501,7 +2501,7 @@ static void iscsi_shutdown_post(struct iscsi_softc *sc) { - if (panicstr == NULL) { + if (!KERNEL_PANICKED()) { ISCSI_DEBUG("removing all sessions due to shutdown"); iscsi_terminate_sessions(sc); } Modified: head/sys/dev/mrsas/mrsas.c ============================================================================== --- head/sys/dev/mrsas/mrsas.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/mrsas/mrsas.c Sun Jan 12 06:07:54 2020 (r356655) @@ -1190,7 +1190,7 @@ mrsas_shutdown(device_t dev) sc = device_get_softc(dev); sc->remove_in_progress = 1; - if (panicstr == NULL) { + if (!KERNEL_PANICKED()) { if (sc->ocr_thread_active) wakeup(&sc->ocr_chan); i = 0; Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/syscons/syscons.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2163,7 +2163,7 @@ sccnupdate(scr_stat *scp) if (suspend_in_progress || scp->sc->font_loading_in_progress) return; - if (kdb_active || panicstr || shutdown_in_progress) { + if (kdb_active || KERNEL_PANICKED() || shutdown_in_progress) { sc_touch_scrn_saver(); } else if (scp != scp->sc->cur_scp) { return; @@ -2229,7 +2229,7 @@ scrn_timer(void *arg) } /* should we stop the screen saver? */ - if (kdb_active || panicstr || shutdown_in_progress) + if (kdb_active || KERNEL_PANICKED() || shutdown_in_progress) sc_touch_scrn_saver(); if (run_scrn_saver) { if (time_uptime > sc->scrn_time_stamp + scrn_blank_time) Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/vt/vt_core.c Sun Jan 12 06:07:54 2020 (r356655) @@ -1301,7 +1301,7 @@ vt_flush(struct vt_device *vd) /* Check if the cursor should be displayed or not. */ if ((vd->vd_flags & VDF_MOUSECURSOR) && /* Mouse support enabled. */ !(vw->vw_flags & VWF_MOUSE_HIDE) && /* Cursor displayed. */ - !kdb_active && panicstr == NULL) { /* DDB inactive. */ + !kdb_active && !KERNEL_PANICKED()) { /* DDB inactive. */ vd->vd_mshown = 1; } else { vd->vd_mshown = 0; @@ -1398,7 +1398,7 @@ vtterm_done(struct terminal *tm) struct vt_window *vw = tm->tm_softc; struct vt_device *vd = vw->vw_device; - if (kdb_active || panicstr != NULL) { + if (kdb_active || KERNEL_PANICKED()) { /* Switch to the debugger. */ if (vd->vd_curwindow != vw) { vd->vd_curwindow = vw; Modified: head/sys/dev/xen/console/xen_console.c ============================================================================== --- head/sys/dev/xen/console/xen_console.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/dev/xen/console/xen_console.c Sun Jan 12 06:07:54 2020 (r356655) @@ -199,7 +199,7 @@ xc_printf(const char *fmt, ...) static inline void xencons_lock(struct xencons_priv *cons) { - if (panicstr == NULL) + if (!KERNEL_PANICKED()) mtx_lock_spin(&cons->mtx); } @@ -207,7 +207,7 @@ static inline void xencons_lock(struct xencons_priv *c static inline void xencons_unlock(struct xencons_priv *cons) { - if (panicstr == NULL) + if (!KERNEL_PANICKED()) mtx_unlock_spin(&cons->mtx); } Modified: head/sys/gdb/netgdb.c ============================================================================== --- head/sys/gdb/netgdb.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/gdb/netgdb.c Sun Jan 12 06:07:54 2020 (r356655) @@ -340,7 +340,7 @@ DB_FUNC(netgdb, db_netgdb_cmd, db_cmd_table, CS_OWN, N struct debugnet_pcb *pcb; int error; - if (panicstr == NULL) { + if (!KERNEL_PANICKED()) { /* TODO: This limitation should be removed in future work. */ printf("%s: netgdb is currently limited to use only after a " "panic. Sorry.\n", __func__); Modified: head/sys/geom/journal/g_journal.c ============================================================================== --- head/sys/geom/journal/g_journal.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/geom/journal/g_journal.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2653,7 +2653,7 @@ g_journal_shutdown(void *arg, int howto __unused) struct g_class *mp; struct g_geom *gp, *gp2; - if (panicstr != NULL) + if (KERNEL_PANICKED()) return; mp = arg; g_topology_lock(); Modified: head/sys/geom/mirror/g_mirror.c ============================================================================== --- head/sys/geom/mirror/g_mirror.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/geom/mirror/g_mirror.c Sun Jan 12 06:07:54 2020 (r356655) @@ -3481,7 +3481,7 @@ g_mirror_shutdown_post_sync(void *arg, int howto) struct g_mirror_softc *sc; int error; - if (panicstr != NULL) + if (KERNEL_PANICKED()) return; mp = arg; Modified: head/sys/kern/kern_ktr.c ============================================================================== --- head/sys/kern/kern_ktr.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/kern_ktr.c Sun Jan 12 06:07:54 2020 (r356655) @@ -324,7 +324,7 @@ ktr_tracepoint(uint64_t mask, const char *file, int li #endif int cpu; - if (panicstr || kdb_active) + if (KERNEL_PANICKED() || kdb_active) return; if ((ktr_mask & mask) == 0 || ktr_buf == NULL) return; Modified: head/sys/kern/kern_lock.c ============================================================================== --- head/sys/kern/kern_lock.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/kern_lock.c Sun Jan 12 06:07:54 2020 (r356655) @@ -558,7 +558,7 @@ lockmgr_slock_hard(struct lock *lk, u_int flags, struc int contested = 0; #endif - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) goto out; tid = (uintptr_t)curthread; @@ -700,7 +700,7 @@ lockmgr_xlock_hard(struct lock *lk, u_int flags, struc int contested = 0; #endif - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) goto out; tid = (uintptr_t)curthread; @@ -882,7 +882,7 @@ lockmgr_upgrade(struct lock *lk, u_int flags, struct l int wakeup_swapper = 0; int op; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) goto out; tid = (uintptr_t)curthread; @@ -941,7 +941,7 @@ lockmgr_lock_fast_path(struct lock *lk, u_int flags, s u_int op; bool locked; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) return (0); op = flags & LK_TYPE_MASK; @@ -1003,7 +1003,7 @@ lockmgr_sunlock_hard(struct lock *lk, uintptr_t x, u_i { int wakeup_swapper = 0; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) goto out; wakeup_swapper = wakeupshlk(lk, file, line); @@ -1022,7 +1022,7 @@ lockmgr_xunlock_hard(struct lock *lk, uintptr_t x, u_i u_int realexslp; int queue; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) goto out; tid = (uintptr_t)curthread; @@ -1126,7 +1126,7 @@ lockmgr_unlock_fast_path(struct lock *lk, u_int flags, const char *file; int line; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) return (0); file = __FILE__; @@ -1254,7 +1254,7 @@ __lockmgr_args(struct lock *lk, u_int flags, struct lo int contested = 0; #endif - if (panicstr != NULL) + if (KERNEL_PANICKED()) return (0); error = 0; @@ -1662,7 +1662,7 @@ _lockmgr_assert(const struct lock *lk, int what, const { int slocked = 0; - if (panicstr != NULL) + if (KERNEL_PANICKED()) return; switch (what) { case KA_SLOCKED: Modified: head/sys/kern/kern_mutex.c ============================================================================== --- head/sys/kern/kern_mutex.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/kern_mutex.c Sun Jan 12 06:07:54 2020 (r356655) @@ -1071,7 +1071,7 @@ __mtx_assert(const volatile uintptr_t *c, int what, co { const struct mtx *m; - if (panicstr != NULL || dumping || SCHEDULER_STOPPED()) + if (KERNEL_PANICKED() || dumping || SCHEDULER_STOPPED()) return; m = mtxlock2mtx(c); @@ -1229,7 +1229,7 @@ _mtx_lock_indefinite_check(struct mtx *m, struct lock_ struct thread *td; ldap->spin_cnt++; - if (ldap->spin_cnt < 60000000 || kdb_active || panicstr != NULL) + if (ldap->spin_cnt < 60000000 || kdb_active || KERNEL_PANICKED()) cpu_lock_delay(); else { td = mtx_owner(m); Modified: head/sys/kern/kern_switch.c ============================================================================== --- head/sys/kern/kern_switch.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/kern_switch.c Sun Jan 12 06:07:54 2020 (r356655) @@ -181,7 +181,7 @@ choosethread(void) td = sched_choose(); - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) return (choosethread_panic(td)); TD_SET_RUNNING(td); Modified: head/sys/kern/kern_synch.c ============================================================================== --- head/sys/kern/kern_synch.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/kern_synch.c Sun Jan 12 06:07:54 2020 (r356655) @@ -480,8 +480,8 @@ mi_switch(int flags) if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td)) mtx_assert(&Giant, MA_NOTOWNED); #endif - KASSERT(td->td_critnest == 1 || panicstr, - ("mi_switch: switch in a critical section")); + KASSERT(td->td_critnest == 1 || KERNEL_PANICKED(), + ("mi_switch: switch in a critical section")); KASSERT((flags & (SW_INVOL | SW_VOL)) != 0, ("mi_switch: switch must be voluntary or involuntary")); Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/sched_4bsd.c Sun Jan 12 06:07:54 2020 (r356655) @@ -348,7 +348,7 @@ maybe_preempt(struct thread *td) ("maybe_preempt: trying to run inhibited thread")); pri = td->td_priority; cpri = ctd->td_priority; - if (panicstr != NULL || pri >= cpri /* || dumping */ || + if (KERNEL_PANICKED() || pri >= cpri /* || dumping */ || TD_IS_INHIBITED(ctd)) return (0); #ifndef FULL_PREEMPTION @@ -1138,7 +1138,7 @@ forward_wakeup(int cpunum) if ((!forward_wakeup_enabled) || (forward_wakeup_use_mask == 0 && forward_wakeup_use_loop == 0)) return (0); - if (!smp_started || panicstr) + if (!smp_started || KERNEL_PANICKED()) return (0); forward_wakeups_requested++; Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/sched_ule.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2533,7 +2533,7 @@ sched_setpreempt(struct thread *td) cpri = ctd->td_priority; if (pri < cpri) ctd->td_flags |= TDF_NEEDRESCHED; - if (panicstr != NULL || pri >= cpri || cold || TD_IS_INHIBITED(ctd)) + if (KERNEL_PANICKED() || pri >= cpri || cold || TD_IS_INHIBITED(ctd)) return; if (!sched_shouldpreempt(pri, cpri, 0)) return; Modified: head/sys/kern/subr_csan.c ============================================================================== --- head/sys/kern/subr_csan.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/subr_csan.c Sun Jan 12 06:07:54 2020 (r356655) @@ -153,7 +153,7 @@ kcsan_access(uintptr_t addr, size_t size, bool write, return; if (__predict_false(kcsan_md_unsupported((vm_offset_t)addr))) return; - if (__predict_false(panicstr != NULL)) + if (KERNEL_PANICKED()) return; new.addr = addr; Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/subr_prf.c Sun Jan 12 06:07:54 2020 (r356655) @@ -409,7 +409,7 @@ vprintf(const char *fmt, va_list ap) retval = _vprintf(-1, TOCONS | TOLOG, fmt, ap); - if (!panicstr) + if (!KERNEL_PANICKED()) msgbuftrigger = 1; return (retval); @@ -423,7 +423,7 @@ prf_putbuf(char *bufr, int flags, int pri) msglogstr(bufr, pri, /*filter_cr*/1); if (flags & TOCONS) { - if ((panicstr == NULL) && (constty != NULL)) + if ((!KERNEL_PANICKED()) && (constty != NULL)) msgbuf_addstr(&consmsgbuf, -1, bufr, /*filter_cr*/ 0); @@ -492,7 +492,7 @@ putchar(int c, void *arg) return; } - if ((flags & TOTTY) && tp != NULL && panicstr == NULL) + if ((flags & TOTTY) && tp != NULL && !KERNEL_PANICKED()) tty_putchar(tp, c); if ((flags & (TOCONS | TOLOG)) && c != '\0') Modified: head/sys/kern/subr_smp.c ============================================================================== --- head/sys/kern/subr_smp.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/subr_smp.c Sun Jan 12 06:07:54 2020 (r356655) @@ -195,7 +195,7 @@ forward_signal(struct thread *td) CTR1(KTR_SMP, "forward_signal(%p)", td->td_proc); - if (!smp_started || cold || panicstr) + if (!smp_started || cold || KERNEL_PANICKED()) return; if (!forward_signal_enabled) return; Modified: head/sys/kern/subr_witness.c ============================================================================== --- head/sys/kern/subr_witness.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/subr_witness.c Sun Jan 12 06:07:54 2020 (r356655) @@ -899,7 +899,7 @@ witness_init(struct lock_object *lock, const char *typ * it to the pending_locks list. If it is not too early, then enroll * the lock now. */ - if (witness_watch < 1 || panicstr != NULL || + if (witness_watch < 1 || KERNEL_PANICKED() || (lock->lo_flags & LO_WITNESS) == 0) lock->lo_witness = NULL; else if (witness_cold) { @@ -1077,7 +1077,7 @@ int witness_defineorder(struct lock_object *lock1, struct lock_object *lock2) { - if (witness_watch == -1 || panicstr != NULL) + if (witness_watch == -1 || KERNEL_PANICKED()) return (0); /* Require locks that witness knows about. */ @@ -1118,7 +1118,7 @@ witness_checkorder(struct lock_object *lock, int flags int i, j; if (witness_cold || witness_watch < 1 || lock->lo_witness == NULL || - panicstr != NULL) + KERNEL_PANICKED()) return; w = lock->lo_witness; @@ -1464,7 +1464,7 @@ witness_lock(struct lock_object *lock, int flags, cons struct thread *td; if (witness_cold || witness_watch == -1 || lock->lo_witness == NULL || - panicstr != NULL) + KERNEL_PANICKED()) return; w = lock->lo_witness; td = curthread; @@ -1522,7 +1522,7 @@ witness_upgrade(struct lock_object *lock, int flags, c struct lock_class *class; KASSERT(witness_cold == 0, ("%s: witness_cold", __func__)); - if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch == -1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if (witness_watch) { @@ -1568,7 +1568,7 @@ witness_downgrade(struct lock_object *lock, int flags, struct lock_class *class; KASSERT(witness_cold == 0, ("%s: witness_cold", __func__)); - if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch == -1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if (witness_watch) { @@ -1616,7 +1616,7 @@ witness_unlock(struct lock_object *lock, int flags, co register_t s; int i, j; - if (witness_cold || lock->lo_witness == NULL || panicstr != NULL) + if (witness_cold || lock->lo_witness == NULL || KERNEL_PANICKED()) return; td = curthread; class = LOCK_CLASS(lock); @@ -1722,7 +1722,7 @@ witness_thread_exit(struct thread *td) int i, n; lle = td->td_sleeplocks; - if (lle == NULL || panicstr != NULL) + if (lle == NULL || KERNEL_PANICKED()) return; if (lle->ll_count != 0) { for (n = 0; lle != NULL; lle = lle->ll_next) @@ -1757,7 +1757,7 @@ witness_warn(int flags, struct lock_object *lock, cons va_list ap; int i, n; - if (witness_cold || witness_watch < 1 || panicstr != NULL) + if (witness_cold || witness_watch < 1 || KERNEL_PANICKED()) return (0); n = 0; td = curthread; @@ -1849,7 +1849,7 @@ enroll(const char *description, struct lock_class *loc MPASS(description != NULL); - if (witness_watch == -1 || panicstr != NULL) + if (witness_watch == -1 || KERNEL_PANICKED()) return (NULL); if ((lock_class->lc_flags & LC_SPINLOCK)) { if (witness_skipspin) @@ -2323,7 +2323,7 @@ witness_save(struct lock_object *lock, const char **fi if (SCHEDULER_STOPPED()) return; KASSERT(witness_cold == 0, ("%s: witness_cold", __func__)); - if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch == -1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if (class->lc_flags & LC_SLEEPLOCK) @@ -2358,7 +2358,7 @@ witness_restore(struct lock_object *lock, const char * if (SCHEDULER_STOPPED()) return; KASSERT(witness_cold == 0, ("%s: witness_cold", __func__)); - if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch == -1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if (class->lc_flags & LC_SLEEPLOCK) @@ -2388,7 +2388,7 @@ witness_assert(const struct lock_object *lock, int fla struct lock_instance *instance; struct lock_class *class; - if (lock->lo_witness == NULL || witness_watch < 1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch < 1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if ((class->lc_flags & LC_SLEEPLOCK) != 0) @@ -2460,7 +2460,7 @@ witness_setflag(struct lock_object *lock, int flag, in struct lock_instance *instance; struct lock_class *class; - if (lock->lo_witness == NULL || witness_watch == -1 || panicstr != NULL) + if (lock->lo_witness == NULL || witness_watch == -1 || KERNEL_PANICKED()) return; class = LOCK_CLASS(lock); if (class->lc_flags & LC_SLEEPLOCK) Modified: head/sys/kern/tty_info.c ============================================================================== --- head/sys/kern/tty_info.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/tty_info.c Sun Jan 12 06:07:54 2020 (r356655) @@ -229,7 +229,7 @@ sbuf_tty_drain(void *a, const char *d, int len) cnputsn(d, len); return (len); } - if (tp != NULL && panicstr == NULL) { + if (tp != NULL && !KERNEL_PANICKED()) { rc = tty_putstrn(tp, d, len); if (rc != 0) return (-ENXIO); Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/vfs_bio.c Sun Jan 12 06:07:54 2020 (r356655) @@ -1431,7 +1431,7 @@ bufshutdown(int show_busybufs) /* * Unmount filesystems */ - if (panicstr == NULL) + if (!KERNEL_PANICKED()) vfs_unmountall(); } swapoff_all(); Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/kern/vfs_subr.c Sun Jan 12 06:07:54 2020 (r356655) @@ -5023,7 +5023,7 @@ extattr_check_cred(struct vnode *vp, int attrnamespace * This only exists to suppress warnings from unlocked specfs accesses. It is * no longer ok to have an unlocked VFS. */ -#define IGNORE_LOCK(vp) (panicstr != NULL || (vp) == NULL || \ +#define IGNORE_LOCK(vp) (KERNEL_PANICKED() || (vp) == NULL || \ (vp)->v_type == VCHR || (vp)->v_type == VBAD) int vfs_badlock_ddb = 1; /* Drop into debugger on violation. */ @@ -5172,7 +5172,7 @@ vop_strategy_pre(void *ap) if ((bp->b_flags & B_CLUSTER) != 0) return; - if (panicstr == NULL && !BUF_ISLOCKED(bp)) { + if (!KERNEL_PANICKED() && !BUF_ISLOCKED(bp)) { if (vfs_badlock_print) printf( "VOP_STRATEGY: bp is not locked but should be\n"); Modified: head/sys/netinet/netdump/netdump_client.c ============================================================================== --- head/sys/netinet/netdump/netdump_client.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/netinet/netdump/netdump_client.c Sun Jan 12 06:07:54 2020 (r356655) @@ -293,7 +293,7 @@ netdump_start(struct dumperinfo *di) if (!netdump_enabled()) return (EINVAL); - if (panicstr == NULL) { + if (!KERNEL_PANICKED()) { printf( "netdump_start: netdump may only be used after a panic\n"); return (EINVAL); Modified: head/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/mp_machdep.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/sparc64/sparc64/mp_machdep.c Sun Jan 12 06:07:54 2020 (r356655) @@ -611,7 +611,7 @@ spitfire_ipi_single(u_int cpu, u_long d0, u_long d1, u if ((ids & (IDR_BUSY | IDR_NACK)) == 0) return; } - if (kdb_active != 0 || panicstr != NULL) + if (kdb_active != 0 || KERNEL_PANICKED()) printf("%s: couldn't send IPI to module 0x%u\n", __func__, mid); else @@ -650,7 +650,7 @@ cheetah_ipi_single(u_int cpu, u_long d0, u_long d1, u_ if ((ids & (IDR_BUSY | IDR_NACK)) == 0) return; } - if (kdb_active != 0 || panicstr != NULL) + if (kdb_active != 0 || KERNEL_PANICKED()) printf("%s: couldn't send IPI to module 0x%u\n", __func__, mid); else @@ -709,7 +709,7 @@ cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long if (CPU_EMPTY(&cpus)) return; } - if (kdb_active != 0 || panicstr != NULL) + if (kdb_active != 0 || KERNEL_PANICKED()) printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); else @@ -750,7 +750,7 @@ jalapeno_ipi_single(u_int cpu, u_long d0, u_long d1, u if ((ids & busynack) == 0) return; } - if (kdb_active != 0 || panicstr != NULL) + if (kdb_active != 0 || KERNEL_PANICKED()) printf("%s: couldn't send IPI to module 0x%u\n", __func__, mid); else @@ -801,7 +801,7 @@ jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long (2 * cpuid_to_mid[cpu]))) == 0) CPU_CLR(cpu, &cpus); } - if (kdb_active != 0 || panicstr != NULL) + if (kdb_active != 0 || KERNEL_PANICKED()) printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", __func__, cpusetobj_strprint(ipi_pbuf, &cpus), ids); else Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/sys/systm.h Sun Jan 12 06:07:54 2020 (r356655) @@ -53,6 +53,7 @@ extern int cold; /* nonzero if we are doing a cold bo extern int suspend_blocked; /* block suspend due to pending shutdown */ extern int rebooting; /* kern_reboot() has been called. */ extern const char *panicstr; /* panic message */ +#define KERNEL_PANICKED() __predict_false(panicstr != NULL) extern char version[]; /* system version */ extern char compiler_version[]; /* compiler version */ extern char copyright[]; /* system copyright */ Modified: head/sys/x86/x86/local_apic.c ============================================================================== --- head/sys/x86/x86/local_apic.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/x86/x86/local_apic.c Sun Jan 12 06:07:54 2020 (r356655) @@ -2076,7 +2076,7 @@ native_lapic_ipi_vectored(u_int vector, int dest) /* Wait for an earlier IPI to finish. */ if (!lapic_ipi_wait(BEFORE_SPIN)) { - if (panicstr != NULL) + if (KERNEL_PANICKED()) return; else panic("APIC: Previous IPI is stuck"); Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Sun Jan 12 05:25:06 2020 (r356654) +++ head/sys/x86/x86/mp_x86.c Sun Jan 12 06:07:54 2020 (r356655) @@ -1459,7 +1459,7 @@ cpustop_handler(void) * again, and might as well save power / release resources * (e.g., overprovisioned VM infrastructure). */ - while (__predict_false(!IS_BSP() && panicstr != NULL)) + while (__predict_false(!IS_BSP() && KERNEL_PANICKED())) halt(); } @@ -1672,7 +1672,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector int cpu; /* It is not necessary to signal other CPUs while in the debugger. */ - if (kdb_active || panicstr != NULL) + if (kdb_active || KERNEL_PANICKED()) return; /* From owner-svn-src-all@freebsd.org Sun Jan 12 06:09:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D15AF2254B9; Sun, 12 Jan 2020 06:09:10 +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 47wRBG4vShz424w; Sun, 12 Jan 2020 06:09:10 +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 A3887F49D; Sun, 12 Jan 2020 06:09:10 +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 00C69AW6050820; Sun, 12 Jan 2020 06:09:10 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C69Anp050819; Sun, 12 Jan 2020 06:09:10 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001120609.00C69Anp050819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 Jan 2020 06:09:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356656 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 356656 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 06:09:10 -0000 Author: mjg Date: Sun Jan 12 06:09:10 2020 New Revision: 356656 URL: https://svnweb.freebsd.org/changeset/base/356656 Log: Add "panicked" boolean which can be tested instead of panicstr The test is performed all the time and reading entire panicstr to do it wastes space. Modified: head/sys/kern/kern_shutdown.c head/sys/sys/systm.h Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Sun Jan 12 06:07:54 2020 (r356655) +++ head/sys/kern/kern_shutdown.c Sun Jan 12 06:09:10 2020 (r356656) @@ -217,7 +217,8 @@ SYSCTL_INT(_kern, OID_AUTO, kerneldump_gzlevel, CTLFLA * Variable panicstr contains argument to first call to panic; used as flag * to indicate that the kernel has already called panic. */ -const char __read_mostly *panicstr; +const char *panicstr; +bool __read_frequently panicked; int __read_mostly dumping; /* system is dumping */ int rebooting; /* system is rebooting */ @@ -873,6 +874,7 @@ vpanic(const char *fmt, va_list ap) else { bootopt |= RB_DUMP; panicstr = fmt; + panicked = true; newpanic = 1; } Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sun Jan 12 06:07:54 2020 (r356655) +++ head/sys/sys/systm.h Sun Jan 12 06:09:10 2020 (r356656) @@ -53,7 +53,8 @@ extern int cold; /* nonzero if we are doing a cold bo extern int suspend_blocked; /* block suspend due to pending shutdown */ extern int rebooting; /* kern_reboot() has been called. */ extern const char *panicstr; /* panic message */ -#define KERNEL_PANICKED() __predict_false(panicstr != NULL) +extern bool panicked; +#define KERNEL_PANICKED() __predict_false(panicked) extern char version[]; /* system version */ extern char compiler_version[]; /* compiler version */ extern char copyright[]; /* system copyright */ From owner-svn-src-all@freebsd.org Sun Jan 12 06:13:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E848E2257B8; Sun, 12 Jan 2020 06:13:52 +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 47wRHh5s3Yz42Y5; Sun, 12 Jan 2020 06:13:52 +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 AA6C0F65F; Sun, 12 Jan 2020 06:13:52 +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 00C6Dq7p056531; Sun, 12 Jan 2020 06:13:52 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C6DqZV056530; Sun, 12 Jan 2020 06:13:52 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <202001120613.00C6DqZV056530@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 12 Jan 2020 06:13:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356657 - 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: 356657 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 06:13:53 -0000 Author: delphij Date: Sun Jan 12 06:13:52 2020 New Revision: 356657 URL: https://svnweb.freebsd.org/changeset/base/356657 Log: Tighten FAT checks and fix off-by-one error in corner case. sbin/fsck_msdosfs/fat.c: - readfat: * Only truncate out-of-range cluster pointers (1, or greater than NumClusters but smaller than CLUST_RSRVD), as the current cluster may contain some data. We can't fix reserved cluster pointers at this pass, because we do no know the potential cluster preceding it. * Accept valid cluster for head bitmap. This is a no-op, and mainly to improve code readability, because the 1 is already handled in the previous else if block. - truncate_at: absorbed into checkchain. - checkchain: save the previous node we have traversed in case that we have a chain that ends with a special (>= CLUST_RSRVD) cluster, or is free. In these cases, we need to truncate at the cluster preceding the current cluster, as the current cluster contains a marker instead of a next pointer and can not be changed to CLUST_EOF (the else case can happen if the user answered "no" at some point in readfat()). - clearchain: correct the iterator for next cluster so that we don't stop after clearing the first cluster. - checklost: If checkchain() thinks the chain have no cluster, it doesn't make sense to reconnect it, so don't bother asking. Reviewed by: kevlo MFC after: 24 days X-MFC-With: r356313 Differential Revision: https://reviews.freebsd.org/D23065 Modified: head/sbin/fsck_msdosfs/fat.c Modified: head/sbin/fsck_msdosfs/fat.c ============================================================================== --- head/sbin/fsck_msdosfs/fat.c Sun Jan 12 06:09:10 2020 (r356656) +++ head/sbin/fsck_msdosfs/fat.c Sun Jan 12 06:13:52 2020 (r356657) @@ -935,17 +935,16 @@ readfat(int fs, struct bootblock *boot, struct fat_des fat_clear_cl_head(fat, cl); } boot->NumBad++; - } else if (!valid_cl(fat, nextcl) && nextcl < CLUST_EOFS) { - pwarn("Cluster %u continues with %s " + } else if (!valid_cl(fat, nextcl) && nextcl < CLUST_RSRVD) { + pwarn("Cluster %u continues with out of range " "cluster number %u\n", - cl, (nextcl < CLUST_RSRVD) ? - "out of range" : "reserved", + cl, nextcl & boot->ClustMask); if (ask(0, "Truncate")) { ret |= fat_set_cl_next(fat, cl, CLUST_EOF); ret |= FSFATMOD; } - } else if (nextcl < boot->NumClusters) { + } else if (valid_cl(fat, nextcl)) { if (fat_is_cl_head(fat, nextcl)) { fat_clear_cl_head(fat, nextcl); } else { @@ -985,29 +984,13 @@ rsrvdcltype(cl_t cl) } /* - * Offer to truncate a chain at the specified CL, called by checkchain(). - */ -static inline int -truncate_at(struct fat_descriptor *fat, cl_t current_cl, size_t *chainsize) -{ - int ret = 0; - - if (ask(0, "Truncate")) { - ret = fat_set_cl_next(fat, current_cl, CLUST_EOF); - (*chainsize)++; - return (ret | FSFATMOD); - } else { - return FSERROR; - } -} - -/* * Examine a cluster chain for errors and count its size. */ int checkchain(struct fat_descriptor *fat, cl_t head, size_t *chainsize) { - cl_t current_cl, next_cl; + cl_t prev_cl, current_cl, next_cl; + const char *op; /* * We expect that the caller to give us a real, unvisited 'head' @@ -1038,10 +1021,10 @@ checkchain(struct fat_descriptor *fat, cl_t head, size * it as EOF) when the next node violates that. */ *chainsize = 0; - current_cl = head; + prev_cl = current_cl = head; for (next_cl = fat_get_cl_next(fat, current_cl); valid_cl(fat, next_cl); - current_cl = next_cl, next_cl = fat_get_cl_next(fat, current_cl)) + prev_cl = current_cl, current_cl = next_cl, next_cl = fat_get_cl_next(fat, current_cl)) (*chainsize)++; /* A natural end */ @@ -1050,12 +1033,40 @@ checkchain(struct fat_descriptor *fat, cl_t head, size return FSOK; } - /* The chain ended with an out-of-range cluster number. */ - pwarn("Cluster %u continues with %s cluster number %u\n", - current_cl, - next_cl < CLUST_RSRVD ? "out of range" : "reserved", - next_cl & boot_of_(fat)->ClustMask); - return (truncate_at(fat, current_cl, chainsize)); + /* + * The chain ended with an out-of-range cluster number. + * + * If the current node is e.g. CLUST_FREE, CLUST_BAD, etc., + * it should not be present in a chain and we has to truncate + * at the previous node. + * + * If the current cluster points to an invalid cluster, the + * current cluster might have useful data and we truncate at + * the current cluster instead. + */ + if (next_cl == CLUST_FREE || next_cl >= CLUST_RSRVD) { + pwarn("Cluster chain starting at %u ends with cluster marked %s\n", + head, rsrvdcltype(next_cl)); + current_cl = prev_cl; + } else { + pwarn("Cluster chain starting at %u ends with cluster out of range (%u)\n", + head, + next_cl & boot_of_(fat)->ClustMask); + (*chainsize)++; + } + + if (*chainsize > 0) { + op = "Truncate"; + next_cl = CLUST_EOF; + } else { + op = "Clear"; + next_cl = CLUST_FREE; + } + if (ask(0, "%s", op)) { + return (fat_set_cl_next(fat, current_cl, next_cl) | FSFATMOD); + } else { + return (FSERROR); + } } /* @@ -1070,7 +1081,7 @@ clearchain(struct fat_descriptor *fat, cl_t head) current_cl = head; while (valid_cl(fat, current_cl)) { - next_cl = fat_get_cl_next(fat, head); + next_cl = fat_get_cl_next(fat, current_cl); (void)fat_set_cl_next(fat, current_cl, CLUST_FREE); boot->NumFree++; current_cl = next_cl; @@ -1218,7 +1229,7 @@ checklost(struct fat_descriptor *fat) } if (fat_is_cl_head(fat, head)) { ret = checkchain(fat, head, &chainlength); - if (ret != FSERROR) { + if (ret != FSERROR && chainlength > 0) { pwarn("Lost cluster chain at cluster %u\n" "%zd Cluster(s) lost\n", head, chainlength); From owner-svn-src-all@freebsd.org Sun Jan 12 09:00:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D53ED22982A; Sun, 12 Jan 2020 09:00:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47wVzs42YKz49hj; Sun, 12 Jan 2020 09:00:25 +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 00C90Adm029140 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 12 Jan 2020 11:00:13 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 00C90Adm029140 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 00C90Apm029138; Sun, 12 Jan 2020 11:00:10 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 12 Jan 2020 11:00:10 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r356656 - in head/sys: kern sys Message-ID: <20200112090010.GA2068@kib.kiev.ua> References: <202001120609.00C69Anp050819@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202001120609.00C69Anp050819@repo.freebsd.org> 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.3 X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on tom.home X-Rspamd-Queue-Id: 47wVzs42YKz49hj X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 09:00:25 -0000 On Sun, Jan 12, 2020 at 06:09:10AM +0000, Mateusz Guzik wrote: > Author: mjg > Date: Sun Jan 12 06:09:10 2020 > New Revision: 356656 > URL: https://svnweb.freebsd.org/changeset/base/356656 > > Log: > Add "panicked" boolean which can be tested instead of panicstr > > The test is performed all the time and reading entire panicstr to do it > wastes space. What space does it waste ? The space in the read-mostly section ? And what is the difference between reading a pointer vs. reading a byte ? CPU still has to read the whole cache line. > > Modified: > head/sys/kern/kern_shutdown.c > head/sys/sys/systm.h > > Modified: head/sys/kern/kern_shutdown.c > ============================================================================== > --- head/sys/kern/kern_shutdown.c Sun Jan 12 06:07:54 2020 (r356655) > +++ head/sys/kern/kern_shutdown.c Sun Jan 12 06:09:10 2020 (r356656) > @@ -217,7 +217,8 @@ SYSCTL_INT(_kern, OID_AUTO, kerneldump_gzlevel, CTLFLA > * Variable panicstr contains argument to first call to panic; used as flag > * to indicate that the kernel has already called panic. > */ > -const char __read_mostly *panicstr; > +const char *panicstr; > +bool __read_frequently panicked; > > int __read_mostly dumping; /* system is dumping */ > int rebooting; /* system is rebooting */ > @@ -873,6 +874,7 @@ vpanic(const char *fmt, va_list ap) > else { > bootopt |= RB_DUMP; > panicstr = fmt; > + panicked = true; > newpanic = 1; > } > > > Modified: head/sys/sys/systm.h > ============================================================================== > --- head/sys/sys/systm.h Sun Jan 12 06:07:54 2020 (r356655) > +++ head/sys/sys/systm.h Sun Jan 12 06:09:10 2020 (r356656) > @@ -53,7 +53,8 @@ extern int cold; /* nonzero if we are doing a cold bo > extern int suspend_blocked; /* block suspend due to pending shutdown */ > extern int rebooting; /* kern_reboot() has been called. */ > extern const char *panicstr; /* panic message */ > -#define KERNEL_PANICKED() __predict_false(panicstr != NULL) > +extern bool panicked; > +#define KERNEL_PANICKED() __predict_false(panicked) > extern char version[]; /* system version */ > extern char compiler_version[]; /* compiler version */ > extern char copyright[]; /* system copyright */ From owner-svn-src-all@freebsd.org Sun Jan 12 10:08:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE29322AE03; Sun, 12 Jan 2020 10:08:06 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47wXTx53lDz4Dh9; Sun, 12 Jan 2020 10:08:05 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x444.google.com with SMTP id t2so5724859wrr.1; Sun, 12 Jan 2020 02:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vVXKTqaxSvUUWAAucGeuGjBLFpd2unbzwMpp00Opc7o=; b=fB8OKZcthpoz6VG+ghT28+4RIWsF/MrWoAh2oEAtsps4kaToyF3jv6shMcT4XUeOZF DXEInYAMuqhbB3JIeK89CiObRH7nAs+KNU8nFTrVCGAs71i3XIfkORIET7ouYuMW3M7F V+hpIjIL35HsrBMIV10xo+Sf1L7B4OBtYNijbb1Yqqu/PKHXKAkY+kU0efZi8TeYynIn w57XrKh3v8pREMoAUIGSPsWJZy9gNsTddZx4fLmSrDRVTgDOPzwG8n5hDbgZ9VsGHwCq 5tWXrABDpx+x1i4n6Gx95uXPr5rHsA7/HuyrqyKGzHKh6DSPtEAA7wm+HWt+xevgE8GQ JlPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vVXKTqaxSvUUWAAucGeuGjBLFpd2unbzwMpp00Opc7o=; b=YEpoQ49ECvJBQ5JqzkJJYokcwqxBPe3qePvTDWvR7B3zsEL9wAy99WrceBnL1xA8uH Rt3pYtjQ/59T+JvLFuiXDoQayCZ6MxJEjh/x4pwb0IKLU2Rcyxod7Xv+Zg3cBaS3KMr1 3VKevZoqvYHL3Q85TIP/XiHbPBAgnpPuNvLT+NRioP0lsK4Y+tz1BMP65zmtkqcdTXgc qCfvZ6+KV5lCknZk6JKfrHiSXwV/0rZmfuTvs7BCqF5FJyrvUD3ZfL75S2Mq43wgQ1nH YAgu8Vz3hjvdH4arxKZTMU2EgE5J9mrnnuZnZArW2/nnkAG5LfUTO9AIVmLZ5o9Umwpp IKrg== X-Gm-Message-State: APjAAAVtGuJgfD7FLLLC8zg9EcftK958Ky3sEOqIcBrgj8uz1iXcHzDH Ucbe7GvsNcScUTIA60vidIYkXzLJd4PNFuAqqP4= X-Google-Smtp-Source: APXvYqwhdWBo0lv8pyS0n1o0ZtbjDC3EPW4O0Nl6MRgkHCdF+wu/8ogrbtNUoeUHgSlkZxLTKvmC57LQIHk0AA0IfhM= X-Received: by 2002:a5d:4d8d:: with SMTP id b13mr13467957wru.6.1578823684259; Sun, 12 Jan 2020 02:08:04 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:6b02:0:0:0:0:0 with HTTP; Sun, 12 Jan 2020 02:08:02 -0800 (PST) In-Reply-To: <20200112090010.GA2068@kib.kiev.ua> References: <202001120609.00C69Anp050819@repo.freebsd.org> <20200112090010.GA2068@kib.kiev.ua> From: Mateusz Guzik Date: Sun, 12 Jan 2020 11:08:02 +0100 Message-ID: Subject: Re: svn commit: r356656 - in head/sys: kern sys To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 47wXTx53lDz4Dh9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=fB8OKZct; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::444 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.00)[ip: (2.70), ipnet: 2a00:1450::/32(-2.60), asn: 15169(-1.84), country: US(-0.05)]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[4.4.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 10:08:06 -0000 On 1/12/20, Konstantin Belousov wrote: > On Sun, Jan 12, 2020 at 06:09:10AM +0000, Mateusz Guzik wrote: >> Author: mjg >> Date: Sun Jan 12 06:09:10 2020 >> New Revision: 356656 >> URL: https://svnweb.freebsd.org/changeset/base/356656 >> >> Log: >> Add "panicked" boolean which can be tested instead of panicstr >> >> The test is performed all the time and reading entire panicstr to do it >> wastes space. > What space does it waste ? The space in the read-mostly section ? > > And what is the difference between reading a pointer vs. reading a byte ? > CPU still has to read the whole cache line. > Note the annotation with __read_frequently which groups fields. Currently it results in the following (with tail filled up from __read_mostly): ---------------- ffffffff80c01000 D hc_source_mask ffffffff80c01004 D pti ffffffff80c01008 D locks_delay ffffffff80c0100c D locks_delay_retries ffffffff80c0100e D locks_delay_loops ffffffff80c01010 d fortuna_concurrent_read ffffffff80c01011 D random_chachamode ffffffff80c01012 D systrace_enabled ffffffff80c01013 D lockstat_enabled ffffffff80c01014 D dtrace_malloc_enabled ffffffff80c01015 D racct_enable ffffffff80c01016 D sdt_probes_enabled ffffffff80c01017 D panicked ffffffff80c01018 D kdb_active ffffffff80c01019 D trap_enotcap ffffffff80c0101a D audit_syscalls_enabled ffffffff80c01020 D cam_dflags ffffffff80c01028 d epoch_inited ffffffff80c01030 d rs_epoch ffffffff80c01038 d biozone ---------------- Should panicstr land here it would avoidably take up 8 bytes instead of 1. -- Mateusz Guzik From owner-svn-src-all@freebsd.org Sun Jan 12 13:38:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34B4B22F6C5; Sun, 12 Jan 2020 13:38:52 +0000 (UTC) (envelope-from trasz@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 47wd980RVZz4P0G; Sun, 12 Jan 2020 13:38:52 +0000 (UTC) (envelope-from trasz@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 0A4DB1C6AB; Sun, 12 Jan 2020 13:38:52 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CDcpaX021055; Sun, 12 Jan 2020 13:38:51 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CDcpwG021053; Sun, 12 Jan 2020 13:38:51 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202001121338.00CDcpwG021053@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 12 Jan 2020 13:38:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356658 - in head/sys: compat/linux kern sys X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: in head/sys: compat/linux kern sys X-SVN-Commit-Revision: 356658 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 13:38:52 -0000 Author: trasz Date: Sun Jan 12 13:38:51 2020 New Revision: 356658 URL: https://svnweb.freebsd.org/changeset/base/356658 Log: Add kern_setpriority(), use it in Linuxulator. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22841 Modified: head/sys/compat/linux/linux_misc.c head/sys/kern/kern_resource.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Sun Jan 12 06:13:52 2020 (r356657) +++ head/sys/compat/linux/linux_misc.c Sun Jan 12 13:38:51 2020 (r356658) @@ -1207,12 +1207,8 @@ linux_getitimer(struct thread *td, struct linux_getiti int linux_nice(struct thread *td, struct linux_nice_args *args) { - struct setpriority_args bsd_args; - bsd_args.which = PRIO_PROCESS; - bsd_args.who = 0; /* current process */ - bsd_args.prio = args->inc; - return (sys_setpriority(td, &bsd_args)); + return (kern_setpriority(td, PRIO_PROCESS, 0, args->inc)); } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ Modified: head/sys/kern/kern_resource.c ============================================================================== --- head/sys/kern/kern_resource.c Sun Jan 12 06:13:52 2020 (r356657) +++ head/sys/kern/kern_resource.c Sun Jan 12 13:38:51 2020 (r356658) @@ -175,24 +175,31 @@ struct setpriority_args { int sys_setpriority(struct thread *td, struct setpriority_args *uap) { + + return (kern_setpriority(td, uap->which, uap->who, uap->prio)); +} + +int +kern_setpriority(struct thread *td, int which, int who, int prio) +{ struct proc *curp, *p; struct pgrp *pg; int found = 0, error = 0; curp = td->td_proc; - switch (uap->which) { + switch (which) { case PRIO_PROCESS: - if (uap->who == 0) { + if (who == 0) { PROC_LOCK(curp); - error = donice(td, curp, uap->prio); + error = donice(td, curp, prio); PROC_UNLOCK(curp); } else { - p = pfind(uap->who); + p = pfind(who); if (p == NULL) break; error = p_cansee(td, p); if (error == 0) - error = donice(td, p, uap->prio); + error = donice(td, p, prio); PROC_UNLOCK(p); } found++; @@ -200,11 +207,11 @@ sys_setpriority(struct thread *td, struct setpriority_ case PRIO_PGRP: sx_slock(&proctree_lock); - if (uap->who == 0) { + if (who == 0) { pg = curp->p_pgrp; PGRP_LOCK(pg); } else { - pg = pgfind(uap->who); + pg = pgfind(who); if (pg == NULL) { sx_sunlock(&proctree_lock); break; @@ -215,7 +222,7 @@ sys_setpriority(struct thread *td, struct setpriority_ PROC_LOCK(p); if (p->p_state == PRS_NORMAL && p_cansee(td, p) == 0) { - error = donice(td, p, uap->prio); + error = donice(td, p, prio); found++; } PROC_UNLOCK(p); @@ -224,15 +231,15 @@ sys_setpriority(struct thread *td, struct setpriority_ break; case PRIO_USER: - if (uap->who == 0) - uap->who = td->td_ucred->cr_uid; + if (who == 0) + who = td->td_ucred->cr_uid; sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); if (p->p_state == PRS_NORMAL && - p->p_ucred->cr_uid == uap->who && + p->p_ucred->cr_uid == who && p_cansee(td, p) == 0) { - error = donice(td, p, uap->prio); + error = donice(td, p, prio); found++; } PROC_UNLOCK(p); Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Sun Jan 12 06:13:52 2020 (r356657) +++ head/sys/sys/syscallsubr.h Sun Jan 12 13:38:51 2020 (r356658) @@ -251,6 +251,7 @@ int kern_sendit(struct thread *td, int s, struct msghd int kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups); int kern_setitimer(struct thread *, u_int, struct itimerval *, struct itimerval *); +int kern_setpriority(struct thread *td, int which, int who, int prio); int kern_setrlimit(struct thread *, u_int, struct rlimit *); int kern_setsockopt(struct thread *td, int s, int level, int name, const void *optval, enum uio_seg valseg, socklen_t valsize); From owner-svn-src-all@freebsd.org Sun Jan 12 14:25:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 71C231D86C1; Sun, 12 Jan 2020 14:25:45 +0000 (UTC) (envelope-from trasz@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 47wfCF2Lmnz4Qrm; Sun, 12 Jan 2020 14:25:45 +0000 (UTC) (envelope-from trasz@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 479F21CFAD; Sun, 12 Jan 2020 14:25:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CEPjqG050052; Sun, 12 Jan 2020 14:25:45 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CEPijO050048; Sun, 12 Jan 2020 14:25:44 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202001121425.00CEPijO050048@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 12 Jan 2020 14:25:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356659 - in head/sys: compat/linux kern sys X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: in head/sys: compat/linux kern sys X-SVN-Commit-Revision: 356659 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 14:25:45 -0000 Author: trasz Date: Sun Jan 12 14:25:44 2020 New Revision: 356659 URL: https://svnweb.freebsd.org/changeset/base/356659 Log: dd kern_getpriority(), make Linuxulator use it. Reviewed by: kib, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22842 Modified: head/sys/compat/linux/linux_misc.c head/sys/kern/kern_resource.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Sun Jan 12 13:38:51 2020 (r356658) +++ head/sys/compat/linux/linux_misc.c Sun Jan 12 14:25:44 2020 (r356659) @@ -1613,12 +1613,9 @@ linux_nosys(struct thread *td, struct nosys_args *igno int linux_getpriority(struct thread *td, struct linux_getpriority_args *args) { - struct getpriority_args bsd_args; int error; - bsd_args.which = args->which; - bsd_args.who = args->who; - error = sys_getpriority(td, &bsd_args); + error = kern_getpriority(td, args->which, args->who); td->td_retval[0] = 20 - td->td_retval[0]; return (error); } Modified: head/sys/kern/kern_resource.c ============================================================================== --- head/sys/kern/kern_resource.c Sun Jan 12 13:38:51 2020 (r356658) +++ head/sys/kern/kern_resource.c Sun Jan 12 14:25:44 2020 (r356659) @@ -92,19 +92,26 @@ struct getpriority_args { int sys_getpriority(struct thread *td, struct getpriority_args *uap) { + + return (kern_getpriority(td, uap->which, uap->who)); +} + +int +kern_getpriority(struct thread *td, int which, int who) +{ struct proc *p; struct pgrp *pg; int error, low; error = 0; low = PRIO_MAX + 1; - switch (uap->which) { + switch (which) { case PRIO_PROCESS: - if (uap->who == 0) + if (who == 0) low = td->td_proc->p_nice; else { - p = pfind(uap->who); + p = pfind(who); if (p == NULL) break; if (p_cansee(td, p) == 0) @@ -115,11 +122,11 @@ sys_getpriority(struct thread *td, struct getpriority_ case PRIO_PGRP: sx_slock(&proctree_lock); - if (uap->who == 0) { + if (who == 0) { pg = td->td_proc->p_pgrp; PGRP_LOCK(pg); } else { - pg = pgfind(uap->who); + pg = pgfind(who); if (pg == NULL) { sx_sunlock(&proctree_lock); break; @@ -139,14 +146,14 @@ sys_getpriority(struct thread *td, struct getpriority_ break; case PRIO_USER: - if (uap->who == 0) - uap->who = td->td_ucred->cr_uid; + if (who == 0) + who = td->td_ucred->cr_uid; sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); if (p->p_state == PRS_NORMAL && p_cansee(td, p) == 0 && - p->p_ucred->cr_uid == uap->who) { + p->p_ucred->cr_uid == who) { if (p->p_nice < low) low = p->p_nice; } Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Sun Jan 12 13:38:51 2020 (r356658) +++ head/sys/sys/syscallsubr.h Sun Jan 12 14:25:44 2020 (r356659) @@ -141,6 +141,7 @@ int kern_getitimer(struct thread *, u_int, struct itim int kern_getppid(struct thread *); int kern_getpeername(struct thread *td, int fd, struct sockaddr **sa, socklen_t *alen); +int kern_getpriority(struct thread *td, int which, int who); int kern_getrusage(struct thread *td, int who, struct rusage *rup); int kern_getsid(struct thread *td, pid_t pid); int kern_getsockname(struct thread *td, int fd, struct sockaddr **sa, From owner-svn-src-all@freebsd.org Sun Jan 12 15:45:28 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A4991D9D98; Sun, 12 Jan 2020 15:45:28 +0000 (UTC) (envelope-from tuexen@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 47wgzC6Frrz4TvM; Sun, 12 Jan 2020 15:45:27 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD4811DE7A; Sun, 12 Jan 2020 15:45:27 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CFjRE1097803; Sun, 12 Jan 2020 15:45:27 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CFjRwU097802; Sun, 12 Jan 2020 15:45:27 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202001121545.00CFjRwU097802@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 12 Jan 2020 15:45:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356660 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 356660 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 15:45:28 -0000 Author: tuexen Date: Sun Jan 12 15:45:27 2020 New Revision: 356660 URL: https://svnweb.freebsd.org/changeset/base/356660 Log: Fix division by zero issue. Thanks to Stas Denisov for reporting the issue for the userland stack and providing a fix. MFC after: 3 days Modified: head/sys/netinet/sctp_cc_functions.c Modified: head/sys/netinet/sctp_cc_functions.c ============================================================================== --- head/sys/netinet/sctp_cc_functions.c Sun Jan 12 14:25:44 2020 (r356659) +++ head/sys/netinet/sctp_cc_functions.c Sun Jan 12 15:45:27 2020 (r356660) @@ -1876,7 +1876,7 @@ htcp_cong_time(struct htcp *ca) static inline uint32_t htcp_ccount(struct htcp *ca) { - return (htcp_cong_time(ca) / ca->minRTT); + return (ca->minRTT == 0 ? htcp_cong_time(ca) : htcp_cong_time(ca) / ca->minRTT); } static inline void From owner-svn-src-all@freebsd.org Sun Jan 12 16:58:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A9E31DBE9C; Sun, 12 Jan 2020 16:58:22 +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 47wjbL2Vlrz4Zs0; Sun, 12 Jan 2020 16:58:22 +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 4CF551EB72; Sun, 12 Jan 2020 16:58:22 +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 00CGwMvq043156; Sun, 12 Jan 2020 16:58:22 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CGwLsw043154; Sun, 12 Jan 2020 16:58:21 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001121658.00CGwLsw043154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sun, 12 Jan 2020 16:58:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356661 - head/sys/netinet6 X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/netinet6 X-SVN-Commit-Revision: 356661 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 16:58:22 -0000 Author: bz Date: Sun Jan 12 16:58:21 2020 New Revision: 356661 URL: https://svnweb.freebsd.org/changeset/base/356661 Log: nd6_rtr: make nd6_prefix_onlink() static nd6_prefix_onlink() is not used anywhere outside nd6_rtr.c. Stop exporting it and make it file local static. Modified: head/sys/netinet6/nd6.h head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/nd6.h ============================================================================== --- head/sys/netinet6/nd6.h Sun Jan 12 15:45:27 2020 (r356660) +++ head/sys/netinet6/nd6.h Sun Jan 12 16:58:21 2020 (r356661) @@ -418,7 +418,6 @@ void nd6_prefix_unlink(struct nd_prefix *, struct nd_p void nd6_prefix_del(struct nd_prefix *); void nd6_prefix_ref(struct nd_prefix *); void nd6_prefix_rele(struct nd_prefix *); -int nd6_prefix_onlink(struct nd_prefix *); int nd6_prefix_offlink(struct nd_prefix *); void pfxlist_onlink_check(void); struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *); Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Sun Jan 12 15:45:27 2020 (r356660) +++ head/sys/netinet6/nd6_rtr.c Sun Jan 12 16:58:21 2020 (r356661) @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *); static int prelist_update(struct nd_prefixctl *, struct nd_defrouter *, struct mbuf *, int); +static int nd6_prefix_onlink(struct nd_prefix *); TAILQ_HEAD(nd6_drhead, nd_defrouter); VNET_DEFINE_STATIC(struct nd6_drhead, nd6_defrouter); @@ -2088,7 +2089,7 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, stru return (a_failure); } -int +static int nd6_prefix_onlink(struct nd_prefix *pr) { struct epoch_tracker et; From owner-svn-src-all@freebsd.org Sun Jan 12 17:41:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B6C51DD09B; Sun, 12 Jan 2020 17:41:10 +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 47wkXj70gJz4dC3; Sun, 12 Jan 2020 17:41:09 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2C7A1F4F9; Sun, 12 Jan 2020 17:41:09 +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 00CHf9ug069926; Sun, 12 Jan 2020 17:41:09 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CHf98k069925; Sun, 12 Jan 2020 17:41:09 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001121741.00CHf98k069925@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sun, 12 Jan 2020 17:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356662 - head/sys/netinet6 X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/netinet6 X-SVN-Commit-Revision: 356662 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 17:41:10 -0000 Author: bz Date: Sun Jan 12 17:41:09 2020 New Revision: 356662 URL: https://svnweb.freebsd.org/changeset/base/356662 Log: nd6_rtr: constantly use __func__ for nd6log() Over time one or two hard coded function names did not match the actual function anymore. Consistently use __func__ for nd6log() calls and re-wrap/re-format some messages for consitency. MFC after: 2 weeks Modified: head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Sun Jan 12 16:58:21 2020 (r356661) +++ head/sys/netinet6/nd6_rtr.c Sun Jan 12 17:41:09 2020 (r356662) @@ -177,7 +177,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) ip6 = mtod(m, struct ip6_hdr *); if (ip6->ip6_hlim != 255) { nd6log((LOG_ERR, - "nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n", + "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); goto bad; @@ -205,7 +205,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) nd6_option_init(nd_rs + 1, icmp6len, &ndopts); if (nd6_options(&ndopts) < 0) { nd6log((LOG_INFO, - "nd6_rs_input: invalid ND option, ignored\n")); + "%s: invalid ND option, ignored\n", __func__)); /* nd6_options have incremented stats */ goto freeit; } @@ -219,9 +219,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) { nd6log((LOG_INFO, - "nd6_rs_input: lladdrlen mismatch for %s " - "(if %d, RS packet %d)\n", - ip6_sprintf(ip6bufs, &saddr6), + "%s: lladdrlen mismatch for %s (if %d, RS packet %d)\n", + __func__, ip6_sprintf(ip6bufs, &saddr6), ifp->if_addrlen, lladdrlen - 2)); goto bad; } @@ -377,7 +376,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) ip6 = mtod(m, struct ip6_hdr *); if (ip6->ip6_hlim != 255) { nd6log((LOG_ERR, - "nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n", + "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src), ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp))); goto bad; @@ -386,7 +385,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) saddr6 = ip6->ip6_src; if (!IN6_IS_ADDR_LINKLOCAL(&saddr6)) { nd6log((LOG_ERR, - "nd6_ra_input: src %s is not link-local\n", + "%s: src %s is not link-local\n", __func__, ip6_sprintf(ip6bufs, &saddr6))); goto bad; } @@ -405,7 +404,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) nd6_option_init(nd_ra + 1, icmp6len, &ndopts); if (nd6_options(&ndopts) < 0) { nd6log((LOG_INFO, - "nd6_ra_input: invalid ND option, ignored\n")); + "%s: invalid ND option, ignored\n", __func__)); /* nd6_options have incremented stats */ goto freeit; } @@ -482,26 +481,25 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) if (pi->nd_opt_pi_len != 4) { nd6log((LOG_INFO, - "nd6_ra_input: invalid option " - "len %d for prefix information option, " - "ignored\n", pi->nd_opt_pi_len)); + "%s: invalid option len %d for prefix " + "information option, ignored\n", __func__, + pi->nd_opt_pi_len)); continue; } if (128 < pi->nd_opt_pi_prefix_len) { nd6log((LOG_INFO, - "nd6_ra_input: invalid prefix " - "len %d for prefix information option, " - "ignored\n", pi->nd_opt_pi_prefix_len)); + "%s: invalid prefix len %d for prefix " + "information option, ignored\n", __func__, + pi->nd_opt_pi_prefix_len)); continue; } if (IN6_IS_ADDR_MULTICAST(&pi->nd_opt_pi_prefix) || IN6_IS_ADDR_LINKLOCAL(&pi->nd_opt_pi_prefix)) { nd6log((LOG_INFO, - "nd6_ra_input: invalid prefix " - "%s, ignored\n", - ip6_sprintf(ip6bufs, + "%s: invalid prefix %s, ignored\n", + __func__, ip6_sprintf(ip6bufs, &pi->nd_opt_pi_prefix))); continue; } @@ -538,8 +536,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) /* lower bound */ if (mtu < IPV6_MMTU) { - nd6log((LOG_INFO, "nd6_ra_input: bogus mtu option " - "mtu=%lu sent from %s, ignoring\n", + nd6log((LOG_INFO, "%s: bogus mtu option mtu=%lu sent " + "from %s, ignoring\n", __func__, mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src))); goto skip; } @@ -557,9 +555,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) rt_updatemtu(ifp); } } else { - nd6log((LOG_INFO, "nd6_ra_input: bogus mtu " - "mtu=%lu sent from %s; " - "exceeds maxmtu %lu, ignoring\n", + nd6log((LOG_INFO, "%s: bogus mtu=%lu sent from %s; " + "exceeds maxmtu %lu, ignoring\n", __func__, mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src), maxmtu)); } } @@ -580,8 +577,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) { nd6log((LOG_INFO, - "nd6_ra_input: lladdrlen mismatch for %s " - "(if %d, RA packet %d)\n", ip6_sprintf(ip6bufs, &saddr6), + "%s: lladdrlen mismatch for %s (if %d, RA packet %d)\n", + __func__, ip6_sprintf(ip6bufs, &saddr6), ifp->if_addrlen, lladdrlen - 2)); goto bad; } @@ -1223,9 +1220,9 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast) plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL); if (prefixlen != plen0) { ifa_free(ifa); - nd6log((LOG_INFO, "in6_ifadd: wrong prefixlen for %s " - "(prefix=%d ifid=%d)\n", - if_name(ifp), prefixlen, 128 - plen0)); + nd6log((LOG_INFO, + "%s: wrong prefixlen for %s (prefix=%d ifid=%d)\n", + __func__, if_name(ifp), prefixlen, 128 - plen0)); return NULL; } @@ -1278,7 +1275,7 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast) updateflags |= IN6_IFAUPDATE_DADDELAY; if ((error = in6_update_ifa(ifp, &ifra, NULL, updateflags)) != 0) { nd6log((LOG_ERR, - "in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n", + "%s: failed to make ifaddr %s on %s (errno=%d)\n", __func__, ip6_sprintf(ip6buf, &ifra.ifra_addr.sin6_addr), if_name(ifp), error)); return (NULL); /* ifaddr must not have been allocated. */ @@ -1383,8 +1380,8 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_def ND6_ONLINK_LOCK(); NET_EPOCH_ENTER(et); if ((error = nd6_prefix_onlink(new)) != 0) { - nd6log((LOG_ERR, "nd6_prelist_add: failed to make " - "the prefix %s/%d on-link on %s (errno=%d)\n", + nd6log((LOG_ERR, "%s: failed to make the prefix %s/%d " + "on-link on %s (errno=%d)\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, if_name(pr->ndpr_ifp), error)); /* proceed anyway. XXX: is it correct? */ @@ -1441,8 +1438,8 @@ nd6_prefix_del(struct nd_prefix *pr) ND6_ONLINK_LOCK(); if ((e = nd6_prefix_offlink(pr)) != 0) { nd6log((LOG_ERR, - "nd6_prefix_del: failed to make %s/%d offlink " - "on %s, errno=%d\n", + "%s: failed to make the prefix %s/%d offlink on %s " + "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, if_name(pr->ndpr_ifp), e)); /* what should we do? */ @@ -1515,9 +1512,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def ND6_ONLINK_LOCK(); if ((error = nd6_prefix_onlink(pr)) != 0) { nd6log((LOG_ERR, - "prelist_update: failed to make " - "the prefix %s/%d on-link on %s " - "(errno=%d)\n", + "%s: failed to make the prefix %s/%d " + "on-link on %s (errno=%d)\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, if_name(pr->ndpr_ifp), @@ -1537,8 +1533,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def error = nd6_prelist_add(new, dr, &pr); if (error != 0) { - nd6log((LOG_NOTICE, "prelist_update: " - "nd6_prelist_add failed for %s/%d on %s errno=%d\n", + nd6log((LOG_NOTICE, "%s: nd6_prelist_add() failed for " + "the prefix %s/%d on %s (errno=%d)\n", __func__, ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr), new->ndpr_plen, if_name(new->ndpr_ifp), error)); goto end; /* we should just give up in this case. */ @@ -1736,9 +1732,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def } if (ifidlen + pr->ndpr_plen != 128) { nd6log((LOG_INFO, - "prelist_update: invalid prefixlen " - "%d for %s, ignored\n", - pr->ndpr_plen, if_name(ifp))); + "%s: invalid prefixlen %d for %s, ignored\n", + __func__, pr->ndpr_plen, if_name(ifp))); goto end; } @@ -1764,10 +1759,9 @@ prelist_update(struct nd_prefixctl *new, struct nd_def if (V_ip6_use_tempaddr) { int e; if ((e = in6_tmpifadd(ia6, 1, 1)) != 0) { - nd6log((LOG_NOTICE, "prelist_update: " - "failed to create a temporary " - "address, errno=%d\n", - e)); + nd6log((LOG_NOTICE, "%s: failed to " + "create a temporary address " + "(errno=%d)\n", __func__, e)); } } ifa_free(&ia6->ia_ifa); @@ -1931,16 +1925,16 @@ restart: if ((flags & NDPRF_ONLINK) != 0 && (e = nd6_prefix_offlink(pr)) != 0) { nd6log((LOG_ERR, - "pfxlist_onlink_check: failed to " - "make %s/%d offlink, errno=%d\n", + "%s: failed to make %s/%d offlink " + "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, e)); } else if ((flags & NDPRF_ONLINK) == 0 && (e = nd6_prefix_onlink(pr)) != 0) { nd6log((LOG_ERR, - "pfxlist_onlink_check: failed to " - "make %s/%d onlink, errno=%d\n", + "%s: failed to make %s/%d onlink " + "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, e)); @@ -2065,9 +2059,9 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, stru struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)ifa->ifa_addr; - nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add " + nd6log((LOG_ERR, "%s: failed to add " "route for a prefix (%s/%d) on %s, gw=%s, mask=%s, " - "flags=%lx errno = %d\n", + "flags=%lx errno = %d\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, if_name(pr->ndpr_ifp), ip6_sprintf(ip6bufg, &sin6->sin6_addr), @@ -2159,8 +2153,8 @@ nd6_prefix_onlink(struct nd_prefix *pr) * interface. This should, of course, be rare though. */ nd6log((LOG_NOTICE, - "nd6_prefix_onlink: failed to find any ifaddr" - " to add route for a prefix(%s/%d) on %s\n", + "%s: failed to find any ifaddr to add route for a " + "prefix(%s/%d) on %s\n", __func__, ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr), pr->ndpr_plen, if_name(ifp))); return (0); @@ -2259,10 +2253,9 @@ restart: ND6_RUNLOCK(); if ((e = nd6_prefix_onlink(opr)) != 0) { nd6log((LOG_ERR, - "nd6_prefix_offlink: failed to " - "recover a prefix %s/%d from %s " - "to %s (errno = %d)\n", - ip6_sprintf(ip6buf, + "%s: failed to recover a prefix " + "%s/%d from %s to %s (errno=%d)\n", + __func__, ip6_sprintf(ip6buf, &opr->ndpr_prefix.sin6_addr), opr->ndpr_plen, if_name(ifp), if_name(opr->ndpr_ifp), e)); @@ -2277,10 +2270,9 @@ restart: } else { /* XXX: can we still set the NDPRF_ONLINK flag? */ nd6log((LOG_ERR, - "nd6_prefix_offlink: failed to delete route: " - "%s/%d on %s (errno = %d)\n", - ip6_sprintf(ip6buf, &sa6.sin6_addr), pr->ndpr_plen, - if_name(ifp), error)); + "%s: failed to delete route: %s/%d on %s (errno=%d)\n", + __func__, ip6_sprintf(ip6buf, &sa6.sin6_addr), + pr->ndpr_plen, if_name(ifp), error)); } if (a_failure) @@ -2316,8 +2308,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege again: if (in6_get_tmpifid(ifp, (u_int8_t *)randid, (const u_int8_t *)&ia0->ia_addr.sin6_addr.s6_addr[8], forcegen)) { - nd6log((LOG_NOTICE, "in6_tmpifadd: failed to find a good " - "random IFID\n")); + nd6log((LOG_NOTICE, "%s: failed to find a good random IFID\n", + __func__)); return (EINVAL); } ifra.ifra_addr.sin6_addr.s6_addr32[2] |= @@ -2339,8 +2331,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege } /* Give up. Something strange should have happened. */ - nd6log((LOG_NOTICE, "in6_tmpifadd: failed to " - "find a unique random IFID\n")); + nd6log((LOG_NOTICE, "%s: failed to find a unique random IFID\n", + __func__)); return (EEXIST); } @@ -2393,8 +2385,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege newia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); if (newia == NULL) { /* XXX: can it happen? */ nd6log((LOG_ERR, - "in6_tmpifadd: ifa update succeeded, but we got " - "no ifaddr\n")); + "%s: ifa update succeeded, but we got no ifaddr\n", + __func__)); return (EINVAL); /* XXX */ } newia->ia6_ndpr = ia0->ia6_ndpr; From owner-svn-src-all@freebsd.org Sun Jan 12 17:52:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32A0A1DD49B; Sun, 12 Jan 2020 17:52:34 +0000 (UTC) (envelope-from tuexen@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 47wknt0ZmLz4dpk; Sun, 12 Jan 2020 17:52:34 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F33D1F76C; Sun, 12 Jan 2020 17:52:34 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CHqXTJ079405; Sun, 12 Jan 2020 17:52:33 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CHqXrL079401; Sun, 12 Jan 2020 17:52:33 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202001121752.00CHqXrL079401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 12 Jan 2020 17:52:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356663 - in head/sys: netinet netinet6 X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: in head/sys: netinet netinet6 X-SVN-Commit-Revision: 356663 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 17:52:34 -0000 Author: tuexen Date: Sun Jan 12 17:52:32 2020 New Revision: 356663 URL: https://svnweb.freebsd.org/changeset/base/356663 Log: Fix race when accepting TCP connections. When expanding a SYN-cache entry to a socket/inp a two step approach was taken: 1) The local address was filled in, then the inp was added to the hash table. 2) The remote address was filled in and the inp was relocated in the hash table. Before the epoch changes, a write lock was held when this happens and the code looking up entries was holding a corresponding read lock. Since the read lock is gone away after the introduction of the epochs, the half populated inp was found during lookup. This resulted in processing TCP segments in the context of the wrong TCP connection. This patch changes the above procedure in a way that the inp is fully populated before inserted into the hash table. Thanks to Paul for reporting the issue on the net@ mailing list and for testing the patch! Reviewed by: rrs@ MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D22971 Modified: head/sys/netinet/in_pcb.c head/sys/netinet/in_pcb.h head/sys/netinet/tcp_syncache.c head/sys/netinet6/in6_pcb.c head/sys/netinet6/in6_pcb.h Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Sun Jan 12 17:41:09 2020 (r356662) +++ head/sys/netinet/in_pcb.c Sun Jan 12 17:52:32 2020 (r356663) @@ -972,7 +972,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *n */ int in_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr *nam, - struct ucred *cred, struct mbuf *m) + struct ucred *cred, struct mbuf *m, bool rehash) { u_short lport, fport; in_addr_t laddr, faddr; @@ -991,6 +991,8 @@ in_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr /* Do the initial binding of the local address if required. */ if (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) { + KASSERT(rehash == true, + ("Rehashing required for unbound inps")); inp->inp_lport = lport; inp->inp_laddr.s_addr = laddr; if (in_pcbinshash(inp) != 0) { @@ -1005,7 +1007,11 @@ in_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr inp->inp_laddr.s_addr = laddr; inp->inp_faddr.s_addr = faddr; inp->inp_fport = fport; - in_pcbrehash_mbuf(inp, m); + if (rehash) { + in_pcbrehash_mbuf(inp, m); + } else { + in_pcbinshash_mbuf(inp, m); + } if (anonport) inp->inp_flags |= INP_ANONPORT; @@ -1016,7 +1022,7 @@ int in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) { - return (in_pcbconnect_mbuf(inp, nam, cred, NULL)); + return (in_pcbconnect_mbuf(inp, nam, cred, NULL, true)); } /* @@ -2500,7 +2506,7 @@ in_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in * Insert PCB onto various hash lists. */ static int -in_pcbinshash_internal(struct inpcb *inp, int do_pcbgroup_update) +in_pcbinshash_internal(struct inpcb *inp, struct mbuf *m) { struct inpcbhead *pcbhash; struct inpcbporthead *pcbporthash; @@ -2566,35 +2572,27 @@ in_pcbinshash_internal(struct inpcb *inp, int do_pcbgr CK_LIST_INSERT_HEAD(pcbhash, inp, inp_hash); inp->inp_flags |= INP_INHASHLIST; #ifdef PCBGROUP - if (do_pcbgroup_update) + if (m != NULL) { + in_pcbgroup_update_mbuf(inp, m); + } else { in_pcbgroup_update(inp); + } #endif return (0); } -/* - * For now, there are two public interfaces to insert an inpcb into the hash - * lists -- one that does update pcbgroups, and one that doesn't. The latter - * is used only in the TCP syncache, where in_pcbinshash is called before the - * full 4-tuple is set for the inpcb, and we don't want to install in the - * pcbgroup until later. - * - * XXXRW: This seems like a misfeature. in_pcbinshash should always update - * connection groups, and partially initialised inpcbs should not be exposed - * to either reservation hash tables or pcbgroups. - */ int in_pcbinshash(struct inpcb *inp) { - return (in_pcbinshash_internal(inp, 1)); + return (in_pcbinshash_internal(inp, NULL)); } int -in_pcbinshash_nopcbgroup(struct inpcb *inp) +in_pcbinshash_mbuf(struct inpcb *inp, struct mbuf *m) { - return (in_pcbinshash_internal(inp, 0)); + return (in_pcbinshash_internal(inp, m)); } /* Modified: head/sys/netinet/in_pcb.h ============================================================================== --- head/sys/netinet/in_pcb.h Sun Jan 12 17:41:09 2020 (r356662) +++ head/sys/netinet/in_pcb.h Sun Jan 12 17:52:32 2020 (r356663) @@ -832,7 +832,7 @@ int in_pcbbind_setup(struct inpcb *, struct sockaddr * u_short *, struct ucred *); int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); int in_pcbconnect_mbuf(struct inpcb *, struct sockaddr *, struct ucred *, - struct mbuf *); + struct mbuf *, bool); int in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *, u_short *, in_addr_t *, u_short *, struct inpcb **, struct ucred *); @@ -841,7 +841,7 @@ void in_pcbdisconnect(struct inpcb *); void in_pcbdrop(struct inpcb *); void in_pcbfree(struct inpcb *); int in_pcbinshash(struct inpcb *); -int in_pcbinshash_nopcbgroup(struct inpcb *); +int in_pcbinshash_mbuf(struct inpcb *, struct mbuf *); int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *, struct ucred *); struct inpcb * Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Sun Jan 12 17:41:09 2020 (r356662) +++ head/sys/netinet/tcp_syncache.c Sun Jan 12 17:52:32 2020 (r356663) @@ -841,34 +841,8 @@ syncache_socket(struct syncache *sc, struct socket *ls #endif } - /* - * Install in the reservation hash table for now, but don't yet - * install a connection group since the full 4-tuple isn't yet - * configured. - */ inp->inp_lport = sc->sc_inc.inc_lport; - if ((error = in_pcbinshash_nopcbgroup(inp)) != 0) { - /* - * Undo the assignments above if we failed to - * put the PCB on the hash lists. - */ #ifdef INET6 - if (sc->sc_inc.inc_flags & INC_ISIPV6) - inp->in6p_laddr = in6addr_any; - else -#endif - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) { - log(LOG_DEBUG, "%s; %s: in_pcbinshash failed " - "with error %i\n", - s, __func__, error); - free(s, M_TCPLOG); - } - INP_HASH_WUNLOCK(&V_tcbinfo); - goto abort; - } -#ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { struct inpcb *oinp = sotoinpcb(lso); @@ -900,7 +874,7 @@ syncache_socket(struct syncache *sc, struct socket *ls if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) inp->in6p_laddr = sc->sc_inc.inc6_laddr; if ((error = in6_pcbconnect_mbuf(inp, (struct sockaddr *)&sin6, - thread0.td_ucred, m)) != 0) { + thread0.td_ucred, m, false)) != 0) { inp->in6p_laddr = laddr6; if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) { log(LOG_DEBUG, "%s; %s: in6_pcbconnect failed " @@ -940,7 +914,7 @@ syncache_socket(struct syncache *sc, struct socket *ls if (inp->inp_laddr.s_addr == INADDR_ANY) inp->inp_laddr = sc->sc_inc.inc_laddr; if ((error = in_pcbconnect_mbuf(inp, (struct sockaddr *)&sin, - thread0.td_ucred, m)) != 0) { + thread0.td_ucred, m, false)) != 0) { inp->inp_laddr = laddr; if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) { log(LOG_DEBUG, "%s; %s: in_pcbconnect failed " Modified: head/sys/netinet6/in6_pcb.c ============================================================================== --- head/sys/netinet6/in6_pcb.c Sun Jan 12 17:41:09 2020 (r356662) +++ head/sys/netinet6/in6_pcb.c Sun Jan 12 17:52:32 2020 (r356663) @@ -411,7 +411,7 @@ in6_pcbladdr(struct inpcb *inp, struct sockaddr *nam, */ int in6_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr *nam, - struct ucred *cred, struct mbuf *m) + struct ucred *cred, struct mbuf *m, bool rehash) { struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; @@ -437,6 +437,8 @@ in6_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr } if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { if (inp->inp_lport == 0) { + KASSERT(rehash == true, + ("Rehashing required for unbound inps")); error = in6_pcbbind(inp, (struct sockaddr *)0, cred); if (error) return (error); @@ -451,7 +453,11 @@ in6_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr inp->inp_flow |= (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); - in_pcbrehash_mbuf(inp, m); + if (rehash) { + in_pcbrehash_mbuf(inp, m); + } else { + in_pcbinshash_mbuf(inp, m); + } return (0); } @@ -460,7 +466,7 @@ int in6_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) { - return (in6_pcbconnect_mbuf(inp, nam, cred, NULL)); + return (in6_pcbconnect_mbuf(inp, nam, cred, NULL, true)); } void Modified: head/sys/netinet6/in6_pcb.h ============================================================================== --- head/sys/netinet6/in6_pcb.h Sun Jan 12 17:41:09 2020 (r356662) +++ head/sys/netinet6/in6_pcb.h Sun Jan 12 17:52:32 2020 (r356663) @@ -86,7 +86,7 @@ void in6_losing(struct inpcb *); int in6_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *); int in6_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); int in6_pcbconnect_mbuf(struct inpcb *, struct sockaddr *, - struct ucred *, struct mbuf *); + struct ucred *, struct mbuf *, bool); void in6_pcbdisconnect(struct inpcb *); struct inpcb * in6_pcblookup_local(struct inpcbinfo *, From owner-svn-src-all@freebsd.org Sun Jan 12 19:10:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A33BB1DF1FF; Sun, 12 Jan 2020 19:10:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47wmXD2rlnz4jJV; Sun, 12 Jan 2020 19:10:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id 00CJAido071538 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 12 Jan 2020 21:10:47 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 00CJAido071538 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 00CJAiSr071537; Sun, 12 Jan 2020 21:10:44 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 12 Jan 2020 21:10:44 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r356656 - in head/sys: kern sys Message-ID: <20200112191044.GB2068@kib.kiev.ua> References: <202001120609.00C69Anp050819@repo.freebsd.org> <20200112090010.GA2068@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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.3 X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on tom.home X-Rspamd-Queue-Id: 47wmXD2rlnz4jJV X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; IP_SCORE_FREEMAIL(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(0.00)[ip: (-3.03), ipnet: 2001:470::/32(-4.67), asn: 6939(-3.57), country: US(-0.05)]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 19:10:53 -0000 On Sun, Jan 12, 2020 at 11:08:02AM +0100, Mateusz Guzik wrote: > On 1/12/20, Konstantin Belousov wrote: > > On Sun, Jan 12, 2020 at 06:09:10AM +0000, Mateusz Guzik wrote: > >> Author: mjg > >> Date: Sun Jan 12 06:09:10 2020 > >> New Revision: 356656 > >> URL: https://svnweb.freebsd.org/changeset/base/356656 > >> > >> Log: > >> Add "panicked" boolean which can be tested instead of panicstr > >> > >> The test is performed all the time and reading entire panicstr to do it > >> wastes space. > > What space does it waste ? The space in the read-mostly section ? > > > > And what is the difference between reading a pointer vs. reading a byte ? > > CPU still has to read the whole cache line. > > > > Note the annotation with __read_frequently which groups fields. > > Currently it results in the following (with tail filled up from > __read_mostly): > > ---------------- > ffffffff80c01000 D hc_source_mask > ffffffff80c01004 D pti pti should be remove from __read_frequently, probably moving it to __read_mostly is fine, and changed to bool as well. > ffffffff80c01008 D locks_delay > ffffffff80c0100c D locks_delay_retries > ffffffff80c0100e D locks_delay_loops > ffffffff80c01010 d fortuna_concurrent_read > ffffffff80c01011 D random_chachamode > ffffffff80c01012 D systrace_enabled > ffffffff80c01013 D lockstat_enabled > ffffffff80c01014 D dtrace_malloc_enabled > ffffffff80c01015 D racct_enable > ffffffff80c01016 D sdt_probes_enabled > ffffffff80c01017 D panicked > ffffffff80c01018 D kdb_active > ffffffff80c01019 D trap_enotcap > ffffffff80c0101a D audit_syscalls_enabled > ffffffff80c01020 D cam_dflags > ffffffff80c01028 d epoch_inited > ffffffff80c01030 d rs_epoch > ffffffff80c01038 d biozone > ---------------- > > Should panicstr land here it would avoidably take up 8 bytes instead of 1. > > -- > Mateusz Guzik From owner-svn-src-all@freebsd.org Sun Jan 12 20:12:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45A341E9069; Sun, 12 Jan 2020 20:12:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.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 47wnvR17LXz4mHC; Sun, 12 Jan 2020 20:12:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2214B2113B; Sun, 12 Jan 2020 20:12:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CKCZ30064552; Sun, 12 Jan 2020 20:12:35 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CKCZDW064551; Sun, 12 Jan 2020 20:12:35 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202001122012.00CKCZDW064551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 12 Jan 2020 20:12:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356664 - stable/12/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Commit-Revision: 356664 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 20:12:35 -0000 Author: markj Date: Sun Jan 12 20:12:34 2020 New Revision: 356664 URL: https://svnweb.freebsd.org/changeset/base/356664 Log: MFC r356187: Add libdtrace support for arm64 USDT probes. Modified: stable/12/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Sun Jan 12 17:52:32 2020 (r356663) +++ stable/12/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Sun Jan 12 20:12:34 2020 (r356664) @@ -229,9 +229,10 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, for (j = 0; j < nrel; j++) { #if defined(__aarch64__) -/* XXX */ - printf("%s:%s(%d): aarch64 not implemented\n", - __FUNCTION__, __FILE__, __LINE__); + rel->r_offset = s->dofs_offset + + dofr[j].dofr_offset; + rel->r_info = ELF32_R_INFO(count + dep->de_global, + R_ARM_REL32); #elif defined(__arm__) /* XXX */ printf("%s:%s(%d): arm not implemented\n", @@ -425,7 +426,10 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, for (j = 0; j < nrel; j++) { #if defined(__aarch64__) -/* XXX */ + rel->r_offset = s->dofs_offset + + dofr[j].dofr_offset; + rel->r_info = ELF64_R_INFO(count + dep->de_global, + R_AARCH64_PREL64); #elif defined(__arm__) /* XXX */ #elif defined(__mips__) @@ -541,6 +545,8 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, in elf_file.ehdr.e_machine = EM_SPARC; #elif defined(__i386) || defined(__amd64) elf_file.ehdr.e_machine = EM_386; +#elif defined(__aarch64__) + elf_file.ehdr.e_machine = EM_AARCH64; #endif elf_file.ehdr.e_version = EV_CURRENT; elf_file.ehdr.e_shoff = sizeof (Elf32_Ehdr); @@ -687,6 +693,8 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, in elf_file.ehdr.e_machine = EM_SPARCV9; #elif defined(__i386) || defined(__amd64) elf_file.ehdr.e_machine = EM_AMD64; +#elif defined(__aarch64__) + elf_file.ehdr.e_machine = EM_AARCH64; #endif elf_file.ehdr.e_version = EV_CURRENT; elf_file.ehdr.e_shoff = sizeof (Elf64_Ehdr); @@ -802,14 +810,66 @@ dt_symtab_lookup(Elf_Data *data_sym, int start, int en } #if defined(__aarch64__) -/* XXX */ +#define DT_OP_NOP 0xd503201f +#define DT_OP_RET 0xd65f03c0 +#define DT_OP_CALL26 0x94000000 +#define DT_OP_JUMP26 0x14000000 + static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { - printf("%s:%s(%d): aarch64 not implemented\n", __FUNCTION__, __FILE__, - __LINE__); - return (-1); + uint32_t *ip; + + /* + * Ensure that the offset is aligned on an instruction boundary. + */ + if ((rela->r_offset & (sizeof (uint32_t) - 1)) != 0) + return (-1); + + /* + * We only know about some specific relocation types. + * We also recognize relocation type NONE, since that gets used for + * relocations of USDT probes, and we might be re-processing a file. + */ + if (GELF_R_TYPE(rela->r_info) != R_AARCH64_CALL26 && + GELF_R_TYPE(rela->r_info) != R_AARCH64_JUMP26 && + GELF_R_TYPE(rela->r_info) != R_AARCH64_NONE) + return (-1); + + ip = (uint32_t *)(p + rela->r_offset); + + /* + * We may have already processed this object file in an earlier linker + * invocation. Check to see if the present instruction sequence matches + * the one we would install below. + */ + if (ip[0] == DT_OP_NOP || ip[0] == DT_OP_RET) + return (0); + + /* + * We only expect call instructions with a displacement of 0, or a jump + * instruction acting as a tail call. + */ + if (ip[0] != DT_OP_CALL26 && ip[0] != DT_OP_JUMP26) { + dt_dprintf("found %x instead of a call or jmp instruction at " + "%llx\n", ip[0], (u_longlong_t)rela->r_offset); + return (-1); + } + + /* + * On arm64, we do not have to differentiate between regular probes and + * is-enabled probes. Both cases are encoded as a regular branch for + * non-tail call locations, and a jump for tail call locations. Calls + * are to be converted into a no-op whereas jumps should become a + * return. + */ + if (ip[0] == DT_OP_CALL26) + ip[0] = DT_OP_NOP; + else + ip[0] = DT_OP_RET; + + return (0); } #elif defined(__arm__) /* XXX */ @@ -1254,6 +1314,8 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *e emachine1 = emachine2 = EM_SPARCV9; #elif defined(__i386) || defined(__amd64) emachine1 = emachine2 = EM_AMD64; +#elif defined(__aarch64__) + emachine1 = emachine2 = EM_AARCH64; #endif symsize = sizeof (Elf64_Sym); } else { From owner-svn-src-all@freebsd.org Sun Jan 12 20:19:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65CE11E9252; Sun, 12 Jan 2020 20:19:01 +0000 (UTC) (envelope-from sbruno@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 47wp2s26lCz4mdM; Sun, 12 Jan 2020 20:19:01 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 440E521145; Sun, 12 Jan 2020 20:19:01 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CKJ1WJ065392; Sun, 12 Jan 2020 20:19:01 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CKJ0Od065387; Sun, 12 Jan 2020 20:19:00 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <202001122019.00CKJ0Od065387@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 12 Jan 2020 20:19:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356665 - in stable/12: share/man/man4 sys/dev/sound/pci/hda X-SVN-Group: stable-12 X-SVN-Commit-Author: sbruno X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/sound/pci/hda X-SVN-Commit-Revision: 356665 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 20:19:01 -0000 Author: sbruno Date: Sun Jan 12 20:19:00 2020 New Revision: 356665 URL: https://svnweb.freebsd.org/changeset/base/356665 Log: MFC r350078 Add the ability to accept the default pin widget configuration to help with various laptops using hdaa(4) sound devices. We don't seem to know the "correct" configurations for these devices and the defaults are far superiour, e.g. they work if you don't nuke the default configs. Modified: stable/12/share/man/man4/snd_hda.4 stable/12/sys/dev/sound/pci/hda/hdaa.c stable/12/sys/dev/sound/pci/hda/hdaa.h Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/snd_hda.4 ============================================================================== --- stable/12/share/man/man4/snd_hda.4 Sun Jan 12 20:12:34 2020 (r356664) +++ stable/12/share/man/man4/snd_hda.4 Sun Jan 12 20:19:00 2020 (r356665) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 1, 2018 +.Dd July 16, 2019 .Dt SND_HDA 4 .Os .Sh NAME @@ -153,6 +153,12 @@ The and .Dq Li ovref Ns Ar X options control the voltage used to power external microphones. +.It Va dev.hdaa.%d.init_clear +Zero out the pin widget config setup by the system. +Some systems seem to have unuseable audio devices if the pin widgit +configuration is cleared. +Set this value to 0 to accept the default configuration values setup by the +BIOS. .It Va hint.hdaa.%d.gpio_config Overrides audio function GPIO pins configuration set by BIOS. May be specified as a set of space-separated Modified: stable/12/sys/dev/sound/pci/hda/hdaa.c ============================================================================== --- stable/12/sys/dev/sound/pci/hda/hdaa.c Sun Jan 12 20:12:34 2020 (r356664) +++ stable/12/sys/dev/sound/pci/hda/hdaa.c Sun Jan 12 20:19:00 2020 (r356665) @@ -5034,11 +5034,13 @@ hdaa_audio_prepare_pin_ctrl(struct hdaa_devinfo *devin pincap = w->wclass.pin.cap; /* Disable everything. */ - w->wclass.pin.ctrl &= ~( - HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE | - HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE | - HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE | - HDA_CMD_SET_PIN_WIDGET_CTRL_VREF_ENABLE_MASK); + if (devinfo->init_clear) { + w->wclass.pin.ctrl &= ~( + HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE | + HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE | + HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE | + HDA_CMD_SET_PIN_WIDGET_CTRL_VREF_ENABLE_MASK); + } if (w->enable == 0) { /* Pin is unused so left it disabled. */ @@ -6671,6 +6673,10 @@ hdaa_attach(device_t dev) SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "reconfig", CTLTYPE_INT | CTLFLAG_RW, dev, 0, hdaa_sysctl_reconfig, "I", "Reprocess configuration"); + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, + "init_clear", CTLFLAG_RW, + &devinfo->init_clear, 1,"Clear initial pin widget configuration"); bus_generic_attach(dev); return (0); } Modified: stable/12/sys/dev/sound/pci/hda/hdaa.h ============================================================================== --- stable/12/sys/dev/sound/pci/hda/hdaa.h Sun Jan 12 20:12:34 2020 (r356664) +++ stable/12/sys/dev/sound/pci/hda/hdaa.h Sun Jan 12 20:19:00 2020 (r356665) @@ -214,6 +214,7 @@ struct hdaa_devinfo { struct hdaa_chan *chans; struct callout poll_jack; int poll_ival; + uint32_t init_clear; }; #define HDAA_CHN_RUNNING 0x00000001 From owner-svn-src-all@freebsd.org Sun Jan 12 20:25:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A00911E9647; Sun, 12 Jan 2020 20:25:12 +0000 (UTC) (envelope-from gad@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 47wpB03ht0z4nCV; Sun, 12 Jan 2020 20:25:12 +0000 (UTC) (envelope-from gad@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 7A2A521323; Sun, 12 Jan 2020 20:25:12 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00CKPCk4071373; Sun, 12 Jan 2020 20:25:12 GMT (envelope-from gad@FreeBSD.org) Received: (from gad@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CKPBSW071370; Sun, 12 Jan 2020 20:25:11 GMT (envelope-from gad@FreeBSD.org) Message-Id: <202001122025.00CKPBSW071370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gad set sender to gad@FreeBSD.org using -f From: Garance A Drosehn Date: Sun, 12 Jan 2020 20:25:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356666 - in head/usr.bin: factor primes X-SVN-Group: head X-SVN-Commit-Author: gad X-SVN-Commit-Paths: in head/usr.bin: factor primes X-SVN-Commit-Revision: 356666 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 20:25:12 -0000 Author: gad Date: Sun Jan 12 20:25:11 2020 New Revision: 356666 URL: https://svnweb.freebsd.org/changeset/base/356666 Log: Fix the way 'factor' behaves when using OpenSSL to match the description of how it works when not compiled with OpenSSL. Also, allow users to specify a hexadecimal number by using a prefix of '0x'. Before this, users could only specify a hexadecimal value if that value included a hex digit ('a'-'f') in the value. PR: 243136 Submitted by: Steve Kargl Reviewed by: gad MFC after: 3 weeks Modified: head/usr.bin/factor/factor.6 head/usr.bin/factor/factor.c head/usr.bin/primes/primes.c Modified: head/usr.bin/factor/factor.6 ============================================================================== --- head/usr.bin/factor/factor.6 Sun Jan 12 20:19:00 2020 (r356665) +++ head/usr.bin/factor/factor.6 Sun Jan 12 20:25:11 2020 (r356666) @@ -36,7 +36,7 @@ .\" .\" chongo /\oo/\ .\" -.Dd October 10, 2002 +.Dd January 12, 2020 .Dt FACTOR 6 .Os .Sh NAME @@ -67,11 +67,22 @@ When .Nm is invoked with no arguments, .Nm -reads numbers, one per line, from standard input, until end of file or error. +reads numbers, one per line, from standard input until end of file or 0 +is entered or an error occurs. Leading white-space and empty lines are ignored. +.Pp Numbers may be preceded by a single .Ql + . +Numbers can be either decimal or hexadecimal strings where the longest +leading substring is used. Numbers are terminated by a non-digit character (such as a newline). +If the string contains only decimal digits, it is treated as a +decimal representation for a number. +A hexadecimal string can contain an optional +.Em 0x +or +.Em 0X +prefix. After a number is read, it is factored. .Pp The @@ -89,7 +100,7 @@ The value must not be greater than the maximum. The default and maximum value of .Ar stop -is 3825123056546413050. +is 18446744073709551615. .Pp When the .Nm primes Modified: head/usr.bin/factor/factor.c ============================================================================== --- head/usr.bin/factor/factor.c Sun Jan 12 20:19:00 2020 (r356665) +++ head/usr.bin/factor/factor.c Sun Jan 12 20:25:11 2020 (r356666) @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -97,15 +98,16 @@ typedef u_long BN_ULONG; #define BN_is_one(v) (*(v) == 1) #define BN_mod_word(a, b) (*(a) % (b)) -static int BN_dec2bn(BIGNUM **a, const char *str); -static int BN_hex2bn(BIGNUM **a, const char *str); +static int BN_dec2bn(BIGNUM **, const char *); +static int BN_hex2bn(BIGNUM **, const char *); static BN_ULONG BN_div_word(BIGNUM *, BN_ULONG); static void BN_print_fp(FILE *, const BIGNUM *); #endif static void BN_print_dec_fp(FILE *, const BIGNUM *); - +static void convert_str2bn(BIGNUM **, char *); +static bool is_hex_str(char *); static void pr_fact(BIGNUM *); /* print factors of a value */ static void pr_print(BIGNUM *); /* print a prime */ static void usage(void); @@ -148,21 +150,13 @@ main(int argc, char *argv[]) for (p = buf; isblank(*p); ++p); if (*p == '\n' || *p == '\0') continue; - if (*p == '-') - errx(1, "negative numbers aren't permitted."); - if (BN_dec2bn(&val, buf) == 0 && - BN_hex2bn(&val, buf) == 0) - errx(1, "%s: illegal numeric format.", buf); + convert_str2bn(&val, p); pr_fact(val); } /* Factor the arguments. */ else - for (; *argv != NULL; ++argv) { - if (argv[0][0] == '-') - errx(1, "negative numbers aren't permitted."); - if (BN_dec2bn(&val, argv[0]) == 0 && - BN_hex2bn(&val, argv[0]) == 0) - errx(1, "%s: illegal numeric format.", argv[0]); + for (p = *argv; p != NULL; p = *++argv) { + convert_str2bn(&val, p); pr_fact(val); } exit(0); @@ -346,7 +340,7 @@ BN_dec2bn(BIGNUM **a, const char *str) errno = 0; **a = strtoul(str, &p, 10); - return (errno == 0 && (*p == '\n' || *p == '\0')); + return (errno == 0 ? 1 : 0); /* OpenSSL returns 0 on error! */ } static int @@ -356,7 +350,7 @@ BN_hex2bn(BIGNUM **a, const char *str) errno = 0; **a = strtoul(str, &p, 16); - return (errno == 0 && (*p == '\n' || *p == '\0')); + return (errno == 0 ? 1 : 0); /* OpenSSL returns 0 on error! */ } static BN_ULONG @@ -370,3 +364,46 @@ BN_div_word(BIGNUM *a, BN_ULONG b) } #endif + +/* + * Scan the string from left-to-right to see if the longest substring + * is a valid hexadecimal number. + */ +static bool +is_hex_str(char *str) +{ + char c, *p; + bool saw_hex = false; + + for (p = str; *p; p++) { + if (isdigit(*p)) + continue; + c = tolower(*p); + if (c >= 'a' && c <= 'f') { + saw_hex = true; + continue; + } + break; /* Not a hexadecimal digit. */ + } + return saw_hex; +} + +/* Convert string pointed to by *str to a bignum. */ +static void +convert_str2bn(BIGNUM **val, char *p) +{ + int n = 0; + + if (*p == '+') p++; + if (*p == '-') + errx(1, "negative numbers aren't permitted."); + if (*p == '0') { + p++; + if (*p == 'x' || *p == 'X') + n = BN_hex2bn(val, ++p); + } else { + n = is_hex_str(p) ? BN_hex2bn(val, p) : BN_dec2bn(val, p); + } + if (n == 0) + errx(1, "%s: illegal numeric format.", p); +} Modified: head/usr.bin/primes/primes.c ============================================================================== --- head/usr.bin/primes/primes.c Sun Jan 12 20:19:00 2020 (r356665) +++ head/usr.bin/primes/primes.c Sun Jan 12 20:25:11 2020 (r356666) @@ -55,8 +55,8 @@ static const char rcsid[] = * primes [-h] [start [stop]] * * Print primes >= start and < stop. If stop is omitted, - * the value 4294967295 (2^32-1) is assumed. If start is - * omitted, start is read from standard input. + * the value 18446744073709551615 (2^64-1) is assumed. If + * start is omitted, start is read from standard input. * * validation check: there are 664579 primes between 0 and 10^7 */ From owner-svn-src-all@freebsd.org Sun Jan 12 20:47:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E97261EA370; Sun, 12 Jan 2020 20:47:39 +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 47wpgv5wbxz4pKv; Sun, 12 Jan 2020 20:47:39 +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 C202C216EA; Sun, 12 Jan 2020 20:47:39 +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 00CKldg3084097; Sun, 12 Jan 2020 20:47:39 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CKld5M084094; Sun, 12 Jan 2020 20:47:39 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202001122047.00CKld5M084094@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sun, 12 Jan 2020 20:47:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356667 - in head: lib/libc/sys sys/kern sys/sys X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: lib/libc/sys sys/kern sys/sys X-SVN-Commit-Revision: 356667 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 20:47:40 -0000 Author: cem Date: Sun Jan 12 20:47:38 2020 New Revision: 356667 URL: https://svnweb.freebsd.org/changeset/base/356667 Log: getrandom(2): Add Linux GRND_INSECURE API flag Treat it as a synonym for GRND_NONBLOCK. The reasoning is this: We have two choices for handling Linux's GRND_INSECURE API flag. 1. We could ignore it completely (like GRND_RANDOM). However, this might produce the surprising result of GRND_INSECURE requests blocking, when the Linux API does not block. 2. Alternatively, we could treat GRND_INSECURE requests as requests for GRND_NONBLOCk. Here, the surprising result for Linux programs is that invocations with unseeded random(4) will produce EAGAIN, rather than garbage. Honoring the flag in the way Linux does seems fraught. If we actually use the output of a random(4) implementation prior to seeding, we leak some entropy (in an information theory and also practical sense) from what will be the initial seed to attackers (or allow attackers to arbitrary DoS initial seeding, if we don't leak). This seems unacceptable -- it defeats the purpose of blocking on initial seeding. Secondary to that concern, before seeding we may have arbitrarily little entropy collected; producing output from zero or a handful of entropy bits does not seem particularly useful to userspace. If userspace can accept garbage, insecure, non-random bytes, they can create their own insecure garbage with srandom(time(NULL)) or similar. Any program which would be satisfied with a 3-bit key CTR stream has no need for CSPRNG bytes. So asking the kernel to produce such an output from the secure getrandom(2) API seems inane. For now, we've elected to emulate GRND_INSECURE as an alternative spelling of GRND_NONBLOCK (2). Consider this API not-quite stable for now. We guarantee it will never block. But we will attempt to monitor actual port uptake of this bizarre API and may revise our plans for the unseeded behavior (prior stable/13 branching). Approved by: csprng(markm), manpages(bcr) See also: https://lwn.net/ml/linux-kernel/cover.1577088521.git.luto@kernel.org/ See also: https://lwn.net/ml/linux-kernel/20200107204400.GH3619@mit.edu/ Differential Revision: https://reviews.freebsd.org/D23130 Modified: head/lib/libc/sys/getrandom.2 head/sys/kern/sys_getrandom.c head/sys/sys/random.h Modified: head/lib/libc/sys/getrandom.2 ============================================================================== --- head/lib/libc/sys/getrandom.2 Sun Jan 12 20:25:11 2020 (r356666) +++ head/lib/libc/sys/getrandom.2 Sun Jan 12 20:47:38 2020 (r356667) @@ -1,5 +1,4 @@ -.\" Copyright (c) 2018 Conrad Meyer -.\" All rights reserved. +.\" Copyright 2020, 2018 Conrad Meyer . All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -24,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 24, 2018 +.Dd January 12, 2020 .Dt GETRANDOM 2 .Os .Sh NAME @@ -64,13 +63,16 @@ This flag does nothing on and .Pa /dev/urandom are identical. +.It Ql GRND_INSECURE +This flag is treated as an alternative name for +.Dv GRND_NONBLOCK . +It is provided solely for API compatibility with Linux. .El .Pp If the .Xr random 4 device has been seeded, reads of up to 256 bytes will always return as many bytes as requested and will not be interrupted by signals. -.Pp .Sh RETURN VALUES Upon successful completion, the number of bytes which were actually read is returned. @@ -87,6 +89,8 @@ operation returns the following errors: .It Bq Er EAGAIN The .Ql GRND_NONBLOCK +(or +.Ql GRND_INSECURE ) flag was set and the .Xr random 4 device was not yet seeded. @@ -111,7 +115,7 @@ was larger than .Xr getentropy 3 , .Xr random 4 .Sh STANDARDS -.Fn getentropy +.Fn getrandom is non-standard. It is present in Linux. .Sh HISTORY @@ -119,3 +123,11 @@ The .Fn getrandom system call first appeared in .Fx 12.0 . +.Sh CAVEATS +Unlike Linux, the +.Dv GRND_INSECURE +flag on +.Fx +does not produce any output before the +.Xr random 4 +device is seeded. Modified: head/sys/kern/sys_getrandom.c ============================================================================== --- head/sys/kern/sys_getrandom.c Sun Jan 12 20:25:11 2020 (r356666) +++ head/sys/kern/sys_getrandom.c Sun Jan 12 20:47:38 2020 (r356667) @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define GRND_VALIDFLAGS (GRND_NONBLOCK | GRND_RANDOM) +#define GRND_VALIDFLAGS (GRND_NONBLOCK | GRND_RANDOM | GRND_INSECURE) /* * random_read_uio(9) returns EWOULDBLOCK if a nonblocking request would block, @@ -59,6 +59,40 @@ kern_getrandom(struct thread *td, void *user_buf, size return (EINVAL); if (buflen > IOSIZE_MAX) return (EINVAL); + + /* + * Linux compatibility: We have two choices for handling Linux's + * GRND_INSECURE. + * + * 1. We could ignore it completely (like GRND_RANDOM). However, this + * might produce the surprising result of GRND_INSECURE requests + * blocking, when the Linux API does not block. + * + * 2. Alternatively, we could treat GRND_INSECURE requests as requests + * for GRND_NONBLOCk. Here, the surprising result for Linux programs + * is that invocations with unseeded random(4) will produce EAGAIN, + * rather than garbage. + * + * Honoring the flag in the way Linux does seems fraught. If we + * actually use the output of a random(4) implementation prior to + * seeding, we leak some entropy about the initial seed to attackers. + * This seems unacceptable -- it defeats the purpose of blocking on + * initial seeding. + * + * Secondary to that concern, before seeding we may have arbitrarily + * little entropy collected; producing output from zero or a handful of + * entropy bits does not seem particularly useful to userspace. + * + * If userspace can accept garbage, insecure non-random bytes, they can + * create their own insecure garbage with srandom(time(NULL)) or + * similar. Asking the kernel to produce it from the secure + * getrandom(2) API seems inane. + * + * We elect to emulate GRND_INSECURE as an alternative spelling of + * GRND_NONBLOCK (2). + */ + if ((flags & GRND_INSECURE) != 0) + flags |= GRND_NONBLOCK; if (buflen == 0) { td->td_retval[0] = 0; Modified: head/sys/sys/random.h ============================================================================== --- head/sys/sys/random.h Sun Jan 12 20:25:11 2020 (r356666) +++ head/sys/sys/random.h Sun Jan 12 20:47:38 2020 (r356667) @@ -159,6 +159,7 @@ void random_harvest_deregister_source(enum random_entr #define GRND_NONBLOCK 0x1 #define GRND_RANDOM 0x2 +#define GRND_INSECURE 0x4 __BEGIN_DECLS ssize_t getrandom(void *buf, size_t buflen, unsigned int flags); From owner-svn-src-all@freebsd.org Sun Jan 12 23:52:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2D221EF67A; Sun, 12 Jan 2020 23:52:17 +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 47wtmx2crsz3FZn; Sun, 12 Jan 2020 23:52:17 +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 553D623B10; Sun, 12 Jan 2020 23:52:17 +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 00CNqHYO018003; Sun, 12 Jan 2020 23:52:17 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00CNqHG2018001; Sun, 12 Jan 2020 23:52:17 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202001122352.00CNqHG2018001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sun, 12 Jan 2020 23:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356668 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 356668 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 23:52:17 -0000 Author: cem Date: Sun Jan 12 23:52:16 2020 New Revision: 356668 URL: https://svnweb.freebsd.org/changeset/base/356668 Log: Fix a typo in r356667 comment No functional change. Reported by: bdragon Approved by: csprng(markm), earlier version X-MFC-With: r356667 Modified: head/sys/kern/sys_getrandom.c Modified: head/sys/kern/sys_getrandom.c ============================================================================== --- head/sys/kern/sys_getrandom.c Sun Jan 12 20:47:38 2020 (r356667) +++ head/sys/kern/sys_getrandom.c Sun Jan 12 23:52:16 2020 (r356668) @@ -69,7 +69,7 @@ kern_getrandom(struct thread *td, void *user_buf, size * blocking, when the Linux API does not block. * * 2. Alternatively, we could treat GRND_INSECURE requests as requests - * for GRND_NONBLOCk. Here, the surprising result for Linux programs + * for GRND_NONBLOCK. Here, the surprising result for Linux programs * is that invocations with unseeded random(4) will produce EAGAIN, * rather than garbage. * From owner-svn-src-all@freebsd.org Mon Jan 13 02:31:54 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37EB31F2FEE; Mon, 13 Jan 2020 02:31:54 +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 47wyK61VVFz3M8w; Mon, 13 Jan 2020 02:31:54 +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 2E8D125810; Mon, 13 Jan 2020 02:31:54 +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 00D2Vs3E025355; Mon, 13 Jan 2020 02:31:54 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00D2Vpbp025339; Mon, 13 Jan 2020 02:31:51 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001130231.00D2Vpbp025339@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 13 Jan 2020 02:31:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356669 - in head/sys/ufs: ffs ufs X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys/ufs: ffs ufs X-SVN-Commit-Revision: 356669 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jan 2020 02:31:54 -0000 Author: mjg Date: Mon Jan 13 02:31:51 2020 New Revision: 356669 URL: https://svnweb.freebsd.org/changeset/base/356669 Log: ufs: add a setter for inode i_flag field This will be used later to add vnodes to the lazy list. Reviewed by: kib (previous version), jeff Tested by: pho (in a larger patch) Differential Revision: https://reviews.freebsd.org/D22994 Modified: head/sys/ufs/ffs/ffs_alloc.c head/sys/ufs/ffs/ffs_balloc.c head/sys/ufs/ffs/ffs_inode.c head/sys/ufs/ffs/ffs_snapshot.c head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/ffs_vfsops.c head/sys/ufs/ffs/ffs_vnops.c head/sys/ufs/ufs/inode.h head/sys/ufs/ufs/ufs_acl.c head/sys/ufs/ufs/ufs_inode.c head/sys/ufs/ufs/ufs_lookup.c head/sys/ufs/ufs/ufs_vnops.c Modified: head/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_alloc.c Sun Jan 12 23:52:16 2020 (r356668) +++ head/sys/ufs/ffs/ffs_alloc.c Mon Jan 13 02:31:51 2020 (r356669) @@ -202,9 +202,9 @@ retry: delta = btodb(size); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + delta); if (flags & IO_EXT) - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); else - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); *bnp = bno; return (0); } @@ -329,9 +329,9 @@ retry: delta = btodb(nsize - osize); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + delta); if (flags & IO_EXT) - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); else - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); allocbuf(bp, nsize); bp->b_flags |= B_DONE; vfs_bio_bzero_buf(bp, osize, nsize - osize); @@ -413,9 +413,9 @@ retry: delta = btodb(nsize - osize); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + delta); if (flags & IO_EXT) - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); else - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); allocbuf(bp, nsize); bp->b_flags |= B_DONE; vfs_bio_bzero_buf(bp, osize, nsize - osize); @@ -743,7 +743,7 @@ ffs_reallocblks_ufs1(ap) else bwrite(sbp); } else { - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (!doasyncfree) ffs_update(vp, 1); } @@ -1007,7 +1007,7 @@ ffs_reallocblks_ufs2(ap) else bwrite(sbp); } else { - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (!doasyncfree) ffs_update(vp, 1); } @@ -1150,7 +1150,7 @@ retry: ip = VTOI(*vpp); if (ip->i_mode) goto dup_alloc; - ip->i_flag |= IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_MODIFIED); vput(*vpp); } return (error); @@ -1185,7 +1185,7 @@ dup_alloc: (*vpp)->v_type = VNON; if (fs->fs_magic == FS_UFS2_MAGIC) { (*vpp)->v_op = &ffs_vnodeops2; - ip->i_flag |= IN_UFS2; + UFS_INODE_SET_FLAG(ip, IN_UFS2); } else { (*vpp)->v_op = &ffs_vnodeops1; } @@ -3238,7 +3238,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) ip->i_nlink += cmd.size; DIP_SET(ip, i_nlink, ip->i_nlink); ip->i_effnlink += cmd.size; - ip->i_flag |= IN_CHANGE | IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_MODIFIED); error = ffs_update(vp, 1); if (DOINGSOFTDEP(vp)) softdep_change_linkcnt(ip); @@ -3257,7 +3257,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) break; ip = VTOI(vp); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + cmd.size); - ip->i_flag |= IN_CHANGE | IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_MODIFIED); error = ffs_update(vp, 1); vput(vp); break; @@ -3274,7 +3274,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) break; ip = VTOI(vp); DIP_SET(ip, i_size, cmd.size); - ip->i_flag |= IN_CHANGE | IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_MODIFIED); error = ffs_update(vp, 1); vput(vp); break; @@ -3494,7 +3494,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) vput(vp); break; } - ip->i_flag |= IN_CHANGE | IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_MODIFIED); error = ffs_update(vp, 1); vput(vp); break; Modified: head/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_balloc.c Sun Jan 12 23:52:16 2020 (r356668) +++ head/sys/ufs/ffs/ffs_balloc.c Mon Jan 13 02:31:51 2020 (r356669) @@ -154,7 +154,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, i ip->i_size = smalllblktosize(fs, nb + 1); dp->di_size = ip->i_size; dp->di_db[nb] = dbtofsb(fs, bp->b_blkno); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (flags & IO_SYNC) bwrite(bp); else if (DOINGASYNC(vp)) @@ -224,7 +224,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, i nsize, 0, bp); } dp->di_db[lbn] = dbtofsb(fs, bp->b_blkno); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); *bpp = bp; return (0); } @@ -280,7 +280,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, i } allocib = &dp->di_ib[indirs[0].in_off]; *allocib = nb; - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } /* * Fetch through the indirect blocks, allocating as necessary. @@ -542,7 +542,7 @@ fail: (void) chkdq(ip, -btodb(deallocated), cred, FORCE); #endif dp->di_blocks -= btodb(deallocated); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } (void) ffs_syncvnode(vp, MNT_WAIT, 0); /* @@ -645,7 +645,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i dp->di_extsize = smalllblktosize(fs, nb + 1); dp->di_extb[nb] = dbtofsb(fs, bp->b_blkno); bp->b_xflags |= BX_ALTDATA; - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); if (flags & IO_SYNC) bwrite(bp); else @@ -719,7 +719,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i nsize, 0, bp); } dp->di_extb[lbn] = dbtofsb(fs, bp->b_blkno); - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); *bpp = bp; return (0); } @@ -748,7 +748,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i ip->i_size = smalllblktosize(fs, nb + 1); dp->di_size = ip->i_size; dp->di_db[nb] = dbtofsb(fs, bp->b_blkno); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (flags & IO_SYNC) bwrite(bp); else @@ -818,7 +818,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i nsize, 0, bp); } dp->di_db[lbn] = dbtofsb(fs, bp->b_blkno); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); *bpp = bp; return (0); } @@ -875,7 +875,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i } allocib = &dp->di_ib[indirs[0].in_off]; *allocib = nb; - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } /* * Fetch through the indirect blocks, allocating as necessary. @@ -1144,7 +1144,7 @@ fail: (void) chkdq(ip, -btodb(deallocated), cred, FORCE); #endif dp->di_blocks -= btodb(deallocated); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } (void) ffs_syncvnode(vp, MNT_WAIT, 0); /* Modified: head/sys/ufs/ffs/ffs_inode.c ============================================================================== --- head/sys/ufs/ffs/ffs_inode.c Sun Jan 12 23:52:16 2020 (r356668) +++ head/sys/ufs/ffs/ffs_inode.c Mon Jan 13 02:31:51 2020 (r356669) @@ -275,7 +275,7 @@ ffs_truncate(vp, length, flags, cred) oldblks[i] = ip->i_din2->di_extb[i]; ip->i_din2->di_extb[i] = 0; } - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); if ((error = ffs_update(vp, waitforupdate))) return (error); for (i = 0; i < UFS_NXADDR; i++) { @@ -299,13 +299,13 @@ ffs_truncate(vp, length, flags, cred) bzero(SHORTLINK(ip), (u_int)ip->i_size); ip->i_size = 0; DIP_SET(ip, i_size, 0); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (needextclean) goto extclean; return (ffs_update(vp, waitforupdate)); } if (ip->i_size == length) { - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); if (needextclean) goto extclean; return (ffs_update(vp, 0)); @@ -339,7 +339,7 @@ ffs_truncate(vp, length, flags, cred) bdwrite(bp); else bawrite(bp); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); return (ffs_update(vp, waitforupdate)); } /* @@ -405,7 +405,7 @@ ffs_truncate(vp, length, flags, cred) softdep_setup_freeblocks(ip, length, flags); ASSERT_VOP_LOCKED(vp, "ffs_truncate1"); if (journaltrunc == 0) { - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); error = ffs_update(vp, 0); } return (error); @@ -489,7 +489,7 @@ ffs_truncate(vp, length, flags, cred) if (i > lastblock) DIP_SET(ip, i_db[i], 0); } - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); allerror = ffs_update(vp, waitforupdate); /* @@ -619,7 +619,7 @@ done: DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - blocksreleased); else /* sanity */ DIP_SET(ip, i_blocks, 0); - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); #ifdef QUOTA (void) chkdq(ip, -blocksreleased, NOCRED, FORCE); #endif Modified: head/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- head/sys/ufs/ffs/ffs_snapshot.c Sun Jan 12 23:52:16 2020 (r356668) +++ head/sys/ufs/ffs/ffs_snapshot.c Mon Jan 13 02:31:51 2020 (r356669) @@ -319,7 +319,7 @@ restart: goto out; ip->i_size = lblktosize(fs, (off_t)numblks); DIP_SET(ip, i_size, ip->i_size); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); error = readblock(vp, bp, numblks - 1); bawrite(bp); if (error != 0) @@ -401,7 +401,7 @@ restart: */ ip->i_flags |= SF_SNAPSHOT; DIP_SET(ip, i_flags, ip->i_flags); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * Ensure that the snapshot is completely on disk. * Since we have marked it as a snapshot it is safe to @@ -1215,7 +1215,7 @@ snapacct_ufs1(vp, oldblkp, lastblkp, fs, lblkno, expun lbn = fragstoblks(fs, blkno); if (lbn < UFS_NDADDR) { blkp = &ip->i_din1->di_db[lbn]; - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } else { error = ffs_balloc_ufs1(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp); @@ -1501,7 +1501,7 @@ snapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expun lbn = fragstoblks(fs, blkno); if (lbn < UFS_NDADDR) { blkp = &ip->i_din2->di_db[lbn]; - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } else { error = ffs_balloc_ufs2(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp); @@ -1724,7 +1724,7 @@ ffs_snapremove(vp) */ ip->i_flags &= ~SF_SNAPSHOT; DIP_SET(ip, i_flags, ip->i_flags); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * The dirtied indirects must be written out before * softdep_setup_freeblocks() is called. Otherwise indir_trunc() @@ -1830,7 +1830,7 @@ retry: panic("snapblkfree: inconsistent block type"); if (lbn < UFS_NDADDR) { DIP_SET(ip, i_db[lbn], BLK_NOCOPY); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); } else if (I_IS_UFS1(ip)) { ((ufs1_daddr_t *)(ibp->b_data))[indiroff] = BLK_NOCOPY; @@ -1887,7 +1887,7 @@ retry: bdwrite(ibp); } DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + btodb(size)); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); lockmgr(vp->v_vnlock, LK_RELEASE, NULL); return (1); } @@ -2580,7 +2580,7 @@ process_deferred_inactive(struct mount *mp) ip = VTOI(vp); if ((ip->i_flag & IN_LAZYACCESS) != 0) { ip->i_flag &= ~IN_LAZYACCESS; - ip->i_flag |= IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_MODIFIED); } VI_LOCK(vp); if ((vp->v_iflag & VI_OWEINACT) == 0 || vp->v_usecount > 0) { Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sun Jan 12 23:52:16 2020 (r356668) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Jan 13 02:31:51 2020 (r356669) @@ -6656,7 +6656,7 @@ softdep_journal_freeblocks(ip, cred, length, flags) * journaling. */ if (length != 0 && lastlbn >= UFS_NDADDR) { - ip->i_flag |= IN_TRUNCATED; + UFS_INODE_SET_FLAG(ip, IN_TRUNCATED); newjtrunc(freeblks, length, 0); } ip->i_size = length; @@ -6780,7 +6780,7 @@ softdep_journal_freeblocks(ip, cred, length, flags) } ip->i_size = length; DIP_SET(ip, i_size, length); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); allocbuf(bp, frags); ffs_update(vp, 0); bawrite(bp); @@ -7647,7 +7647,7 @@ softdep_freefile(pvp, ino, mode) WORKLIST_INSERT(&inodedep->id_inowait, &freefile->fx_list); FREE_LOCK(ump); if (ip->i_number == ino) - ip->i_flag |= IN_MODIFIED; + UFS_INODE_SET_FLAG(ip, IN_MODIFIED); } /* @@ -8056,7 +8056,7 @@ handle_complete_freeblocks(freeblks, flags) vgone(vp); } else if (DIP(ip, i_modrev) == freeblks->fb_modrev) { DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - spare); - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); /* * We must wait so this happens before the * journal is reclaimed. @@ -9873,7 +9873,7 @@ handle_workitem_remove(dirrem, flags) "%ju negative i_nlink %d", (intmax_t)ip->i_number, ip->i_nlink)); DIP_SET(ip, i_nlink, ip->i_nlink); - ip->i_flag |= IN_CHANGE; + UFS_INODE_SET_FLAG(ip, IN_CHANGE); if (ip->i_nlink < ip->i_effnlink) panic("handle_workitem_remove: bad file delta"); if (ip->i_nlink == 0) @@ -9896,7 +9896,7 @@