From owner-dev-commits-src-branches@freebsd.org Mon Apr 5 08:04:21 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 613915C6324; Mon, 5 Apr 2021 08:04:21 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDNTx26czz3QLv; Mon, 5 Apr 2021 08:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A1CF15416; Mon, 5 Apr 2021 08:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13584LrV018409; Mon, 5 Apr 2021 08:04:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13584L9G018408; Mon, 5 Apr 2021 08:04:21 GMT (envelope-from git) Date: Mon, 5 Apr 2021 08:04:21 GMT Message-Id: <202104050804.13584L9G018408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 75b13b151c9e - stable/13 - netmap: iflib: add nm_config callback MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 75b13b151c9e3d8fd71eab3578d4a83b067dadf6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 08:04:21 -0000 The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=75b13b151c9e3d8fd71eab3578d4a83b067dadf6 commit 75b13b151c9e3d8fd71eab3578d4a83b067dadf6 Author: Vincenzo Maffione AuthorDate: 2021-03-29 09:26:12 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-05 08:04:00 +0000 netmap: iflib: add nm_config callback This per-driver callback is invoked by netmap when it wants to align the number of TX/RX netmap rings and/or the number of TX/RX netmap slots to the actual state configured in the hardware. The alignment happens when netmap mode is switched on (with no active netmap file descriptors for that netmap port), or when collecting netmap port information. MFC after: 1 week (cherry picked from commit 21d0c01226eb979556d6d792ec58eb54012fbc24) --- sys/net/iflib.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 9f3eff555728..788cc51822a1 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -829,6 +829,26 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) return (status); } +static int +iflib_netmap_config(struct netmap_adapter *na, struct nm_config_info *info) +{ + if_t ifp = na->ifp; + if_ctx_t ctx = ifp->if_softc; + iflib_rxq_t rxq = &ctx->ifc_rxqs[0]; + iflib_fl_t fl = &rxq->ifr_fl[0]; + + info->num_tx_rings = ctx->ifc_softc_ctx.isc_ntxqsets; + info->num_rx_rings = ctx->ifc_softc_ctx.isc_nrxqsets; + info->num_tx_descs = iflib_num_tx_descs(ctx); + info->num_rx_descs = iflib_num_rx_descs(ctx); + info->rx_buf_maxsize = fl->ifl_buf_size; + nm_prinf("txr %u rxr %u txd %u rxd %u rbufsz %u", + info->num_tx_rings, info->num_rx_rings, info->num_tx_descs, + info->num_rx_descs, info->rx_buf_maxsize); + + return 0; +} + static int netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring *kring, bool init) { @@ -1279,6 +1299,7 @@ iflib_netmap_attach(if_ctx_t ctx) na.nm_rxsync = iflib_netmap_rxsync; na.nm_register = iflib_netmap_register; na.nm_intr = iflib_netmap_intr; + na.nm_config = iflib_netmap_config; na.num_tx_rings = ctx->ifc_softc_ctx.isc_ntxqsets; na.num_rx_rings = ctx->ifc_softc_ctx.isc_nrxqsets; return (netmap_attach(&na)); From owner-dev-commits-src-branches@freebsd.org Mon Apr 5 08:09:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 68B555C6684; Mon, 5 Apr 2021 08:09:36 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDNc021Ykz3QmW; Mon, 5 Apr 2021 08:09:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36DD815594; Mon, 5 Apr 2021 08:09:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13589aS3019305; Mon, 5 Apr 2021 08:09:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13589aJm019304; Mon, 5 Apr 2021 08:09:36 GMT (envelope-from git) Date: Mon, 5 Apr 2021 08:09:36 GMT Message-Id: <202104050809.13589aJm019304@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 8d415b19409b - stable/12 - netmap: iflib: add nm_config callback MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8d415b19409b7709193b2f045d75a6b3bdeaf290 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 08:09:36 -0000 The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=8d415b19409b7709193b2f045d75a6b3bdeaf290 commit 8d415b19409b7709193b2f045d75a6b3bdeaf290 Author: Vincenzo Maffione AuthorDate: 2021-03-29 09:26:12 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-05 08:05:16 +0000 netmap: iflib: add nm_config callback This per-driver callback is invoked by netmap when it wants to align the number of TX/RX netmap rings and/or the number of TX/RX netmap slots to the actual state configured in the hardware. The alignment happens when netmap mode is switched on (with no active netmap file descriptors for that netmap port), or when collecting netmap port information. MFC after: 1 week (cherry picked from commit 21d0c01226eb979556d6d792ec58eb54012fbc24) --- sys/net/iflib.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index f99b076cf0d3..1976852209a1 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -835,6 +835,26 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) return (status); } +static int +iflib_netmap_config(struct netmap_adapter *na, struct nm_config_info *info) +{ + if_t ifp = na->ifp; + if_ctx_t ctx = ifp->if_softc; + iflib_rxq_t rxq = &ctx->ifc_rxqs[0]; + iflib_fl_t fl = &rxq->ifr_fl[0]; + + info->num_tx_rings = ctx->ifc_softc_ctx.isc_ntxqsets; + info->num_rx_rings = ctx->ifc_softc_ctx.isc_nrxqsets; + info->num_tx_descs = iflib_num_tx_descs(ctx); + info->num_rx_descs = iflib_num_rx_descs(ctx); + info->rx_buf_maxsize = fl->ifl_buf_size; + nm_prinf("txr %u rxr %u txd %u rxd %u rbufsz %u", + info->num_tx_rings, info->num_rx_rings, info->num_tx_descs, + info->num_rx_descs, info->rx_buf_maxsize); + + return 0; +} + static int netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring *kring, bool init) { @@ -1286,6 +1306,7 @@ iflib_netmap_attach(if_ctx_t ctx) na.nm_rxsync = iflib_netmap_rxsync; na.nm_register = iflib_netmap_register; na.nm_intr = iflib_netmap_intr; + na.nm_config = iflib_netmap_config; na.num_tx_rings = ctx->ifc_softc_ctx.isc_ntxqsets; na.num_rx_rings = ctx->ifc_softc_ctx.isc_nrxqsets; return (netmap_attach(&na)); From owner-dev-commits-src-branches@freebsd.org Mon Apr 5 08:44:02 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 ECC595C72A6; Mon, 5 Apr 2021 08:44:02 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDPMk6G5fz3j2B; Mon, 5 Apr 2021 08:44:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C85AD15E8E; Mon, 5 Apr 2021 08:44:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1358i2EO074343; Mon, 5 Apr 2021 08:44:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1358i2Ga074342; Mon, 5 Apr 2021 08:44:02 GMT (envelope-from git) Date: Mon, 5 Apr 2021 08:44:02 GMT Message-Id: <202104050844.1358i2Ga074342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: c5f88140d0e8 - stable/13 - cnv(9): Use a proper manual page section MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c5f88140d0e83c77ae8b25fc1e2b09e14a49c8a5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 08:44:03 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c5f88140d0e83c77ae8b25fc1e2b09e14a49c8a5 commit c5f88140d0e83c77ae8b25fc1e2b09e14a49c8a5 Author: Gordon Bergling AuthorDate: 2021-01-27 17:18:17 +0000 Commit: Gordon Bergling CommitDate: 2021-04-05 08:43:32 +0000 cnv(9): Use a proper manual page section (cherry picked from commit 8dba3dd846cf60c9014f81b099058a9023477096) --- share/man/man9/cnv.9 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man9/cnv.9 b/share/man/man9/cnv.9 index 737a1b2fb518..eaae3f7156ab 100644 --- a/share/man/man9/cnv.9 +++ b/share/man/man9/cnv.9 @@ -166,7 +166,7 @@ resources. If an element of the given cookie has the wrong type or does not exist, the program is aborted. -.Sh EXAMPLE +.Sh EXAMPLES The following example demonstrates how to deal with cnvlist API. .Bd -literal int type; From owner-dev-commits-src-branches@freebsd.org Mon Apr 5 08:53:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 BDEDB5C72EA; Mon, 5 Apr 2021 08:53:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDPZ44pKTz3jST; Mon, 5 Apr 2021 08:53:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9684215E46; Mon, 5 Apr 2021 08:53:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1358r0Cc087960; Mon, 5 Apr 2021 08:53:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1358r023087959; Mon, 5 Apr 2021 08:53:00 GMT (envelope-from git) Date: Mon, 5 Apr 2021 08:53:00 GMT Message-Id: <202104050853.1358r023087959@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: 95a466b20d92 - stable/13 - VOP_BMAP(9): Remove obsolete comma MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 95a466b20d92e8016058ec8bad46b63ca06dc60d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 08:53:00 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=95a466b20d92e8016058ec8bad46b63ca06dc60d commit 95a466b20d92e8016058ec8bad46b63ca06dc60d Author: Gordon Bergling AuthorDate: 2021-01-27 17:20:04 +0000 Commit: Gordon Bergling CommitDate: 2021-04-05 08:52:40 +0000 VOP_BMAP(9): Remove obsolete comma (cherry picked from commit 8a2f9dff2b9393503f63902c6ba7802efd8d6e49) --- share/man/man9/VOP_BMAP.9 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man9/VOP_BMAP.9 b/share/man/man9/VOP_BMAP.9 index 7ddb2b52c7ca..02869838274b 100644 --- a/share/man/man9/VOP_BMAP.9 +++ b/share/man/man9/VOP_BMAP.9 @@ -75,7 +75,7 @@ The vnode will be locked on entry and should remain locked on return. .Sh RETURN VALUES Zero is returned on success, otherwise an error code is returned. .Sh SEE ALSO -.Xr vnode 9 , +.Xr vnode 9 .Sh HISTORY A .Fn bmap From owner-dev-commits-src-branches@freebsd.org Mon Apr 5 13:51:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A45625B9EFC; Mon, 5 Apr 2021 13:51:59 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDXC34B8xz4Zxd; Mon, 5 Apr 2021 13:51:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 80D9A19B37; Mon, 5 Apr 2021 13:51:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 135Dpxtn028092; Mon, 5 Apr 2021 13:51:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 135Dpxr7028091; Mon, 5 Apr 2021 13:51:59 GMT (envelope-from git) Date: Mon, 5 Apr 2021 13:51:59 GMT Message-Id: <202104051351.135Dpxr7028091@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d3f2c31b43b7 - stable/13 - traceroute6: Fix Capsicum rights for rcvsock MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d3f2c31b43b726ffbb180a42cee4b9f00c5ad5ed Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 13:51:59 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d3f2c31b43b726ffbb180a42cee4b9f00c5ad5ed commit d3f2c31b43b726ffbb180a42cee4b9f00c5ad5ed Author: Mark Johnston AuthorDate: 2021-04-01 13:58:32 +0000 Commit: Mark Johnston CommitDate: 2021-04-05 13:51:56 +0000 traceroute6: Fix Capsicum rights for rcvsock - Always use distinct sockets for send and recv - Limit rights on the recv socket For ICMP6 we were using the same socket for both send and receive, and we limited rights on the socket such that it's impossible to receive anything. PR: 254623 Diagnosed by: Zhenlei Huang Reviewed by: oshogbo Differential Revision: https://reviews.freebsd.org/D29523 (cherry picked from commit b8ae450f05e62a851f444edaf7db2506ff99aa37) --- usr.sbin/traceroute6/traceroute6.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index 7663283a6c44..8449a9861302 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -578,8 +578,6 @@ main(int argc, char *argv[]) */ switch (useproto) { case IPPROTO_ICMPV6: - sndsock = rcvsock; - break; case IPPROTO_NONE: case IPPROTO_SCTP: case IPPROTO_TCP: @@ -928,7 +926,6 @@ main(int argc, char *argv[]) * namespaces (e.g filesystem) is restricted (see capsicum(4)). * We must connect(2) our socket before this point. */ - if (caph_enter_casper() < 0) { fprintf(stderr, "caph_enter_casper: %s\n", strerror(errno)); exit(1); @@ -940,6 +937,12 @@ main(int argc, char *argv[]) strerror(errno)); exit(1); } + cap_rights_init(&rights, CAP_RECV); + if (caph_rights_limit(rcvsock, &rights) < 0) { + fprintf(stderr, "caph_rights_limit rcvsock: %s\n", + strerror(errno)); + exit(1); + } /* * Main loop From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 00:48:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 AF3D85CC4C4; Tue, 6 Apr 2021 00:48:17 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDpmK4QYzz4Vlt; Tue, 6 Apr 2021 00:48:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 845722280F; Tue, 6 Apr 2021 00:48:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1360mHYn043307; Tue, 6 Apr 2021 00:48:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1360mHcL043306; Tue, 6 Apr 2021 00:48:17 GMT (envelope-from git) Date: Tue, 6 Apr 2021 00:48:17 GMT Message-Id: <202104060048.1360mHcL043306@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3a014191d72b - stable/13 - libc//sys/cerror.S: fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3a014191d72ba55861009487072a7fa72b935469 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 00:48:17 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3a014191d72ba55861009487072a7fa72b935469 commit 3a014191d72ba55861009487072a7fa72b935469 Author: Konstantin Belousov AuthorDate: 2021-04-03 01:36:41 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-06 00:47:34 +0000 libc//sys/cerror.S: fix typo (cherry picked from commit 4c2e9c35fb1958544040493e4fd8d8b8a0927677) --- lib/libc/amd64/sys/cerror.S | 2 +- lib/libc/i386/sys/cerror.S | 2 +- lib/libc/powerpc/sys/cerror.S | 2 +- lib/libc/powerpc64/sys/cerror.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/amd64/sys/cerror.S b/lib/libc/amd64/sys/cerror.S index ffce9d561993..1928acd0b7a9 100644 --- a/lib/libc/amd64/sys/cerror.S +++ b/lib/libc/amd64/sys/cerror.S @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); /* * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, + * programs and the initial thread in threaded programs, * it returns a pointer to the global errno variable. */ .globl CNAME(__error) diff --git a/lib/libc/i386/sys/cerror.S b/lib/libc/i386/sys/cerror.S index 423d716cb651..47bd0fade000 100644 --- a/lib/libc/i386/sys/cerror.S +++ b/lib/libc/i386/sys/cerror.S @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); /* * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, + * programs and the initial thread in threaded programs, * it returns a pointer to the global errno variable. */ .globl CNAME(__error) diff --git a/lib/libc/powerpc/sys/cerror.S b/lib/libc/powerpc/sys/cerror.S index c2bc994b9c33..9ec3cbaf63a2 100644 --- a/lib/libc/powerpc/sys/cerror.S +++ b/lib/libc/powerpc/sys/cerror.S @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); /* * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, + * programs and the initial thread in threaded programs, * it returns a pointer to the global errno variable. */ HIDENAME(cerror): diff --git a/lib/libc/powerpc64/sys/cerror.S b/lib/libc/powerpc64/sys/cerror.S index 3362c9fdf046..93172fdb822e 100644 --- a/lib/libc/powerpc64/sys/cerror.S +++ b/lib/libc/powerpc64/sys/cerror.S @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); /* * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, + * programs and the initial thread in threaded programs, * it returns a pointer to the global errno variable. */ ENTRY_NOPROF(HIDENAME(cerror)) From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 00:48:18 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 BF1505CC532; Tue, 6 Apr 2021 00:48:18 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDpmL4ypGz4W53; Tue, 6 Apr 2021 00:48:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C31B22933; Tue, 6 Apr 2021 00:48:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1360mIN6043331; Tue, 6 Apr 2021 00:48:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1360mIAx043329; Tue, 6 Apr 2021 00:48:18 GMT (envelope-from git) Date: Tue, 6 Apr 2021 00:48:18 GMT Message-Id: <202104060048.1360mIAx043329@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: fb698c2c6dd1 - stable/13 - amd64 fabs(3): move signbit to .rodata MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fb698c2c6dd1a0f8c5dd00888294dd272a42602c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 00:48:19 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fb698c2c6dd1a0f8c5dd00888294dd272a42602c commit fb698c2c6dd1a0f8c5dd00888294dd272a42602c Author: Konstantin Belousov AuthorDate: 2021-04-03 01:32:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-06 00:47:34 +0000 amd64 fabs(3): move signbit to .rodata (cherry picked from commit f548033818b8bbcee17ad3926103f2a9b2c975df) (cherry picked from commit 6d3f54fd090162ab14e2ec66f46bb1335a127a30) (cherry picked from commit d218c6f6af336135ea88342d472b0e66c21239c9) --- lib/libc/amd64/gen/fabs.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libc/amd64/gen/fabs.S b/lib/libc/amd64/gen/fabs.S index 2ace0f9fb926..38e67ab03873 100644 --- a/lib/libc/amd64/gen/fabs.S +++ b/lib/libc/amd64/gen/fabs.S @@ -39,7 +39,8 @@ ENTRY(fabs) ret END(fabs) - .data + .section .rodata + .p2align 3 signbit: .quad 0x8000000000000000 From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 00:48:20 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 50D7C5CC453; Tue, 6 Apr 2021 00:48:20 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDpmM74j5z4VxK; Tue, 6 Apr 2021 00:48:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C917F2278F; Tue, 6 Apr 2021 00:48:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1360mJMP043354; Tue, 6 Apr 2021 00:48:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1360mJD9043353; Tue, 6 Apr 2021 00:48:19 GMT (envelope-from git) Date: Tue, 6 Apr 2021 00:48:19 GMT Message-Id: <202104060048.1360mJD9043353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5524122ee3b7 - stable/13 - x86: clear %db registers in new process MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5524122ee3b78b3a9bba1d0a0d9b8ac080a8e6d8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 00:48:20 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5524122ee3b78b3a9bba1d0a0d9b8ac080a8e6d8 commit 5524122ee3b78b3a9bba1d0a0d9b8ac080a8e6d8 Author: Konstantin Belousov AuthorDate: 2021-03-30 15:40:02 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-06 00:47:34 +0000 x86: clear %db registers in new process PR: 254661 (cherry picked from commit 8223717ce62c1ad0becc34ce69fe2d1771f3ba05) --- sys/amd64/amd64/vm_machdep.c | 8 ++++++++ sys/i386/i386/vm_machdep.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index f64259decbff..98d212dc8771 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -229,6 +229,14 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) copy_thread(td1, td2); + /* Reset debug registers in the new process */ + pcb2->pcb_dr0 = 0; + pcb2->pcb_dr1 = 0; + pcb2->pcb_dr2 = 0; + pcb2->pcb_dr3 = 0; + pcb2->pcb_dr6 = 0; + pcb2->pcb_dr7 = 0; + /* Point mdproc and then copy over p1's contents */ mdp2 = &p2->p_md; bcopy(&p1->p_md, mdp2, sizeof(*mdp2)); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index c04fb57db4b1..ed40ebe5d1c8 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -241,6 +241,14 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) copy_thread(td1, td2); + /* Reset debug registers in the new process */ + pcb2->pcb_dr0 = 0; + pcb2->pcb_dr1 = 0; + pcb2->pcb_dr2 = 0; + pcb2->pcb_dr3 = 0; + pcb2->pcb_dr6 = 0; + pcb2->pcb_dr7 = 0; + /* Point mdproc and then copy over td1's contents */ mdp2 = &p2->p_md; bcopy(&p1->p_md, mdp2, sizeof(*mdp2)); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 06:51:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B9DC15D5C1A; Tue, 6 Apr 2021 06:51:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDyq54prYz3CCZ; Tue, 6 Apr 2021 06:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96E9A27154; Tue, 6 Apr 2021 06:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1366pDbn077767; Tue, 6 Apr 2021 06:51:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1366pDjD077766; Tue, 6 Apr 2021 06:51:13 GMT (envelope-from git) Date: Tue, 6 Apr 2021 06:51:13 GMT Message-Id: <202104060651.1366pDjD077766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 38c299fe8562 - stable/12 - ipdivert: check that PCB is still valid after taking INPCB_RLOCK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 38c299fe856216d6ab38eb5e04d9ee4f8c22995d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 06:51:13 -0000 The branch stable/12 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=38c299fe856216d6ab38eb5e04d9ee4f8c22995d commit 38c299fe856216d6ab38eb5e04d9ee4f8c22995d Author: Andrey V. Elsukov AuthorDate: 2021-03-30 09:31:09 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-04-06 06:50:55 +0000 ipdivert: check that PCB is still valid after taking INPCB_RLOCK. We are inspecting PCBs of divert sockets under NET_EPOCH section, but PCB could be already detached and we should check INP_FREED flag when we took INP_RLOCK. PR: 254478 Differential Revision: https://reviews.freebsd.org/D29420 (cherry picked from commit c80a4b76ceacc5aab322e7ac1407eea8c90cb3b1) --- sys/netinet/ip_divert.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index bcde5416456b..81e70177e641 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -278,6 +278,10 @@ divert_packet(struct mbuf *m, int incoming) /* XXX why does only one socket match? */ if (inp->inp_lport == nport) { INP_RLOCK(inp); + if (__predict_false(inp->inp_flags2 & INP_FREED)) { + INP_RUNLOCK(inp); + continue; + } sa = inp->inp_socket; SOCKBUF_LOCK(&sa->so_rcv); if (sbappendaddr_locked(&sa->so_rcv, From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 06:49:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 E0EAB5D5BBC; Tue, 6 Apr 2021 06:49:54 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDynZ5tWnz3Byx; Tue, 6 Apr 2021 06:49:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4953270D0; Tue, 6 Apr 2021 06:49:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1366nsLX067856; Tue, 6 Apr 2021 06:49:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1366nsHB067855; Tue, 6 Apr 2021 06:49:54 GMT (envelope-from git) Date: Tue, 6 Apr 2021 06:49:54 GMT Message-Id: <202104060649.1366nsHB067855@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 6b8c65318e81 - stable/13 - ipdivert: check that PCB is still valid after taking INPCB_RLOCK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6b8c65318e81a451b33ed57b84a5495284dcb20f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 06:49:55 -0000 The branch stable/13 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=6b8c65318e81a451b33ed57b84a5495284dcb20f commit 6b8c65318e81a451b33ed57b84a5495284dcb20f Author: Andrey V. Elsukov AuthorDate: 2021-03-30 09:31:09 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-04-06 06:47:54 +0000 ipdivert: check that PCB is still valid after taking INPCB_RLOCK. We are inspecting PCBs of divert sockets under NET_EPOCH section, but PCB could be already detached and we should check INP_FREED flag when we took INP_RLOCK. PR: 254478 Differential Revision: https://reviews.freebsd.org/D29420 (cherry picked from commit c80a4b76ceacc5aab322e7ac1407eea8c90cb3b1) --- sys/netinet/ip_divert.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 65f1d263b5fa..70d3fbd1f230 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -280,6 +280,10 @@ divert_packet(struct mbuf *m, bool incoming) /* XXX why does only one socket match? */ if (inp->inp_lport == nport) { INP_RLOCK(inp); + if (__predict_false(inp->inp_flags2 & INP_FREED)) { + INP_RUNLOCK(inp); + continue; + } sa = inp->inp_socket; SOCKBUF_LOCK(&sa->so_rcv); if (sbappendaddr_locked(&sa->so_rcv, From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 10:25:18 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 02E175C9A66; Tue, 6 Apr 2021 10:25:18 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF3Z56jR2z4SBw; Tue, 6 Apr 2021 10:25:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF4422141; Tue, 6 Apr 2021 10:25:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136APHEa070764; Tue, 6 Apr 2021 10:25:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136APHSQ070763; Tue, 6 Apr 2021 10:25:17 GMT (envelope-from git) Date: Tue, 6 Apr 2021 10:25:17 GMT Message-Id: <202104061025.136APHSQ070763@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 38e7de43ba24 - stable/13 - Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 38e7de43ba245c1e7067868a99d7cc6e074bcdd9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 10:25:18 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=38e7de43ba245c1e7067868a99d7cc6e074bcdd9 commit 38e7de43ba245c1e7067868a99d7cc6e074bcdd9 Author: Hans Petter Selasky AuthorDate: 2021-03-28 07:36:48 +0000 Commit: Hans Petter Selasky CommitDate: 2021-04-06 10:23:08 +0000 Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. Differential Revision: https://reviews.freebsd.org/D29467 Reviewed by: kib@ and markj@ Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 177772088060ab0f41bcdbdd81c4712e7f1c7621) --- sys/compat/linuxkpi/common/include/linux/sched.h | 1 + sys/compat/linuxkpi/common/src/linux_rcu.c | 43 ++++++++++++++++++------ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index da38d89eb639..937e9f27870c 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -82,6 +82,7 @@ struct task_struct { int bsd_interrupt_value; struct work_struct *work; /* current work struct, if set */ struct task_struct *group_leader; + unsigned rcu_section[TS_RCU_TYPE_MAX]; }; #define current ({ \ diff --git a/sys/compat/linuxkpi/common/src/linux_rcu.c b/sys/compat/linuxkpi/common/src/linux_rcu.c index 86ec193aa4e4..404c5cec4ae4 100644 --- a/sys/compat/linuxkpi/common/src/linux_rcu.c +++ b/sys/compat/linuxkpi/common/src/linux_rcu.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Matthew Macy (mmacy@mattmacy.io) - * Copyright (c) 2017-2020 Hans Petter Selasky (hselasky@freebsd.org) + * Copyright (c) 2017-2021 Hans Petter Selasky (hselasky@freebsd.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,15 @@ struct linux_epoch_record { */ CTASSERT(sizeof(struct rcu_head) == sizeof(struct callback_head)); +/* + * Verify that "rcu_section[0]" has the same size as + * "ck_epoch_section_t". This has been done to avoid having to add + * special compile flags for including ck_epoch.h to all clients of + * the LinuxKPI. + */ +CTASSERT(sizeof(((struct task_struct *)0)->rcu_section[0] == + sizeof(ck_epoch_section_t))); + /* * Verify that "epoch_record" is at beginning of "struct * linux_epoch_record": @@ -189,6 +198,14 @@ linux_rcu_read_lock(unsigned type) if (RCU_SKIP()) return; + ts = current; + + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] != INT_MAX); + + if (++(ts->rcu_recurse[type]) != 1) + return; + /* * Pin thread to current CPU so that the unlock code gets the * same per-CPU epoch record: @@ -196,17 +213,15 @@ linux_rcu_read_lock(unsigned type) sched_pin(); record = &DPCPU_GET(linux_epoch_record[type]); - ts = current; /* * Use a critical section to prevent recursion inside * ck_epoch_begin(). Else this function supports recursion. */ critical_enter(); - ck_epoch_begin(&record->epoch_record, NULL); - ts->rcu_recurse[type]++; - if (ts->rcu_recurse[type] == 1) - TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_begin(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); critical_exit(); } @@ -221,18 +236,24 @@ linux_rcu_read_unlock(unsigned type) if (RCU_SKIP()) return; - record = &DPCPU_GET(linux_epoch_record[type]); ts = current; + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] > 0); + + if (--(ts->rcu_recurse[type]) != 0) + return; + + record = &DPCPU_GET(linux_epoch_record[type]); + /* * Use a critical section to prevent recursion inside * ck_epoch_end(). Else this function supports recursion. */ critical_enter(); - ck_epoch_end(&record->epoch_record, NULL); - ts->rcu_recurse[type]--; - if (ts->rcu_recurse[type] == 0) - TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_end(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); critical_exit(); sched_unpin(); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 10:27:23 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 33CB15C9E1A; Tue, 6 Apr 2021 10:27:23 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF3cW11Jbz4SQf; Tue, 6 Apr 2021 10:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 158B921A2; Tue, 6 Apr 2021 10:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136ARNAV071014; Tue, 6 Apr 2021 10:27:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136ARNiT071013; Tue, 6 Apr 2021 10:27:23 GMT (envelope-from git) Date: Tue, 6 Apr 2021 10:27:23 GMT Message-Id: <202104061027.136ARNiT071013@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 30b1f8cd1122 - stable/12 - Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 30b1f8cd1122ef7d770431956c86dd468ae48275 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 10:27:23 -0000 The branch stable/12 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=30b1f8cd1122ef7d770431956c86dd468ae48275 commit 30b1f8cd1122ef7d770431956c86dd468ae48275 Author: Hans Petter Selasky AuthorDate: 2021-03-28 07:36:48 +0000 Commit: Hans Petter Selasky CommitDate: 2021-04-06 10:25:00 +0000 Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. Differential Revision: https://reviews.freebsd.org/D29467 Reviewed by: kib@ and markj@ Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 177772088060ab0f41bcdbdd81c4712e7f1c7621) --- sys/compat/linuxkpi/common/include/linux/sched.h | 1 + sys/compat/linuxkpi/common/src/linux_rcu.c | 43 ++++++++++++++++++------ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index da38d89eb639..937e9f27870c 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -82,6 +82,7 @@ struct task_struct { int bsd_interrupt_value; struct work_struct *work; /* current work struct, if set */ struct task_struct *group_leader; + unsigned rcu_section[TS_RCU_TYPE_MAX]; }; #define current ({ \ diff --git a/sys/compat/linuxkpi/common/src/linux_rcu.c b/sys/compat/linuxkpi/common/src/linux_rcu.c index d2a414926e54..04166926775a 100644 --- a/sys/compat/linuxkpi/common/src/linux_rcu.c +++ b/sys/compat/linuxkpi/common/src/linux_rcu.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Matthew Macy (mmacy@mattmacy.io) - * Copyright (c) 2017-2020 Hans Petter Selasky (hselasky@freebsd.org) + * Copyright (c) 2017-2021 Hans Petter Selasky (hselasky@freebsd.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,15 @@ struct linux_epoch_record { */ CTASSERT(sizeof(struct rcu_head) == sizeof(struct callback_head)); +/* + * Verify that "rcu_section[0]" has the same size as + * "ck_epoch_section_t". This has been done to avoid having to add + * special compile flags for including ck_epoch.h to all clients of + * the LinuxKPI. + */ +CTASSERT(sizeof(((struct task_struct *)0)->rcu_section[0] == + sizeof(ck_epoch_section_t))); + /* * Verify that "epoch_record" is at beginning of "struct * linux_epoch_record": @@ -190,6 +199,14 @@ linux_rcu_read_lock(unsigned type) if (RCU_SKIP()) return; + ts = current; + + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] != INT_MAX); + + if (++(ts->rcu_recurse[type]) != 1) + return; + /* * Pin thread to current CPU so that the unlock code gets the * same per-CPU epoch record: @@ -197,17 +214,15 @@ linux_rcu_read_lock(unsigned type) sched_pin(); record = &DPCPU_GET(linux_epoch_record[type]); - ts = current; /* * Use a critical section to prevent recursion inside * ck_epoch_begin(). Else this function supports recursion. */ critical_enter(); - ck_epoch_begin(&record->epoch_record, NULL); - ts->rcu_recurse[type]++; - if (ts->rcu_recurse[type] == 1) - TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_begin(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); critical_exit(); } @@ -222,18 +237,24 @@ linux_rcu_read_unlock(unsigned type) if (RCU_SKIP()) return; - record = &DPCPU_GET(linux_epoch_record[type]); ts = current; + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] > 0); + + if (--(ts->rcu_recurse[type]) != 0) + return; + + record = &DPCPU_GET(linux_epoch_record[type]); + /* * Use a critical section to prevent recursion inside * ck_epoch_end(). Else this function supports recursion. */ critical_enter(); - ck_epoch_end(&record->epoch_record, NULL); - ts->rcu_recurse[type]--; - if (ts->rcu_recurse[type] == 0) - TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_end(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); critical_exit(); sched_unpin(); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 10:29:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 09CE15C9D56; Tue, 6 Apr 2021 10:29:26 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF3fs6w4Sz4SVM; Tue, 6 Apr 2021 10:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E040E1F64; Tue, 6 Apr 2021 10:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136ATPD4071371; Tue, 6 Apr 2021 10:29:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136ATP7h071370; Tue, 6 Apr 2021 10:29:25 GMT (envelope-from git) Date: Tue, 6 Apr 2021 10:29:25 GMT Message-Id: <202104061029.136ATP7h071370@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: b9de88350f2e - stable/11 - Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: b9de88350f2e5b7d1c837d619d34b9fe3a79826e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 10:29:26 -0000 The branch stable/11 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=b9de88350f2e5b7d1c837d619d34b9fe3a79826e commit b9de88350f2e5b7d1c837d619d34b9fe3a79826e Author: Hans Petter Selasky AuthorDate: 2021-03-28 07:36:48 +0000 Commit: Hans Petter Selasky CommitDate: 2021-04-06 10:27:48 +0000 Reduce chance of RCU deadlock in the LinuxKPI by implementing the section feature of the concurrency kit, CK. Differential Revision: https://reviews.freebsd.org/D29467 Reviewed by: kib@ and markj@ Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 177772088060ab0f41bcdbdd81c4712e7f1c7621) --- sys/compat/linuxkpi/common/include/linux/sched.h | 1 + sys/compat/linuxkpi/common/src/linux_rcu.c | 43 ++++++++++++++++++------ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index 877b05189cdb..bc08550b18ee 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -81,6 +81,7 @@ struct task_struct { int rcu_recurse[TS_RCU_TYPE_MAX]; int bsd_interrupt_value; struct work_struct *work; /* current work struct, if set */ + unsigned rcu_section[TS_RCU_TYPE_MAX]; }; #define current ({ \ diff --git a/sys/compat/linuxkpi/common/src/linux_rcu.c b/sys/compat/linuxkpi/common/src/linux_rcu.c index 61aa21ae37ec..b180c6b74361 100644 --- a/sys/compat/linuxkpi/common/src/linux_rcu.c +++ b/sys/compat/linuxkpi/common/src/linux_rcu.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2016 Matthew Macy (mmacy@mattmacy.io) - * Copyright (c) 2017-2020 Hans Petter Selasky (hselasky@freebsd.org) + * Copyright (c) 2017-2021 Hans Petter Selasky (hselasky@freebsd.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,15 @@ struct linux_epoch_record { */ CTASSERT(sizeof(struct rcu_head) == sizeof(struct callback_head)); +/* + * Verify that "rcu_section[0]" has the same size as + * "ck_epoch_section_t". This has been done to avoid having to add + * special compile flags for including ck_epoch.h to all clients of + * the LinuxKPI. + */ +CTASSERT(sizeof(((struct task_struct *)0)->rcu_section[0] == + sizeof(ck_epoch_section_t))); + /* * Verify that "epoch_record" is at beginning of "struct * linux_epoch_record": @@ -190,6 +199,14 @@ linux_rcu_read_lock(unsigned type) if (RCU_SKIP()) return; + ts = current; + + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] != INT_MAX); + + if (++(ts->rcu_recurse[type]) != 1) + return; + /* * Pin thread to current CPU so that the unlock code gets the * same per-CPU epoch record: @@ -197,17 +214,15 @@ linux_rcu_read_lock(unsigned type) sched_pin(); record = &DPCPU_GET(linux_epoch_record[type]); - ts = current; /* * Use a critical section to prevent recursion inside * ck_epoch_begin(). Else this function supports recursion. */ critical_enter(); - ck_epoch_begin(&record->epoch_record, NULL); - ts->rcu_recurse[type]++; - if (ts->rcu_recurse[type] == 1) - TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_begin(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_INSERT_TAIL(&record->ts_head, ts, rcu_entry[type]); critical_exit(); } @@ -222,18 +237,24 @@ linux_rcu_read_unlock(unsigned type) if (RCU_SKIP()) return; - record = &DPCPU_GET(linux_epoch_record[type]); ts = current; + /* assert valid refcount */ + MPASS(ts->rcu_recurse[type] > 0); + + if (--(ts->rcu_recurse[type]) != 0) + return; + + record = &DPCPU_GET(linux_epoch_record[type]); + /* * Use a critical section to prevent recursion inside * ck_epoch_end(). Else this function supports recursion. */ critical_enter(); - ck_epoch_end(&record->epoch_record, NULL); - ts->rcu_recurse[type]--; - if (ts->rcu_recurse[type] == 0) - TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); + ck_epoch_end(&record->epoch_record, + (ck_epoch_section_t *)&ts->rcu_section[type]); + TAILQ_REMOVE(&record->ts_head, ts, rcu_entry[type]); critical_exit(); sched_unpin(); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 11:27:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A2D415CC9FE; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF4xc4CRmz4ZxS; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8364A2C53; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136BRGmv052464; Tue, 6 Apr 2021 11:27:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136BRG5b052463; Tue, 6 Apr 2021 11:27:16 GMT (envelope-from git) Date: Tue, 6 Apr 2021 11:27:16 GMT Message-Id: <202104061127.136BRG5b052463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: e21b6ce854f2 - stable/13 - [PowerPC64] Port optimized strcpy to PPC64LE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e21b6ce854f25540f9f8ba33f15d60c5de91bc29 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 11:27:16 -0000 The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=e21b6ce854f25540f9f8ba33f15d60c5de91bc29 commit e21b6ce854f25540f9f8ba33f15d60c5de91bc29 Author: Leandro Lupori AuthorDate: 2021-03-25 16:14:00 +0000 Commit: Leandro Lupori CommitDate: 2021-04-06 11:26:30 +0000 [PowerPC64] Port optimized strcpy to PPC64LE Submitted by: Bruno Larsen Reviewed by: luporl, bdragon (IRC) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D29067 (cherry picked from commit 9f50aa45be18b9b11b14345fe0a137d1ac51a391) --- lib/libc/powerpc64/string/Makefile.inc | 7 +-- lib/libc/powerpc64/string/strcpy_arch_2_05.S | 66 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/lib/libc/powerpc64/string/Makefile.inc b/lib/libc/powerpc64/string/Makefile.inc index 14f0845595c9..486ca47a44be 100644 --- a/lib/libc/powerpc64/string/Makefile.inc +++ b/lib/libc/powerpc64/string/Makefile.inc @@ -12,12 +12,7 @@ MDSRCS+= \ memmove_resolver.c \ strncpy_arch_2_05.S \ strncpy.c \ - strncpy_resolver.c - -# XXX Port strcpy to LE. -.if ${MACHINE_ARCH} == "powerpc64" -MDSRCS+= \ + strncpy_resolver.c \ strcpy_arch_2_05.S \ strcpy.c \ strcpy_resolver.c -.endif diff --git a/lib/libc/powerpc64/string/strcpy_arch_2_05.S b/lib/libc/powerpc64/string/strcpy_arch_2_05.S index 23ffb5c2a75e..7f42fd813395 100644 --- a/lib/libc/powerpc64/string/strcpy_arch_2_05.S +++ b/lib/libc/powerpc64/string/strcpy_arch_2_05.S @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#if !defined(__BIG_ENDIAN__) -#error "Optimized SRTCPY is only supported by big-endian architecture!" -#endif #include __FBSDID("$FreeBSD$"); @@ -71,6 +68,7 @@ ENTRY(__strcpy_arch_2_05) beq cr7,.Lcopy_dw_loop addi %r8,%r8,8 /* Forward r8 to use std instruction. */ +#if defined(__BIG_ENDIAN__) /* Find where the zero is located. */ .Lcheck_zero: rldicr. %r5,%r0,0,7 @@ -136,6 +134,68 @@ ENTRY(__strcpy_arch_2_05) .Lfound_on_byte_0: srdi %r6,%r0,56 stb %r6,0(%r8) +#elif defined(__LITTLE_ENDIAN__) +/* Find where the zero is located. */ +.Lcheck_zero: + andi. %r7,%r0,0xff + beq .Lfound_on_byte_0 + andi. %r7,%r0,0xff00 + beq .Lfound_on_byte_1 + andis. %r7,%r0,0xff + beq .Lfound_on_byte_2 + andis. %r7,%r0,0xff00 + beq .Lfound_on_byte_3 + rldicr. %r7,%r0,24,7 + beq .Lfound_on_byte_4 + rldicr. %r7,%r0,16,7 + beq .Lfound_on_byte_5 + rldicr. %r7,%r0,8,7 + beq .Lfound_on_byte_6 + +/* Copy the last string bytes according to the string end position. */ +.Lfound_on_byte_7: + std %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_6: + stw %r0,0(%r8) + srdi %r6,%r0,32 + sth %r6,4(%r8) + srdi %r6,%r0,48 + stb %r6,6(%r8) + b .Lexit + +.Lfound_on_byte_5: + stw %r0,0(%r8) + srdi %r6,%r0,32 + sth %r6,4(%r8) + b .Lexit + +.Lfound_on_byte_4: + stw %r0,0(%r8) + srdi %r6,%r0,32 + stb %r6,4(%r8) + b .Lexit + +.Lfound_on_byte_3: + stw %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_2: + sth %r0,0(%r8) + srdi %r6,%r0,16 + stb %r6,2(%r8) + b .Lexit + +.Lfound_on_byte_1: + sth %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_0: + stb %r0,0(%r8) +#else +#error "Unable to determine Endianness" +#endif .Lexit: blr From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 11:29:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 432125CCC6C; Tue, 6 Apr 2021 11:29:48 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF50X1Tx3z4b49; Tue, 6 Apr 2021 11:29:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 17F612E35; Tue, 6 Apr 2021 11:29:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136BTlJd052806; Tue, 6 Apr 2021 11:29:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136BTlkO052805; Tue, 6 Apr 2021 11:29:47 GMT (envelope-from git) Date: Tue, 6 Apr 2021 11:29:47 GMT Message-Id: <202104061129.136BTlkO052805@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: 1805ce694542 - stable/13 - powerpc64: enforce natural alignment in bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1805ce694542f03a95a064aa3be5905ce9cffa3b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 11:29:48 -0000 The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=1805ce694542f03a95a064aa3be5905ce9cffa3b commit 1805ce694542f03a95a064aa3be5905ce9cffa3b Author: Leandro Lupori AuthorDate: 2021-03-25 14:54:06 +0000 Commit: Leandro Lupori CommitDate: 2021-04-06 11:28:26 +0000 powerpc64: enforce natural alignment in bcopy POWER architecture CPUs (Book-S) require natural alignment for cache-inhibited storage accesses. Since we can't know the caching model for a page ahead of time, always enforce natural alignment in bcopy. This fixes a SIGBUS when calling the function with misaligned pointers on POWER7. Submitted by: Bruno Larsen Reviewed by: luporl, bdragon (IRC) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D28776 (cherry picked from commit 2f561284033c0f53d0911baf9056078e6026a278) --- lib/libc/powerpc64/string/bcopy.S | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/libc/powerpc64/string/bcopy.S b/lib/libc/powerpc64/string/bcopy.S index bb860c098feb..4dc80c264362 100644 --- a/lib/libc/powerpc64/string/bcopy.S +++ b/lib/libc/powerpc64/string/bcopy.S @@ -34,6 +34,11 @@ __FBSDID("$FreeBSD$"); #define BLOCK_SIZE (1 << BLOCK_SIZE_BITS) #define BLOCK_SIZE_MASK (BLOCK_SIZE - 1) +/* Minimum 8 byte alignment, to avoid cache-inhibited alignment faults.*/ +#ifndef ALIGN_MASK +#define ALIGN_MASK 0x7 +#endif + #define MULTI_PHASE_THRESHOLD 512 #ifndef FN_NAME @@ -66,9 +71,38 @@ ENTRY(FN_NAME) mr %r4, %r0 #endif + /* First check for relative alignment, if unaligned copy one byte at a time */ + andi. %r8, %r3, ALIGN_MASK + andi. %r7, %r4, ALIGN_MASK + cmpd %r7, %r8 + bne .Lunaligned + + cmpldi %r5, MULTI_PHASE_THRESHOLD bge .Lmulti_phase + b .Lfast_copy + +.Lunaligned: + /* forward or backward copy? */ + cmpd %r4, %r3 + blt .Lbackward_unaligned + + /* Just need to setup increment and jump to copy */ + li %r0, 1 + mtctr %r5 + b .Lsingle_1_loop + +.Lbackward_unaligned: + /* advance src and dst to last byte, set decrement and jump to copy */ + add %r3, %r3, %r5 + addi %r3, %r3, -1 + add %r4, %r4, %r5 + addi %r4, %r4, -1 + li %r0, -1 + mtctr %r5 + b .Lsingle_1_loop +.Lfast_copy: /* align src */ cmpd %r4, %r3 /* forward or backward copy? */ blt .Lbackward_align From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 11:48:32 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 11E345CD69E; Tue, 6 Apr 2021 11:48:32 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF5Q804F4z4dFh; Tue, 6 Apr 2021 11:48:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9754343F; Tue, 6 Apr 2021 11:48:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136BmV8C079328; Tue, 6 Apr 2021 11:48:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136BmV0M079327; Tue, 6 Apr 2021 11:48:31 GMT (envelope-from git) Date: Tue, 6 Apr 2021 11:48:31 GMT Message-Id: <202104061148.136BmV0M079327@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: 32b50b8520d0 - stable/13 - powerpc64: support superpages on pmap_mincore MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32b50b8520d00b58ff88ab9ea46cf2423a3ad81b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 11:48:32 -0000 The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=32b50b8520d00b58ff88ab9ea46cf2423a3ad81b commit 32b50b8520d00b58ff88ab9ea46cf2423a3ad81b Author: Leandro Lupori AuthorDate: 2021-03-30 18:54:01 +0000 Commit: Leandro Lupori CommitDate: 2021-04-06 11:47:43 +0000 powerpc64: support superpages on pmap_mincore Now that superpages for HPT MMU has landed, finish implementation of pmap_mincore by adding support for superpages. Submitted by: Fernando Eckhardt Valle Reviewed by: bdragon, luporl MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D29230 (cherry picked from commit 75e67b4920f2d70b98bd1383966d17d541b7c46c) --- sys/powerpc/aim/mmu_oea64.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index 14fea6f29a52..f311b61188e7 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -1400,13 +1400,15 @@ moea64_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap) PMAP_LOCK(pmap); - /* XXX Add support for superpages */ pvo = moea64_pvo_find_va(pmap, addr); if (pvo != NULL) { pa = PVO_PADDR(pvo); m = PHYS_TO_VM_PAGE(pa); managed = (pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED; - val = MINCORE_INCORE; + if (PVO_IS_SP(pvo)) + val = MINCORE_INCORE | MINCORE_PSIND(1); + else + val = MINCORE_INCORE; } else { PMAP_UNLOCK(pmap); return (0); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 13:08:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 4F1CC5D0D5C; Tue, 6 Apr 2021 13:08:26 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF7BL1r54z4q8B; Tue, 6 Apr 2021 13:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 320B946B1; Tue, 6 Apr 2021 13:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136D8Qwo089194; Tue, 6 Apr 2021 13:08:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136D8QN9089193; Tue, 6 Apr 2021 13:08:26 GMT (envelope-from git) Date: Tue, 6 Apr 2021 13:08:26 GMT Message-Id: <202104061308.136D8QN9089193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: edda63ba979a - stable/13 - makefs: Ignore the "tags" keyword in mtree manifests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: edda63ba979a8e39e935ed97e1c9049ee1ff4e0a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 13:08:26 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=edda63ba979a8e39e935ed97e1c9049ee1ff4e0a commit edda63ba979a8e39e935ed97e1c9049ee1ff4e0a Author: Mark Johnston AuthorDate: 2021-03-23 18:38:28 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 13:07:24 +0000 makefs: Ignore the "tags" keyword in mtree manifests An install using -DNO_ROOT emits mtree entries containing tags used by pkgbase. makefs(8) can safely ignore them, so do that rather than emitting a warning for each entry. Reviewed by: brooks, imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29384 (cherry picked from commit ed42b22abc48ba53aaa38e1e64438b6d71e7e944) --- usr.sbin/makefs/mtree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c index 266315466900..4272299ce135 100644 --- a/usr.sbin/makefs/mtree.c +++ b/usr.sbin/makefs/mtree.c @@ -629,7 +629,13 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOSYS; break; case 't': - if (strcmp(keyword, "time") == 0) { + if (strcmp(keyword, "tags") == 0) { + if (value == NULL) { + error = ENOATTR; + break; + } + /* Ignore. */ + } else if (strcmp(keyword, "time") == 0) { if (value == NULL) { error = ENOATTR; break; From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 15:20:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 383895D5288; Tue, 6 Apr 2021 15:20:47 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFB724SMtz3ND1; Tue, 6 Apr 2021 15:20:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54A4C65AF; Tue, 6 Apr 2021 15:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136FKeTG072386; Tue, 6 Apr 2021 15:20:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136FKex0072385; Tue, 6 Apr 2021 15:20:40 GMT (envelope-from git) Date: Tue, 6 Apr 2021 15:20:40 GMT Message-Id: <202104061520.136FKex0072385@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: bd422989a99b - stable/12 - Lock busdma operations and serialize detach against open/close MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bd422989a99b5acbc1017945a115f111ac81c131 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 15:20:47 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bd422989a99b5acbc1017945a115f111ac81c131 commit bd422989a99b5acbc1017945a115f111ac81c131 Author: Marcel Moolenaar AuthorDate: 2019-07-04 02:51:34 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 15:20:13 +0000 Lock busdma operations and serialize detach against open/close Use sx to allow M_WAITOK allocations (suggested by markj). admbugs: 782 Reviewed by: markj (cherry picked from commit 9f011bca829751ed3552ac94fe7c865d75fabfc4) --- sys/dev/proto/proto.h | 8 ++++-- sys/dev/proto/proto_busdma.c | 27 +++++++++++++++--- sys/dev/proto/proto_busdma.h | 3 +- sys/dev/proto/proto_core.c | 66 +++++++++++++++++++++++++++++++------------- 4 files changed, 77 insertions(+), 27 deletions(-) diff --git a/sys/dev/proto/proto.h b/sys/dev/proto/proto.h index cf89512f6ea7..14f6af648f82 100644 --- a/sys/dev/proto/proto.h +++ b/sys/dev/proto/proto.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014, 2015 Marcel Moolenaar + * Copyright (c) 2014, 2015, 2019 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,8 @@ #define PROTO_RES_BUSDMA 11 struct proto_res { - int r_type; + u_int r_type:8; + u_int r_opened:1; int r_rid; union { struct resource *res; @@ -47,13 +48,14 @@ struct proto_res { void *cookie; struct cdev *cdev; } r_u; - uintptr_t r_opened; }; struct proto_softc { device_t sc_dev; struct proto_res sc_res[PROTO_RES_MAX]; int sc_rescnt; + int sc_opencnt; + struct mtx sc_mtx; }; extern devclass_t proto_devclass; diff --git a/sys/dev/proto/proto_busdma.c b/sys/dev/proto/proto_busdma.c index 6f6bf7b08916..6838af1e3a1e 100644 --- a/sys/dev/proto/proto_busdma.c +++ b/sys/dev/proto/proto_busdma.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Marcel Moolenaar + * Copyright (c) 2015, 2019 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -355,6 +356,7 @@ proto_busdma_attach(struct proto_softc *sc) struct proto_busdma *busdma; busdma = malloc(sizeof(*busdma), M_PROTO_BUSDMA, M_WAITOK | M_ZERO); + sx_init(&busdma->sxlck, "proto-busdma"); return (busdma); } @@ -363,6 +365,7 @@ proto_busdma_detach(struct proto_softc *sc, struct proto_busdma *busdma) { proto_busdma_cleanup(sc, busdma); + sx_destroy(&busdma->sxlck); free(busdma, M_PROTO_BUSDMA); return (0); } @@ -373,10 +376,12 @@ proto_busdma_cleanup(struct proto_softc *sc, struct proto_busdma *busdma) struct proto_md *md, *md1; struct proto_tag *tag, *tag1; + sx_xlock(&busdma->sxlck); LIST_FOREACH_SAFE(md, &busdma->mds, mds, md1) proto_busdma_md_destroy_internal(busdma, md); LIST_FOREACH_SAFE(tag, &busdma->tags, tags, tag1) proto_busdma_tag_destroy(busdma, tag); + sx_xunlock(&busdma->sxlck); return (0); } @@ -388,6 +393,8 @@ proto_busdma_ioctl(struct proto_softc *sc, struct proto_busdma *busdma, struct proto_md *md; int error; + sx_xlock(&busdma->sxlck); + error = 0; switch (ioc->request) { case PROTO_IOC_BUSDMA_TAG_CREATE: @@ -470,6 +477,9 @@ proto_busdma_ioctl(struct proto_softc *sc, struct proto_busdma *busdma, error = EINVAL; break; } + + sx_xunlock(&busdma->sxlck); + return (error); } @@ -477,11 +487,20 @@ int proto_busdma_mmap_allowed(struct proto_busdma *busdma, vm_paddr_t physaddr) { struct proto_md *md; + int result; + sx_xlock(&busdma->sxlck); + + result = 0; LIST_FOREACH(md, &busdma->mds, mds) { if (physaddr >= trunc_page(md->physaddr) && - physaddr <= trunc_page(md->physaddr + md->tag->maxsz)) - return (1); + physaddr <= trunc_page(md->physaddr + md->tag->maxsz)) { + result = 1; + break; + } } - return (0); + + sx_xunlock(&busdma->sxlck); + + return (result); } diff --git a/sys/dev/proto/proto_busdma.h b/sys/dev/proto/proto_busdma.h index 2b645cebcc4d..a3a3f0087ba3 100644 --- a/sys/dev/proto/proto_busdma.h +++ b/sys/dev/proto/proto_busdma.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Marcel Moolenaar + * Copyright (c) 2015, 2019 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,6 +60,7 @@ struct proto_busdma { LIST_HEAD(,proto_tag) tags; LIST_HEAD(,proto_md) mds; bus_dma_tag_t bd_roottag; + struct sx sxlck; }; struct proto_busdma *proto_busdma_attach(struct proto_softc *); diff --git a/sys/dev/proto/proto_core.c b/sys/dev/proto/proto_core.c index 83da523b1cbb..404ba498f09d 100644 --- a/sys/dev/proto/proto_core.c +++ b/sys/dev/proto/proto_core.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014, 2015 Marcel Moolenaar + * Copyright (c) 2014, 2015, 2019 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -184,6 +184,7 @@ proto_attach(device_t dev) sc = device_get_softc(dev); sc->sc_dev = dev; + mtx_init(&sc->sc_mtx, "proto-softc", NULL, MTX_DEF); for (res = 0; res < sc->sc_rescnt; res++) { r = sc->sc_res + res; @@ -231,15 +232,16 @@ proto_detach(device_t dev) sc = device_get_softc(dev); - /* Don't detach if we have open device files. */ - for (res = 0; res < sc->sc_rescnt; res++) { - r = sc->sc_res + res; - if (r->r_opened) - return (EBUSY); - } + mtx_lock(&sc->sc_mtx); + if (sc->sc_opencnt == 0) + sc->sc_opencnt = -1; + mtx_unlock(&sc->sc_mtx); + if (sc->sc_opencnt > 0) + return (EBUSY); for (res = 0; res < sc->sc_rescnt; res++) { r = sc->sc_res + res; + switch (r->r_type) { case SYS_RES_IRQ: /* XXX TODO */ @@ -252,21 +254,25 @@ proto_detach(device_t dev) break; case SYS_RES_MEMORY: case SYS_RES_IOPORT: + destroy_dev(r->r_u.cdev); bus_release_resource(dev, r->r_type, r->r_rid, r->r_d.res); - destroy_dev(r->r_u.cdev); break; case PROTO_RES_PCICFG: destroy_dev(r->r_u.cdev); break; case PROTO_RES_BUSDMA: - proto_busdma_detach(sc, r->r_d.busdma); destroy_dev(r->r_u.cdev); + proto_busdma_detach(sc, r->r_d.busdma); break; } r->r_type = PROTO_RES_UNUSED; } + mtx_lock(&sc->sc_mtx); sc->sc_rescnt = 0; + sc->sc_opencnt = 0; + mtx_unlock(&sc->sc_mtx); + mtx_destroy(&sc->sc_mtx); return (0); } @@ -278,11 +284,23 @@ static int proto_open(struct cdev *cdev, int oflags, int devtype, struct thread *td) { struct proto_res *r; + struct proto_softc *sc; + int error; - r = cdev->si_drv2; - if (!atomic_cmpset_acq_ptr(&r->r_opened, 0UL, (uintptr_t)td->td_proc)) - return (EBUSY); - return (0); + sc = cdev->si_drv1; + mtx_lock(&sc->sc_mtx); + if (sc->sc_opencnt >= 0) { + r = cdev->si_drv2; + if (!r->r_opened) { + r->r_opened = 1; + sc->sc_opencnt++; + error = 0; + } else + error = EBUSY; + } else + error = ENXIO; + mtx_unlock(&sc->sc_mtx); + return (error); } static int @@ -290,14 +308,24 @@ proto_close(struct cdev *cdev, int fflag, int devtype, struct thread *td) { struct proto_res *r; struct proto_softc *sc; + int error; sc = cdev->si_drv1; - r = cdev->si_drv2; - if (!atomic_cmpset_acq_ptr(&r->r_opened, (uintptr_t)td->td_proc, 0UL)) - return (ENXIO); - if (r->r_type == PROTO_RES_BUSDMA) - proto_busdma_cleanup(sc, r->r_d.busdma); - return (0); + mtx_lock(&sc->sc_mtx); + if (sc->sc_opencnt > 0) { + r = cdev->si_drv2; + if (r->r_opened) { + if (r->r_type == PROTO_RES_BUSDMA) + proto_busdma_cleanup(sc, r->r_d.busdma); + r->r_opened = 0; + sc->sc_opencnt--; + error = 0; + } else + error = ENXIO; + } else + error = ENXIO; + mtx_unlock(&sc->sc_mtx); + return (error); } static int From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:18:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B0E515B50D8; Tue, 6 Apr 2021 19:18:15 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHP32SDQz4cDn; Tue, 6 Apr 2021 19:18:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 701DC11B97; Tue, 6 Apr 2021 19:18:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JIDJg097128; Tue, 6 Apr 2021 19:18:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JIDS2097127; Tue, 6 Apr 2021 19:18:13 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:18:13 GMT Message-Id: <202104061918.136JIDS2097127@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2e08308d62f3 - stable/13 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2e08308d62f381312b3da9dac8970dcdad4b3f2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:18:15 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2e08308d62f381312b3da9dac8970dcdad4b3f2d commit 2e08308d62f381312b3da9dac8970dcdad4b3f2d Author: Mark Johnston AuthorDate: 2021-03-15 20:02:17 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 18:50:46 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm (cherry picked from commit 982693bb729badac4e65ecd59772979f2849a2b2) --- sys/vm/vm_fault.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 585e1544415d..0e8ff9b27ed1 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -896,6 +896,9 @@ vm_fault_cow(struct faultstate *fs) { bool is_first_object_locked; + KASSERT(fs->object != fs->first_object, + ("source and target COW objects are identical")); + /* * This allows pages to be virtually copied from a backing_object * into the first_object, where the backing object has no other @@ -959,11 +962,29 @@ vm_fault_cow(struct faultstate *fs) */ fs->m_cow = fs->m; fs->m = NULL; + + /* + * Typically, the shadow object is either private to this + * address space (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of a shadow object + * are read/write shared between this and other address spaces, + * we need to ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing object are + * removed from those other address spaces. + * + * The flag check is racy, but this is tolerable: if + * OBJ_ONEMAPPING is cleared after the check, the busy state + * ensures that new mappings of m_cow can't be created. + * pmap_enter() will replace an existing mapping in the current + * address space. If OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some unnecessary page + * faults. + */ + vm_page_assert_xbusied(fs->m_cow); + if ((fs->first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs->m_cow); } - /* - * fs->object != fs->first_object due to above - * conditional - */ + vm_object_pip_wakeup(fs->object); /* From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:18:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 11A015B5059; Tue, 6 Apr 2021 19:18:16 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHP3612kz4cDp; Tue, 6 Apr 2021 19:18:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90ABC11C12; Tue, 6 Apr 2021 19:18:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JIEWN097149; Tue, 6 Apr 2021 19:18:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JIEdT097148; Tue, 6 Apr 2021 19:18:14 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:18:14 GMT Message-Id: <202104061918.136JIEdT097148@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3ae17faa3704 - stable/13 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3ae17faa370491d7ce1fcfc4d5b9cd1ed0117b67 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:18:16 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3ae17faa370491d7ce1fcfc4d5b9cd1ed0117b67 commit 3ae17faa370491d7ce1fcfc4d5b9cd1ed0117b67 Author: Mark Johnston AuthorDate: 2021-04-05 21:19:15 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 18:50:48 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount (cherry picked from commit 2425f5e9128102c8e6e473567ad6759a55be5b02) --- sys/kern/vfs_mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index b3870e46c5e9..59000728efcc 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -918,10 +918,10 @@ vfs_domount_first( /* * If the jail of the calling thread lacks permission for this type of - * file system, deny immediately. + * file system, or is trying to cover its own root, deny immediately. */ - if (jailed(td->td_ucred) && !prison_allow(td->td_ucred, - vfsp->vfc_prison_flag)) { + if (jailed(td->td_ucred) && (!prison_allow(td->td_ucred, + vfsp->vfc_prison_flag) || vp == td->td_ucred->cr_prison->pr_root)) { vput(vp); return (EPERM); } From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 57C145B4FF7; Tue, 6 Apr 2021 19:19:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQB1cZvz4cr8; Tue, 6 Apr 2021 19:19:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1FCC811968; Tue, 6 Apr 2021 19:19:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJEBj097407; Tue, 6 Apr 2021 19:19:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJE0S097406; Tue, 6 Apr 2021 19:19:14 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:14 GMT Message-Id: <202104061919.136JJE0S097406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 724bc23da1a9 - releng/13.0 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 724bc23da1a9c40768723a4796060c921dbaf224 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:14 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=724bc23da1a9c40768723a4796060c921dbaf224 commit 724bc23da1a9c40768723a4796060c921dbaf224 Author: Mark Johnston AuthorDate: 2021-03-15 20:02:17 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:18:49 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: re (so, implicit) Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm (cherry picked from commit 982693bb729badac4e65ecd59772979f2849a2b2) (cherry picked from commit 2e08308d62f381312b3da9dac8970dcdad4b3f2d) --- sys/vm/vm_fault.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index da7b1f1d2d8e..8b212f3f84e5 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -894,6 +894,9 @@ vm_fault_cow(struct faultstate *fs) { bool is_first_object_locked; + KASSERT(fs->object != fs->first_object, + ("source and target COW objects are identical")); + /* * This allows pages to be virtually copied from a backing_object * into the first_object, where the backing object has no other @@ -957,11 +960,29 @@ vm_fault_cow(struct faultstate *fs) */ fs->m_cow = fs->m; fs->m = NULL; + + /* + * Typically, the shadow object is either private to this + * address space (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of a shadow object + * are read/write shared between this and other address spaces, + * we need to ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing object are + * removed from those other address spaces. + * + * The flag check is racy, but this is tolerable: if + * OBJ_ONEMAPPING is cleared after the check, the busy state + * ensures that new mappings of m_cow can't be created. + * pmap_enter() will replace an existing mapping in the current + * address space. If OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some unnecessary page + * faults. + */ + vm_page_assert_xbusied(fs->m_cow); + if ((fs->first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs->m_cow); } - /* - * fs->object != fs->first_object due to above - * conditional - */ + vm_object_pip_wakeup(fs->object); /* From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7F8B55B54A1; Tue, 6 Apr 2021 19:19:16 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQD36J7z4ckb; Tue, 6 Apr 2021 19:19:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C5BE117E1; Tue, 6 Apr 2021 19:19:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJGle097454; Tue, 6 Apr 2021 19:19:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJGgf097453; Tue, 6 Apr 2021 19:19:16 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:16 GMT Message-Id: <202104061919.136JJGgf097453@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 273977acb0aa - releng/13.0 - Add UPDATING entries and bump version MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 273977acb0aa4b999b851c85d8ce44db0ade1b44 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:16 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=273977acb0aa4b999b851c85d8ce44db0ade1b44 commit 273977acb0aa4b999b851c85d8ce44db0ade1b44 Author: Mark Johnston AuthorDate: 2021-04-06 19:03:53 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:19:09 +0000 Add UPDATING entries and bump version Approved by: re (implicit, so) Approved by: so --- UPDATING | 7 +++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 019b45d7c6e0..14efebc5d37b 100644 --- a/UPDATING +++ b/UPDATING @@ -11,6 +11,13 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +20210406: 13.0-RC5-p1 FreeBSD-SA-21:08.vm + FreeBSD-SA-21:10.jail_mount + + Memory disclosure by stale virtual memory mapping [SA-21:08.vm] + + Jail escape possible by mounting over jail root [SA-21:10.jail_mount] + 20210325: 13.0-RC3-p1 FreeBSD-SA-21:07.openssl Fix multiple OpenSSL issues [SA-21:07.openssl] diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 1afb885e9c9d..0d6ec4b72680 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -54,7 +54,7 @@ TYPE="FreeBSD" REVISION="13.0" -BRANCH="RC5" +BRANCH="RC5-p1" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 5F7265B51F2; Tue, 6 Apr 2021 19:19:15 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQC2JSrz4cnj; Tue, 6 Apr 2021 19:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4292811B98; Tue, 6 Apr 2021 19:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJFXe097428; Tue, 6 Apr 2021 19:19:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJFXW097427; Tue, 6 Apr 2021 19:19:15 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:15 GMT Message-Id: <202104061919.136JJFXW097427@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4710439ec594 - releng/13.0 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 4710439ec594a5375657acc403326f868d05a05a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:15 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4710439ec594a5375657acc403326f868d05a05a commit 4710439ec594a5375657acc403326f868d05a05a Author: Mark Johnston AuthorDate: 2021-04-05 21:19:15 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:18:59 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: re (so, implicit) Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount (cherry picked from commit 2425f5e9128102c8e6e473567ad6759a55be5b02) (cherry picked from commit 3ae17faa370491d7ce1fcfc4d5b9cd1ed0117b67) --- sys/kern/vfs_mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index b3870e46c5e9..59000728efcc 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -918,10 +918,10 @@ vfs_domount_first( /* * If the jail of the calling thread lacks permission for this type of - * file system, deny immediately. + * file system, or is trying to cover its own root, deny immediately. */ - if (jailed(td->td_ucred) && !prison_allow(td->td_ucred, - vfsp->vfc_prison_flag)) { + if (jailed(td->td_ucred) && (!prison_allow(td->td_ucred, + vfsp->vfc_prison_flag) || vp == td->td_ucred->cr_prison->pr_root)) { vput(vp); return (EPERM); } From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 AD1455B54D1; Tue, 6 Apr 2021 19:19:34 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQX1kcLz4d3b; Tue, 6 Apr 2021 19:19:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AEFAD11C14; Tue, 6 Apr 2021 19:19:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJSJt097591; Tue, 6 Apr 2021 19:19:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJSmK097590; Tue, 6 Apr 2021 19:19:28 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:28 GMT Message-Id: <202104061919.136JJSmK097590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 304a533fd2ec - stable/12 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 304a533fd2ec6d61805eb7c991b3e9ce502fc730 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:34 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=304a533fd2ec6d61805eb7c991b3e9ce502fc730 commit 304a533fd2ec6d61805eb7c991b3e9ce502fc730 Author: Mark Johnston AuthorDate: 2021-04-06 18:56:37 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 18:56:37 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm --- sys/vm/vm_fault.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cf2db256eaa3..7829b3691d83 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1298,6 +1298,33 @@ readrest: vm_page_unwire(fs.m, PQ_INACTIVE); vm_page_unlock(fs.m); } + + /* + * Typically, the shadow object is either + * private to this address space + * (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of + * a shadow object are read/write shared between + * this and other address spaces, we need to + * ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing + * object are removed from those other address + * spaces. + * + * The flag check is racy, but this is + * tolerable: if OBJ_ONEMAPPING is cleared after + * the check, the busy state ensures that new + * mappings of fs.m can't be created. + * pmap_enter() will replace an existing mapping + * in the current address space. If + * OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some + * unnecessary page faults. + */ + vm_page_assert_xbusied(fs.m); + if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs.m); + /* * We no longer need the old page or object. */ From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B69525B5793; Tue, 6 Apr 2021 19:19:34 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQX2DkSz4d0t; Tue, 6 Apr 2021 19:19:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D222E11A42; Tue, 6 Apr 2021 19:19:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJT5i097615; Tue, 6 Apr 2021 19:19:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJTWM097614; Tue, 6 Apr 2021 19:19:29 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:29 GMT Message-Id: <202104061919.136JJTWM097614@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 110ebf088682 - stable/12 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 110ebf0886825227d03d2ab17139a8741272aef5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:34 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=110ebf0886825227d03d2ab17139a8741272aef5 commit 110ebf0886825227d03d2ab17139a8741272aef5 Author: Mark Johnston AuthorDate: 2021-04-06 18:57:57 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 18:57:57 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount --- sys/kern/vfs_mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 9befa5361c16..4addc14f7541 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -844,10 +844,10 @@ vfs_domount_first( /* * If the jail of the calling thread lacks permission for this type of - * file system, deny immediately. + * file system, or is trying to cover its own root, deny immediately. */ - if (jailed(td->td_ucred) && !prison_allow(td->td_ucred, - vfsp->vfc_prison_flag)) { + if (jailed(td->td_ucred) && (!prison_allow(td->td_ucred, + vfsp->vfc_prison_flag) || vp == td->td_ucred->cr_prison->pr_root)) { vput(vp); return (EPERM); } From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 DB3735B57CE; Tue, 6 Apr 2021 19:19:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQz3JC5z4dCP; Tue, 6 Apr 2021 19:19:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8869C11A43; Tue, 6 Apr 2021 19:19:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJpp8097818; Tue, 6 Apr 2021 19:19:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJpRs097817; Tue, 6 Apr 2021 19:19:51 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:51 GMT Message-Id: <202104061919.136JJpRs097817@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 49f3ea024bc1 - releng/12.2 - accept_filter: Fix filter parameter handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 49f3ea024bc1a12c82d3729254221d5a0242794d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:57 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=49f3ea024bc1a12c82d3729254221d5a0242794d commit 49f3ea024bc1a12c82d3729254221d5a0242794d Author: Mark Johnston AuthorDate: 2021-03-25 21:55:20 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 18:59:00 +0000 accept_filter: Fix filter parameter handling For filters which implement accf_create, the setsockopt(2) handler caches the filter name in the socket, but it also incorrectly frees the buffer containing the copy, leaving a dangling pointer. Note that no accept filters provided in the base system are susceptible to this, as they don't implement accf_create. Reported by: Alexey Kulaev Discussed with: emaste Sponsored by: The FreeBSD Foundation Approved by: so Security: CVE-2021-29627 Security: FreeBSD-SA-21:09.accept_filter (cherry picked from commit 653a437c04440495cd8e7712c7cf39444f26f1ee) (cherry picked from commit 6008a5fad3c110c4ec03cc3fe60ce41c4e548b98) --- sys/kern/uipc_accf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c index 9aab541883d6..98cefe0789a8 100644 --- a/sys/kern/uipc_accf.c +++ b/sys/kern/uipc_accf.c @@ -298,6 +298,7 @@ accept_filt_setopt(struct socket *so, struct sockopt *sopt) so->sol_accept_filter = afp; so->sol_accept_filter_arg = accept_filter_arg; so->sol_accept_filter_str = accept_filter_str; + accept_filter_str = NULL; so->so_options |= SO_ACCEPTFILTER; out: SOCK_UNLOCK(so); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:19:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 CAF355B5641; Tue, 6 Apr 2021 19:19:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHQz0KXFz4dKv; Tue, 6 Apr 2021 19:19:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4C111174E; Tue, 6 Apr 2021 19:19:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJqnQ097848; Tue, 6 Apr 2021 19:19:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJqIo097847; Tue, 6 Apr 2021 19:19:52 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:52 GMT Message-Id: <202104061919.136JJqIo097847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 421c07013f2d - releng/12.2 - MFC r368588: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 421c07013f2d6de9bbd4b528897abef27c558b7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:19:57 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=421c07013f2d6de9bbd4b528897abef27c558b7e commit 421c07013f2d6de9bbd4b528897abef27c558b7e Author: Kristof Provost AuthorDate: 2020-12-15 08:29:45 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:00:05 +0000 MFC r368588: pf: Allow net.pf.request_maxcount to be set from loader.conf Mark request_maxcount as RWTUN so we can set it both at runtime and from loader.conf. This avoids users getting caught out by the change from tunable to run time configuration. Suggested by: Franco Fichtner Approved by: so Security: FreeBSD-EN-21:06.pf (cherry picked from commit 08d13750ebdae45bcdb73d52665b823e9ba93db1) --- sys/netpfil/pf/pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index f1d89a752f1e..bbc374365bdd 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -382,7 +382,7 @@ SYSCTL_ULONG(_net_pf, OID_AUTO, states_hashsize, CTLFLAG_RDTUN, &pf_hashsize, 0, "Size of pf(4) states hashtable"); SYSCTL_ULONG(_net_pf, OID_AUTO, source_nodes_hashsize, CTLFLAG_RDTUN, &pf_srchashsize, 0, "Size of pf(4) source nodes hashtable"); -SYSCTL_ULONG(_net_pf, OID_AUTO, request_maxcount, CTLFLAG_RW, +SYSCTL_ULONG(_net_pf, OID_AUTO, request_maxcount, CTLFLAG_RWTUN, &pf_ioctl_maxcount, 0, "Maximum number of tables, addresses, ... in a single ioctl() call"); VNET_DEFINE(void *, pf_swi_cookie); From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 382EB5B57DA; Tue, 6 Apr 2021 19:20:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHR24X9Lz4dR5; Tue, 6 Apr 2021 19:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 198C711A44; Tue, 6 Apr 2021 19:19:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJt6i097912; Tue, 6 Apr 2021 19:19:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJtOi097911; Tue, 6 Apr 2021 19:19:55 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:55 GMT Message-Id: <202104061919.136JJtOi097911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d50b66a6c387 - releng/12.2 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: d50b66a6c387930377f94c9362343cca8ddc0886 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:00 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d50b66a6c387930377f94c9362343cca8ddc0886 commit d50b66a6c387930377f94c9362343cca8ddc0886 Author: Mark Johnston AuthorDate: 2021-04-06 18:57:57 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:02:24 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount (cherry picked from commit 110ebf0886825227d03d2ab17139a8741272aef5) --- sys/kern/vfs_mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index afbb3e313d75..a7db7a3dd9d4 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -844,10 +844,10 @@ vfs_domount_first( /* * If the jail of the calling thread lacks permission for this type of - * file system, deny immediately. + * file system, or is trying to cover its own root, deny immediately. */ - if (jailed(td->td_ucred) && !prison_allow(td->td_ucred, - vfsp->vfc_prison_flag)) { + if (jailed(td->td_ucred) && (!prison_allow(td->td_ucred, + vfsp->vfc_prison_flag) || vp == td->td_ucred->cr_prison->pr_root)) { vput(vp); return (EPERM); } From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 AA8615B55DE; Tue, 6 Apr 2021 19:20:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHR24Jb1z4dR4; Tue, 6 Apr 2021 19:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E182F11969; Tue, 6 Apr 2021 19:19:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJsFO097891; Tue, 6 Apr 2021 19:19:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJsh1097890; Tue, 6 Apr 2021 19:19:54 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:54 GMT Message-Id: <202104061919.136JJsh1097890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e7b28b5bb38e - releng/12.2 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: e7b28b5bb38ed942bc49b4cf9d313f9a051c9966 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:00 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e7b28b5bb38ed942bc49b4cf9d313f9a051c9966 commit e7b28b5bb38ed942bc49b4cf9d313f9a051c9966 Author: Mark Johnston AuthorDate: 2021-04-06 18:56:37 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:02:17 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm (cherry picked from commit 304a533fd2ec6d61805eb7c991b3e9ce502fc730) --- sys/vm/vm_fault.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cf2db256eaa3..7829b3691d83 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1298,6 +1298,33 @@ readrest: vm_page_unwire(fs.m, PQ_INACTIVE); vm_page_unlock(fs.m); } + + /* + * Typically, the shadow object is either + * private to this address space + * (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of + * a shadow object are read/write shared between + * this and other address spaces, we need to + * ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing + * object are removed from those other address + * spaces. + * + * The flag check is racy, but this is + * tolerable: if OBJ_ONEMAPPING is cleared after + * the check, the busy state ensures that new + * mappings of fs.m can't be created. + * pmap_enter() will replace an existing mapping + * in the current address space. If + * OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some + * unnecessary page faults. + */ + vm_page_assert_xbusied(fs.m); + if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs.m); + /* * We no longer need the old page or object. */ From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 ADC845B55DF; Tue, 6 Apr 2021 19:20:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHR32prJz4dFT; Tue, 6 Apr 2021 19:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4A7D1174F; Tue, 6 Apr 2021 19:19:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJrV7097870; Tue, 6 Apr 2021 19:19:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJrUm097869; Tue, 6 Apr 2021 19:19:53 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:53 GMT Message-Id: <202104061919.136JJrUm097869@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f1d1353d2d7b - releng/12.2 - MFC r364480: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: f1d1353d2d7b84434cb7d6bb003d6f560bfc83e3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:01 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f1d1353d2d7b84434cb7d6bb003d6f560bfc83e3 commit f1d1353d2d7b84434cb7d6bb003d6f560bfc83e3 Author: Dimitry Andric AuthorDate: 2020-10-31 18:42:03 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:01:24 +0000 MFC r364480: Merge commit 1ce07cd614be from llvm git (by me): Instantiate Error in Target::GetEntryPointAddress() only when necessary When Target::GetEntryPointAddress() calls exe_module->GetObjectFile()->GetEntryPointAddress(), and the returned entry_addr is valid, it can immediately be returned. However, just before that, an llvm::Error value has been setup, but in this case it is not consumed before returning, like is done further below in the function. In https://bugs.freebsd.org/248745 we got a bug report for this, where a very simple test case aborts and dumps core: * thread #1, name = 'testcase', stop reason = breakpoint 1.1 frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5 1 int main(int argc, char *argv[]) 2 { -> 3 return 0; 4 } (lldb) p argc Program aborted due to an unhandled Error: Error value was Success. (Note: Success values must still be checked prior to being destroyed). Thread 1 received signal SIGABRT, Aborted. thr_kill () at thr_kill.S:3 3 thr_kill.S: No such file or directory. (gdb) bt #0 thr_kill () at thr_kill.S:3 #1 0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52 #2 0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 #3 0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112 #4 0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267 #5 0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67 #6 0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114 #7 0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97 #8 0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604 #9 0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347 #10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383 #11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301 #12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331 #13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190 #14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372 #15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414 #16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646 #17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003 #18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762 #19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760 #20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548 #21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903 #22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946 #23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169 #24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675 #25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890 Fix the incorrect error catch by only instantiating an Error object if it is necessary. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D86355 This should fix lldb aborting as described in the scenario above. Reported by: dmgk PR: 248745 Approved by: so Security: FreeBSD-EN-21:07.lldb (cherry picked from commit eb41eed03c084bd6eefe91992b0f704caa0fb58b) --- contrib/llvm-project/lldb/source/Target/Target.cpp | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/contrib/llvm-project/lldb/source/Target/Target.cpp b/contrib/llvm-project/lldb/source/Target/Target.cpp index 83e6f3062666..47e4c78496ab 100644 --- a/contrib/llvm-project/lldb/source/Target/Target.cpp +++ b/contrib/llvm-project/lldb/source/Target/Target.cpp @@ -2412,21 +2412,13 @@ lldb::addr_t Target::GetPersistentSymbol(ConstString name) { llvm::Expected Target::GetEntryPointAddress() { Module *exe_module = GetExecutableModulePointer(); - llvm::Error error = llvm::Error::success(); - assert(!error); // Check the success value when assertions are enabled. - if (!exe_module || !exe_module->GetObjectFile()) { - error = llvm::make_error("No primary executable found", - llvm::inconvertibleErrorCode()); - } else { + // Try to find the entry point address in the primary executable. + const bool has_primary_executable = exe_module && exe_module->GetObjectFile(); + if (has_primary_executable) { Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress(); if (entry_addr.IsValid()) return entry_addr; - - error = llvm::make_error( - "Could not find entry point address for executable module \"" + - exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", - llvm::inconvertibleErrorCode()); } const ModuleList &modules = GetImages(); @@ -2437,14 +2429,21 @@ llvm::Expected Target::GetEntryPointAddress() { continue; Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress(); - if (entry_addr.IsValid()) { - // Discard the error. - llvm::consumeError(std::move(error)); + if (entry_addr.IsValid()) return entry_addr; - } } - return std::move(error); + // We haven't found the entry point address. Return an appropriate error. + if (!has_primary_executable) + return llvm::make_error( + "No primary executable found and could not find entry point address in " + "any executable module", + llvm::inconvertibleErrorCode()); + + return llvm::make_error( + "Could not find entry point address for primary executable module \"" + + exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", + llvm::inconvertibleErrorCode()); } lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr, From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 398A95B572C; Tue, 6 Apr 2021 19:20:04 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHR64Q6Vz4dHk; Tue, 6 Apr 2021 19:20:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 27BDF11B99; Tue, 6 Apr 2021 19:19:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JJvgH097933; Tue, 6 Apr 2021 19:19:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JJvTL097932; Tue, 6 Apr 2021 19:19:57 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:19:57 GMT Message-Id: <202104061919.136JJvTL097932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: fb01adcfa76f - releng/12.2 - Add UPDATING entries and bump version MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: fb01adcfa76f0f32b7788d3a97c9fa79703a1caf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:04 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fb01adcfa76f0f32b7788d3a97c9fa79703a1caf commit fb01adcfa76f0f32b7788d3a97c9fa79703a1caf Author: Mark Johnston AuthorDate: 2021-04-06 19:07:29 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:07:29 +0000 Add UPDATING entries and bump version Approved by: so --- UPDATING | 16 ++++++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index dcb82fbcf4a6..60c75b005a0b 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,22 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210406: p6 FreeBSD-EN-21:06.pf + FreeBSD-EN-21:07.lldb + FreeBSD-SA-21:08.vm + FreeBSD-SA-21:09.accept_filter + FreeBSD-SA-21:10.jail_mount + + net.pf.request_maxcount not settable from loader.conf(5) [EN-21:06.pf] + + lldb abort on print command [EN-21:07.lldb] + + Memory disclosure by stale virtual memory mapping [SA-21:08.vm] + + Double free in accept_filter(9) socket configuration interface [SA-21:09.accept_filter] + + Jail escape possible by mounting over jail root [SA-21:10.jail_mount] + 20210325: p5 FreeBSD-SA-21:07.openssl Fix multiple OpenSSL issues [SA-21:07.openssl] diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 68ee29d30168..51990433f5e6 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.2" -BRANCH="RELEASE-p5" +BRANCH="RELEASE-p6" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 088205B57F3; Tue, 6 Apr 2021 19:20:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHRF1nF4z4dX1; Tue, 6 Apr 2021 19:20:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BDB6011C15; Tue, 6 Apr 2021 19:20:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JK6Th000732; Tue, 6 Apr 2021 19:20:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JK63K000730; Tue, 6 Apr 2021 19:20:06 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:06 GMT Message-Id: <202104061920.136JK63K000730@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 71a0b26df14a - stable/11 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 71a0b26df14a18b720faaa924bd4e18fcb9638d5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:11 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71a0b26df14a18b720faaa924bd4e18fcb9638d5 commit 71a0b26df14a18b720faaa924bd4e18fcb9638d5 Author: Mark Johnston AuthorDate: 2021-04-06 19:09:01 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:09:01 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm --- sys/vm/vm_fault.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cb21edb23f05..1d4736aa92bc 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1147,6 +1147,33 @@ readrest: vm_page_unwire(fs.m, PQ_INACTIVE); vm_page_unlock(fs.m); } + + /* + * Typically, the shadow object is either + * private to this address space + * (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of + * a shadow object are read/write shared between + * this and other address spaces, we need to + * ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing + * object are removed from those other address + * spaces. + * + * The flag check is racy, but this is + * tolerable: if OBJ_ONEMAPPING is cleared after + * the check, the busy state ensures that new + * mappings of fs.m can't be created. + * pmap_enter() will replace an existing mapping + * in the current address space. If + * OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some + * unnecessary page faults. + */ + vm_page_assert_xbusied(fs.m); + if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs.m); + /* * We no longer need the old page or object. */ From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 3CF605B57F8; Tue, 6 Apr 2021 19:20:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHRJ3b5mz4dPd; Tue, 6 Apr 2021 19:20:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C251911C16; Tue, 6 Apr 2021 19:20:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JK7Kg000944; Tue, 6 Apr 2021 19:20:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JK78P000942; Tue, 6 Apr 2021 19:20:07 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:07 GMT Message-Id: <202104061920.136JK78P000942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 6f7815083ad6 - stable/11 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 6f7815083ad66c34bad0dfa08c7033ff670b3be1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:13 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6f7815083ad66c34bad0dfa08c7033ff670b3be1 commit 6f7815083ad66c34bad0dfa08c7033ff670b3be1 Author: Mark Johnston AuthorDate: 2021-04-06 19:09:43 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:09:43 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount --- sys/kern/vfs_mount.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 7885052c27d6..613872303982 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -830,6 +830,11 @@ vfs_domount_first( ASSERT_VOP_ELOCKED(vp, __func__); KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); + if (vp == td->td_ucred->cr_prison->pr_root) { + vput(vp); + return (EPERM); + } + /* * If the user is not root, ensure that they own the directory * onto which we are attempting to mount. From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 AF41C5B599C; Tue, 6 Apr 2021 19:20:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHRd0b4yz4dTB; Tue, 6 Apr 2021 19:20:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 86E3D11B2B; Tue, 6 Apr 2021 19:20:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JKOdZ006558; Tue, 6 Apr 2021 19:20:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JKOtx006557; Tue, 6 Apr 2021 19:20:24 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:24 GMT Message-Id: <202104061920.136JKOtx006557@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e59bfcaa37fc - releng/11.4 - mount: Disallow mounting over a jail root MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: e59bfcaa37fc8fe5c6e200e53aa6daa841751cb7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:31 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e59bfcaa37fc8fe5c6e200e53aa6daa841751cb7 commit e59bfcaa37fc8fe5c6e200e53aa6daa841751cb7 Author: Mark Johnston AuthorDate: 2021-04-06 19:09:43 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:10:21 +0000 mount: Disallow mounting over a jail root Discussed with: jamie Approved by: so Security: CVE-2020-25584 Security: FreeBSD-SA-21:10.jail_mount (cherry picked from commit 6f7815083ad66c34bad0dfa08c7033ff670b3be1) --- sys/kern/vfs_mount.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 3e5ebe715a42..c88f2be54d02 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -830,6 +830,11 @@ vfs_domount_first( ASSERT_VOP_ELOCKED(vp, __func__); KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); + if (vp == td->td_ucred->cr_prison->pr_root) { + vput(vp); + return (EPERM); + } + /* * If the user is not root, ensure that they own the directory * onto which we are attempting to mount. From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 26FA65B58CC; Tue, 6 Apr 2021 19:20:31 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHRd45Zpz4dgR; Tue, 6 Apr 2021 19:20:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ADC9411B2C; Tue, 6 Apr 2021 19:20:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JKPS2006579; Tue, 6 Apr 2021 19:20:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JKPQk006578; Tue, 6 Apr 2021 19:20:25 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:25 GMT Message-Id: <202104061920.136JKPQk006578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: b2127f3c6b29 - releng/11.4 - Add UPDATING entries and bump version MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: b2127f3c6b298ad55cf2d84c484a7cf09b120191 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:31 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b2127f3c6b298ad55cf2d84c484a7cf09b120191 commit b2127f3c6b298ad55cf2d84c484a7cf09b120191 Author: Mark Johnston AuthorDate: 2021-04-06 19:11:19 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:11:19 +0000 Add UPDATING entries and bump version Approved by: so --- UPDATING | 7 +++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index f67b1d59b118..c9f01e72a4ba 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,13 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210406: p9 FreeBSD-SA-21:08.vm + FreeBSD-SA-21:10.jail_mount + + Memory disclosure by stale virtual memory mapping [SA-21:08.vm] + + Jail escape possible by mounting over jail root [SA-21:10.jail_mount] + 20210223: p8 FreeBSD-SA-21:03.pam_login_access FreeBSD-SA-21:04.jail_remove FreeBSD-SA-21:05.jail_chdir diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 96d5d515e010..095499d9ea62 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -44,7 +44,7 @@ TYPE="FreeBSD" REVISION="11.4" -BRANCH="RELEASE-p8" +BRANCH="RELEASE-p9" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 19:20:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A29DB5B599B; Tue, 6 Apr 2021 19:20:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFHRf10qPz4dk1; Tue, 6 Apr 2021 19:20:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FBDF11C8A; Tue, 6 Apr 2021 19:20:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136JKN5C006537; Tue, 6 Apr 2021 19:20:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JKNIO006536; Tue, 6 Apr 2021 19:20:23 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:23 GMT Message-Id: <202104061920.136JKNIO006536@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e5e06b6d295b - releng/11.4 - vm_fault: Shoot down multiply mapped COW source page mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: e5e06b6d295b5445a79eafaaa17af5aba1b8e972 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:31 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e5e06b6d295b5445a79eafaaa17af5aba1b8e972 commit e5e06b6d295b5445a79eafaaa17af5aba1b8e972 Author: Mark Johnston AuthorDate: 2021-04-06 19:09:01 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:10:17 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm (cherry picked from commit 71a0b26df14a18b720faaa924bd4e18fcb9638d5) --- sys/vm/vm_fault.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cb21edb23f05..1d4736aa92bc 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1147,6 +1147,33 @@ readrest: vm_page_unwire(fs.m, PQ_INACTIVE); vm_page_unlock(fs.m); } + + /* + * Typically, the shadow object is either + * private to this address space + * (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of + * a shadow object are read/write shared between + * this and other address spaces, we need to + * ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing + * object are removed from those other address + * spaces. + * + * The flag check is racy, but this is + * tolerable: if OBJ_ONEMAPPING is cleared after + * the check, the busy state ensures that new + * mappings of fs.m can't be created. + * pmap_enter() will replace an existing mapping + * in the current address space. If + * OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some + * unnecessary page faults. + */ + vm_page_assert_xbusied(fs.m); + if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs.m); + /* * We no longer need the old page or object. */ From owner-dev-commits-src-branches@freebsd.org Tue Apr 6 20:19:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C6FF95B7B0A; Tue, 6 Apr 2021 20:19:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFJmD40Cqz4lgY; Tue, 6 Apr 2021 20:19:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 42A6C124C5; Tue, 6 Apr 2021 20:19:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136KJuWd078079; Tue, 6 Apr 2021 20:19:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136KJuQj078078; Tue, 6 Apr 2021 20:19:56 GMT (envelope-from git) Date: Tue, 6 Apr 2021 20:19:56 GMT Message-Id: <202104062019.136KJuQj078078@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 81526c74d9cd - releng/12.2 - Correct EN numbers in the most recent UPDATING entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 81526c74d9cd16944ca240573680c358a031c989 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 20:19:56 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=81526c74d9cd16944ca240573680c358a031c989 commit 81526c74d9cd16944ca240573680c358a031c989 Author: Mark Johnston AuthorDate: 2021-04-06 20:18:44 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 20:18:44 +0000 Correct EN numbers in the most recent UPDATING entry Approved by: so --- UPDATING | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UPDATING b/UPDATING index 60c75b005a0b..898bd853fe9a 100644 --- a/UPDATING +++ b/UPDATING @@ -16,15 +16,15 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. -20210406: p6 FreeBSD-EN-21:06.pf - FreeBSD-EN-21:07.lldb +20210406: p6 FreeBSD-EN-21:09.pf + FreeBSD-EN-21:10.lldb FreeBSD-SA-21:08.vm FreeBSD-SA-21:09.accept_filter FreeBSD-SA-21:10.jail_mount - net.pf.request_maxcount not settable from loader.conf(5) [EN-21:06.pf] + net.pf.request_maxcount not settable from loader.conf(5) [EN-21:09.pf] - lldb abort on print command [EN-21:07.lldb] + lldb abort on print command [EN-21:10.lldb] Memory disclosure by stale virtual memory mapping [SA-21:08.vm] From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:31:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 80FBC5C36CD; Wed, 7 Apr 2021 00:31:16 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQLD3HQQz3DhR; Wed, 7 Apr 2021 00:31:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6397D1567B; Wed, 7 Apr 2021 00:31:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370VGeZ019506; Wed, 7 Apr 2021 00:31:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370VGT4019505; Wed, 7 Apr 2021 00:31:16 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:31:16 GMT Message-Id: <202104070031.1370VGT4019505@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 9c27e7141b74 - stable/13 - Change mwait_bm_avoidance use to match Linux. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9c27e7141b749d68d9fee68e5fb44413765265e2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:31:16 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=9c27e7141b749d68d9fee68e5fb44413765265e2 commit 9c27e7141b749d68d9fee68e5fb44413765265e2 Author: Alexander Motin AuthorDate: 2021-03-08 22:57:46 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:30:23 +0000 Change mwait_bm_avoidance use to match Linux. Even though the information is very limited, it seems the intent of this flag is to control ACPI_BITREG_BUS_MASTER_STATUS use for C3, not force ACPI_BITREG_ARB_DISABLE manipulations for C2, where it was never needed, and which register not really doing anything for years. It wasted lots of CPU time on congested global ACPI hardware lock when many CPU cores were trying to enter/exit deep C-states same time. On idle 80-core system it pushed ping localhost latency up to 20ms, since badport_bandlim() via counter_ratecheck() wakes up all CPUs same time once a second just to synchronously reset the counters. Now enabling C-states increases the latency from 0.1 to just 0.25ms. Discussed with: kib MFC after: 1 month (cherry picked from commit 455219675dbd61010e180cacdfed51e7e34111e1) --- sys/dev/acpica/acpi_cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index ce252ab92816..436dd9ddaa93 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1153,17 +1153,19 @@ acpi_cpu_idle(sbintime_t sbt) * driver polling for new devices keeps this bit set all the * time if USB is loaded. */ + cx_next = &sc->cpu_cx_states[cx_next_idx]; if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0 && - cx_next_idx > sc->cpu_non_c3) { + cx_next_idx > sc->cpu_non_c3 && + (!cx_next->do_mwait || cx_next->mwait_bm_avoidance)) { status = AcpiReadBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active); if (ACPI_SUCCESS(status) && bm_active != 0) { AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1); cx_next_idx = sc->cpu_non_c3; + cx_next = &sc->cpu_cx_states[cx_next_idx]; } } /* Select the next state and update statistics. */ - cx_next = &sc->cpu_cx_states[cx_next_idx]; sc->cpu_cx_stats[cx_next_idx]++; KASSERT(cx_next->type != ACPI_STATE_C0, ("acpi_cpu_idle: C0 sleep")); @@ -1197,7 +1199,7 @@ acpi_cpu_idle(sbintime_t sbt) * For C3, disable bus master arbitration and enable bus master wake * if BM control is available, otherwise flush the CPU cache. */ - if (cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) { + if (cx_next->type == ACPI_STATE_C3) { if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1); AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); @@ -1237,7 +1239,7 @@ acpi_cpu_idle(sbintime_t sbt) end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); /* Enable bus master arbitration and disable bus master wakeup. */ - if ((cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) && + if (cx_next->type == ACPI_STATE_C3 && (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0); AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:31:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A6F0D5C3815; Wed, 7 Apr 2021 00:31:17 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQLF4HSpz3Dc4; Wed, 7 Apr 2021 00:31:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 85F941567D; Wed, 7 Apr 2021 00:31:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370VHeg019527; Wed, 7 Apr 2021 00:31:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370VHEu019526; Wed, 7 Apr 2021 00:31:17 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:31:17 GMT Message-Id: <202104070031.1370VHEu019526@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: e6e4f79a6c4d - stable/13 - Do not read timer extra time when MWAIT is used. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e6e4f79a6c4d3fcde9999e2a7897451de204f1c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:31:17 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=e6e4f79a6c4d3fcde9999e2a7897451de204f1c7 commit e6e4f79a6c4d3fcde9999e2a7897451de204f1c7 Author: Alexander Motin AuthorDate: 2021-03-08 23:43:47 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:31:10 +0000 Do not read timer extra time when MWAIT is used. When we enter C2+ state via memory read, it may take chipset some time to stop CPU. Extra register read covers that time. But MWAIT makes CPU stop immediately, so we don't need to waste time after wakeup with interrupts still disabled, increasing latency. On my system it reduces ping localhost latency, waking up all CPUs once a second, from 277us to 242us. MFC after: 1 month (cherry picked from commit 075e4807df3e6b0d9196d56e4dbc33765d57e1f8) --- sys/dev/acpica/acpi_cpu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 436dd9ddaa93..56182ed743de 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1220,18 +1220,19 @@ acpi_cpu_idle(sbintime_t sbt) start_time = 0; cputicks = cpu_ticks(); } - if (cx_next->do_mwait) + if (cx_next->do_mwait) { acpi_cpu_idle_mwait(cx_next->mwait_hint); - else + } else { CPU_GET_REG(cx_next->p_lvlx, 1); + /* + * Read the end time twice. Since it may take an arbitrary time + * to enter the idle state, the first read may be executed before + * the processor has stopped. Doing it again provides enough + * margin that we are certain to have a correct value. + */ + AcpiGetTimer(&end_time); + } - /* - * Read the end time twice. Since it may take an arbitrary time - * to enter the idle state, the first read may be executed before - * the processor has stopped. Doing it again provides enough - * margin that we are certain to have a correct value. - */ - AcpiGetTimer(&end_time); if (cx_next->type == ACPI_STATE_C3) { AcpiGetTimer(&end_time); AcpiGetTimerDuration(start_time, end_time, &end_time); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:31:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C5BDA5C3838; Wed, 7 Apr 2021 00:31:47 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQLq5JmFz3F0V; Wed, 7 Apr 2021 00:31:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A934A15DC1; Wed, 7 Apr 2021 00:31:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370Vlhm020496; Wed, 7 Apr 2021 00:31:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370Vlb4020495; Wed, 7 Apr 2021 00:31:47 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:31:47 GMT Message-Id: <202104070031.1370Vlb4020495@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: c3afa8d1884f - stable/12 - Change mwait_bm_avoidance use to match Linux. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c3afa8d1884fd4eaef0cecc1a009f1121ad3a11c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:31:47 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c3afa8d1884fd4eaef0cecc1a009f1121ad3a11c commit c3afa8d1884fd4eaef0cecc1a009f1121ad3a11c Author: Alexander Motin AuthorDate: 2021-03-08 22:57:46 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:31:38 +0000 Change mwait_bm_avoidance use to match Linux. Even though the information is very limited, it seems the intent of this flag is to control ACPI_BITREG_BUS_MASTER_STATUS use for C3, not force ACPI_BITREG_ARB_DISABLE manipulations for C2, where it was never needed, and which register not really doing anything for years. It wasted lots of CPU time on congested global ACPI hardware lock when many CPU cores were trying to enter/exit deep C-states same time. On idle 80-core system it pushed ping localhost latency up to 20ms, since badport_bandlim() via counter_ratecheck() wakes up all CPUs same time once a second just to synchronously reset the counters. Now enabling C-states increases the latency from 0.1 to just 0.25ms. Discussed with: kib MFC after: 1 month (cherry picked from commit 455219675dbd61010e180cacdfed51e7e34111e1) --- sys/dev/acpica/acpi_cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 4d7573d9b7d2..94f5b981b3c1 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1155,17 +1155,19 @@ acpi_cpu_idle(sbintime_t sbt) * driver polling for new devices keeps this bit set all the * time if USB is loaded. */ + cx_next = &sc->cpu_cx_states[cx_next_idx]; if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0 && - cx_next_idx > sc->cpu_non_c3) { + cx_next_idx > sc->cpu_non_c3 && + (!cx_next->do_mwait || cx_next->mwait_bm_avoidance)) { status = AcpiReadBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, &bm_active); if (ACPI_SUCCESS(status) && bm_active != 0) { AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_STATUS, 1); cx_next_idx = sc->cpu_non_c3; + cx_next = &sc->cpu_cx_states[cx_next_idx]; } } /* Select the next state and update statistics. */ - cx_next = &sc->cpu_cx_states[cx_next_idx]; sc->cpu_cx_stats[cx_next_idx]++; KASSERT(cx_next->type != ACPI_STATE_C0, ("acpi_cpu_idle: C0 sleep")); @@ -1199,7 +1201,7 @@ acpi_cpu_idle(sbintime_t sbt) * For C3, disable bus master arbitration and enable bus master wake * if BM control is available, otherwise flush the CPU cache. */ - if (cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) { + if (cx_next->type == ACPI_STATE_C3) { if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1); AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); @@ -1239,7 +1241,7 @@ acpi_cpu_idle(sbintime_t sbt) end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); /* Enable bus master arbitration and disable bus master wakeup. */ - if ((cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) && + if (cx_next->type == ACPI_STATE_C3 && (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0); AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:31:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0520A5C36E2; Wed, 7 Apr 2021 00:31:49 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQLr6bpFz3Drm; Wed, 7 Apr 2021 00:31:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB97615F8E; Wed, 7 Apr 2021 00:31:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370VmST020517; Wed, 7 Apr 2021 00:31:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370Vm9J020516; Wed, 7 Apr 2021 00:31:48 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:31:48 GMT Message-Id: <202104070031.1370Vm9J020516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 40074783d818 - stable/12 - Do not read timer extra time when MWAIT is used. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 40074783d8189c1f278d4fe5c373e45a85168534 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:31:49 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=40074783d8189c1f278d4fe5c373e45a85168534 commit 40074783d8189c1f278d4fe5c373e45a85168534 Author: Alexander Motin AuthorDate: 2021-03-08 23:43:47 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:31:43 +0000 Do not read timer extra time when MWAIT is used. When we enter C2+ state via memory read, it may take chipset some time to stop CPU. Extra register read covers that time. But MWAIT makes CPU stop immediately, so we don't need to waste time after wakeup with interrupts still disabled, increasing latency. On my system it reduces ping localhost latency, waking up all CPUs once a second, from 277us to 242us. MFC after: 1 month (cherry picked from commit 075e4807df3e6b0d9196d56e4dbc33765d57e1f8) --- sys/dev/acpica/acpi_cpu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 94f5b981b3c1..44662741a040 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1222,18 +1222,19 @@ acpi_cpu_idle(sbintime_t sbt) start_time = 0; cputicks = cpu_ticks(); } - if (cx_next->do_mwait) + if (cx_next->do_mwait) { acpi_cpu_idle_mwait(cx_next->mwait_hint); - else + } else { CPU_GET_REG(cx_next->p_lvlx, 1); + /* + * Read the end time twice. Since it may take an arbitrary time + * to enter the idle state, the first read may be executed before + * the processor has stopped. Doing it again provides enough + * margin that we are certain to have a correct value. + */ + AcpiGetTimer(&end_time); + } - /* - * Read the end time twice. Since it may take an arbitrary time - * to enter the idle state, the first read may be executed before - * the processor has stopped. Doing it again provides enough - * margin that we are certain to have a correct value. - */ - AcpiGetTimer(&end_time); if (cx_next->type == ACPI_STATE_C3) { AcpiGetTimer(&end_time); AcpiGetTimerDuration(start_time, end_time, &end_time); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:34:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 40F735C3E1E; Wed, 7 Apr 2021 00:34:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQPT1Lfxz3FXQ; Wed, 7 Apr 2021 00:34:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2130B15E17; Wed, 7 Apr 2021 00:34:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370Y5eU023783; Wed, 7 Apr 2021 00:34:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370Y5o4023782; Wed, 7 Apr 2021 00:34:05 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:34:05 GMT Message-Id: <202104070034.1370Y5o4023782@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 88fe518973b7 - stable/13 - Move time math out of disabled interrupts sections. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 88fe518973b7d94736394e379ed50cce01f6cc70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:34:05 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=88fe518973b7d94736394e379ed50cce01f6cc70 commit 88fe518973b7d94736394e379ed50cce01f6cc70 Author: Alexander Motin AuthorDate: 2021-03-10 18:39:15 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:33:59 +0000 Move time math out of disabled interrupts sections. We don't need the result before next sleep time, so no reason to additionally increase interrupt latency. While there, remove extra PM ticks to microseconds conversion, making C2/C3 sleep times look 4 times smaller than really. The conversion is already done by AcpiGetTimerDuration(). Now I see reported sleep times up to 0.5s, just as expected for planned 2 wakeups per second. MFC after: 1 month (cherry picked from commit 2cee045b4d62568d065b838a6cf129fed2424709) --- sys/dev/acpica/acpi_cpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 56182ed743de..3c81d55436ca 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -114,8 +114,6 @@ struct acpi_cpu_device { (bus_space_write_ ## width(rman_get_bustag((reg)), \ rman_get_bushandle((reg)), 0, (val))) -#define PM_USEC(x) ((x) >> 2) /* ~4 clocks per usec (3.57955 Mhz) */ - #define ACPI_NOTIFY_CX_STATES 0x81 /* _CST changed. */ #define CPU_QUIRK_NO_C3 (1<<0) /* C3-type states are not usable. */ @@ -1107,7 +1105,7 @@ acpi_cpu_idle(sbintime_t sbt) { struct acpi_cpu_softc *sc; struct acpi_cx *cx_next; - uint64_t cputicks; + uint64_t start_ticks, end_ticks; uint32_t start_time, end_time; ACPI_STATUS status; int bm_active, cx_next_idx, i, us; @@ -1176,7 +1174,7 @@ acpi_cpu_idle(sbintime_t sbt) * we are called inside critical section, delaying context switch. */ if (cx_next->type == ACPI_STATE_C1) { - cputicks = cpu_ticks(); + start_ticks = cpu_ticks(); if (cx_next->p_lvlx != NULL) { /* C1 I/O then Halt */ CPU_GET_REG(cx_next->p_lvlx, 1); @@ -1185,12 +1183,13 @@ acpi_cpu_idle(sbintime_t sbt) acpi_cpu_idle_mwait(cx_next->mwait_hint); else acpi_cpu_c1(); - end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); - if (curthread->td_critnest == 0) - end_time = min(end_time, 500000 / hz); + end_ticks = cpu_ticks(); /* acpi_cpu_c1() returns with interrupts enabled. */ if (cx_next->do_mwait) ACPI_ENABLE_IRQS(); + end_time = ((end_ticks - start_ticks) << 20) / cpu_tickrate(); + if (!cx_next->do_mwait && curthread->td_critnest == 0) + end_time = min(end_time, 500000 / hz); sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4; return; } @@ -1215,10 +1214,10 @@ acpi_cpu_idle(sbintime_t sbt) */ if (cx_next->type == ACPI_STATE_C3) { AcpiGetTimer(&start_time); - cputicks = 0; + start_ticks = 0; } else { start_time = 0; - cputicks = cpu_ticks(); + start_ticks = cpu_ticks(); } if (cx_next->do_mwait) { acpi_cpu_idle_mwait(cx_next->mwait_hint); @@ -1233,11 +1232,10 @@ acpi_cpu_idle(sbintime_t sbt) AcpiGetTimer(&end_time); } - if (cx_next->type == ACPI_STATE_C3) { + if (cx_next->type == ACPI_STATE_C3) AcpiGetTimer(&end_time); - AcpiGetTimerDuration(start_time, end_time, &end_time); - } else - end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); + else + end_ticks = cpu_ticks(); /* Enable bus master arbitration and disable bus master wakeup. */ if (cx_next->type == ACPI_STATE_C3 && @@ -1247,7 +1245,11 @@ acpi_cpu_idle(sbintime_t sbt) } ACPI_ENABLE_IRQS(); - sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + PM_USEC(end_time)) / 4; + if (cx_next->type == ACPI_STATE_C3) + AcpiGetTimerDuration(start_time, end_time, &end_time); + else + end_time = ((end_ticks - start_ticks) << 20) / cpu_tickrate(); + sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4; } #endif From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 00:34:18 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 90F2E5C3DD1; Wed, 7 Apr 2021 00:34:18 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFQPk2b47z3FfH; Wed, 7 Apr 2021 00:34:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A32115FA6; Wed, 7 Apr 2021 00:34:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1370YIFM023907; Wed, 7 Apr 2021 00:34:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1370YI1r023906; Wed, 7 Apr 2021 00:34:18 GMT (envelope-from git) Date: Wed, 7 Apr 2021 00:34:18 GMT Message-Id: <202104070034.1370YI1r023906@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 0d745e16f2d7 - stable/12 - Move time math out of disabled interrupts sections. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 0d745e16f2d79951a35d822a26c7145de804cc26 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 00:34:18 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=0d745e16f2d79951a35d822a26c7145de804cc26 commit 0d745e16f2d79951a35d822a26c7145de804cc26 Author: Alexander Motin AuthorDate: 2021-03-10 18:39:15 +0000 Commit: Alexander Motin CommitDate: 2021-04-07 00:34:12 +0000 Move time math out of disabled interrupts sections. We don't need the result before next sleep time, so no reason to additionally increase interrupt latency. While there, remove extra PM ticks to microseconds conversion, making C2/C3 sleep times look 4 times smaller than really. The conversion is already done by AcpiGetTimerDuration(). Now I see reported sleep times up to 0.5s, just as expected for planned 2 wakeups per second. MFC after: 1 month (cherry picked from commit 2cee045b4d62568d065b838a6cf129fed2424709) --- sys/dev/acpica/acpi_cpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 44662741a040..ca4162e5faa5 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -114,8 +114,6 @@ struct acpi_cpu_device { (bus_space_write_ ## width(rman_get_bustag((reg)), \ rman_get_bushandle((reg)), 0, (val))) -#define PM_USEC(x) ((x) >> 2) /* ~4 clocks per usec (3.57955 Mhz) */ - #define ACPI_NOTIFY_CX_STATES 0x81 /* _CST changed. */ #define CPU_QUIRK_NO_C3 (1<<0) /* C3-type states are not usable. */ @@ -1109,7 +1107,7 @@ acpi_cpu_idle(sbintime_t sbt) { struct acpi_cpu_softc *sc; struct acpi_cx *cx_next; - uint64_t cputicks; + uint64_t start_ticks, end_ticks; uint32_t start_time, end_time; ACPI_STATUS status; int bm_active, cx_next_idx, i, us; @@ -1178,7 +1176,7 @@ acpi_cpu_idle(sbintime_t sbt) * we are called inside critical section, delaying context switch. */ if (cx_next->type == ACPI_STATE_C1) { - cputicks = cpu_ticks(); + start_ticks = cpu_ticks(); if (cx_next->p_lvlx != NULL) { /* C1 I/O then Halt */ CPU_GET_REG(cx_next->p_lvlx, 1); @@ -1187,12 +1185,13 @@ acpi_cpu_idle(sbintime_t sbt) acpi_cpu_idle_mwait(cx_next->mwait_hint); else acpi_cpu_c1(); - end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); - if (curthread->td_critnest == 0) - end_time = min(end_time, 500000 / hz); + end_ticks = cpu_ticks(); /* acpi_cpu_c1() returns with interrupts enabled. */ if (cx_next->do_mwait) ACPI_ENABLE_IRQS(); + end_time = ((end_ticks - start_ticks) << 20) / cpu_tickrate(); + if (!cx_next->do_mwait && curthread->td_critnest == 0) + end_time = min(end_time, 500000 / hz); sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4; return; } @@ -1217,10 +1216,10 @@ acpi_cpu_idle(sbintime_t sbt) */ if (cx_next->type == ACPI_STATE_C3) { AcpiGetTimer(&start_time); - cputicks = 0; + start_ticks = 0; } else { start_time = 0; - cputicks = cpu_ticks(); + start_ticks = cpu_ticks(); } if (cx_next->do_mwait) { acpi_cpu_idle_mwait(cx_next->mwait_hint); @@ -1235,11 +1234,10 @@ acpi_cpu_idle(sbintime_t sbt) AcpiGetTimer(&end_time); } - if (cx_next->type == ACPI_STATE_C3) { + if (cx_next->type == ACPI_STATE_C3) AcpiGetTimer(&end_time); - AcpiGetTimerDuration(start_time, end_time, &end_time); - } else - end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); + else + end_ticks = cpu_ticks(); /* Enable bus master arbitration and disable bus master wakeup. */ if (cx_next->type == ACPI_STATE_C3 && @@ -1249,7 +1247,11 @@ acpi_cpu_idle(sbintime_t sbt) } ACPI_ENABLE_IRQS(); - sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + PM_USEC(end_time)) / 4; + if (cx_next->type == ACPI_STATE_C3) + AcpiGetTimerDuration(start_time, end_time, &end_time); + else + end_time = ((end_ticks - start_ticks) << 20) / cpu_tickrate(); + sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4; } #endif From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 03:12:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6482E5C6853; Wed, 7 Apr 2021 03:12:10 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFTvt2HjGz3Ql0; Wed, 7 Apr 2021 03:12:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41BAB17EB8; Wed, 7 Apr 2021 03:12:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1373CAUf036156; Wed, 7 Apr 2021 03:12:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1373CAas036155; Wed, 7 Apr 2021 03:12:10 GMT (envelope-from git) Date: Wed, 7 Apr 2021 03:12:10 GMT Message-Id: <202104070312.1373CAas036155@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brandon Bergren Subject: git: a8b0d01fedbf - stable/13 - powerpc/pseries: Add new hypercall definition, H_REGISTER_PROC_TBL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bdragon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a8b0d01fedbf5c73c796b5f2ce6256d552ea7f8c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 03:12:10 -0000 The branch stable/13 has been updated by bdragon: URL: https://cgit.FreeBSD.org/src/commit/?id=a8b0d01fedbf5c73c796b5f2ce6256d552ea7f8c commit a8b0d01fedbf5c73c796b5f2ce6256d552ea7f8c Author: Justin Hibbits AuthorDate: 2020-08-16 16:01:49 +0000 Commit: Brandon Bergren CommitDate: 2021-04-07 03:10:09 +0000 powerpc/pseries: Add new hypercall definition, H_REGISTER_PROC_TBL This will be used by the Radix MMU on pseries. (cherry picked from commit a5f07fa0c6b162964b414d00fab319fd13c61f57) --- sys/powerpc/pseries/phyp-hvcall.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/powerpc/pseries/phyp-hvcall.h b/sys/powerpc/pseries/phyp-hvcall.h index fdc6a774ce03..90f75807e56a 100644 --- a/sys/powerpc/pseries/phyp-hvcall.h +++ b/sys/powerpc/pseries/phyp-hvcall.h @@ -321,7 +321,9 @@ #define H_SET_MODE 0x31C /* Reserved ... */ #define H_GET_DMA_XLATES_L 0x324 -#define MAX_HCALL_OPCODE H_GET_DMA_XLATES_L +/* Reserved ... */ +#define H_REGISTER_PROC_TBL 0x37c +#define MAX_HCALL_OPCODE H_REGISTER_PROC_TBL int64_t phyp_hcall(uint64_t opcode, ...); int64_t phyp_pft_hcall(uint64_t opcode, uint64_t flags, uint64_t pteidx, From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 03:12:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 824CC5C685B; Wed, 7 Apr 2021 03:12:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFTvv3GVsz3QfJ; Wed, 7 Apr 2021 03:12:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6171617EB9; Wed, 7 Apr 2021 03:12:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1373CB3I036177; Wed, 7 Apr 2021 03:12:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1373CBcJ036176; Wed, 7 Apr 2021 03:12:11 GMT (envelope-from git) Date: Wed, 7 Apr 2021 03:12:11 GMT Message-Id: <202104070312.1373CBcJ036176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brandon Bergren Subject: git: 557ab8869921 - stable/13 - [PowerPC] Remove unused IPI type count tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bdragon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 557ab8869921c226c7d7b9b9a7f44adfcdea042a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 03:12:11 -0000 The branch stable/13 has been updated by bdragon: URL: https://cgit.FreeBSD.org/src/commit/?id=557ab8869921c226c7d7b9b9a7f44adfcdea042a commit 557ab8869921c226c7d7b9b9a7f44adfcdea042a Author: Justin Hibbits AuthorDate: 2020-09-24 15:00:31 +0000 Commit: Brandon Bergren CommitDate: 2021-04-07 03:10:40 +0000 [PowerPC] Remove unused IPI type count tracking. ipi_msg_count is inaccessible outside this file and is never read. It was introduced in the original SMP support code in r178628 and was never actually used anywhere. Remove it to slightly improve IPI performance. Submitted by: jhibbits (cherry picked from commit 74f6cb0f316bc0f8fae0b7f31d78d041dc4d509e) --- sys/powerpc/powerpc/mp_machdep.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 619c344b69a7..a9f2aaf36adc 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); volatile static int ap_awake; volatile static u_int ap_letgo; volatile static u_quad_t ap_timebase; -static u_int ipi_msg_cnt[32]; static struct mtx ap_boot_mtx; struct pcb stoppcbs[MAXCPU]; @@ -309,7 +308,6 @@ powerpc_ipi_handler(void *arg) return (FILTER_STRAY); while ((msg = ffs(ipimask) - 1) != -1) { ipimask &= ~(1u << msg); - ipi_msg_cnt[msg]++; switch (msg) { case IPI_AST: CTR1(KTR_SMP, "%s: IPI_AST", __func__); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 03:32:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A95B25C7905; Wed, 7 Apr 2021 03:32:53 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFVMn4MtQz3hpw; Wed, 7 Apr 2021 03:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 88E2618588; Wed, 7 Apr 2021 03:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1373Wrrj062712; Wed, 7 Apr 2021 03:32:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1373WrdD062711; Wed, 7 Apr 2021 03:32:53 GMT (envelope-from git) Date: Wed, 7 Apr 2021 03:32:53 GMT Message-Id: <202104070332.1373WrdD062711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2f5491784ebc - stable/13 - vxlan: correct interface MTU when using hw offloads MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2f5491784ebc64e838a94480cd90d416df6f8457 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 03:32:53 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2f5491784ebc64e838a94480cd90d416df6f8457 commit 2f5491784ebc64e838a94480cd90d416df6f8457 Author: Konstantin Belousov AuthorDate: 2021-03-29 09:03:07 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-07 03:32:39 +0000 vxlan: correct interface MTU when using hw offloads (cherry picked from commit baacf701372bfeb3927c6b9e0b85d6eff198c6a3) --- share/man/man4/vxlan.4 | 15 +++++++++++++-- sys/net/if_vxlan.c | 17 +++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/share/man/man4/vxlan.4 b/share/man/man4/vxlan.4 index 1848897d97c9..99f3411c02d2 100644 --- a/share/man/man4/vxlan.4 +++ b/share/man/man4/vxlan.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2020 +.Dd March 30, 2021 .Dt VXLAN 4 .Os .Sh NAME @@ -175,13 +175,24 @@ The .Nm specification recommends the physical network MTU be configured to use jumbo frames to accommodate the encapsulated frame size. +.Pp +By default, the +.Nm +driver sets its MTU to usual ethernet MTU of 1500 bytes, reduced by +the size of vxlan headers prepended to the encapsulated packets. +.Pp Alternatively, the .Xr ifconfig 8 .Cm mtu -command may be used to reduce the MTU size on the +command may be used to set the fixed MTU size on the .Nm interface to allow the encapsulated frame to fit in the current MTU of the physical network. +If the +.Cm mtu +command was used, system no longer adjust the +.Nm +interface MTU on routing or address changes. .Sh HARDWARE The .Nm diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index d0d335dba9ed..dd6e4522ccbb 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -171,6 +171,7 @@ struct vxlan_softc { #define VXLAN_FLAG_INIT 0x0001 #define VXLAN_FLAG_TEARDOWN 0x0002 #define VXLAN_FLAG_LEARN 0x0004 +#define VXLAN_FLAG_USER_MTU 0x0008 uint32_t vxl_port_hash_key; uint16_t vxl_min_port; @@ -1620,6 +1621,8 @@ vxlan_setup_interface_hdrlen(struct vxlan_softc *sc) { struct ifnet *ifp; + VXLAN_LOCK_WASSERT(sc); + ifp = sc->vxl_ifp; ifp->if_hdrlen = ETHER_HDR_LEN + sizeof(struct vxlanudphdr); @@ -1627,6 +1630,9 @@ vxlan_setup_interface_hdrlen(struct vxlan_softc *sc) ifp->if_hdrlen += sizeof(struct ip); else if (VXLAN_SOCKADDR_IS_IPV6(&sc->vxl_dst_addr) != 0) ifp->if_hdrlen += sizeof(struct ip6_hdr); + + if ((sc->vxl_flags & VXLAN_FLAG_USER_MTU) == 0) + ifp->if_mtu = ETHERMTU - ifp->if_hdrlen; } static int @@ -2354,10 +2360,14 @@ vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCSIFMTU: - if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > VXLAN_MAX_MTU) + if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > VXLAN_MAX_MTU) { error = EINVAL; - else + } else { + VXLAN_WLOCK(sc); ifp->if_mtu = ifr->ifr_mtu; + sc->vxl_flags |= VXLAN_FLAG_USER_MTU; + VXLAN_WUNLOCK(sc); + } break; case SIOCSIFCAP: @@ -3210,7 +3220,10 @@ vxlan_clone_create(struct if_clone *ifc, int unit, caddr_t params) ether_ifattach(ifp, sc->vxl_hwaddr.octet); ifp->if_baudrate = 0; + + VXLAN_WLOCK(sc); vxlan_setup_interface_hdrlen(sc); + VXLAN_WUNLOCK(sc); return (0); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 03:32:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 CA1AD5C751E; Wed, 7 Apr 2021 03:32:54 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFVMp5N5dz3hs6; Wed, 7 Apr 2021 03:32:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB72E18589; Wed, 7 Apr 2021 03:32:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1373Ws66062737; Wed, 7 Apr 2021 03:32:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1373WsYW062736; Wed, 7 Apr 2021 03:32:54 GMT (envelope-from git) Date: Wed, 7 Apr 2021 03:32:54 GMT Message-Id: <202104070332.1373WsYW062736@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5cbc9d80b8ab - stable/13 - mbuf: add a way to mark flowid as calculated from the internal headers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5cbc9d80b8ab3dbc85538fdf72b1228223591f5b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 03:32:54 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5cbc9d80b8ab3dbc85538fdf72b1228223591f5b commit 5cbc9d80b8ab3dbc85538fdf72b1228223591f5b Author: Konstantin Belousov AuthorDate: 2021-02-12 13:38:07 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-07 03:32:39 +0000 mbuf: add a way to mark flowid as calculated from the internal headers (cherry picked from commit e243367b644562c9410b39f8d78dafdb7e785d85) --- sys/kern/uipc_mbuf.c | 23 +++++++++++++++++++++++ sys/net/if_gif.c | 3 ++- sys/net/if_vxlan.c | 3 ++- sys/sys/mbuf.h | 12 +++++++++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 5296aac0edc4..f7852bc7dd7f 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -855,6 +855,29 @@ m_adj(struct mbuf *mp, int req_len) } } +void +m_adj_decap(struct mbuf *mp, int len) +{ + uint8_t rsstype; + + m_adj(mp, len); + if ((mp->m_flags & M_PKTHDR) != 0) { + /* + * If flowid was calculated by card from the inner + * headers, move flowid to the decapsulated mbuf + * chain, otherwise clear. This depends on the + * internals of m_adj, which keeps pkthdr as is, in + * particular not changing rsstype and flowid. + */ + rsstype = mp->m_pkthdr.rsstype; + if ((rsstype & M_HASHTYPE_INNER) != 0) { + M_HASHTYPE_SET(mp, rsstype & ~M_HASHTYPE_INNER); + } else { + M_HASHTYPE_CLEAR(mp); + } + } +} + /* * Rearange an mbuf chain so that len bytes are contiguous * and in the data area of an mbuf (so that mtod will work diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 1784d034ac2d..113bcb5c916e 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -540,7 +540,8 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn) m_freem(m); goto drop; } - m_adj(m, sizeof(struct etherip_header)); + + m_adj_decap(m, sizeof(struct etherip_header)); m->m_flags &= ~(M_BCAST|M_MCAST); m->m_pkthdr.rcvif = ifp; diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index dd6e4522ccbb..f56ec23540a7 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2790,8 +2790,9 @@ vxlan_rcv_udp_packet(struct mbuf *m, int offset, struct inpcb *inpcb, goto out; vni = ntohl(vxh->vxlh_vni) >> VXLAN_HDR_VNI_SHIFT; + /* Adjust to the start of the inner Ethernet frame. */ - m_adj(m, offset + sizeof(struct vxlan_header)); + m_adj_decap(m, offset + sizeof(struct vxlan_header)); error = vxlan_input(vso, vni, &m, srcsa); MPASS(error != 0 || m == NULL); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index e7d958da2037..0a249b6e2c6a 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -531,6 +531,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) * https://docs.microsoft.com/en-us/windows-hardware/drivers/network/rss-hashing-types#ndishashipv6ex */ #define M_HASHTYPE_HASHPROP 0x80 /* has hash properties */ +#define M_HASHTYPE_INNER 0x40 /* calculated from inner headers */ #define M_HASHTYPE_HASH(t) (M_HASHTYPE_HASHPROP | (t)) /* Microsoft RSS standard hash types */ #define M_HASHTYPE_NONE 0 @@ -547,15 +548,19 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) #define M_HASHTYPE_RSS_UDP_IPV6_EX M_HASHTYPE_HASH(10)/* IPv6 UDP 4-tuple + * ext hdrs */ -#define M_HASHTYPE_OPAQUE 63 /* ordering, not affinity */ +#define M_HASHTYPE_OPAQUE 0x3f /* ordering, not affinity */ #define M_HASHTYPE_OPAQUE_HASH M_HASHTYPE_HASH(M_HASHTYPE_OPAQUE) /* ordering+hash, not affinity*/ #define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0) -#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype) +#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype & ~M_HASHTYPE_INNER) #define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v)) #define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) -#define M_HASHTYPE_ISHASH(m) (M_HASHTYPE_GET(m) & M_HASHTYPE_HASHPROP) +#define M_HASHTYPE_ISHASH(m) \ + (((m)->m_pkthdr.rsstype & M_HASHTYPE_HASHPROP) != 0) +#define M_HASHTYPE_SETINNER(m) do { \ + (m)->m_pkthdr.rsstype |= M_HASHTYPE_INNER; \ + } while (0) /* * External mbuf storage buffer types. @@ -791,6 +796,7 @@ int mb_unmapped_compress(struct mbuf *m); struct mbuf *mb_unmapped_to_ext(struct mbuf *m); void mb_free_notready(struct mbuf *m, int count); void m_adj(struct mbuf *, int); +void m_adj_decap(struct mbuf *, int); int m_apply(struct mbuf *, int, int, int (*)(void *, void *, u_int), void *); int m_append(struct mbuf *, int, c_caddr_t); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 03:32:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 436FE5C7893; Wed, 7 Apr 2021 03:32:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFVMr078Tz3hgw; Wed, 7 Apr 2021 03:32:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8D2D181BC; Wed, 7 Apr 2021 03:32:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1373Wtgh062761; Wed, 7 Apr 2021 03:32:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1373WtkB062760; Wed, 7 Apr 2021 03:32:55 GMT (envelope-from git) Date: Wed, 7 Apr 2021 03:32:55 GMT Message-Id: <202104070332.1373WtkB062760@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b007a05b5a45 - stable/13 - Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b007a05b5a45901f3b0b9ce368707e7b40c04924 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 03:32:56 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b007a05b5a45901f3b0b9ce368707e7b40c04924 commit b007a05b5a45901f3b0b9ce368707e7b40c04924 Author: Konstantin Belousov AuthorDate: 2021-04-04 16:27:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-07 03:32:40 +0000 Style (cherry picked from commit 51a7be5f6036ebd47c8b3f704d52e7ec3f837114) --- sys/vm/vm_kern.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 0677d901d408..8d6e4f678970 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -886,7 +886,7 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) i = 0; error = sysctl_handle_int(oidp, &i, 0, req); - if (error) + if (error != 0) return (error); if ((i & ~(VM_LOW_KMEM | VM_LOW_PAGES)) != 0) return (EINVAL); @@ -895,5 +895,6 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) return (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"); +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"); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 10:56:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D04D65D2D12; Wed, 7 Apr 2021 10:56:04 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFhC85fFzz4r9m; Wed, 7 Apr 2021 10:56:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFAF71DBFF; Wed, 7 Apr 2021 10:56:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Au4sX046721; Wed, 7 Apr 2021 10:56:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Au4E6046720; Wed, 7 Apr 2021 10:56:04 GMT (envelope-from git) Date: Wed, 7 Apr 2021 10:56:04 GMT Message-Id: <202104071056.137Au4E6046720@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: c5345a05ce7d - stable/13 - ivrs_drv: Fix IVHDs with duplicated BaseAddress MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c5345a05ce7dc86c422bdb707e817407ab52fa21 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 10:56:04 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=c5345a05ce7dc86c422bdb707e817407ab52fa21 commit c5345a05ce7dc86c422bdb707e817407ab52fa21 Author: Ka Ho Ng AuthorDate: 2021-03-22 09:33:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-04-07 10:55:38 +0000 ivrs_drv: Fix IVHDs with duplicated BaseAddress Reviewed by: jhb Approved by: philip (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28945 (cherry picked from commit ede14736fd6d74db0374f4a233491ad5dc0e9b1d) --- sys/amd64/vmm/amd/ivrs_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c index da3e0e17d140..d33229623a96 100644 --- a/sys/amd64/vmm/amd/ivrs_drv.c +++ b/sys/amd64/vmm/amd/ivrs_drv.c @@ -366,10 +366,11 @@ ivhd_identify(driver_t *driver, device_t parent) for (i = ivhd_count - 1 ; i > 0 ; i--){ if (ivhd_is_newer(&ivhd_hdrs[i-1]->Header, &ivhd_hdrs[i]->Header)) { - ivhd_hdrs[i-1] = ivhd_hdrs[i]; + memmove(&ivhd_hdrs[i-1], &ivhd_hdrs[i], + sizeof(void *) * (ivhd_count - i)); ivhd_count--; } - } + } ivhd_devs = malloc(sizeof(device_t) * ivhd_count, M_DEVBUF, M_WAITOK | M_ZERO); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 10:56:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 EFD185D2CC4; Wed, 7 Apr 2021 10:56:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFhC96HBNz4r5c; Wed, 7 Apr 2021 10:56:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C9FD61DB62; Wed, 7 Apr 2021 10:56:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Au54A046748; Wed, 7 Apr 2021 10:56:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Au5cr046747; Wed, 7 Apr 2021 10:56:05 GMT (envelope-from git) Date: Wed, 7 Apr 2021 10:56:05 GMT Message-Id: <202104071056.137Au5cr046747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: d7ffa208d929 - stable/13 - AMD-vi: Fix IOMMU device interrupts being overridden MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d7ffa208d92933e0c72564bfd422aec49dca2fd4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 10:56:06 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=d7ffa208d92933e0c72564bfd422aec49dca2fd4 commit d7ffa208d92933e0c72564bfd422aec49dca2fd4 Author: Ka Ho Ng AuthorDate: 2021-03-22 09:33:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-04-07 10:55:38 +0000 AMD-vi: Fix IOMMU device interrupts being overridden Currently, AMD-vi PCI-e passthrough will lead to the following lines in dmesg: "kernel: CPU0: local APIC error 0x40 ivhd0: Error: completion failed tail:0x720, head:0x0." After some tracing, the problem is due to the interaction with amdvi_alloc_intr_resources() and pci_driver_added(). In ivrs_drv, the identification of AMD-vi IVHD is done by walking over the ACPI IVRS table and ivhdX device_ts are added under the acpi bus, while there are no driver handling the corresponding IOMMU PCI function. In amdvi_alloc_intr_resources(), the MSI intr are allocated with the ivhdX device_t instead of the IOMMU PCI function device_t. bus_setup_intr() is called on ivhdX. the IOMMU pci function device_t is only used for pci_enable_msi(). Since bus_setup_intr() is not called on IOMMU pci function, the IOMMU PCI function device_t's dinfo->cfg.msi is never updated to reflect the supposed msi_data and msi_addr. So the msi_data and msi_addr stay in the value 0. When pci_driver_added() tried to loop over the children of a pci bus, and do pci_cfg_restore() on each of them, msi_addr and msi_data with value 0 will be written to the MSI capability of the IOMMU pci function, thus explaining the errors in dmesg. This change includes an amdiommu driver which currently does attaching, detaching and providing DEVMETHODs for setting up and tearing down interrupt. The purpose of the driver is to prevent pci_driver_added() from calling pci_cfg_restore() on the IOMMU PCI function device_t. The introduction of the amdiommu driver handles allocation of an IRQ resource within the IOMMU PCI function, so that the dinfo->cfg.msi is populated. This has been tested on EPYC Rome 7282 with Radeon 5700XT GPU. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Approved by: philip (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28984 (cherry picked from commit 74ada297e8978b8efda3dffdd1bb24aee7c5faa4) --- sys/amd64/vmm/amd/amdiommu.c | 185 +++++++++++++++++++++++++++++++++++++++++ sys/amd64/vmm/amd/amdvi_hw.c | 89 +++----------------- sys/amd64/vmm/amd/amdvi_priv.h | 5 +- sys/amd64/vmm/amd/ivhd_if.m | 46 ++++++++++ sys/amd64/vmm/amd/ivrs_drv.c | 6 ++ sys/modules/vmm/Makefile | 3 + 6 files changed, 253 insertions(+), 81 deletions(-) diff --git a/sys/amd64/vmm/amd/amdiommu.c b/sys/amd64/vmm/amd/amdiommu.c new file mode 100644 index 000000000000..4ded23dff003 --- /dev/null +++ b/sys/amd64/vmm/amd/amdiommu.c @@ -0,0 +1,185 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Fondation + * + * Portions of this software were developed by Ka Ho Ng + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include + +#include "amdvi_priv.h" +#include "ivhd_if.h" + +struct amdiommu_softc { + struct resource *event_res; /* Event interrupt resource. */ + void *event_tag; /* Event interrupt tag. */ + int event_rid; +}; + +static int amdiommu_probe(device_t); +static int amdiommu_attach(device_t); +static int amdiommu_detach(device_t); +static int ivhd_setup_intr(device_t, driver_intr_t, void *, + const char *); +static int ivhd_teardown_intr(device_t); + +static device_method_t amdiommu_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, amdiommu_probe), + DEVMETHOD(device_attach, amdiommu_attach), + DEVMETHOD(device_detach, amdiommu_detach), + DEVMETHOD(ivhd_setup_intr, ivhd_setup_intr), + DEVMETHOD(ivhd_teardown_intr, ivhd_teardown_intr), + DEVMETHOD_END +}; +static driver_t amdiommu_driver = { + "amdiommu", + amdiommu_methods, + sizeof(struct amdiommu_softc), +}; + +static int +amdiommu_probe(device_t dev) +{ + int error; + int capoff; + + /* + * Check base class and sub-class + */ + if (pci_get_class(dev) != PCIC_BASEPERIPH || + pci_get_subclass(dev) != PCIS_BASEPERIPH_IOMMU) + return (ENXIO); + + /* + * A IOMMU capability block carries a 0Fh capid. + */ + error = pci_find_cap(dev, PCIY_SECDEV, &capoff); + if (error) + return (ENXIO); + + /* + * bit [18:16] == 011b indicates the capability block is IOMMU + * capability block. If the field is not set to 011b, bail out. + */ + if ((pci_read_config(dev, capoff + 2, 2) & 0x7) != 0x3) + return (ENXIO); + + return (BUS_PROBE_SPECIFIC); +} + +static int +amdiommu_attach(device_t dev) +{ + + device_set_desc(dev, "AMD-Vi/IOMMU PCI function"); + return (0); +} + +static int +amdiommu_detach(device_t dev) +{ + + return (0); +} + +static int +ivhd_setup_intr(device_t dev, driver_intr_t handler, void *arg, + const char *desc) +{ + struct amdiommu_softc *sc; + int error, msicnt; + + sc = device_get_softc(dev); + msicnt = 1; + if (sc->event_res != NULL) + panic("%s is called without intr teardown", __func__); + sc->event_rid = 1; + + error = pci_alloc_msi(dev, &msicnt); + if (error) { + device_printf(dev, "Couldn't find event MSI IRQ resource.\n"); + return (ENOENT); + } + + sc->event_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &sc->event_rid, RF_ACTIVE); + if (sc->event_res == NULL) { + device_printf(dev, "Unable to allocate event INTR resource.\n"); + error = ENOMEM; + goto fail; + } + + error = bus_setup_intr(dev, sc->event_res, INTR_TYPE_MISC | INTR_MPSAFE, + NULL, handler, arg, &sc->event_tag); + if (error) { + device_printf(dev, "Fail to setup event intr\n"); + goto fail; + } + + bus_describe_intr(dev, sc->event_res, sc->event_tag, "%s", desc); + return (0); + +fail: + ivhd_teardown_intr(dev); + return (error); +} + +static int +ivhd_teardown_intr(device_t dev) +{ + struct amdiommu_softc *sc; + + sc = device_get_softc(dev); + + if (sc->event_res != NULL) { + bus_teardown_intr(dev, sc->event_res, sc->event_tag); + sc->event_tag = NULL; + } + if (sc->event_res != NULL) { + bus_release_resource(dev, SYS_RES_IRQ, sc->event_rid, + sc->event_res); + sc->event_res = NULL; + } + pci_release_msi(dev); + return (0); +} + +static devclass_t amdiommu_devclass; + +/* This driver has to be loaded before ivhd */ +DRIVER_MODULE(amdiommu, pci, amdiommu_driver, amdiommu_devclass, 0, 0); +MODULE_DEPEND(amdiommu, pci, 1, 1, 1); diff --git a/sys/amd64/vmm/amd/amdvi_hw.c b/sys/amd64/vmm/amd/amdvi_hw.c index 132ae8389f2a..3581b43ea4de 100644 --- a/sys/amd64/vmm/amd/amdvi_hw.c +++ b/sys/amd64/vmm/amd/amdvi_hw.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "ivhd_if.h" #include "pcib_if.h" #include "io/iommu.h" @@ -771,99 +772,33 @@ amdvi_free_evt_intr_res(device_t dev) { struct amdvi_softc *softc; + device_t mmio_dev; softc = device_get_softc(dev); - if (softc->event_tag != NULL) { - bus_teardown_intr(dev, softc->event_res, softc->event_tag); - } - if (softc->event_res != NULL) { - bus_release_resource(dev, SYS_RES_IRQ, softc->event_rid, - softc->event_res); - } - bus_delete_resource(dev, SYS_RES_IRQ, softc->event_rid); - PCIB_RELEASE_MSI(device_get_parent(device_get_parent(dev)), - dev, 1, &softc->event_irq); + mmio_dev = softc->pci_dev; + + IVHD_TEARDOWN_INTR(mmio_dev); } static bool amdvi_alloc_intr_resources(struct amdvi_softc *softc) { struct amdvi_ctrl *ctrl; - device_t dev, pcib; - device_t mmio_dev; - uint64_t msi_addr; - uint32_t msi_data; + device_t dev, mmio_dev; int err; dev = softc->dev; - pcib = device_get_parent(device_get_parent(dev)); - mmio_dev = pci_find_bsf(PCI_RID2BUS(softc->pci_rid), - PCI_RID2SLOT(softc->pci_rid), PCI_RID2FUNC(softc->pci_rid)); - if (device_is_attached(mmio_dev)) { - device_printf(dev, - "warning: IOMMU device is claimed by another driver %s\n", - device_get_driver(mmio_dev)->name); - } - - softc->event_irq = -1; - softc->event_rid = 0; - - /* - * Section 3.7.1 of IOMMU rev 2.0. With MSI, there is only one - * interrupt. XXX: Enable MSI/X support. - */ - err = PCIB_ALLOC_MSI(pcib, dev, 1, 1, &softc->event_irq); - if (err) { - device_printf(dev, - "Couldn't find event MSI IRQ resource.\n"); - return (ENOENT); - } - - err = bus_set_resource(dev, SYS_RES_IRQ, softc->event_rid, - softc->event_irq, 1); - if (err) { - device_printf(dev, "Couldn't set event MSI resource.\n"); - return (ENXIO); - } - - softc->event_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &softc->event_rid, RF_ACTIVE); - if (!softc->event_res) { - device_printf(dev, - "Unable to allocate event INTR resource.\n"); - return (ENOMEM); - } - - if (bus_setup_intr(dev, softc->event_res, - INTR_TYPE_MISC | INTR_MPSAFE, NULL, amdvi_event_intr, - softc, &softc->event_tag)) { - device_printf(dev, "Fail to setup event intr\n"); - bus_release_resource(softc->dev, SYS_RES_IRQ, - softc->event_rid, softc->event_res); - softc->event_res = NULL; - return (ENXIO); - } - - bus_describe_intr(dev, softc->event_res, softc->event_tag, - "fault"); - - err = PCIB_MAP_MSI(pcib, dev, softc->event_irq, &msi_addr, - &msi_data); - if (err) { - device_printf(dev, - "Event interrupt config failed, err=%d.\n", - err); - amdvi_free_evt_intr_res(softc->dev); - return (err); - } + mmio_dev = softc->pci_dev; /* Clear interrupt status bits. */ ctrl = softc->ctrl; ctrl->status &= AMDVI_STATUS_EV_OF | AMDVI_STATUS_EV_INTR; - /* Now enable MSI interrupt. */ - pci_enable_msi(mmio_dev, msi_addr, msi_data); - return (0); + err = IVHD_SETUP_INTR(mmio_dev, amdvi_event_intr, softc, "fault"); + if (err) + device_printf(dev, "Interrupt setup failed on %s\n", + device_get_nameunit(mmio_dev)); + return (err); } static void diff --git a/sys/amd64/vmm/amd/amdvi_priv.h b/sys/amd64/vmm/amd/amdvi_priv.h index 2db6914f08f4..0eae7ca6ca4c 100644 --- a/sys/amd64/vmm/amd/amdvi_priv.h +++ b/sys/amd64/vmm/amd/amdvi_priv.h @@ -375,17 +375,14 @@ enum IvrsType struct amdvi_softc { struct amdvi_ctrl *ctrl; /* Control area. */ device_t dev; /* IOMMU device. */ + device_t pci_dev; /* IOMMU PCI function device. */ enum IvrsType ivhd_type; /* IOMMU IVHD type. */ bool iotlb; /* IOTLB supported by IOMMU */ struct amdvi_cmd *cmd; /* Command descriptor area. */ int cmd_max; /* Max number of commands. */ uint64_t cmp_data; /* Command completion write back. */ struct amdvi_event *event; /* Event descriptor area. */ - struct resource *event_res; /* Event interrupt resource. */ - void *event_tag; /* Event interrupt tag. */ int event_max; /* Max number of events. */ - int event_irq; - int event_rid; /* ACPI various flags. */ uint32_t ivhd_flag; /* ACPI IVHD flag. */ uint32_t ivhd_feature; /* ACPI v1 Reserved or v2 attribute. */ diff --git a/sys/amd64/vmm/amd/ivhd_if.m b/sys/amd64/vmm/amd/ivhd_if.m new file mode 100644 index 000000000000..eaae01ae0131 --- /dev/null +++ b/sys/amd64/vmm/amd/ivhd_if.m @@ -0,0 +1,46 @@ +#- +# Copyright (c) 2021 The FreeBSD Fondation +# +# Portions of this software were developed by Ka Ho Ng +# under sponsorship from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +#include +#include +#include + +INTERFACE ivhd; + +METHOD int setup_intr { + device_t dev; + driver_intr_t handler; + void *arg; + const char *desc; +}; + +METHOD int teardown_intr { + device_t dev; +}; diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c index d33229623a96..6291895c212f 100644 --- a/sys/amd64/vmm/amd/ivrs_drv.c +++ b/sys/amd64/vmm/amd/ivrs_drv.c @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2016, Anish Gupta (anish@freebsd.org) + * Copyright (c) 2021 The FreeBSD Foundation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include "io/iommu.h" #include "amdvi_priv.h" @@ -628,6 +631,9 @@ ivhd_attach(device_t dev) softc->dev = dev; ivhd = ivhd_hdrs[unit]; KASSERT(ivhd, ("ivhd is NULL")); + softc->pci_dev = pci_find_bsf(PCI_RID2BUS(ivhd->Header.DeviceId), + PCI_RID2SLOT(ivhd->Header.DeviceId), + PCI_RID2FUNC(ivhd->Header.DeviceId)); softc->ivhd_type = ivhd->Header.Type; softc->pci_seg = ivhd->PciSegmentGroup; diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile index b5d62c358272..ef0d9dcb6786 100644 --- a/sys/modules/vmm/Makefile +++ b/sys/modules/vmm/Makefile @@ -51,6 +51,9 @@ SRCS+= ept.c \ # amd-specific files .PATH: ${SRCTOP}/sys/amd64/vmm/amd SRCS+= vmcb.c \ + amdiommu.c \ + ivhd_if.c \ + ivhd_if.h \ svm.c \ svm_support.S \ npt.c \ From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 10:56:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 278C95D2D90; Wed, 7 Apr 2021 10:56:07 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFhCC0JLWz4r9s; Wed, 7 Apr 2021 10:56:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDFBE1E280; Wed, 7 Apr 2021 10:56:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Au6Ii046770; Wed, 7 Apr 2021 10:56:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Au6Tv046769; Wed, 7 Apr 2021 10:56:06 GMT (envelope-from git) Date: Wed, 7 Apr 2021 10:56:06 GMT Message-Id: <202104071056.137Au6Tv046769@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 1bbe0448e47f - stable/13 - AMD-vi: Fix mismatched NULL checking in amdiommu teardown path MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1bbe0448e47fd9edeee97060e823331334319038 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 10:56:07 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=1bbe0448e47fd9edeee97060e823331334319038 commit 1bbe0448e47fd9edeee97060e823331334319038 Author: Ka Ho Ng AuthorDate: 2021-03-31 19:30:21 +0000 Commit: Ka Ho Ng CommitDate: 2021-04-07 10:55:38 +0000 AMD-vi: Fix mismatched NULL checking in amdiommu teardown path Sponsored by: The FreeBSD Foundation Approved by: lwhsu (mentor) MFC with: 74ada297e897 (cherry picked from commit cf76495e0a30043503ef126f0a485e314730a221) --- sys/amd64/vmm/amd/amdiommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/vmm/amd/amdiommu.c b/sys/amd64/vmm/amd/amdiommu.c index 4ded23dff003..5eed6ce849cc 100644 --- a/sys/amd64/vmm/amd/amdiommu.c +++ b/sys/amd64/vmm/amd/amdiommu.c @@ -165,7 +165,7 @@ ivhd_teardown_intr(device_t dev) sc = device_get_softc(dev); - if (sc->event_res != NULL) { + if (sc->event_tag != NULL) { bus_teardown_intr(dev, sc->event_res, sc->event_tag); sc->event_tag = NULL; } From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 10:56:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 912B05D2CC7; Wed, 7 Apr 2021 10:56:10 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFhCD6GMwz4r1C; Wed, 7 Apr 2021 10:56:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 364701DF37; Wed, 7 Apr 2021 10:56:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Au8Bw046791; Wed, 7 Apr 2021 10:56:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Au8Xj046790; Wed, 7 Apr 2021 10:56:08 GMT (envelope-from git) Date: Wed, 7 Apr 2021 10:56:08 GMT Message-Id: <202104071056.137Au8Xj046790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 9d7eb557c157 - stable/13 - AMD-vi: Mixed format IVHD block should replace fixed format IVHD block MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9d7eb557c1574f879b4bb4adee285cc9f2d5f18e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 10:56:11 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9d7eb557c1574f879b4bb4adee285cc9f2d5f18e commit 9d7eb557c1574f879b4bb4adee285cc9f2d5f18e Author: Ka Ho Ng AuthorDate: 2021-04-01 01:15:19 +0000 Commit: Ka Ho Ng CommitDate: 2021-04-07 10:55:38 +0000 AMD-vi: Mixed format IVHD block should replace fixed format IVHD block This fixes double IVHD_SETUP_INTR calls on the same IOMMU device. Sponsored by: The FreeBSD Foundation MFC with: 74ada297e897 Reported by: Oleg Ginzburg Reviewed by: grehan Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D29521 (cherry picked from commit 03efa462b2ab3ae8166598363e9e83d4e5cf0398) --- sys/amd64/vmm/amd/ivrs_drv.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c index 6291895c212f..1cd76069d0a2 100644 --- a/sys/amd64/vmm/amd/ivrs_drv.c +++ b/sys/amd64/vmm/amd/ivrs_drv.c @@ -312,14 +312,22 @@ ivhd_dev_parse(ACPI_IVRS_HARDWARE1 *ivhd, struct amdvi_softc *softc) static bool ivhd_is_newer(ACPI_IVRS_HEADER *old, ACPI_IVRS_HEADER *new) { - /* - * Newer IVRS header type take precedence. - */ - if ((old->DeviceId == new->DeviceId) && - (old->Type == IVRS_TYPE_HARDWARE_LEGACY) && - ((new->Type == IVRS_TYPE_HARDWARE_EFR) || - (new->Type == IVRS_TYPE_HARDWARE_MIXED))) { - return (true); + if (old->DeviceId == new->DeviceId) { + /* + * Newer IVRS header type take precedence. + */ + if (old->Type == IVRS_TYPE_HARDWARE_LEGACY && + ((new->Type == IVRS_TYPE_HARDWARE_EFR) || + (new->Type == IVRS_TYPE_HARDWARE_MIXED))) + return (true); + + /* + * Mixed format IVHD header type take precedence + * over fixed format IVHD header types. + */ + if (old->Type == IVRS_TYPE_HARDWARE_EFR && + new->Type == IVRS_TYPE_HARDWARE_MIXED) + return (true); } return (false); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 15:48:08 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 8E7F05BB150; Wed, 7 Apr 2021 15:48:08 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFph83Xcnz3m7Q; Wed, 7 Apr 2021 15:48:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61D7B21D39; Wed, 7 Apr 2021 15:48:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Fm8Bb033953; Wed, 7 Apr 2021 15:48:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Fm81L033952; Wed, 7 Apr 2021 15:48:08 GMT (envelope-from git) Date: Wed, 7 Apr 2021 15:48:08 GMT Message-Id: <202104071548.137Fm81L033952@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: bcfb4750b809 - stable/13 - dummynet: Move packet counters into dn_cfg MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bcfb4750b8099c1d9d3e179385269dc63dc7dcc5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:48:08 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bcfb4750b8099c1d9d3e179385269dc63dc7dcc5 commit bcfb4750b8099c1d9d3e179385269dc63dc7dcc5 Author: Kristof Provost AuthorDate: 2021-03-09 15:27:31 +0000 Commit: Kristof Provost CommitDate: 2021-04-07 15:25:54 +0000 dummynet: Move packet counters into dn_cfg Move the packets counters into the dn_cfg struct. This reduces the global name space use for dummynet and will make future work for things like vnet support and re-use in pf easier. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29245 (cherry picked from commit cd5671efc0190ba0f9eb41bba42e703277af20c3) --- sys/netpfil/ipfw/dn_aqm.h | 5 +---- sys/netpfil/ipfw/dn_sched_fq_codel.h | 2 +- sys/netpfil/ipfw/dn_sched_fq_pie.c | 2 +- sys/netpfil/ipfw/ip_dn_io.c | 24 ++++++++---------------- sys/netpfil/ipfw/ip_dn_private.h | 5 +++++ 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index a8a362a4bde9..8bbe9fe69e86 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -53,9 +53,6 @@ typedef int32_t aqm_stime_t; /* Macro for variable bounding */ #define BOUND_VAR(x,l,h) ((x) > (h)? (h) : ((x) > (l)? (x) : (l))) -/* sysctl variable to count number of dropped packets */ -extern unsigned long io_pkt_drop; - /* * Structure for holding data and function pointers that together represent a * AQM algorithm. @@ -137,7 +134,7 @@ update_stats(struct dn_queue *q, int len, int drop) if (drop) { qni->drops++; sni->drops++; - io_pkt_drop++; + dn_cfg.io_pkt_drop++; } else { /*update queue stats */ qni->length += inc; diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index 725189483ba2..a8369ac83129 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -104,7 +104,7 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 2f21ca77e33a..257dada44345 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -299,7 +299,7 @@ fq_update_stats(struct fq_pie_flow *q, struct fq_pie_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 1b39fcb0359f..f71d07ae1140 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -88,14 +88,6 @@ static long tick_lost; /* Lost(coalesced) ticks number. */ /* Adjusted vs non-adjusted curr_time difference (ticks). */ static long tick_diff; -static unsigned long io_pkt; -static unsigned long io_pkt_fast; - -#ifdef NEW_AQM -unsigned long io_pkt_drop; -#else -static unsigned long io_pkt_drop; -#endif /* * We use a heap to store entities for which we have pending timer events. * The heap is checked at every tick and all entities with expired events @@ -228,13 +220,13 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, fsk_count, SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, queue_count, CTLFLAG_RD, DC(queue_count), 0, "Number of queues"); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt, - CTLFLAG_RD, &io_pkt, 0, + CTLFLAG_RD, DC(io_pkt), 0, "Number of packets passed to dummynet."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast, - CTLFLAG_RD, &io_pkt_fast, 0, + CTLFLAG_RD, DC(io_pkt_fast), 0, "Number of packets bypassed dummynet scheduler."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop, - CTLFLAG_RD, &io_pkt_drop, 0, + CTLFLAG_RD, DC(io_pkt_drop), 0, "Number of packets dropped by dummynet."); #undef DC SYSEND @@ -540,7 +532,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) return (0); drop: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; q->ni.drops++; ni->drops++; FREE_PKT(m); @@ -882,7 +874,7 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) else if (fwa->flags & IPFW_ARGS_IP6) dir |= PROTO_IPV6; DN_BH_WLOCK(); - io_pkt++; + dn_cfg.io_pkt++; /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; @@ -918,7 +910,7 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) m = *m0 = NULL; /* dn_enqueue already increases io_pkt_drop */ - io_pkt_drop--; + dn_cfg.io_pkt_drop--; goto dropit; } @@ -956,7 +948,7 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; - io_pkt_fast++; + dn_cfg.io_pkt_fast++; if (m->m_nextpkt != NULL) { printf("dummynet: fast io: pkt chain detected!\n"); m->m_nextpkt = NULL; @@ -972,7 +964,7 @@ done: return 0; dropit: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; DN_BH_WUNLOCK(); if (m) FREE_PKT(m); diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 24765bc09b0e..38c6ff1201d5 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -131,6 +131,11 @@ struct dn_parms { int fsk_count; int queue_count; + /* packet counters */ + unsigned long io_pkt; + unsigned long io_pkt_fast; + unsigned long io_pkt_drop; + /* ticks and other stuff */ uint64_t curr_time; /* flowsets and schedulers are in hash tables, with 'hash_size' From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 15:48:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D91BC5BAD51; Wed, 7 Apr 2021 15:48:09 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFph94F2pz3lws; Wed, 7 Apr 2021 15:48:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F33D21CA1; Wed, 7 Apr 2021 15:48:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137Fm9BB033976; Wed, 7 Apr 2021 15:48:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Fm9nZ033975; Wed, 7 Apr 2021 15:48:09 GMT (envelope-from git) Date: Wed, 7 Apr 2021 15:48:09 GMT Message-Id: <202104071548.137Fm9nZ033975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: da7865ad1f1b - stable/13 - dummynet: Move timekeeping information into dn_cfg MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: da7865ad1f1bf27688faf03efe7aa0db680769a2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:48:10 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=da7865ad1f1bf27688faf03efe7aa0db680769a2 commit da7865ad1f1bf27688faf03efe7aa0db680769a2 Author: Kristof Provost AuthorDate: 2021-03-09 15:44:26 +0000 Commit: Kristof Provost CommitDate: 2021-04-07 15:25:54 +0000 dummynet: Move timekeeping information into dn_cfg Just like with the packet counters move the timekeeping information into dn_cfg. This reduces the global name space use for dummynet and will make subsequent work to add vnet support and re-use in pf easier. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Different Revision: https://reviews.freebsd.org/D29246 (cherry picked from commit 320bed3c007be1c2ff1f4b0d00d64d541d807fed) --- sys/netpfil/ipfw/ip_dn_io.c | 44 ++++++++++++++++------------------------ sys/netpfil/ipfw/ip_dn_private.h | 8 ++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index f71d07ae1140..b439d2679f3c 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -80,14 +80,6 @@ __FBSDID("$FreeBSD$"); struct dn_parms dn_cfg; //VNET_DEFINE(struct dn_parms, _base_dn_cfg); -static long tick_last; /* Last tick duration (usec). */ -static long tick_delta; /* Last vs standard tick diff (usec). */ -static long tick_delta_sum; /* Accumulated tick difference (usec).*/ -static long tick_adjustment; /* Tick adjustments done. */ -static long tick_lost; /* Lost(coalesced) ticks number. */ -/* Adjusted vs non-adjusted curr_time difference (ticks). */ -static long tick_diff; - /* * We use a heap to store entities for which we have pending timer events. * The heap is checked at every tick and all entities with expired events @@ -192,16 +184,16 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, red_max_pkt_size, /* time adjustment */ SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta, - CTLFLAG_RD, &tick_delta, 0, "Last vs standard tick difference (usec)."); + CTLFLAG_RD, DC(tick_delta), 0, "Last vs standard tick difference (usec)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta_sum, - CTLFLAG_RD, &tick_delta_sum, 0, "Accumulated tick difference (usec)."); + CTLFLAG_RD, DC(tick_delta_sum), 0, "Accumulated tick difference (usec)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_adjustment, - CTLFLAG_RD, &tick_adjustment, 0, "Tick adjustments done."); + CTLFLAG_RD, DC(tick_adjustment), 0, "Tick adjustments done."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_diff, - CTLFLAG_RD, &tick_diff, 0, + CTLFLAG_RD, DC(tick_diff), 0, "Adjusted vs non-adjusted curr_time difference (ticks)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_lost, - CTLFLAG_RD, &tick_lost, 0, + CTLFLAG_RD, DC(tick_lost), 0, "Number of ticks coalesced by dummynet taskqueue."); /* Drain parameters */ @@ -665,16 +657,16 @@ dummynet_task(void *context, int pending) DN_BH_WLOCK(); /* Update number of lost(coalesced) ticks. */ - tick_lost += pending - 1; + dn_cfg.tick_lost += pending - 1; getmicrouptime(&t); /* Last tick duration (usec). */ - tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + + dn_cfg.tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + (t.tv_usec - dn_cfg.prev_t.tv_usec); /* Last tick vs standard tick difference (usec). */ - tick_delta = (tick_last * hz - 1000000) / hz; + dn_cfg.tick_delta = (dn_cfg.tick_last * hz - 1000000) / hz; /* Accumulated tick difference (usec). */ - tick_delta_sum += tick_delta; + dn_cfg.tick_delta_sum += dn_cfg.tick_delta; dn_cfg.prev_t = t; @@ -686,18 +678,18 @@ dummynet_task(void *context, int pending) * adjustment. */ dn_cfg.curr_time++; - if (tick_delta_sum - tick >= 0) { - int diff = tick_delta_sum / tick; + if (dn_cfg.tick_delta_sum - tick >= 0) { + int diff = dn_cfg.tick_delta_sum / tick; dn_cfg.curr_time += diff; - tick_diff += diff; - tick_delta_sum %= tick; - tick_adjustment++; - } else if (tick_delta_sum + tick <= 0) { + dn_cfg.tick_diff += diff; + dn_cfg.tick_delta_sum %= tick; + dn_cfg.tick_adjustment++; + } else if (dn_cfg.tick_delta_sum + tick <= 0) { dn_cfg.curr_time--; - tick_diff--; - tick_delta_sum += tick; - tick_adjustment++; + dn_cfg.tick_diff--; + dn_cfg.tick_delta_sum += tick; + dn_cfg.tick_adjustment++; } /* serve pending events, accumulate in q */ diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 38c6ff1201d5..6e48bc5116a7 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -125,6 +125,14 @@ struct dn_parms { struct timeval prev_t; /* last time dummynet_tick ran */ struct dn_heap evheap; /* scheduled events */ + long tick_last; /* Last tick duration (usec). */ + long tick_delta; /* Last vs standard tick diff (usec). */ + long tick_delta_sum; /* Accumulated tick difference (usec).*/ + long tick_adjustment; /* Tick adjustments done. */ + long tick_lost; /* Lost(coalesced) ticks number. */ + /* Adjusted vs non-adjusted curr_time difference (ticks). */ + long tick_diff; + /* counters of objects -- used for reporting space */ int schk_count; int si_count; From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 15:48:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 52A165BB0F3; Wed, 7 Apr 2021 15:48:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFphD5WB6z3mNg; Wed, 7 Apr 2021 15:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83F9021B5E; Wed, 7 Apr 2021 15:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137FmC09034101; Wed, 7 Apr 2021 15:48:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137FmCab034100; Wed, 7 Apr 2021 15:48:12 GMT (envelope-from git) Date: Wed, 7 Apr 2021 15:48:12 GMT Message-Id: <202104071548.137FmCab034100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 60fa37b7d60a - stable/12 - dummynet: Move packet counters into dn_cfg MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:48:16 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 commit 60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 Author: Kristof Provost AuthorDate: 2021-03-09 15:27:31 +0000 Commit: Kristof Provost CommitDate: 2021-04-07 15:25:38 +0000 dummynet: Move packet counters into dn_cfg Move the packets counters into the dn_cfg struct. This reduces the global name space use for dummynet and will make future work for things like vnet support and re-use in pf easier. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29245 (cherry picked from commit cd5671efc0190ba0f9eb41bba42e703277af20c3) --- sys/netpfil/ipfw/dn_aqm.h | 5 +---- sys/netpfil/ipfw/dn_sched_fq_codel.h | 2 +- sys/netpfil/ipfw/dn_sched_fq_pie.c | 2 +- sys/netpfil/ipfw/ip_dn_io.c | 24 ++++++++---------------- sys/netpfil/ipfw/ip_dn_private.h | 5 +++++ 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index d01e98ebeafa..a8f6c39c0a8c 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -54,9 +54,6 @@ typedef int32_t aqm_stime_t; /* Macro for variable bounding */ #define BOUND_VAR(x,l,h) ((x) > (h)? (h) : ((x) > (l)? (x) : (l))) -/* sysctl variable to count number of dropped packets */ -extern unsigned long io_pkt_drop; - /* * Structure for holding data and function pointers that together represent a * AQM algorithm. @@ -138,7 +135,7 @@ update_stats(struct dn_queue *q, int len, int drop) if (drop) { qni->drops++; sni->drops++; - io_pkt_drop++; + dn_cfg.io_pkt_drop++; } else { /*update queue stats */ qni->length += inc; diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index 4b65781e0bef..e8685caca8d3 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -104,7 +104,7 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 3960ea8ad6ae..2f61ca3de94e 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -299,7 +299,7 @@ fq_update_stats(struct fq_pie_flow *q, struct fq_pie_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index f14532ce9af0..760a24ed041f 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -87,14 +87,6 @@ static long tick_lost; /* Lost(coalesced) ticks number. */ /* Adjusted vs non-adjusted curr_time difference (ticks). */ static long tick_diff; -static unsigned long io_pkt; -static unsigned long io_pkt_fast; - -#ifdef NEW_AQM -unsigned long io_pkt_drop; -#else -static unsigned long io_pkt_drop; -#endif /* * We use a heap to store entities for which we have pending timer events. * The heap is checked at every tick and all entities with expired events @@ -223,13 +215,13 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, fsk_count, SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, queue_count, CTLFLAG_RD, DC(queue_count), 0, "Number of queues"); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt, - CTLFLAG_RD, &io_pkt, 0, + CTLFLAG_RD, DC(io_pkt), 0, "Number of packets passed to dummynet."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast, - CTLFLAG_RD, &io_pkt_fast, 0, + CTLFLAG_RD, DC(io_pkt_fast), 0, "Number of packets bypassed dummynet scheduler."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop, - CTLFLAG_RD, &io_pkt_drop, 0, + CTLFLAG_RD, DC(io_pkt_drop), 0, "Number of packets dropped by dummynet."); #undef DC SYSEND @@ -535,7 +527,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) return (0); drop: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; q->ni.drops++; ni->drops++; FREE_PKT(m); @@ -871,7 +863,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) int fs_id = (fwa->rule.info & IPFW_INFO_MASK) + ((fwa->rule.info & IPFW_IS_PIPE) ? 2*DN_MAX_ID : 0); DN_BH_WLOCK(); - io_pkt++; + dn_cfg.io_pkt++; /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; @@ -907,7 +899,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) m = *m0 = NULL; /* dn_enqueue already increases io_pkt_drop */ - io_pkt_drop--; + dn_cfg.io_pkt_drop--; goto dropit; } @@ -945,7 +937,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; - io_pkt_fast++; + dn_cfg.io_pkt_fast++; if (m->m_nextpkt != NULL) { printf("dummynet: fast io: pkt chain detected!\n"); m->m_nextpkt = NULL; @@ -961,7 +953,7 @@ done: return 0; dropit: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; DN_BH_WUNLOCK(); if (m) FREE_PKT(m); diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 61c61130525c..a318a8e3be37 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -131,6 +131,11 @@ struct dn_parms { int fsk_count; int queue_count; + /* packet counters */ + unsigned long io_pkt; + unsigned long io_pkt_fast; + unsigned long io_pkt_drop; + /* ticks and other stuff */ uint64_t curr_time; /* flowsets and schedulers are in hash tables, with 'hash_size' From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 15:48:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 643C15BAF55; Wed, 7 Apr 2021 15:48:15 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFphG1TKHz3m9M; Wed, 7 Apr 2021 15:48:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3FEE21D3A; Wed, 7 Apr 2021 15:48:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137FmDDF034122; Wed, 7 Apr 2021 15:48:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137FmDWp034121; Wed, 7 Apr 2021 15:48:13 GMT (envelope-from git) Date: Wed, 7 Apr 2021 15:48:13 GMT Message-Id: <202104071548.137FmDWp034121@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 06d8a9c86adf - stable/12 - dummynet: Move timekeeping information into dn_cfg MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 06d8a9c86adfecd16f55053f852f37ceadd26257 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:48:16 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=06d8a9c86adfecd16f55053f852f37ceadd26257 commit 06d8a9c86adfecd16f55053f852f37ceadd26257 Author: Kristof Provost AuthorDate: 2021-03-09 15:44:26 +0000 Commit: Kristof Provost CommitDate: 2021-04-07 15:25:38 +0000 dummynet: Move timekeeping information into dn_cfg Just like with the packet counters move the timekeeping information into dn_cfg. This reduces the global name space use for dummynet and will make subsequent work to add vnet support and re-use in pf easier. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Different Revision: https://reviews.freebsd.org/D29246 (cherry picked from commit 320bed3c007be1c2ff1f4b0d00d64d541d807fed) --- sys/netpfil/ipfw/ip_dn_io.c | 44 ++++++++++++++++------------------------ sys/netpfil/ipfw/ip_dn_private.h | 8 ++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 760a24ed041f..f746023db53c 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -79,14 +79,6 @@ __FBSDID("$FreeBSD$"); struct dn_parms dn_cfg; //VNET_DEFINE(struct dn_parms, _base_dn_cfg); -static long tick_last; /* Last tick duration (usec). */ -static long tick_delta; /* Last vs standard tick diff (usec). */ -static long tick_delta_sum; /* Accumulated tick difference (usec).*/ -static long tick_adjustment; /* Tick adjustments done. */ -static long tick_lost; /* Lost(coalesced) ticks number. */ -/* Adjusted vs non-adjusted curr_time difference (ticks). */ -static long tick_diff; - /* * We use a heap to store entities for which we have pending timer events. * The heap is checked at every tick and all entities with expired events @@ -187,16 +179,16 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, red_max_pkt_size, /* time adjustment */ SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta, - CTLFLAG_RD, &tick_delta, 0, "Last vs standard tick difference (usec)."); + CTLFLAG_RD, DC(tick_delta), 0, "Last vs standard tick difference (usec)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_delta_sum, - CTLFLAG_RD, &tick_delta_sum, 0, "Accumulated tick difference (usec)."); + CTLFLAG_RD, DC(tick_delta_sum), 0, "Accumulated tick difference (usec)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_adjustment, - CTLFLAG_RD, &tick_adjustment, 0, "Tick adjustments done."); + CTLFLAG_RD, DC(tick_adjustment), 0, "Tick adjustments done."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_diff, - CTLFLAG_RD, &tick_diff, 0, + CTLFLAG_RD, DC(tick_diff), 0, "Adjusted vs non-adjusted curr_time difference (ticks)."); SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, tick_lost, - CTLFLAG_RD, &tick_lost, 0, + CTLFLAG_RD, DC(tick_lost), 0, "Number of ticks coalesced by dummynet taskqueue."); /* Drain parameters */ @@ -660,16 +652,16 @@ dummynet_task(void *context, int pending) DN_BH_WLOCK(); /* Update number of lost(coalesced) ticks. */ - tick_lost += pending - 1; + dn_cfg.tick_lost += pending - 1; getmicrouptime(&t); /* Last tick duration (usec). */ - tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + + dn_cfg.tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + (t.tv_usec - dn_cfg.prev_t.tv_usec); /* Last tick vs standard tick difference (usec). */ - tick_delta = (tick_last * hz - 1000000) / hz; + dn_cfg.tick_delta = (dn_cfg.tick_last * hz - 1000000) / hz; /* Accumulated tick difference (usec). */ - tick_delta_sum += tick_delta; + dn_cfg.tick_delta_sum += dn_cfg.tick_delta; dn_cfg.prev_t = t; @@ -681,18 +673,18 @@ dummynet_task(void *context, int pending) * adjustment. */ dn_cfg.curr_time++; - if (tick_delta_sum - tick >= 0) { - int diff = tick_delta_sum / tick; + if (dn_cfg.tick_delta_sum - tick >= 0) { + int diff = dn_cfg.tick_delta_sum / tick; dn_cfg.curr_time += diff; - tick_diff += diff; - tick_delta_sum %= tick; - tick_adjustment++; - } else if (tick_delta_sum + tick <= 0) { + dn_cfg.tick_diff += diff; + dn_cfg.tick_delta_sum %= tick; + dn_cfg.tick_adjustment++; + } else if (dn_cfg.tick_delta_sum + tick <= 0) { dn_cfg.curr_time--; - tick_diff--; - tick_delta_sum += tick; - tick_adjustment++; + dn_cfg.tick_diff--; + dn_cfg.tick_delta_sum += tick; + dn_cfg.tick_adjustment++; } /* serve pending events, accumulate in q */ diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index a318a8e3be37..b655a91fe758 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -125,6 +125,14 @@ struct dn_parms { struct timeval prev_t; /* last time dummynet_tick ran */ struct dn_heap evheap; /* scheduled events */ + long tick_last; /* Last tick duration (usec). */ + long tick_delta; /* Last vs standard tick diff (usec). */ + long tick_delta_sum; /* Accumulated tick difference (usec).*/ + long tick_adjustment; /* Tick adjustments done. */ + long tick_lost; /* Lost(coalesced) ticks number. */ + /* Adjusted vs non-adjusted curr_time difference (ticks). */ + long tick_diff; + /* counters of objects -- used for reporting space */ int schk_count; int si_count; From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 21:04:41 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 077F25C4ECF; Wed, 7 Apr 2021 21:04:41 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFxjN6r6vz4nJZ; Wed, 7 Apr 2021 21:04:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D310B25CF2; Wed, 7 Apr 2021 21:04:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137L4eb2062655; Wed, 7 Apr 2021 21:04:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137L4edh062654; Wed, 7 Apr 2021 21:04:40 GMT (envelope-from git) Date: Wed, 7 Apr 2021 21:04:40 GMT Message-Id: <202104072104.137L4edh062654@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 894b3a1a32cc - stable/13 - netmap: bridge: fix transmission in busy-wait mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 894b3a1a32cc137b16eee2462151617cb0b7db48 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 21:04:41 -0000 The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=894b3a1a32cc137b16eee2462151617cb0b7db48 commit 894b3a1a32cc137b16eee2462151617cb0b7db48 Author: Vincenzo Maffione AuthorDate: 2021-03-30 06:24:56 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-07 21:04:33 +0000 netmap: bridge: fix transmission in busy-wait mode In busy-wait mode (BUSYWAIT defined), NIOCTXSYNC should be performed after packets have been moved to the TX ring (rather than before). Before the change, moved packets may stall for an indefinite time in the TX ring. MFC after: 1 week (cherry picked from commit 51cc31088bf4d23a6ad0bfe8851adaa049d750fc) --- tools/tools/netmap/bridge.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/tools/netmap/bridge.c b/tools/tools/netmap/bridge.c index 77d235bf6e08..0c8f56265ff4 100644 --- a/tools/tools/netmap/bridge.c +++ b/tools/tools/netmap/bridge.c @@ -17,6 +17,10 @@ #include #include +#if defined(_WIN32) +#define BUSYWAIT +#endif + static int verbose = 0; static int do_abort = 0; @@ -321,21 +325,19 @@ main(int argc, char **argv) pollfd[0].revents = pollfd[1].revents = 0; n0 = rx_slots_avail(pa); n1 = rx_slots_avail(pb); -#if defined(_WIN32) || defined(BUSYWAIT) +#ifdef BUSYWAIT if (n0) { - ioctl(pollfd[1].fd, NIOCTXSYNC, NULL); pollfd[1].revents = POLLOUT; } else { ioctl(pollfd[0].fd, NIOCRXSYNC, NULL); } if (n1) { - ioctl(pollfd[0].fd, NIOCTXSYNC, NULL); pollfd[0].revents = POLLOUT; } else { ioctl(pollfd[1].fd, NIOCRXSYNC, NULL); } ret = 1; -#else +#else /* !defined(BUSYWAIT) */ if (n0) pollfd[1].events |= POLLOUT; else @@ -347,7 +349,7 @@ main(int argc, char **argv) /* poll() also cause kernel to txsync/rxsync the NICs */ ret = poll(pollfd, 2, 2500); -#endif /* defined(_WIN32) || defined(BUSYWAIT) */ +#endif /* !defined(BUSYWAIT) */ if (ret <= 0 || verbose) D("poll %s [0] ev %x %x rx %d@%d tx %d," " [1] ev %x %x rx %d@%d tx %d", @@ -375,11 +377,19 @@ main(int argc, char **argv) D("error on fd1, rx [%d,%d,%d)", rx->head, rx->cur, rx->tail); } - if (pollfd[0].revents & POLLOUT) + if (pollfd[0].revents & POLLOUT) { ports_move(pb, pa, burst, msg_b2a); +#ifdef BUSYWAIT + ioctl(pollfd[0].fd, NIOCTXSYNC, NULL); +#endif + } - if (pollfd[1].revents & POLLOUT) + if (pollfd[1].revents & POLLOUT) { ports_move(pa, pb, burst, msg_a2b); +#ifdef BUSYWAIT + ioctl(pollfd[1].fd, NIOCTXSYNC, NULL); +#endif + } /* * We don't need ioctl(NIOCTXSYNC) on the two file descriptors. From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 21:05:35 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 ECE3D5C4EDD; Wed, 7 Apr 2021 21:05:35 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFxkR6S0wz4n8H; Wed, 7 Apr 2021 21:05:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C664625CF3; Wed, 7 Apr 2021 21:05:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137L5ZMg062833; Wed, 7 Apr 2021 21:05:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137L5ZB0062832; Wed, 7 Apr 2021 21:05:35 GMT (envelope-from git) Date: Wed, 7 Apr 2021 21:05:35 GMT Message-Id: <202104072105.137L5ZB0062832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 3f70c3d58f93 - stable/12 - netmap: bridge: fix transmission in busy-wait mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 3f70c3d58f9330039707037b1242ca13ac390cad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 21:05:36 -0000 The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=3f70c3d58f9330039707037b1242ca13ac390cad commit 3f70c3d58f9330039707037b1242ca13ac390cad Author: Vincenzo Maffione AuthorDate: 2021-03-30 06:24:56 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-07 21:05:28 +0000 netmap: bridge: fix transmission in busy-wait mode In busy-wait mode (BUSYWAIT defined), NIOCTXSYNC should be performed after packets have been moved to the TX ring (rather than before). Before the change, moved packets may stall for an indefinite time in the TX ring. MFC after: 1 week (cherry picked from commit 51cc31088bf4d23a6ad0bfe8851adaa049d750fc) --- tools/tools/netmap/bridge.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/tools/netmap/bridge.c b/tools/tools/netmap/bridge.c index 77d235bf6e08..0c8f56265ff4 100644 --- a/tools/tools/netmap/bridge.c +++ b/tools/tools/netmap/bridge.c @@ -17,6 +17,10 @@ #include #include +#if defined(_WIN32) +#define BUSYWAIT +#endif + static int verbose = 0; static int do_abort = 0; @@ -321,21 +325,19 @@ main(int argc, char **argv) pollfd[0].revents = pollfd[1].revents = 0; n0 = rx_slots_avail(pa); n1 = rx_slots_avail(pb); -#if defined(_WIN32) || defined(BUSYWAIT) +#ifdef BUSYWAIT if (n0) { - ioctl(pollfd[1].fd, NIOCTXSYNC, NULL); pollfd[1].revents = POLLOUT; } else { ioctl(pollfd[0].fd, NIOCRXSYNC, NULL); } if (n1) { - ioctl(pollfd[0].fd, NIOCTXSYNC, NULL); pollfd[0].revents = POLLOUT; } else { ioctl(pollfd[1].fd, NIOCRXSYNC, NULL); } ret = 1; -#else +#else /* !defined(BUSYWAIT) */ if (n0) pollfd[1].events |= POLLOUT; else @@ -347,7 +349,7 @@ main(int argc, char **argv) /* poll() also cause kernel to txsync/rxsync the NICs */ ret = poll(pollfd, 2, 2500); -#endif /* defined(_WIN32) || defined(BUSYWAIT) */ +#endif /* !defined(BUSYWAIT) */ if (ret <= 0 || verbose) D("poll %s [0] ev %x %x rx %d@%d tx %d," " [1] ev %x %x rx %d@%d tx %d", @@ -375,11 +377,19 @@ main(int argc, char **argv) D("error on fd1, rx [%d,%d,%d)", rx->head, rx->cur, rx->tail); } - if (pollfd[0].revents & POLLOUT) + if (pollfd[0].revents & POLLOUT) { ports_move(pb, pa, burst, msg_b2a); +#ifdef BUSYWAIT + ioctl(pollfd[0].fd, NIOCTXSYNC, NULL); +#endif + } - if (pollfd[1].revents & POLLOUT) + if (pollfd[1].revents & POLLOUT) { ports_move(pa, pb, burst, msg_a2b); +#ifdef BUSYWAIT + ioctl(pollfd[1].fd, NIOCTXSYNC, NULL); +#endif + } /* * We don't need ioctl(NIOCTXSYNC) on the two file descriptors. From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 21:06:24 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 8C78A5C5203; Wed, 7 Apr 2021 21:06:24 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFxlN3YyRz4nWX; Wed, 7 Apr 2021 21:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6DAEB25EE1; Wed, 7 Apr 2021 21:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137L6Om2062996; Wed, 7 Apr 2021 21:06:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137L6OrT062995; Wed, 7 Apr 2021 21:06:24 GMT (envelope-from git) Date: Wed, 7 Apr 2021 21:06:24 GMT Message-Id: <202104072106.137L6OrT062995@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 588b2e6dd2f6 - stable/13 - netmap: pkt-gen: allow -Z and -z to be used together MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 588b2e6dd2f6fd0d179451f20e901f232810a49e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 21:06:24 -0000 The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=588b2e6dd2f6fd0d179451f20e901f232810a49e commit 588b2e6dd2f6fd0d179451f20e901f232810a49e Author: Vincenzo Maffione AuthorDate: 2021-03-30 06:13:07 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-07 21:06:01 +0000 netmap: pkt-gen: allow -Z and -z to be used together These options are used for generating random source/destination IP/ports within transmitted packets. MFC after: 1 week (cherry picked from commit 27bf5dd3d40397fa7d20a17828de2801c8a94a4b) --- tools/tools/netmap/pkt-gen.c | 125 +++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index 55504c09ae58..ebc0ac977219 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -802,6 +802,25 @@ dump_payload(const char *_p, int len, struct netmap_ring *ring, int cur) #define uh_sum check #endif /* linux */ +static uint16_t +new_ip_sum(uint16_t ip_sum, uint32_t oaddr, uint32_t naddr) +{ + ip_sum = cksum_add(ip_sum, ~oaddr >> 16); + ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); + ip_sum = cksum_add(ip_sum, naddr >> 16); + ip_sum = cksum_add(ip_sum, naddr & 0xffff); + return ip_sum; +} + +static uint16_t +new_udp_sum(uint16_t udp_sum, uint16_t oport, uint16_t nport) +{ + udp_sum = cksum_add(udp_sum, ~oport); + udp_sum = cksum_add(udp_sum, nport); + return udp_sum; +} + + static void update_ip(struct pkt *pkt, struct targ *t) { @@ -810,7 +829,7 @@ update_ip(struct pkt *pkt, struct targ *t) struct udphdr udp; uint32_t oaddr, naddr; uint16_t oport, nport; - uint16_t ip_sum, udp_sum; + uint16_t ip_sum = 0, udp_sum = 0; memcpy(&ip, &pkt->ipv4.ip, sizeof(ip)); memcpy(&udp, &pkt->ipv4.udp, sizeof(udp)); @@ -823,35 +842,28 @@ update_ip(struct pkt *pkt, struct targ *t) udp.uh_sport = nrand48(t->seed); naddr = ntohl(ip.ip_src.s_addr); nport = ntohs(udp.uh_sport); - break; - } - if (oport < g->src_ip.port1) { - nport = oport + 1; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); + } else { + if (oport < g->src_ip.port1) { + nport = oport + 1; + udp.uh_sport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); + break; + } + nport = g->src_ip.port0; udp.uh_sport = htons(nport); - break; - } - nport = g->src_ip.port0; - udp.uh_sport = htons(nport); - if (oaddr < g->src_ip.ipv4.end) { - naddr = oaddr + 1; + if (oaddr < g->src_ip.ipv4.end) { + naddr = oaddr + 1; + ip.ip_src.s_addr = htonl(naddr); + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + break; + } + naddr = g->src_ip.ipv4.start; ip.ip_src.s_addr = htonl(naddr); - break; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } - naddr = g->src_ip.ipv4.start; - ip.ip_src.s_addr = htonl(naddr); - } while (0); - /* update checksums if needed */ - if (oaddr != naddr) { - ip_sum = cksum_add(ip_sum, ~oaddr >> 16); - ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); - ip_sum = cksum_add(ip_sum, naddr >> 16); - ip_sum = cksum_add(ip_sum, naddr & 0xffff); - } - if (oport != nport) { - udp_sum = cksum_add(udp_sum, ~oport); - udp_sum = cksum_add(udp_sum, nport); - } - do { + naddr = oaddr = ntohl(ip.ip_dst.s_addr); nport = oport = ntohs(udp.uh_dport); if (g->options & OPT_RANDOM_DST) { @@ -859,34 +871,29 @@ update_ip(struct pkt *pkt, struct targ *t) udp.uh_dport = nrand48(t->seed); naddr = ntohl(ip.ip_dst.s_addr); nport = ntohs(udp.uh_dport); - break; - } - if (oport < g->dst_ip.port1) { - nport = oport + 1; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); + } else { + if (oport < g->dst_ip.port1) { + nport = oport + 1; + udp.uh_dport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); + break; + } + nport = g->dst_ip.port0; udp.uh_dport = htons(nport); - break; - } - nport = g->dst_ip.port0; - udp.uh_dport = htons(nport); - if (oaddr < g->dst_ip.ipv4.end) { - naddr = oaddr + 1; + if (oaddr < g->dst_ip.ipv4.end) { + naddr = oaddr + 1; + ip.ip_dst.s_addr = htonl(naddr); + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + break; + } + naddr = g->dst_ip.ipv4.start; ip.ip_dst.s_addr = htonl(naddr); - break; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } - naddr = g->dst_ip.ipv4.start; - ip.ip_dst.s_addr = htonl(naddr); } while (0); /* update checksums */ - if (oaddr != naddr) { - ip_sum = cksum_add(ip_sum, ~oaddr >> 16); - ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); - ip_sum = cksum_add(ip_sum, naddr >> 16); - ip_sum = cksum_add(ip_sum, naddr & 0xffff); - } - if (oport != nport) { - udp_sum = cksum_add(udp_sum, ~oport); - udp_sum = cksum_add(udp_sum, nport); - } if (udp_sum != 0) udp.uh_sum = ~cksum_add(~udp.uh_sum, htons(udp_sum)); if (ip_sum != 0) { @@ -939,14 +946,14 @@ update_ip6(struct pkt *pkt, struct targ *t) } naddr = ntohs(g->src_ip.ipv6.start.s6_addr16[group]); ip6.ip6_src.s6_addr16[group] = htons(naddr); - } while (0); - /* update checksums if needed */ - if (oaddr != naddr) - udp_sum = cksum_add(~oaddr, naddr); - if (oport != nport) - udp_sum = cksum_add(udp_sum, - cksum_add(~oport, nport)); - do { + + /* update checksums if needed */ + if (oaddr != naddr) + udp_sum = cksum_add(~oaddr, naddr); + if (oport != nport) + udp_sum = cksum_add(udp_sum, + cksum_add(~oport, nport)); + group = g->dst_ip.ipv6.egroup; naddr = oaddr = ntohs(ip6.ip6_dst.s6_addr16[group]); nport = oport = ntohs(udp.uh_dport); @@ -2504,7 +2511,7 @@ start_threads(struct glob_arg *g) { * using a single descriptor. */ for (i = 0; i < g->nthreads; i++) { - uint64_t seed = time(0) | (time(0) << 32); + uint64_t seed = (uint64_t)time(0) | ((uint64_t)time(0) << 32); t = &targs[i]; bzero(t, sizeof(*t)); From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 21:06:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 31F945C5293; Wed, 7 Apr 2021 21:06:50 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFxlt0vWyz4nRW; Wed, 7 Apr 2021 21:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1186D25C6B; Wed, 7 Apr 2021 21:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137L6nRZ063132; Wed, 7 Apr 2021 21:06:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137L6nuk063131; Wed, 7 Apr 2021 21:06:49 GMT (envelope-from git) Date: Wed, 7 Apr 2021 21:06:49 GMT Message-Id: <202104072106.137L6nuk063131@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: b5cf839053fe - stable/12 - netmap: pkt-gen: allow -Z and -z to be used together MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b5cf839053fef6da328d7b90d2475e8bb82bfa30 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 21:06:50 -0000 The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=b5cf839053fef6da328d7b90d2475e8bb82bfa30 commit b5cf839053fef6da328d7b90d2475e8bb82bfa30 Author: Vincenzo Maffione AuthorDate: 2021-03-30 06:13:07 +0000 Commit: Vincenzo Maffione CommitDate: 2021-04-07 21:06:38 +0000 netmap: pkt-gen: allow -Z and -z to be used together These options are used for generating random source/destination IP/ports within transmitted packets. MFC after: 1 week --- tools/tools/netmap/pkt-gen.c | 125 +++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index 55504c09ae58..ebc0ac977219 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -802,6 +802,25 @@ dump_payload(const char *_p, int len, struct netmap_ring *ring, int cur) #define uh_sum check #endif /* linux */ +static uint16_t +new_ip_sum(uint16_t ip_sum, uint32_t oaddr, uint32_t naddr) +{ + ip_sum = cksum_add(ip_sum, ~oaddr >> 16); + ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); + ip_sum = cksum_add(ip_sum, naddr >> 16); + ip_sum = cksum_add(ip_sum, naddr & 0xffff); + return ip_sum; +} + +static uint16_t +new_udp_sum(uint16_t udp_sum, uint16_t oport, uint16_t nport) +{ + udp_sum = cksum_add(udp_sum, ~oport); + udp_sum = cksum_add(udp_sum, nport); + return udp_sum; +} + + static void update_ip(struct pkt *pkt, struct targ *t) { @@ -810,7 +829,7 @@ update_ip(struct pkt *pkt, struct targ *t) struct udphdr udp; uint32_t oaddr, naddr; uint16_t oport, nport; - uint16_t ip_sum, udp_sum; + uint16_t ip_sum = 0, udp_sum = 0; memcpy(&ip, &pkt->ipv4.ip, sizeof(ip)); memcpy(&udp, &pkt->ipv4.udp, sizeof(udp)); @@ -823,35 +842,28 @@ update_ip(struct pkt *pkt, struct targ *t) udp.uh_sport = nrand48(t->seed); naddr = ntohl(ip.ip_src.s_addr); nport = ntohs(udp.uh_sport); - break; - } - if (oport < g->src_ip.port1) { - nport = oport + 1; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); + } else { + if (oport < g->src_ip.port1) { + nport = oport + 1; + udp.uh_sport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); + break; + } + nport = g->src_ip.port0; udp.uh_sport = htons(nport); - break; - } - nport = g->src_ip.port0; - udp.uh_sport = htons(nport); - if (oaddr < g->src_ip.ipv4.end) { - naddr = oaddr + 1; + if (oaddr < g->src_ip.ipv4.end) { + naddr = oaddr + 1; + ip.ip_src.s_addr = htonl(naddr); + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + break; + } + naddr = g->src_ip.ipv4.start; ip.ip_src.s_addr = htonl(naddr); - break; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } - naddr = g->src_ip.ipv4.start; - ip.ip_src.s_addr = htonl(naddr); - } while (0); - /* update checksums if needed */ - if (oaddr != naddr) { - ip_sum = cksum_add(ip_sum, ~oaddr >> 16); - ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); - ip_sum = cksum_add(ip_sum, naddr >> 16); - ip_sum = cksum_add(ip_sum, naddr & 0xffff); - } - if (oport != nport) { - udp_sum = cksum_add(udp_sum, ~oport); - udp_sum = cksum_add(udp_sum, nport); - } - do { + naddr = oaddr = ntohl(ip.ip_dst.s_addr); nport = oport = ntohs(udp.uh_dport); if (g->options & OPT_RANDOM_DST) { @@ -859,34 +871,29 @@ update_ip(struct pkt *pkt, struct targ *t) udp.uh_dport = nrand48(t->seed); naddr = ntohl(ip.ip_dst.s_addr); nport = ntohs(udp.uh_dport); - break; - } - if (oport < g->dst_ip.port1) { - nport = oport + 1; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); + } else { + if (oport < g->dst_ip.port1) { + nport = oport + 1; + udp.uh_dport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); + break; + } + nport = g->dst_ip.port0; udp.uh_dport = htons(nport); - break; - } - nport = g->dst_ip.port0; - udp.uh_dport = htons(nport); - if (oaddr < g->dst_ip.ipv4.end) { - naddr = oaddr + 1; + if (oaddr < g->dst_ip.ipv4.end) { + naddr = oaddr + 1; + ip.ip_dst.s_addr = htonl(naddr); + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); + break; + } + naddr = g->dst_ip.ipv4.start; ip.ip_dst.s_addr = htonl(naddr); - break; + ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } - naddr = g->dst_ip.ipv4.start; - ip.ip_dst.s_addr = htonl(naddr); } while (0); /* update checksums */ - if (oaddr != naddr) { - ip_sum = cksum_add(ip_sum, ~oaddr >> 16); - ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); - ip_sum = cksum_add(ip_sum, naddr >> 16); - ip_sum = cksum_add(ip_sum, naddr & 0xffff); - } - if (oport != nport) { - udp_sum = cksum_add(udp_sum, ~oport); - udp_sum = cksum_add(udp_sum, nport); - } if (udp_sum != 0) udp.uh_sum = ~cksum_add(~udp.uh_sum, htons(udp_sum)); if (ip_sum != 0) { @@ -939,14 +946,14 @@ update_ip6(struct pkt *pkt, struct targ *t) } naddr = ntohs(g->src_ip.ipv6.start.s6_addr16[group]); ip6.ip6_src.s6_addr16[group] = htons(naddr); - } while (0); - /* update checksums if needed */ - if (oaddr != naddr) - udp_sum = cksum_add(~oaddr, naddr); - if (oport != nport) - udp_sum = cksum_add(udp_sum, - cksum_add(~oport, nport)); - do { + + /* update checksums if needed */ + if (oaddr != naddr) + udp_sum = cksum_add(~oaddr, naddr); + if (oport != nport) + udp_sum = cksum_add(udp_sum, + cksum_add(~oport, nport)); + group = g->dst_ip.ipv6.egroup; naddr = oaddr = ntohs(ip6.ip6_dst.s6_addr16[group]); nport = oport = ntohs(udp.uh_dport); @@ -2504,7 +2511,7 @@ start_threads(struct glob_arg *g) { * using a single descriptor. */ for (i = 0; i < g->nthreads; i++) { - uint64_t seed = time(0) | (time(0) << 32); + uint64_t seed = (uint64_t)time(0) | ((uint64_t)time(0) << 32); t = &targs[i]; bzero(t, sizeof(*t)); From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:20 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 CDD135CA9A4; Thu, 8 Apr 2021 02:17:20 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4f85Rd6z3Nq6; Thu, 8 Apr 2021 02:17:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A974F2A0AE; Thu, 8 Apr 2021 02:17:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HKvm075880; Thu, 8 Apr 2021 02:17:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HKCa075879; Thu, 8 Apr 2021 02:17:20 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:20 GMT Message-Id: <202104080217.1382HKCa075879@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 94db41ccdb93 - stable/13 - mount_nullfs: rename a local variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 94db41ccdb931f75e597d3b159ea1fa14722174f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:20 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=94db41ccdb931f75e597d3b159ea1fa14722174f commit 94db41ccdb931f75e597d3b159ea1fa14722174f Author: Alan Somers AuthorDate: 2021-02-12 18:30:52 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:00 +0000 mount_nullfs: rename a local variable The "source" variable was introduced in r26072, probably as the traditional counterpart to "target". But the "source"/"target" names suggest the opposite of their actual meaning. With ln, for example, the source is the real file and the target is the newly created link. In mount_nullfs the meaning is the opposite: the target is the existing file system and the source is the newly created mountpoint. Better to use "target"/"mountpoint" terminology, which matches the man page. Sponsored by: Axcient (cherry picked from commit f540cb27a23719d88b7e5143be6e62f75dd25f08) --- sbin/mount_nullfs/mount_nullfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c index 1fb44eb864af..77ec0991ea9b 100644 --- a/sbin/mount_nullfs/mount_nullfs.c +++ b/sbin/mount_nullfs/mount_nullfs.c @@ -66,7 +66,7 @@ main(int argc, char *argv[]) { struct iovec *iov; char *p, *val; - char source[MAXPATHLEN]; + char mountpoint[MAXPATHLEN]; char target[MAXPATHLEN]; char errmsg[255]; int ch, iovlen; @@ -97,21 +97,21 @@ main(int argc, char *argv[]) if (argc != 2) usage(); - /* resolve target and source with realpath(3) */ + /* resolve target and mountpoint with realpath(3) */ if (checkpath(argv[0], target) != 0) err(EX_USAGE, "%s", target); - if (checkpath(argv[1], source) != 0) - err(EX_USAGE, "%s", source); + if (checkpath(argv[1], mountpoint) != 0) + err(EX_USAGE, "%s", mountpoint); build_iovec(&iov, &iovlen, "fstype", nullfs, (size_t)-1); - build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); + build_iovec(&iov, &iovlen, "fspath", mountpoint, (size_t)-1); build_iovec(&iov, &iovlen, "target", target, (size_t)-1); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); if (nmount(iov, iovlen, 0) < 0) { if (errmsg[0] != 0) - err(1, "%s: %s", source, errmsg); + err(1, "%s: %s", mountpoint, errmsg); else - err(1, "%s", source); + err(1, "%s", mountpoint); } exit(0); } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:21 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 E93935CAB96; Thu, 8 Apr 2021 02:17:21 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4f96LY9z3Nst; Thu, 8 Apr 2021 02:17:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCEC02A0AF; Thu, 8 Apr 2021 02:17:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HLPR075907; Thu, 8 Apr 2021 02:17:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HLd9075906; Thu, 8 Apr 2021 02:17:21 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:21 GMT Message-Id: <202104080217.1382HLd9075906@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 438e52f814f6 - stable/13 - [skip ci] fix a typo in a comment in mdconfig.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 438e52f814f68f4f8dc00b973539905a8ac6fcd8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:22 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=438e52f814f68f4f8dc00b973539905a8ac6fcd8 commit 438e52f814f68f4f8dc00b973539905a8ac6fcd8 Author: Alan Somers AuthorDate: 2021-02-27 16:04:10 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:35 +0000 [skip ci] fix a typo in a comment in mdconfig.c Sponsored by: Axcient Reviewed by: mav, imp Differential Revision: https://reviews.freebsd.org/D28968 (cherry picked from commit d977417d74a704930b5952cbd653638ccd25eaa7) --- sbin/mdconfig/mdconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 852909aa9032..0f76ca6149f1 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -423,7 +423,7 @@ md_set_file(const char *fn) /* * Lists md(4) disks. Is used also as a query routine, since it handles XML * interface. 'units' can be NULL for listing memory disks. It might be - * coma-separated string containing md(4) disk names. 'opt' distinguished + * comma-separated string containing md(4) disk names. 'opt' distinguished * between list and query mode. */ static int From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:23 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6F7445CA948; Thu, 8 Apr 2021 02:17:23 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4fC1Lldz3Nh6; Thu, 8 Apr 2021 02:17:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0000B2A20A; Thu, 8 Apr 2021 02:17:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HMbw075928; Thu, 8 Apr 2021 02:17:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HMbW075927; Thu, 8 Apr 2021 02:17:22 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:22 GMT Message-Id: <202104080217.1382HMbW075927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 774abe650b84 - stable/13 - Modernize geom_stats_snapshot_get MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 774abe650b840a753bdddbd8cf0bee0a72132009 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:23 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=774abe650b840a753bdddbd8cf0bee0a72132009 commit 774abe650b840a753bdddbd8cf0bee0a72132009 Author: Alan Somers AuthorDate: 2021-03-03 20:06:38 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:39 +0000 Modernize geom_stats_snapshot_get * A logically useless memset() is used to fault in some memory pages. Change it to explicit_bzero so the compiler won't eliminate it. * Eliminate the second memset. It made sense in the days of the Big Kernel Lock, but not in the days of fine-grained SMP and especially not in the days of VDSO. Sponsored by: Axcient Reviewed by: phk Differential Revision: https://reviews.freebsd.org/D29047 (cherry picked from commit f05b724ecb310fb91da1947ae6c68647f58f5f12) --- lib/libgeom/geom_stats.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/libgeom/geom_stats.c b/lib/libgeom/geom_stats.c index 450ee491ea1c..7c9191e29686 100644 --- a/lib/libgeom/geom_stats.c +++ b/lib/libgeom/geom_stats.c @@ -136,9 +136,8 @@ geom_stats_snapshot_get(void) free(sp); return (NULL); } - memset(sp->ptr, 0, pagesize * npages); /* page in, cache */ + explicit_bzero(sp->ptr, pagesize * npages); /* page in, cache */ clock_gettime(CLOCK_REALTIME, &sp->time); - memset(sp->ptr, 0, pagesize * npages); /* page in, cache */ memcpy(sp->ptr, statp, pagesize * npages); sp->pages = npages; sp->perpage = spp; From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D0B2F5CA9B1; Thu, 8 Apr 2021 02:17:26 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4fG05p3z3P5D; Thu, 8 Apr 2021 02:17:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C22029EF7; Thu, 8 Apr 2021 02:17:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HNmo075950; Thu, 8 Apr 2021 02:17:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HNig075949; Thu, 8 Apr 2021 02:17:23 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:23 GMT Message-Id: <202104080217.1382HNig075949@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 32be2332d10f - stable/13 - fusefs: fix two bugs regarding fcntl file locks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32be2332d10f6423def9d4c41d7e7707a97abae6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:26 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=32be2332d10f6423def9d4c41d7e7707a97abae6 commit 32be2332d10f6423def9d4c41d7e7707a97abae6 Author: Alan Somers AuthorDate: 2021-03-18 20:27:27 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:42 +0000 fusefs: fix two bugs regarding fcntl file locks 1) F_SETLKW (blocking) operations would be sent to the FUSE server as F_SETLK (non-blocking). 2) Release operations, F_SETLK with lk_type = F_UNLCK, would simply return EINVAL. PR: 253500 Reported by: John Millikin (cherry picked from commit 929acdb19acb67cc0e6ee5439df98e28a84d4772) --- sys/fs/fuse/fuse_vnops.c | 10 +++++++--- tests/sys/fs/fusefs/flush.cc | 12 ++++++++++- tests/sys/fs/fusefs/locks.cc | 45 +++++++++++++++++++++++++++++++++++++++++- tests/sys/fs/fusefs/release.cc | 12 ++++++++++- 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index 5bbde1e278c9..cdbc42f5adf4 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -437,10 +437,14 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) op = FUSE_GETLK; break; case F_SETLK: - op = FUSE_SETLK; + if (flags & F_WAIT) + op = FUSE_SETLKW; + else + op = FUSE_SETLK; break; - case F_SETLKW: - op = FUSE_SETLKW; + case F_UNLCK: + op = FUSE_SETLK; + flags |= F_UNLCK; break; default: return EINVAL; diff --git a/tests/sys/fs/fusefs/flush.cc b/tests/sys/fs/fusefs/flush.cc index 4d5a87bd66d5..d31a9fdaa386 100644 --- a/tests/sys/fs/fusefs/flush.cc +++ b/tests/sys/fs/fusefs/flush.cc @@ -210,6 +210,16 @@ TEST_F(FlushWithLocks, unlock_on_close) ResultOf([=](auto in) { return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && + in.body.setlk.lk.type == F_RDLCK && + in.body.setlk.fh == FH); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(0))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLK && + in.header.nodeid == ino && + in.body.setlk.lk.type == F_UNLCK && in.body.setlk.fh == FH); }, Eq(true)), _) @@ -224,7 +234,7 @@ TEST_F(FlushWithLocks, unlock_on_close) fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; fl.l_sysid = 0; - ASSERT_NE(-1, fcntl(fd, F_SETLKW, &fl)) << strerror(errno); + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); fd2 = open(FULLPATH, O_WRONLY); ASSERT_LE(0, fd2) << strerror(errno); diff --git a/tests/sys/fs/fusefs/locks.cc b/tests/sys/fs/fusefs/locks.cc index f3f1d42637d9..49f495412259 100644 --- a/tests/sys/fs/fusefs/locks.cc +++ b/tests/sys/fs/fusefs/locks.cc @@ -72,6 +72,23 @@ void expect_setlk(uint64_t ino, pid_t pid, uint64_t start, uint64_t end, return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && in.body.setlk.fh == FH && + in.body.setlk.owner == (uint32_t)pid && + in.body.setlk.lk.start == start && + in.body.setlk.lk.end == end && + in.body.setlk.lk.type == type && + in.body.setlk.lk.pid == (uint64_t)pid); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(err))); +} +void expect_setlkw(uint64_t ino, pid_t pid, uint64_t start, uint64_t end, + uint32_t type, int err) +{ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLKW && + in.header.nodeid == ino && + in.body.setlkw.fh == FH && in.body.setlkw.owner == (uint32_t)pid && in.body.setlkw.lk.start == start && in.body.setlkw.lk.end == end && @@ -343,6 +360,32 @@ TEST_F(SetlkFallback, local) leak(fd); } +/* Clear a lock with FUSE_SETLK */ +TEST_F(Setlk, clear) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + uint64_t ino = 42; + struct flock fl; + int fd; + pid_t pid = 1234; + + expect_lookup(RELPATH, ino); + expect_open(ino, 0, 1); + expect_setlk(ino, pid, 10, 1009, F_UNLCK, 0); + + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + fl.l_start = 10; + fl.l_len = 1000; + fl.l_pid = pid; + fl.l_type = F_UNLCK; + fl.l_whence = SEEK_SET; + fl.l_sysid = 0; + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); + leak(fd); +} + /* Set a new lock with FUSE_SETLK */ TEST_F(Setlk, set) { @@ -465,7 +508,7 @@ TEST_F(Setlkw, set) expect_lookup(RELPATH, ino); expect_open(ino, 0, 1); - expect_setlk(ino, pid, 10, 1009, F_RDLCK, 0); + expect_setlkw(ino, pid, 10, 1009, F_RDLCK, 0); fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); diff --git a/tests/sys/fs/fusefs/release.cc b/tests/sys/fs/fusefs/release.cc index 3caf8589352d..daa3ce39f573 100644 --- a/tests/sys/fs/fusefs/release.cc +++ b/tests/sys/fs/fusefs/release.cc @@ -206,6 +206,16 @@ TEST_F(ReleaseWithLocks, unlock_on_close) ResultOf([=](auto in) { return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && + in.body.setlk.lk.type == F_RDLCK && + in.body.setlk.fh == FH); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(0))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLK && + in.header.nodeid == ino && + in.body.setlk.lk.type == F_UNLCK && in.body.setlk.fh == FH); }, Eq(true)), _) @@ -221,7 +231,7 @@ TEST_F(ReleaseWithLocks, unlock_on_close) fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; fl.l_sysid = 0; - ASSERT_NE(-1, fcntl(fd, F_SETLKW, &fl)) << strerror(errno); + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); ASSERT_EQ(0, close(fd)) << strerror(errno); } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B24145CA9B6; Thu, 8 Apr 2021 02:17:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4fJ26w1z3NhN; Thu, 8 Apr 2021 02:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C4852A0B0; Thu, 8 Apr 2021 02:17:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HP9U075971; Thu, 8 Apr 2021 02:17:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HPfj075970; Thu, 8 Apr 2021 02:17:25 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:25 GMT Message-Id: <202104080217.1382HPfj075970@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 802271fddbf4 - stable/13 - fusefs: fix a dead store in fuse_vnop_advlock MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 802271fddbf4f1cc99aa880e11a4b651b440d1bb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:30 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=802271fddbf4f1cc99aa880e11a4b651b440d1bb commit 802271fddbf4f1cc99aa880e11a4b651b440d1bb Author: Alan Somers AuthorDate: 2021-03-20 01:38:57 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:46 +0000 fusefs: fix a dead store in fuse_vnop_advlock kevans actually caught this in the original review and I fixed it, but then I committed an older copy of the branch. Whoops. Reported by: kevans Differential Revision: https://reviews.freebsd.org/D29031 (cherry picked from commit 9c5aac8f2e84ca4bbdf82514302c08c0453ec59b) --- sys/fs/fuse/fuse_vnops.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index cdbc42f5adf4..a51c1b15e7f0 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -444,7 +444,6 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) break; case F_UNLCK: op = FUSE_SETLK; - flags |= F_UNLCK; break; default: return EINVAL; From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 02:17:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 881355CABA8; Thu, 8 Apr 2021 02:17:31 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FG4fK1ZKlz3P5b; Thu, 8 Apr 2021 02:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E8DA2A0B1; Thu, 8 Apr 2021 02:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1382HQ2i075992; Thu, 8 Apr 2021 02:17:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1382HQR7075991; Thu, 8 Apr 2021 02:17:26 GMT (envelope-from git) Date: Thu, 8 Apr 2021 02:17:26 GMT Message-Id: <202104080217.1382HQR7075991@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: c835e54fdcb8 - stable/13 - mpsutil.8: fix typos in the man page MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c835e54fdcb825172d0bfea33b2d713eab3c8870 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 02:17:31 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=c835e54fdcb825172d0bfea33b2d713eab3c8870 commit c835e54fdcb825172d0bfea33b2d713eab3c8870 Author: Alan Somers AuthorDate: 2021-03-25 14:43:40 +0000 Commit: Alan Somers CommitDate: 2021-04-08 02:15:50 +0000 mpsutil.8: fix typos in the man page Sponsored by: Axcient (cherry picked from commit f073ab8712a032faecf1fb94c4491fd555461ad8) --- usr.sbin/mpsutil/mpsutil.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/mpsutil/mpsutil.8 b/usr.sbin/mpsutil/mpsutil.8 index e4f966355fdd..1dd4f0509174 100644 --- a/usr.sbin/mpsutil/mpsutil.8 +++ b/usr.sbin/mpsutil/mpsutil.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 17, 2015 +.Dd March 25, 2021 .Dt MPSUTIL 8 .Os .Sh NAME @@ -45,7 +45,7 @@ .Cm show all .Nm .Op Fl u Ar unit -.Cm show cfgpages page +.Cm show cfgpage page .Op Ar num .Op Ar addr .Nm @@ -129,7 +129,7 @@ Displays all enclosures. .It Cm show iocfacts Displays IOC Facts messages. .It Cm show cfgpage page Oo Ar num Oc Op Ar addr -Show IOC Facts Message +Dump raw config page in hex. .El .Pp Controller management commands include: From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 16:22:29 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 ACC215B816A; Thu, 8 Apr 2021 16:22:29 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGRPK4Zdmz3jNN; Thu, 8 Apr 2021 16:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 901405916; Thu, 8 Apr 2021 16:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138GMTqh003664; Thu, 8 Apr 2021 16:22:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138GMTOx003663; Thu, 8 Apr 2021 16:22:29 GMT (envelope-from git) Date: Thu, 8 Apr 2021 16:22:29 GMT Message-Id: <202104081622.138GMTOx003663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Tai-hwa Liang Subject: git: f87d56d4bf5c - stable/13 - net: fixing a memory leak in if_deregister_com_alloc() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avatar X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f87d56d4bf5cb4dfdbcdd04ad386a41556fc170b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 16:22:29 -0000 The branch stable/13 has been updated by avatar: URL: https://cgit.FreeBSD.org/src/commit/?id=f87d56d4bf5cb4dfdbcdd04ad386a41556fc170b commit f87d56d4bf5cb4dfdbcdd04ad386a41556fc170b Author: Tai-hwa Liang AuthorDate: 2021-03-06 14:36:35 +0000 Commit: Tai-hwa Liang CommitDate: 2021-04-08 16:21:33 +0000 net: fixing a memory leak in if_deregister_com_alloc() Drain the callbacks upon if_deregister_com_alloc() such that the if_com_free[type] won't be nullified before if_destroy(). Taking fwip(4) as an example, before this fix, kldunload if_fwip will go through the following: 1. fwip_detach() 2. if_free() -> schedule if_destroy() through NET_EPOCH_CALL 3. fwip_detach() returns 4. firewire_modevent(MOD_UNLOAD) -> if_deregister_com_alloc() 5. kernel complains about: Warning: memory type fw_com leaked memory on destroy (1 allocations, 64 bytes leaked). 6. EPOCH runs if_destroy() -> if_free_internal()i By this time, if_com_free[if_alloctype] is NULL since it's already nullified by if_deregister_com_alloc(); hence, firewire_free() won't have a chance to release the allocated fw_com. Reviewed by: hselasky, glebius MFC after: 2 weeks (cherry picked from commit 092f3f081265c68cd8de0234ba8e46560ccc061e) --- sys/net/if.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/net/if.c b/sys/net/if.c index 948be6876b65..776fcf2fc78d 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -4045,6 +4045,14 @@ if_deregister_com_alloc(u_char type) ("if_deregister_com_alloc: %d not registered", type)); KASSERT(if_com_free[type] != NULL, ("if_deregister_com_alloc: %d free not registered", type)); + + /* + * Ensure all pending EPOCH(9) callbacks have been executed. This + * fixes issues about late invocation of if_destroy(), which leads + * to memory leak from if_com_alloc[type] allocated if_l2com. + */ + epoch_drain_callbacks(net_epoch_preempt); + if_com_alloc[type] = NULL; if_com_free[type] = NULL; } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 20:38:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 703475BEB15; Thu, 8 Apr 2021 20:38:53 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGY592nSmz4Z2W; Thu, 8 Apr 2021 20:38:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 528F8110EF; Thu, 8 Apr 2021 20:38:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138KcrEk035311; Thu, 8 Apr 2021 20:38:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138Kcriv035310; Thu, 8 Apr 2021 20:38:53 GMT (envelope-from git) Date: Thu, 8 Apr 2021 20:38:53 GMT Message-Id: <202104082038.138Kcriv035310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: c3254131a4af - stable/13 - Fix fib algo rebuild delay calculation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c3254131a4af1a0fb66a2b5431b0a918676f4256 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 20:38:53 -0000 The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=c3254131a4af1a0fb66a2b5431b0a918676f4256 commit c3254131a4af1a0fb66a2b5431b0a918676f4256 Author: Alexander V. Chernikov AuthorDate: 2021-03-15 21:09:07 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-04-08 20:15:04 +0000 Fix fib algo rebuild delay calculation. Submitted by: Marco Zec (cherry picked from commit e4ac3f74637778981b2d89745188bb2a39e24e42) --- sys/net/route/fib_algo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/route/fib_algo.c b/sys/net/route/fib_algo.c index b2aa2de087de..03c265d28d09 100644 --- a/sys/net/route/fib_algo.c +++ b/sys/net/route/fib_algo.c @@ -462,7 +462,7 @@ static void schedule_callout(struct fib_data *fd, int delay_ms) { - callout_reset_sbt(&fd->fd_callout, 0, SBT_1MS * delay_ms, + callout_reset_sbt(&fd->fd_callout, SBT_1MS * delay_ms, 0, rebuild_fd_callout, fd, 0); } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C24105C0C04; Thu, 8 Apr 2021 21:34:26 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKG53z3z4gcf; Thu, 8 Apr 2021 21:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E7BD11FBA; Thu, 8 Apr 2021 21:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYQCs015402; Thu, 8 Apr 2021 21:34:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYQls015401; Thu, 8 Apr 2021 21:34:26 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:26 GMT Message-Id: <202104082134.138LYQls015401@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: e02c4d8d9bc7 - stable/12 - fusefs: set d_off during VOP_READDIR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e02c4d8d9bc7c8a0ba4477c31cbac5b67283ea06 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:26 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=e02c4d8d9bc7c8a0ba4477c31cbac5b67283ea06 commit e02c4d8d9bc7c8a0ba4477c31cbac5b67283ea06 Author: Alan Somers AuthorDate: 2021-02-12 01:01:10 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:32:59 +0000 fusefs: set d_off during VOP_READDIR This allows d_off to be used with lseek to position the file so that getdirentries(2) will return the next entry. It is not used by readdir(3). PR: 253411 Reported by: John Millikin Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D28605 (cherry picked from commit 71befc35061b3c9d8cc07e34c5dce622c848fcdb) --- sys/fs/fuse/fuse_internal.c | 13 ++++---- tests/sys/fs/fusefs/Makefile | 3 ++ tests/sys/fs/fusefs/readdir.cc | 74 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 74 insertions(+), 16 deletions(-) diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index 22bc2d630971..57ff01cd70b7 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -584,7 +584,7 @@ fuse_internal_readdir_processdata(struct uio *uio, u_long **cookiesp) { int err = 0; - int bytesavail; + int oreclen; size_t freclen; struct dirent *de; @@ -621,10 +621,10 @@ fuse_internal_readdir_processdata(struct uio *uio, err = EINVAL; break; } - bytesavail = GENERIC_DIRSIZ((struct pseudo_dirent *) + oreclen = GENERIC_DIRSIZ((struct pseudo_dirent *) &fudge->namelen); - if (bytesavail > uio_resid(uio)) { + if (oreclen > uio_resid(uio)) { /* Out of space for the dir so we are done. */ err = -1; break; @@ -634,12 +634,13 @@ fuse_internal_readdir_processdata(struct uio *uio, * the requested offset in the directory is found. */ if (*fnd_start != 0) { - fiov_adjust(cookediov, bytesavail); - bzero(cookediov->base, bytesavail); + fiov_adjust(cookediov, oreclen); + bzero(cookediov->base, oreclen); de = (struct dirent *)cookediov->base; de->d_fileno = fudge->ino; - de->d_reclen = bytesavail; + de->d_off = fudge->off; + de->d_reclen = oreclen; de->d_type = fudge->type; de->d_namlen = fudge->namelen; memcpy((char *)cookediov->base + sizeof(struct dirent) - diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index ebe4061c1668..c3cf1f14e5bf 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -69,6 +69,9 @@ FUSEFS= ${SRCTOP}/sys/fs/fuse MOUNT= ${SRCTOP}/sbin/mount # Suppress warnings that GCC generates for the libc++ and gtest headers. CXXWARNFLAGS.gcc+= -Wno-placement-new -Wno-attributes +# Suppress Wcast-align for readdir.cc, because it is unavoidable when using +# getdirentries. +CXXWARNFLAGS.readdir.cc+= -Wno-cast-align .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80000 CXXWARNFLAGS+= -Wno-class-memaccess .endif diff --git a/tests/sys/fs/fusefs/readdir.cc b/tests/sys/fs/fusefs/readdir.cc index 8f0b9742890e..b6b807f350e9 100644 --- a/tests/sys/fs/fusefs/readdir.cc +++ b/tests/sys/fs/fusefs/readdir.cc @@ -62,6 +62,9 @@ void expect_lookup(const char *relpath, uint64_t ino) } }; +const char dot[] = "."; +const char dotdot[] = ".."; + /* FUSE_READDIR returns nothing but "." and ".." */ TEST_F(Readdir, dots) { @@ -72,8 +75,6 @@ TEST_F(Readdir, dots) struct dirent *de; vector ents(2); vector empty_ents(0); - const char dot[] = "."; - const char dotdot[] = ".."; expect_lookup(RELPATH, ino); expect_opendir(ino); @@ -98,11 +99,6 @@ TEST_F(Readdir, dots) de = readdir(dir); ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(2ul, de->d_fileno); - /* - * fuse(4) doesn't actually set d_off, which is ok for now because - * nothing uses it. - */ - //EXPECT_EQ(2000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); EXPECT_EQ(sizeof(dotdot), de->d_namlen); EXPECT_EQ(0, strcmp(dotdot, de->d_name)); @@ -111,7 +107,6 @@ TEST_F(Readdir, dots) de = readdir(dir); ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(3ul, de->d_fileno); - //EXPECT_EQ(3000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); EXPECT_EQ(sizeof(dot), de->d_namlen); EXPECT_EQ(0, strcmp(dot, de->d_name)); @@ -153,8 +148,11 @@ TEST_F(Readdir, eio) leakdir(dir); } -/* getdirentries(2) can use a larger buffer size than readdir(3) */ -TEST_F(Readdir, getdirentries) +/* + * getdirentries(2) can use a larger buffer size than readdir(3). It also has + * some additional non-standardized fields in the returned dirent. + */ +TEST_F(Readdir, getdirentries_empty) { const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; @@ -186,6 +184,62 @@ TEST_F(Readdir, getdirentries) leak(fd); } +/* + * The dirent.d_off field can be used with lseek to position the directory so + * that getdirentries will return the subsequent dirent. + */ +TEST_F(Readdir, getdirentries_seek) +{ + const char FULLPATH[] = "mountpoint/some_dir"; + const char RELPATH[] = "some_dir"; + vector ents0(2); + vector ents1(1); + uint64_t ino = 42; + int fd; + const size_t bufsize = 8192; + char buf[bufsize]; + struct dirent *de0, *de1; + ssize_t r; + + expect_lookup(RELPATH, ino); + expect_opendir(ino); + + ents0[0].d_fileno = 2; + ents0[0].d_off = 2000; + ents0[0].d_namlen = sizeof(dotdot); + ents0[0].d_type = DT_DIR; + strncpy(ents0[0].d_name, dotdot, ents0[0].d_namlen); + expect_readdir(ino, 0, ents0); + ents0[1].d_fileno = 3; + ents0[1].d_off = 3000; + ents0[1].d_namlen = sizeof(dot); + ents0[1].d_type = DT_DIR; + ents1[0].d_fileno = 3; + ents1[0].d_off = 3000; + ents1[0].d_namlen = sizeof(dot); + ents1[0].d_type = DT_DIR; + strncpy(ents1[0].d_name, dot, ents1[0].d_namlen); + expect_readdir(ino, 0, ents0); + expect_readdir(ino, 2000, ents1); + + fd = open(FULLPATH, O_DIRECTORY); + ASSERT_LE(0, fd) << strerror(errno); + r = getdirentries(fd, buf, sizeof(buf), 0); + ASSERT_LT(0, r) << strerror(errno); + de0 = (struct dirent*)&buf[0]; + ASSERT_EQ(2000, de0->d_off); + ASSERT_LT(de0->d_reclen + offsetof(struct dirent, d_fileno), bufsize); + de1 = (struct dirent*)(&(buf[de0->d_reclen])); + ASSERT_EQ(3ul, de1->d_fileno); + + r = lseek(fd, de0->d_off, SEEK_SET); + ASSERT_LE(0, r); + r = getdirentries(fd, buf, sizeof(buf), 0); + ASSERT_LT(0, r) << strerror(errno); + de0 = (struct dirent*)&buf[0]; + ASSERT_EQ(3000, de0->d_off); +} + /* * Nothing bad should happen if getdirentries is called on two file descriptors * which were concurrently open, but one has already been closed. From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C98785C0B8D; Thu, 8 Apr 2021 21:34:25 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKF4SQ8z4gnj; Thu, 8 Apr 2021 21:34:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 824FC12245; Thu, 8 Apr 2021 21:34:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYP0J015381; Thu, 8 Apr 2021 21:34:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYPCH015380; Thu, 8 Apr 2021 21:34:25 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:25 GMT Message-Id: <202104082134.138LYPCH015380@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 5061d5a0cfaf - stable/12 - mount_nullfs: rename a local variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:25 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 commit 5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 Author: Alan Somers AuthorDate: 2021-02-12 18:30:52 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:32:55 +0000 mount_nullfs: rename a local variable The "source" variable was introduced in r26072, probably as the traditional counterpart to "target". But the "source"/"target" names suggest the opposite of their actual meaning. With ln, for example, the source is the real file and the target is the newly created link. In mount_nullfs the meaning is the opposite: the target is the existing file system and the source is the newly created mountpoint. Better to use "target"/"mountpoint" terminology, which matches the man page. Sponsored by: Axcient (cherry picked from commit f540cb27a23719d88b7e5143be6e62f75dd25f08) --- sbin/mount_nullfs/mount_nullfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c index e62f60bd022d..3bb46fdfd66c 100644 --- a/sbin/mount_nullfs/mount_nullfs.c +++ b/sbin/mount_nullfs/mount_nullfs.c @@ -67,7 +67,7 @@ main(int argc, char *argv[]) { struct iovec *iov; char *p, *val; - char source[MAXPATHLEN]; + char mountpoint[MAXPATHLEN]; char target[MAXPATHLEN]; char errmsg[255]; int ch, iovlen; @@ -98,25 +98,25 @@ main(int argc, char *argv[]) if (argc != 2) usage(); - /* resolve target and source with realpath(3) */ + /* resolve target and mountpoint with realpath(3) */ if (checkpath(argv[0], target) != 0) err(EX_USAGE, "%s", target); - if (checkpath(argv[1], source) != 0) - err(EX_USAGE, "%s", source); + if (checkpath(argv[1], mountpoint) != 0) + err(EX_USAGE, "%s", mountpoint); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); build_iovec(&iov, &iovlen, "fstype", nullfs, (size_t)-1); - build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); + build_iovec(&iov, &iovlen, "fspath", mountpoint, (size_t)-1); build_iovec(&iov, &iovlen, "target", target, (size_t)-1); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); if (nmount(iov, iovlen, 0) < 0) { if (errmsg[0] != 0) - err(1, "%s: %s", source, errmsg); + err(1, "%s: %s", mountpoint, errmsg); else - err(1, "%s", source); + err(1, "%s", mountpoint); } exit(0); } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 1B6405C0D12; Thu, 8 Apr 2021 21:34:31 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKL1sSbz4gbB; Thu, 8 Apr 2021 21:34:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1345912246; Thu, 8 Apr 2021 21:34:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYSoN015444; Thu, 8 Apr 2021 21:34:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYSkA015443; Thu, 8 Apr 2021 21:34:28 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:28 GMT Message-Id: <202104082134.138LYSkA015443@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 8cfe6a4729f5 - stable/12 - Speed up geom_stats_resync in the presence of many devices MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8cfe6a4729f598d8a65d846a01184f1fabe2ebc7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:32 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=8cfe6a4729f598d8a65d846a01184f1fabe2ebc7 commit 8cfe6a4729f598d8a65d846a01184f1fabe2ebc7 Author: Alan Somers AuthorDate: 2021-02-27 15:59:40 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:33:09 +0000 Speed up geom_stats_resync in the presence of many devices The old code had a O(n) loop, where n is the size of /dev/devstat. Multiply that by another O(n) loop in devstat_mmap for a total of O(n^2). This change adds DIOCGMEDIASIZE support to /dev/devstat so userland can quickly determine the right amount of memory to map, eliminating the O(n) loop in userland. This change decreases the time to run "gstat -bI0.001" with 16,384 md devices from 29.7s to 4.2s. Also, fix a memory leak first reported as PR 203097. Sponsored by: Axcient Reviewed by: mav, imp Differential Revision: https://reviews.freebsd.org/D28968 (cherry picked from commit ab63da3564e8ab0907f9d8eb565774848ffdadeb) --- lib/libgeom/geom_stats.c | 26 +++++++++++++++++--------- sys/kern/subr_devstat.c | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/lib/libgeom/geom_stats.c b/lib/libgeom/geom_stats.c index ebf7868c3c65..450ee491ea1c 100644 --- a/lib/libgeom/geom_stats.c +++ b/lib/libgeom/geom_stats.c @@ -32,9 +32,12 @@ */ #include +#include +#include #include #include #include +#include #include #include #include @@ -53,7 +56,7 @@ geom_stats_close(void) { if (statsfd == -1) return; - munmap(statp, npages *pagesize); + munmap(statp, npages * pagesize); statp = NULL; close (statsfd); statsfd = -1; @@ -63,17 +66,22 @@ void geom_stats_resync(void) { void *p; + off_t mediasize; + int error; if (statsfd == -1) return; - for (;;) { - p = mmap(statp, (npages + 1) * pagesize, - PROT_READ, MAP_SHARED, statsfd, 0); - if (p == MAP_FAILED) - break; - else - statp = p; - npages++; + error = ioctl(statsfd, DIOCGMEDIASIZE, &mediasize); + if (error) + err(1, "DIOCGMEDIASIZE(" _PATH_DEV DEVSTAT_DEVICE_NAME ")"); + + munmap(statp, npages * pagesize); + p = mmap(statp, mediasize, PROT_READ, MAP_SHARED, statsfd, 0); + if (p == MAP_FAILED) + err(1, "mmap(/dev/devstat):"); + else { + statp = p; + npages = mediasize / pagesize; } } diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 617e1e439a94..1bbac1839f77 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -476,10 +477,12 @@ SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, #define statsperpage (PAGE_SIZE / sizeof(struct devstat)) +static d_ioctl_t devstat_ioctl; static d_mmap_t devstat_mmap; static struct cdevsw devstat_cdevsw = { .d_version = D_VERSION, + .d_ioctl = devstat_ioctl, .d_mmap = devstat_mmap, .d_name = "devstat", }; @@ -490,9 +493,26 @@ struct statspage { u_int nfree; }; +static size_t pagelist_pages = 0; static TAILQ_HEAD(, statspage) pagelist = TAILQ_HEAD_INITIALIZER(pagelist); static MALLOC_DEFINE(M_DEVSTAT, "devstat", "Device statistics"); +static int +devstat_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, + struct thread *td) +{ + int error = ENOTTY; + + switch (cmd) { + case DIOCGMEDIASIZE: + error = 0; + *(off_t *)data = pagelist_pages * PAGE_SIZE; + break; + } + + return (error); +} + static int devstat_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) @@ -559,6 +579,7 @@ devstat_alloc(void) * head but the order on the list determine the * sequence of the mapping so we can't do that. */ + pagelist_pages++; TAILQ_INSERT_TAIL(&pagelist, spp, list); } else break; From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A641E5C0B91; Thu, 8 Apr 2021 21:34:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKK10VSz4gXb; Thu, 8 Apr 2021 21:34:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F4034121BF; Thu, 8 Apr 2021 21:34:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYRoM015423; Thu, 8 Apr 2021 21:34:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYRMf015422; Thu, 8 Apr 2021 21:34:27 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:27 GMT Message-Id: <202104082134.138LYRMf015422@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 9e9ef41bec1f - stable/12 - fortune: add a tip about gstat MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9e9ef41bec1f1c7b4bbccecebb6d8fad92104f7b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:33 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=9e9ef41bec1f1c7b4bbccecebb6d8fad92104f7b commit 9e9ef41bec1f1c7b4bbccecebb6d8fad92104f7b Author: Alan Somers AuthorDate: 2021-02-26 15:06:07 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:33:04 +0000 fortune: add a tip about gstat (cherry picked from commit 60a632f047cdb6e5314711f593a4d3b1f1d8dde9) --- usr.bin/fortune/datfiles/freebsd-tips | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr.bin/fortune/datfiles/freebsd-tips b/usr.bin/fortune/datfiles/freebsd-tips index 5349bc6410c8..93075532cee4 100644 --- a/usr.bin/fortune/datfiles/freebsd-tips +++ b/usr.bin/fortune/datfiles/freebsd-tips @@ -799,3 +799,9 @@ always have space left this way. -- Benedict Reuschling % +Sometimes a single slow HDD can cripple the performance of your entire system. You can spot one like this: + +# gstat -I5s | sort -rn -k9 | head + + -- Alan Somers +% From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 65D3A5C0D15; Thu, 8 Apr 2021 21:34:33 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKN1Rkdz4gtL; Thu, 8 Apr 2021 21:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37A0C11FBB; Thu, 8 Apr 2021 21:34:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYTM6015472; Thu, 8 Apr 2021 21:34:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYT6A015471; Thu, 8 Apr 2021 21:34:29 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:29 GMT Message-Id: <202104082134.138LYT6A015471@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: dee863a2b5a5 - stable/12 - [skip ci] fix a typo in a comment in mdconfig.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: dee863a2b5a5d8ad8a1e661dac677a48f55431b3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:35 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=dee863a2b5a5d8ad8a1e661dac677a48f55431b3 commit dee863a2b5a5d8ad8a1e661dac677a48f55431b3 Author: Alan Somers AuthorDate: 2021-02-27 16:04:10 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:33:16 +0000 [skip ci] fix a typo in a comment in mdconfig.c Sponsored by: Axcient Reviewed by: mav, imp Differential Revision: https://reviews.freebsd.org/D28968 (cherry picked from commit d977417d74a704930b5952cbd653638ccd25eaa7) --- sbin/mdconfig/mdconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 933d448fde32..f61b947469b3 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -414,7 +414,7 @@ md_set_file(const char *fn) /* * Lists md(4) disks. Is used also as a query routine, since it handles XML * interface. 'units' can be NULL for listing memory disks. It might be - * coma-separated string containing md(4) disk names. 'opt' distinguished + * comma-separated string containing md(4) disk names. 'opt' distinguished * between list and query mode. */ static int From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:35 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7D8485C0B1E; Thu, 8 Apr 2021 21:34:35 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKP3ydNz4gpB; Thu, 8 Apr 2021 21:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3D8E61214E; Thu, 8 Apr 2021 21:34:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYVIk015493; Thu, 8 Apr 2021 21:34:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYVg4015492; Thu, 8 Apr 2021 21:34:31 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:31 GMT Message-Id: <202104082134.138LYVg4015492@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: e0c4ed73f3a6 - stable/12 - Modernize geom_stats_snapshot_get MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e0c4ed73f3a6a83f24d9a0bfe89f288ff1b93463 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:36 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=e0c4ed73f3a6a83f24d9a0bfe89f288ff1b93463 commit e0c4ed73f3a6a83f24d9a0bfe89f288ff1b93463 Author: Alan Somers AuthorDate: 2021-03-03 20:06:38 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:33:22 +0000 Modernize geom_stats_snapshot_get * A logically useless memset() is used to fault in some memory pages. Change it to explicit_bzero so the compiler won't eliminate it. * Eliminate the second memset. It made sense in the days of the Big Kernel Lock, but not in the days of fine-grained SMP and especially not in the days of VDSO. Sponsored by: Axcient Reviewed by: phk Differential Revision: https://reviews.freebsd.org/D29047 (cherry picked from commit f05b724ecb310fb91da1947ae6c68647f58f5f12) --- lib/libgeom/geom_stats.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/libgeom/geom_stats.c b/lib/libgeom/geom_stats.c index 450ee491ea1c..7c9191e29686 100644 --- a/lib/libgeom/geom_stats.c +++ b/lib/libgeom/geom_stats.c @@ -136,9 +136,8 @@ geom_stats_snapshot_get(void) free(sp); return (NULL); } - memset(sp->ptr, 0, pagesize * npages); /* page in, cache */ + explicit_bzero(sp->ptr, pagesize * npages); /* page in, cache */ clock_gettime(CLOCK_REALTIME, &sp->time); - memset(sp->ptr, 0, pagesize * npages); /* page in, cache */ memcpy(sp->ptr, statp, pagesize * npages); sp->pages = npages; sp->perpage = spp; From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:37 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 82F365C0CB1; Thu, 8 Apr 2021 21:34:37 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKS3LpVz4gpM; Thu, 8 Apr 2021 21:34:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71B6C12064; Thu, 8 Apr 2021 21:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYXar015535; Thu, 8 Apr 2021 21:34:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYXdQ015534; Thu, 8 Apr 2021 21:34:33 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:33 GMT Message-Id: <202104082134.138LYXdQ015534@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: ebe13089b5fa - stable/12 - mpsutil.8: fix typos in the man page MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ebe13089b5fa449f4c773a466f1ef82908924dfe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:38 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=ebe13089b5fa449f4c773a466f1ef82908924dfe commit ebe13089b5fa449f4c773a466f1ef82908924dfe Author: Alan Somers AuthorDate: 2021-03-25 14:43:40 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:34:14 +0000 mpsutil.8: fix typos in the man page Sponsored by: Axcient (cherry picked from commit f073ab8712a032faecf1fb94c4491fd555461ad8) --- usr.sbin/mpsutil/mpsutil.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/mpsutil/mpsutil.8 b/usr.sbin/mpsutil/mpsutil.8 index e4f966355fdd..1dd4f0509174 100644 --- a/usr.sbin/mpsutil/mpsutil.8 +++ b/usr.sbin/mpsutil/mpsutil.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 17, 2015 +.Dd March 25, 2021 .Dt MPSUTIL 8 .Os .Sh NAME @@ -45,7 +45,7 @@ .Cm show all .Nm .Op Fl u Ar unit -.Cm show cfgpages page +.Cm show cfgpage page .Op Ar num .Op Ar addr .Nm @@ -129,7 +129,7 @@ Displays all enclosures. .It Cm show iocfacts Displays IOC Facts messages. .It Cm show cfgpage page Oo Ar num Oc Op Ar addr -Show IOC Facts Message +Dump raw config page in hex. .El .Pp Controller management commands include: From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:34:37 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 837E95C0B22; Thu, 8 Apr 2021 21:34:37 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZKS2bG8z4gtg; Thu, 8 Apr 2021 21:34:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 32E8412063; Thu, 8 Apr 2021 21:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LYWAw015514; Thu, 8 Apr 2021 21:34:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LYWL6015513; Thu, 8 Apr 2021 21:34:32 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:34:32 GMT Message-Id: <202104082134.138LYWL6015513@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 9a9c9e744b51 - stable/12 - fusefs: fix two bugs regarding fcntl file locks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9a9c9e744b51e00f3446afb922500e40845cddfa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:34:37 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=9a9c9e744b51e00f3446afb922500e40845cddfa commit 9a9c9e744b51e00f3446afb922500e40845cddfa Author: Alan Somers AuthorDate: 2021-03-18 20:27:27 +0000 Commit: Alan Somers CommitDate: 2021-04-08 21:33:55 +0000 fusefs: fix two bugs regarding fcntl file locks 1) F_SETLKW (blocking) operations would be sent to the FUSE server as F_SETLK (non-blocking). 2) Release operations, F_SETLK with lk_type = F_UNLCK, would simply return EINVAL. PR: 253500 Reported by: John Millikin (cherry picked from commit 929acdb19acb67cc0e6ee5439df98e28a84d4772) fusefs: fix a dead store in fuse_vnop_advlock kevans actually caught this in the original review and I fixed it, but then I committed an older copy of the branch. Whoops. Reported by: kevans Differential Revision: https://reviews.freebsd.org/D29031 (cherry picked from commit 9c5aac8f2e84ca4bbdf82514302c08c0453ec59b) --- sys/fs/fuse/fuse_vnops.c | 9 ++++++--- tests/sys/fs/fusefs/flush.cc | 12 ++++++++++- tests/sys/fs/fusefs/locks.cc | 45 +++++++++++++++++++++++++++++++++++++++++- tests/sys/fs/fusefs/release.cc | 12 ++++++++++- 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index eb99e1cc09c0..d30fc32d1dc5 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -412,10 +412,13 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) op = FUSE_GETLK; break; case F_SETLK: - op = FUSE_SETLK; + if (flags & F_WAIT) + op = FUSE_SETLKW; + else + op = FUSE_SETLK; break; - case F_SETLKW: - op = FUSE_SETLKW; + case F_UNLCK: + op = FUSE_SETLK; break; default: return EINVAL; diff --git a/tests/sys/fs/fusefs/flush.cc b/tests/sys/fs/fusefs/flush.cc index 4d5a87bd66d5..d31a9fdaa386 100644 --- a/tests/sys/fs/fusefs/flush.cc +++ b/tests/sys/fs/fusefs/flush.cc @@ -210,6 +210,16 @@ TEST_F(FlushWithLocks, unlock_on_close) ResultOf([=](auto in) { return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && + in.body.setlk.lk.type == F_RDLCK && + in.body.setlk.fh == FH); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(0))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLK && + in.header.nodeid == ino && + in.body.setlk.lk.type == F_UNLCK && in.body.setlk.fh == FH); }, Eq(true)), _) @@ -224,7 +234,7 @@ TEST_F(FlushWithLocks, unlock_on_close) fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; fl.l_sysid = 0; - ASSERT_NE(-1, fcntl(fd, F_SETLKW, &fl)) << strerror(errno); + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); fd2 = open(FULLPATH, O_WRONLY); ASSERT_LE(0, fd2) << strerror(errno); diff --git a/tests/sys/fs/fusefs/locks.cc b/tests/sys/fs/fusefs/locks.cc index f3f1d42637d9..49f495412259 100644 --- a/tests/sys/fs/fusefs/locks.cc +++ b/tests/sys/fs/fusefs/locks.cc @@ -72,6 +72,23 @@ void expect_setlk(uint64_t ino, pid_t pid, uint64_t start, uint64_t end, return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && in.body.setlk.fh == FH && + in.body.setlk.owner == (uint32_t)pid && + in.body.setlk.lk.start == start && + in.body.setlk.lk.end == end && + in.body.setlk.lk.type == type && + in.body.setlk.lk.pid == (uint64_t)pid); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(err))); +} +void expect_setlkw(uint64_t ino, pid_t pid, uint64_t start, uint64_t end, + uint32_t type, int err) +{ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLKW && + in.header.nodeid == ino && + in.body.setlkw.fh == FH && in.body.setlkw.owner == (uint32_t)pid && in.body.setlkw.lk.start == start && in.body.setlkw.lk.end == end && @@ -343,6 +360,32 @@ TEST_F(SetlkFallback, local) leak(fd); } +/* Clear a lock with FUSE_SETLK */ +TEST_F(Setlk, clear) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + uint64_t ino = 42; + struct flock fl; + int fd; + pid_t pid = 1234; + + expect_lookup(RELPATH, ino); + expect_open(ino, 0, 1); + expect_setlk(ino, pid, 10, 1009, F_UNLCK, 0); + + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + fl.l_start = 10; + fl.l_len = 1000; + fl.l_pid = pid; + fl.l_type = F_UNLCK; + fl.l_whence = SEEK_SET; + fl.l_sysid = 0; + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); + leak(fd); +} + /* Set a new lock with FUSE_SETLK */ TEST_F(Setlk, set) { @@ -465,7 +508,7 @@ TEST_F(Setlkw, set) expect_lookup(RELPATH, ino); expect_open(ino, 0, 1); - expect_setlk(ino, pid, 10, 1009, F_RDLCK, 0); + expect_setlkw(ino, pid, 10, 1009, F_RDLCK, 0); fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); diff --git a/tests/sys/fs/fusefs/release.cc b/tests/sys/fs/fusefs/release.cc index 3caf8589352d..daa3ce39f573 100644 --- a/tests/sys/fs/fusefs/release.cc +++ b/tests/sys/fs/fusefs/release.cc @@ -206,6 +206,16 @@ TEST_F(ReleaseWithLocks, unlock_on_close) ResultOf([=](auto in) { return (in.header.opcode == FUSE_SETLK && in.header.nodeid == ino && + in.body.setlk.lk.type == F_RDLCK && + in.body.setlk.fh == FH); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnErrno(0))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_SETLK && + in.header.nodeid == ino && + in.body.setlk.lk.type == F_UNLCK && in.body.setlk.fh == FH); }, Eq(true)), _) @@ -221,7 +231,7 @@ TEST_F(ReleaseWithLocks, unlock_on_close) fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; fl.l_sysid = 0; - ASSERT_NE(-1, fcntl(fd, F_SETLKW, &fl)) << strerror(errno); + ASSERT_NE(-1, fcntl(fd, F_SETLK, &fl)) << strerror(errno); ASSERT_EQ(0, close(fd)) << strerror(errno); } From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 21:39:20 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D634B5C0EE3; Thu, 8 Apr 2021 21:39:20 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGZQw5khbz4hlv; Thu, 8 Apr 2021 21:39:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B367E11CDC; Thu, 8 Apr 2021 21:39:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138LdKC9016116; Thu, 8 Apr 2021 21:39:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138LdKun016115; Thu, 8 Apr 2021 21:39:20 GMT (envelope-from git) Date: Thu, 8 Apr 2021 21:39:20 GMT Message-Id: <202104082139.138LdKun016115@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: fbd57fb445ce - stable/13 - tcp: Perform simple fast retransmit when SACK Blocks are missing on SACK session MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fbd57fb445ce049c9d477e8357de6a299290405c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 21:39:20 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=fbd57fb445ce049c9d477e8357de6a299290405c commit fbd57fb445ce049c9d477e8357de6a299290405c Author: Richard Scheffenegger AuthorDate: 2021-03-25 22:18:06 +0000 Commit: Richard Scheffenegger CommitDate: 2021-04-08 21:12:26 +0000 tcp: Perform simple fast retransmit when SACK Blocks are missing on SACK session MFC after: 2 weeks Reviewed By: #transport, rrs Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28634 (cherry picked from commit 0533fab89e37caab886568df88d9f939e85eeb6c) --- sys/netinet/tcp_input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 4b0f102ca51b..ea9b03ae4a4d 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -2564,6 +2564,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, */ if (th->th_ack != tp->snd_una || ((tp->t_flags & TF_SACK_PERMIT) && + (to.to_flags & TOF_SACK) && !sack_changed)) break; else if (!tcp_timer_active(tp, TT_REXMT)) @@ -2617,6 +2618,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tp->snd_cwnd = imax(maxseg, tp->snd_nxt - tp->snd_recover + tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg)); } else if ((tp->t_flags & TF_SACK_PERMIT) && + (to.to_flags & TOF_SACK) && IN_FASTRECOVERY(tp->t_flags)) { int awnd; @@ -2694,7 +2696,8 @@ enter_recovery: tp->sackhint.recover_fs = max(1, tp->snd_nxt - tp->snd_una); } - if (tp->t_flags & TF_SACK_PERMIT) { + if ((tp->t_flags & TF_SACK_PERMIT) && + (to.to_flags & TOF_SACK)) { TCPSTAT_INC( tcps_sack_recovery_episode); tp->snd_recover = tp->snd_nxt; From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 22:19:24 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7F3725C244B for ; Thu, 8 Apr 2021 22:19:24 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4FGbK75wn9z4mdZ for ; Thu, 8 Apr 2021 22:19:23 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oo1-f41.google.com with SMTP id x187-20020a4a41c40000b02901b664cf3220so878020ooa.10 for ; Thu, 08 Apr 2021 15:19:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=EXYEm1J0e8DeF9+dF3vR05V/Tjw0y+KE+lA1ChdKpo4=; b=enxmcjiOjgMjH1AmrhsEm5L2HCkqNrRqB+DsDYDb+aLvmwNys62w/qsorJhh4pGNku Bw0VEyB4anilUKwb7YeCEhmg3atstJHZVQv2gxvlWAP42LbfoWYUc6B2p6cpHnlAxuD8 gNDKoO61R5sktbBZAKVj+bcm/7OK1Luok/8RkArFYUxypxd50wIxW2ibb0uMZwqR++c1 H5APxPNcKe7jMypv3AhiZ9hBxAqc6HckIGmfV7A7AGRLwhZjoJa9OdeRhtRLvrjLdce6 F6EXB6mIY90r4z3ToVrqJhK1iJEpkVy6hh0Ye0Tk8EHe+B5wEpRWIkZULkU8Co7GTiOv mtBA== X-Gm-Message-State: AOAM533TOeZxGSfhlyyIgnfoEvme4XiDSAml0o+M+1xwusPPQAKRGoMX McDoVMANXvpMhjoPD/t3Ca/Bi8tGjOarqv8Bxswj6OBO X-Received: by 2002:a4a:4005:: with SMTP id n5mt8209044ooa.61.1617920361881; Thu, 08 Apr 2021 15:19:21 -0700 (PDT) MIME-Version: 1.0 References: <202104082134.138LYPCH015380@gitrepo.freebsd.org> In-Reply-To: <202104082134.138LYPCH015380@gitrepo.freebsd.org> From: Alan Somers Date: Thu, 8 Apr 2021 16:19:10 -0600 Message-ID: Subject: Re: git: 5061d5a0cfaf - stable/12 - mount_nullfs: rename a local variable Cc: src-committers , "" , dev-commits-src-branches@freebsd.org X-Rspamd-Queue-Id: 4FGbK75wn9z4mdZ X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.161.41 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-1.00 / 15.00]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; RWL_MAILSPIKE_GOOD(0.00)[209.85.161.41:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MISSING_TO(2.00)[]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.161.41:from]; R_DKIM_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[asomers]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-branches@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[209.85.161.41:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.161.41:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-branches] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 22:19:24 -0000 On Thu, Apr 8, 2021 at 3:34 PM Alan Somers wrote: > The branch stable/12 has been updated by asomers: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 > > commit 5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 > Author: Alan Somers > AuthorDate: 2021-02-12 18:30:52 +0000 > Commit: Alan Somers > CommitDate: 2021-04-08 21:32:55 +0000 > > mount_nullfs: rename a local variable > > The "source" variable was introduced in r26072, probably as the > traditional counterpart to "target". But the "source"/"target" names > suggest the opposite of their actual meaning. With ln, for example, > the > source is the real file and the target is the newly created link. In > mount_nullfs the meaning is the opposite: the target is the existing > file system and the source is the newly created mountpoint. Better to > use "target"/"mountpoint" terminology, which matches the man page. > > Sponsored by: Axcient > > (cherry picked from commit f540cb27a23719d88b7e5143be6e62f75dd25f08) > Oops, this broke the build. I did a build test, but forgot to check that the build actually passed. I'll fix it shortly. -Alan From owner-dev-commits-src-branches@freebsd.org Thu Apr 8 23:12:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 E39E35C3871; Thu, 8 Apr 2021 23:12:48 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGcVm61N1z4rSt; Thu, 8 Apr 2021 23:12:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C1D6F13941; Thu, 8 Apr 2021 23:12:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 138NCmie049240; Thu, 8 Apr 2021 23:12:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 138NCmpu049239; Thu, 8 Apr 2021 23:12:48 GMT (envelope-from git) Date: Thu, 8 Apr 2021 23:12:48 GMT Message-Id: <202104082312.138NCmpu049239@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 4934396cd3e6 - stable/12 - Fix the build after 5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 4934396cd3e6514bbedec11bec4cbb40e4707f53 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 23:12:49 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=4934396cd3e6514bbedec11bec4cbb40e4707f53 commit 4934396cd3e6514bbedec11bec4cbb40e4707f53 Author: Alan Somers AuthorDate: 2021-04-08 23:11:00 +0000 Commit: Alan Somers CommitDate: 2021-04-08 23:11:00 +0000 Fix the build after 5061d5a0cfaf68a6891db82f6bd26ad3e72e87b1 A merge conflict in the MFC broke the build. Direct commit to stable/12 because main and stable/13 are unaffected. --- sbin/mount_nullfs/mount_nullfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c index 3bb46fdfd66c..cae818c35a49 100644 --- a/sbin/mount_nullfs/mount_nullfs.c +++ b/sbin/mount_nullfs/mount_nullfs.c @@ -104,7 +104,7 @@ main(int argc, char *argv[]) if (checkpath(argv[1], mountpoint) != 0) err(EX_USAGE, "%s", mountpoint); - if (subdir(target, source) || subdir(source, target)) + if (subdir(target, mountpoint) || subdir(mountpoint, target)) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 00:14:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 954995C5381; Fri, 9 Apr 2021 00:14:54 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGdtQ3s7dz3CY4; Fri, 9 Apr 2021 00:14:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7749A14278; Fri, 9 Apr 2021 00:14:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1390Esp4030034; Fri, 9 Apr 2021 00:14:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1390Esul030033; Fri, 9 Apr 2021 00:14:54 GMT (envelope-from git) Date: Fri, 9 Apr 2021 00:14:54 GMT Message-Id: <202104090014.1390Esul030033@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: df7114e92efe - releng/13.0 - 13.0: set static __FreeBSD_version MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: df7114e92efea8c74618c228880675594400d017 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 00:14:54 -0000 The branch releng/13.0 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=df7114e92efea8c74618c228880675594400d017 commit df7114e92efea8c74618c228880675594400d017 Author: Glen Barber AuthorDate: 2021-04-09 00:12:37 +0000 Commit: Glen Barber CommitDate: 2021-04-09 00:12:37 +0000 13.0: set static __FreeBSD_version Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- lib/csu/common/crtbrand.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csu/common/crtbrand.S b/lib/csu/common/crtbrand.S index bf223d84bc12..5548009eef44 100644 --- a/lib/csu/common/crtbrand.S +++ b/lib/csu/common/crtbrand.S @@ -45,5 +45,5 @@ __FBSDID("$FreeBSD$"); .4byte NT_FREEBSD_ABI_TAG 1: .asciz NOTE_FREEBSD_VENDOR 2: .p2align 2 -3: .4byte __FreeBSD_version +3: .4byte 1300139 4: From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 00:14:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 ACC425C52A7; Fri, 9 Apr 2021 00:14:55 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGdtR4Xllz3CY5; Fri, 9 Apr 2021 00:14:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F5BC143BD; Fri, 9 Apr 2021 00:14:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1390EtoA030055; Fri, 9 Apr 2021 00:14:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1390EtSC030054; Fri, 9 Apr 2021 00:14:55 GMT (envelope-from git) Date: Fri, 9 Apr 2021 00:14:55 GMT Message-Id: <202104090014.1390EtSC030054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 5003c6014ca6 - releng/13.0 - 13.0/UPDATING: anticipate 13.0-RELEASE date MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 5003c6014ca60853b7e684aa4a639e4f0695d515 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 00:14:55 -0000 The branch releng/13.0 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=5003c6014ca60853b7e684aa4a639e4f0695d515 commit 5003c6014ca60853b7e684aa4a639e4f0695d515 Author: Glen Barber AuthorDate: 2021-04-09 00:13:47 +0000 Commit: Glen Barber CommitDate: 2021-04-09 00:13:47 +0000 13.0/UPDATING: anticipate 13.0-RELEASE date Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- UPDATING | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/UPDATING b/UPDATING index 14efebc5d37b..0e6c4df32190 100644 --- a/UPDATING +++ b/UPDATING @@ -11,18 +11,24 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. -20210406: 13.0-RC5-p1 FreeBSD-SA-21:08.vm +20210413: + 13.0-RELEASE. + +20210406: + 13.0-RC5-p1 FreeBSD-SA-21:08.vm FreeBSD-SA-21:10.jail_mount Memory disclosure by stale virtual memory mapping [SA-21:08.vm] Jail escape possible by mounting over jail root [SA-21:10.jail_mount] -20210325: 13.0-RC3-p1 FreeBSD-SA-21:07.openssl +20210325: + 13.0-RC3-p1 FreeBSD-SA-21:07.openssl Fix multiple OpenSSL issues [SA-21:07.openssl] -20210223: 13.0-BETA3-p1 FreeBSD-SA-21:03.pam_login_access +20210223: + 13.0-BETA3-p1 FreeBSD-SA-21:03.pam_login_access FreeBSD-SA-21:06.xen login.access fails to apply rules [SA-21:03.pam_login_access] From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 00:14:58 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A0EBD5C4DEE; Fri, 9 Apr 2021 00:14:58 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGdtT10DNz3CMW; Fri, 9 Apr 2021 00:14:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE49A1417C; Fri, 9 Apr 2021 00:14:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1390EuMG030078; Fri, 9 Apr 2021 00:14:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1390EucZ030077; Fri, 9 Apr 2021 00:14:56 GMT (envelope-from git) Date: Fri, 9 Apr 2021 00:14:56 GMT Message-Id: <202104090014.1390EucZ030077@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: ea31abc261ff - releng/13.0 - 13.0: update to RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ea31abc261ffc01b6ff5671bffb15cf910a07f4b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 00:14:59 -0000 The branch releng/13.0 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=ea31abc261ffc01b6ff5671bffb15cf910a07f4b commit ea31abc261ffc01b6ff5671bffb15cf910a07f4b Author: Glen Barber AuthorDate: 2021-04-09 00:14:30 +0000 Commit: Glen Barber CommitDate: 2021-04-09 00:14:30 +0000 13.0: update to RELEASE Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/newvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 0d6ec4b72680..306e11fda092 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -54,7 +54,7 @@ TYPE="FreeBSD" REVISION="13.0" -BRANCH="RC5-p1" +BRANCH="RELEASE" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 00:28:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 360835C5A07; Fri, 9 Apr 2021 00:28:44 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGfBM5q02z3DmB; Fri, 9 Apr 2021 00:28:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 943371469E; Fri, 9 Apr 2021 00:28:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1390ShXb043888; Fri, 9 Apr 2021 00:28:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1390ShWj043887; Fri, 9 Apr 2021 00:28:43 GMT (envelope-from git) Date: Fri, 9 Apr 2021 00:28:43 GMT Message-Id: <202104090028.1390ShWj043887@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d6b6bd19e871 - stable/13 - dtrace: Document the libdir, nolibs and syslibdir options MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d6b6bd19e87158b3fdd03966bffaeff3afeb7b81 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 00:28:44 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d6b6bd19e87158b3fdd03966bffaeff3afeb7b81 commit d6b6bd19e87158b3fdd03966bffaeff3afeb7b81 Author: Domagoj Stolfa AuthorDate: 2021-04-02 21:19:47 +0000 Commit: Mark Johnston CommitDate: 2021-04-09 00:28:03 +0000 dtrace: Document the libdir, nolibs and syslibdir options Differential Revision: https://reviews.freebsd.org/D29541 (cherry picked from commit 7653f9317bc3fb3b945cb1485123a80050cfd4e8) --- cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 index b236fd49c260..c91dfc8270bb 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -20,7 +20,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2020 +.Dd April 2, 2021 .Dt DTRACE 1 .Os .Sh NAME @@ -602,8 +602,12 @@ Number of default stack frames for .It Sy jstackstrsize Ns = Ns Ar scalar Default string space size for .Fn jstack . +.It Sy libdir Ns = Ns Ar path +Add a directory to the system library path. .It Sy nspec Ns = Ns Ar scalar Number of speculations. +.It Sy nolibs +Do not load D system libraries. .It Sy quiet Set quiet mode. Same as the @@ -627,6 +631,10 @@ output. Rate of status checking. .It Sy switchrate Ns = Ns Ar time Rate of buffer switching. +.It Sy syslibdir Ns = Ns Ar path +Path to system libraries. +Defaults to +.Pa /usr/lib/dtrace . .It Sy ustackframes Ns = Ns Ar scalar Maximum number of userspace stack frames to unwind when executing the .Fn ustack From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 00:48:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 33D245C5F55; Fri, 9 Apr 2021 00:48:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGfdh12RTz3Glb; Fri, 9 Apr 2021 00:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 07C6114655; Fri, 9 Apr 2021 00:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1390mtZq070176; Fri, 9 Apr 2021 00:48:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1390mtGe070175; Fri, 9 Apr 2021 00:48:55 GMT (envelope-from git) Date: Fri, 9 Apr 2021 00:48:55 GMT Message-Id: <202104090048.1390mtGe070175@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: 27aa4fcbbc73 - stable/13 - Ensure that all allocated data structures in fsck_ffs are freed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 27aa4fcbbc73efd6c2eb7a958443c6b02ef70e74 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 00:48:56 -0000 The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=27aa4fcbbc73efd6c2eb7a958443c6b02ef70e74 commit 27aa4fcbbc73efd6c2eb7a958443c6b02ef70e74 Author: Kirk McKusick AuthorDate: 2021-04-02 18:57:34 +0000 Commit: Kirk McKusick CommitDate: 2021-04-09 00:49:00 +0000 Ensure that all allocated data structures in fsck_ffs are freed. (cherry picked from commit fc56fd262d0bc8ee523f6c8e6a65c0ff5417af6e) --- sbin/fsck_ffs/fsck.h | 4 +++- sbin/fsck_ffs/fsutil.c | 47 +++++++++++++++++++++++++++++++++++++---------- sbin/fsck_ffs/globs.c | 2 -- sbin/fsck_ffs/main.c | 6 ------ 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 676350b75767..9ecc5793e644 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -236,10 +236,12 @@ extern int sujrecovery; /* 1 => doing check using the journal */ } while (0) #define initbarea(bp, type) do { \ (bp)->b_bno = (ufs2_daddr_t)-1; \ + (bp)->b_size = 0; \ + (bp)->b_errs = 0; \ (bp)->b_flags = 0; \ + (bp)->b_type = type; \ (bp)->b_refcnt = 0; \ (bp)->b_index = 0; \ - (bp)->b_type = type; \ } while (0) #define sbdirty() dirty(&sblk) diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index 127884400651..ca19f6726af5 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -84,7 +84,6 @@ static LIST_HEAD(bufhash, bufarea) bufhashhd[HASHSIZE]; /* buffer hash list */ static int numbufs; /* size of buffer cache */ static int cachelookups; /* number of cache lookups */ static int cachereads; /* number of cache reads */ -static struct bufarea *cgbufs; /* header for cylinder group cache */ static int flushtries; /* number of tries to reclaim memory */ char *buftype[BT_NUMBUFTYPES] = BT_NAMES; @@ -187,13 +186,9 @@ bufinit(void) { int i; - pdirbp = (struct bufarea *)0; - bzero(&cgblk, sizeof(struct bufarea)); - cgblk.b_un.b_buf = Malloc((unsigned int)sblock.fs_bsize); - if (cgblk.b_un.b_buf == NULL) + if ((cgblk.b_un.b_buf = Malloc((unsigned int)sblock.fs_bsize)) == NULL) errx(EEXIT, "Initial malloc(%d) failed", sblock.fs_bsize); initbarea(&cgblk, BT_CYLGRP); - cgbufs = NULL; numbufs = cachelookups = cachereads = 0; TAILQ_INIT(&bufqueuehd); for (i = 0; i < HASHSIZE; i++) @@ -559,7 +554,8 @@ void ckfini(int markclean) { struct bufarea *bp, *nbp; - int ofsmodified, cnt; + struct inoinfo *inp, *ninp; + int ofsmodified, cnt, cg, i; if (bkgrdflag) { unlink(snapname); @@ -609,16 +605,20 @@ ckfini(int markclean) free(cgbufs[cnt].b_un.b_cg); } free(cgbufs); + cgbufs = NULL; } flush(fswritefd, &cgblk); free(cgblk.b_un.b_buf); + cgblk.b_un.b_buf = NULL; cnt = 0; /* Step 2: indirect, directory, external attribute, and data blocks */ if (debug) printf("Flush indirect, directory, external attribute, " "and data blocks\n"); - if (pdirbp != NULL) + if (pdirbp != NULL) { brelse(pdirbp); + pdirbp = NULL; + } TAILQ_FOREACH_REVERSE_SAFE(bp, &bufqueuehd, bufqueue, b_list, nbp) { switch (bp->b_type) { /* These should not be in the buffer cache list */ @@ -658,8 +658,10 @@ ckfini(int markclean) /* Step 3: inode blocks */ if (debug) printf("Flush inode blocks\n"); - if (icachebp != NULL) + if (icachebp != NULL) { brelse(icachebp); + icachebp = NULL; + } TAILQ_FOREACH_REVERSE_SAFE(bp, &bufqueuehd, bufqueue, b_list, nbp) { if (debug && bp->b_refcnt != 0) { prtbuf("ckfini: clearing in-use buffer", bp); @@ -686,7 +688,6 @@ ckfini(int markclean) sbdirty(); flush(fswritefd, &sblk); } - pdirbp = (struct bufarea *)0; if (cursnapshot == 0 && sblock.fs_clean != markclean) { if ((sblock.fs_clean = markclean) != 0) { sblock.fs_flags &= ~(FS_UNCLEAN | FS_NEEDSFSCK); @@ -711,6 +712,32 @@ ckfini(int markclean) rerun = 1; } } + /* + * Free allocated tracking structures. + */ + if (blockmap != NULL) + free(blockmap); + blockmap = NULL; + if (inostathead != NULL) { + for (cg = 0; cg < sblock.fs_ncg; cg++) + if (inostathead[cg].il_stat != NULL) + free((char *)inostathead[cg].il_stat); + free(inostathead); + } + inostathead = NULL; + if (inpsort != NULL) + free(inpsort); + inpsort = NULL; + if (inphead != NULL) { + for (i = 0; i < dirhash; i++) { + for (inp = inphead[i]; inp != NULL; inp = ninp) { + ninp = inp->i_nexthash; + free(inp); + } + } + free(inphead); + } + inphead = NULL; finalIOstats(); (void)close(fsreadfd); (void)close(fswritefd); diff --git a/sbin/fsck_ffs/globs.c b/sbin/fsck_ffs/globs.c index 45d6b80d8fe8..be4434ce38ca 100644 --- a/sbin/fsck_ffs/globs.c +++ b/sbin/fsck_ffs/globs.c @@ -128,7 +128,6 @@ fsckinit(void) bzero(totalreadtime, sizeof(struct timespec) * BT_NUMBUFTYPES); bzero(&startprog, sizeof(struct timespec)); bzero(&sblk, sizeof(struct bufarea)); - pdirbp = NULL; cursnapshot = 0; listmax = numdirs = dirhash = inplast = 0; countdirs = 0; @@ -159,7 +158,6 @@ fsckinit(void) fsreadfd = 0; fswritefd = 0; maxfsblock = 0; - blockmap = NULL; maxino = 0; lfdir = 0; lfname = "lost+found"; diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 65cee9b7b8c6..401ee10f9be3 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -243,7 +243,6 @@ checkfilesys(char *filesys) char errmsg[255]; int ofsmodified; int iovlen; - int cylno; intmax_t blks, files; size_t size; @@ -627,11 +626,6 @@ checkfilesys(char *filesys) resolved = 0; ckfini(resolved); - for (cylno = 0; cylno < sblock.fs_ncg; cylno++) - if (inostathead[cylno].il_stat != NULL) - free((char *)inostathead[cylno].il_stat); - free((char *)inostathead); - inostathead = NULL; if (fsmodified && !preen) printf("\n***** FILE SYSTEM WAS MODIFIED *****\n"); if (rerun) { From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 03:24:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0B91A5C95CD; Fri, 9 Apr 2021 03:24:55 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGk5f5yBmz3hQ4; Fri, 9 Apr 2021 03:24:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BFF9A16D95; Fri, 9 Apr 2021 03:24:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1393Osg1083246; Fri, 9 Apr 2021 03:24:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1393OsTx083245; Fri, 9 Apr 2021 03:24:54 GMT (envelope-from git) Date: Fri, 9 Apr 2021 03:24:54 GMT Message-Id: <202104090324.1393OsTx083245@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: 6186592c106b - stable/12 - MFC jail: fix jail(8) synposis and usage message to match reality. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6186592c106be2425dc4959c19c358c8ab86a307 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 03:24:55 -0000 The branch stable/12 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=6186592c106be2425dc4959c19c358c8ab86a307 commit 6186592c106be2425dc4959c19c358c8ab86a307 Author: Jamie Gritton AuthorDate: 2021-04-04 17:49:38 +0000 Commit: Jamie Gritton CommitDate: 2021-04-09 03:24:13 +0000 MFC jail: fix jail(8) synposis and usage message to match reality. Reported by: yuri PR: 254741 (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072) --- usr.sbin/jail/jail.8 | 4 ++-- usr.sbin/jail/jail.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index 3ac4f988a325..0b96f4d4adcc 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 14, 2020 +.Dd April 4, 2021 .Dt JAIL 8 .Os .Sh NAME @@ -58,7 +58,7 @@ .Op Fl U Ar username .Op Fl n Ar jailname .Op Fl s Ar securelevel -.Op Ar path hostname [ Ar ip Ns [ Ns Ar ,... Ns ]] Ar command ... +.Ar path hostname ip Ns [ Ns Ar ,... Ns ] Ar command ... .Nm .Op Fl f Ar conf_file .Fl e diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c index 920e573b9149..eb3b19f2cb82 100644 --- a/usr.sbin/jail/jail.c +++ b/usr.sbin/jail/jail.c @@ -1046,7 +1046,7 @@ usage(void) " jail [-qv] [-f file] -[rR] ['*' | jail ...]\n" " jail [-dhilqv] [-J jid_file] [-u username] [-U username]\n" " [-n jailname] [-s securelevel]\n" - " path hostname [ip[,...]] command ...\n" + " path hostname ip[,...] command ...\n" " jail [-f file] -e separator\n"); exit(1); } From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 03:25:58 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6602B5C9756; Fri, 9 Apr 2021 03:25:58 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGk6t2TfPz3hXw; Fri, 9 Apr 2021 03:25:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 47D8A16942; Fri, 9 Apr 2021 03:25:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1393Pw3a083437; Fri, 9 Apr 2021 03:25:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1393PwTI083436; Fri, 9 Apr 2021 03:25:58 GMT (envelope-from git) Date: Fri, 9 Apr 2021 03:25:58 GMT Message-Id: <202104090325.1393PwTI083436@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: bdb392c1d354 - stable/13 - MFC jail: fix jail(8) synposis and usage message to match reality. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bdb392c1d3547097c5d08ab5ccfdef7235ea1190 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 03:25:58 -0000 The branch stable/13 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=bdb392c1d3547097c5d08ab5ccfdef7235ea1190 commit bdb392c1d3547097c5d08ab5ccfdef7235ea1190 Author: Jamie Gritton AuthorDate: 2021-04-04 17:49:38 +0000 Commit: Jamie Gritton CommitDate: 2021-04-09 03:25:38 +0000 MFC jail: fix jail(8) synposis and usage message to match reality. Reported by: yuri PR: 254741 MFC after: 5 days (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072) --- usr.sbin/jail/jail.8 | 4 ++-- usr.sbin/jail/jail.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index cc3561f03f6a..61fe91cf973e 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 18, 2020 +.Dd April 4, 2021 .Dt JAIL 8 .Os .Sh NAME @@ -58,7 +58,7 @@ .Op Fl U Ar username .Op Fl n Ar jailname .Op Fl s Ar securelevel -.Op Ar path hostname [ Ar ip Ns [ Ns Ar ,... Ns ]] Ar command ... +.Ar path hostname ip Ns [ Ns Ar ,... Ns ] Ar command ... .Nm .Op Fl f Ar conf_file .Fl e diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c index 920e573b9149..eb3b19f2cb82 100644 --- a/usr.sbin/jail/jail.c +++ b/usr.sbin/jail/jail.c @@ -1046,7 +1046,7 @@ usage(void) " jail [-qv] [-f file] -[rR] ['*' | jail ...]\n" " jail [-dhilqv] [-J jid_file] [-u username] [-U username]\n" " [-n jailname] [-s securelevel]\n" - " path hostname [ip[,...]] command ...\n" + " path hostname ip[,...] command ...\n" " jail [-f file] -e separator\n"); exit(1); } From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 03:27:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 69EE15C991F; Fri, 9 Apr 2021 03:27:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGk8K2WwXz3hT4; Fri, 9 Apr 2021 03:27:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 498A016E0B; Fri, 9 Apr 2021 03:27:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1393RDfe083635; Fri, 9 Apr 2021 03:27:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1393RDxj083634; Fri, 9 Apr 2021 03:27:13 GMT (envelope-from git) Date: Fri, 9 Apr 2021 03:27:13 GMT Message-Id: <202104090327.1393RDxj083634@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: 73b04801b316 - stable/11 - MFC jail: fix jail(8) synposis and usage message to match reality. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 73b04801b3163417cff33b279f1bc42451f20009 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 03:27:13 -0000 The branch stable/11 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=73b04801b3163417cff33b279f1bc42451f20009 commit 73b04801b3163417cff33b279f1bc42451f20009 Author: Jamie Gritton AuthorDate: 2021-04-04 17:49:38 +0000 Commit: Jamie Gritton CommitDate: 2021-04-09 03:26:58 +0000 MFC jail: fix jail(8) synposis and usage message to match reality. Reported by: yuri PR: 254741 MFC after: 5 days (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072) --- usr.sbin/jail/jail.8 | 4 ++-- usr.sbin/jail/jail.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index d5babaadf950..e8de0d765e2d 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 17, 2020 +.Dd April 4, 2021 .Dt JAIL 8 .Os .Sh NAME @@ -58,7 +58,7 @@ .Op Fl U Ar username .Op Fl n Ar jailname .Op Fl s Ar securelevel -.Op Ar path hostname [ Ar ip Ns [ Ns Ar ,... Ns ]] Ar command ... +.Ar path hostname ip Ns [ Ns Ar ,... Ns ] Ar command ... .Nm .Op Fl f Ar conf_file .Fl e diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c index 1bf7fad2b2a5..d523a0b63e27 100644 --- a/usr.sbin/jail/jail.c +++ b/usr.sbin/jail/jail.c @@ -1052,7 +1052,7 @@ usage(void) " jail [-qv] [-f file] -[rR] ['*' | jail ...]\n" " jail [-dhilqv] [-J jid_file] [-u username] [-U username]\n" " [-n jailname] [-s securelevel]\n" - " path hostname [ip[,...]] command ...\n" + " path hostname ip[,...] command ...\n" " jail [-f file] -e separator\n"); exit(1); } From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 04:57:20 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 4C1475CB114; Fri, 9 Apr 2021 04:57:20 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGm8J1YTYz3mxq; Fri, 9 Apr 2021 04:57:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 23C4917FB0; Fri, 9 Apr 2021 04:57:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1394vKZE001452; Fri, 9 Apr 2021 04:57:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1394vJu0001451; Fri, 9 Apr 2021 04:57:19 GMT (envelope-from git) Date: Fri, 9 Apr 2021 04:57:19 GMT Message-Id: <202104090457.1394vJu0001451@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ee389afecf85 - stable/13 - nullfs: protect against user creating inconsistent state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ee389afecf85571936957b183921165893c680a6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 04:57:20 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ee389afecf85571936957b183921165893c680a6 commit ee389afecf85571936957b183921165893c680a6 Author: Konstantin Belousov AuthorDate: 2021-04-01 17:42:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-09 04:52:05 +0000 nullfs: protect against user creating inconsistent state PR: 253593 (cherry picked from commit 76b1b5ce6d81f66b09be8a20aecd064b65fd6b50) --- sys/fs/nullfs/null_vnops.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 45065e0be7b5..607755fd62d9 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -389,10 +389,21 @@ null_lookup(struct vop_lookup_args *ap) */ ldvp = NULLVPTOLOWERVP(dvp); vp = lvp = NULL; - KASSERT((ldvp->v_vflag & VV_ROOT) == 0 || - ((dvp->v_vflag & VV_ROOT) != 0 && (flags & ISDOTDOT) == 0), - ("ldvp %p fl %#x dvp %p fl %#x flags %#x", ldvp, ldvp->v_vflag, - dvp, dvp->v_vflag, flags)); + + /* + * Renames in the lower mounts might create an inconsistent + * configuration where lower vnode is moved out of the + * directory tree remounted by our null mount. Do not try to + * handle it fancy, just avoid VOP_LOOKUP() with DOTDOT name + * which cannot be handled by VOP, at least passing over lower + * root. + */ + if ((ldvp->v_vflag & VV_ROOT) != 0 && (flags & ISDOTDOT) != 0) { + KASSERT((dvp->v_vflag & VV_ROOT) == 0, + ("ldvp %p fl %#x dvp %p fl %#x flags %#x", + ldvp, ldvp->v_vflag, dvp, dvp->v_vflag, flags)); + return (ENOENT); + } /* * Hold ldvp. The reference on it, owned by dvp, is lost in From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 05:08:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A91EF5CB617; Fri, 9 Apr 2021 05:08:45 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGmPT4JNtz3nvq; Fri, 9 Apr 2021 05:08:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 824C2180E9; Fri, 9 Apr 2021 05:08:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13958jHf015842; Fri, 9 Apr 2021 05:08:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13958jNk015841; Fri, 9 Apr 2021 05:08:45 GMT (envelope-from git) Date: Fri, 9 Apr 2021 05:08:45 GMT Message-Id: <202104090508.13958jNk015841@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1a4f94944ec7 - stable/12 - mbuf: add a way to mark flowid as calculated from the internal headers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1a4f94944ec7c36027726e77264b62236dee24a1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 05:08:45 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1a4f94944ec7c36027726e77264b62236dee24a1 commit 1a4f94944ec7c36027726e77264b62236dee24a1 Author: Konstantin Belousov AuthorDate: 2021-02-12 13:38:07 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-09 04:57:31 +0000 mbuf: add a way to mark flowid as calculated from the internal headers (cherry picked from commit e243367b644562c9410b39f8d78dafdb7e785d85) --- sys/kern/uipc_mbuf.c | 23 +++++++++++++++++++++++ sys/net/if_gif.c | 3 ++- sys/net/if_vxlan.c | 3 ++- sys/sys/mbuf.h | 12 +++++++++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 0161186fdb7f..9a83380371d6 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -795,6 +795,29 @@ m_adj(struct mbuf *mp, int req_len) } } +void +m_adj_decap(struct mbuf *mp, int len) +{ + uint8_t rsstype; + + m_adj(mp, len); + if ((mp->m_flags & M_PKTHDR) != 0) { + /* + * If flowid was calculated by card from the inner + * headers, move flowid to the decapsulated mbuf + * chain, otherwise clear. This depends on the + * internals of m_adj, which keeps pkthdr as is, in + * particular not changing rsstype and flowid. + */ + rsstype = mp->m_pkthdr.rsstype; + if ((rsstype & M_HASHTYPE_INNER) != 0) { + M_HASHTYPE_SET(mp, rsstype & ~M_HASHTYPE_INNER); + } else { + M_HASHTYPE_CLEAR(mp); + } + } +} + /* * Rearange an mbuf chain so that len bytes are contiguous * and in the data area of an mbuf (so that mtod will work diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index f23be1e143f7..c9ccee4c98bd 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -540,7 +540,8 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn) m_freem(m); goto drop; } - m_adj(m, sizeof(struct etherip_header)); + + m_adj_decap(m, sizeof(struct etherip_header)); m->m_flags &= ~(M_BCAST|M_MCAST); m->m_pkthdr.rcvif = ifp; diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 5e35baae2dbc..e333f7272e52 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2532,8 +2532,9 @@ vxlan_rcv_udp_packet(struct mbuf *m, int offset, struct inpcb *inpcb, goto out; vni = ntohl(vxh->vxlh_vni) >> VXLAN_HDR_VNI_SHIFT; + /* Adjust to the start of the inner Ethernet frame. */ - m_adj(m, offset + sizeof(struct vxlan_header)); + m_adj_decap(m, offset + sizeof(struct vxlan_header)); error = vxlan_input(vso, vni, &m, srcsa); MPASS(error != 0 || m == NULL); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 057e4800f8d3..127dae75726f 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -385,6 +385,7 @@ struct mbuf { * https://docs.microsoft.com/en-us/windows-hardware/drivers/network/rss-hashing-types#ndishashipv6ex */ #define M_HASHTYPE_HASHPROP 0x80 /* has hash properties */ +#define M_HASHTYPE_INNER 0x40 /* calculated from inner headers */ #define M_HASHTYPE_HASH(t) (M_HASHTYPE_HASHPROP | (t)) /* Microsoft RSS standard hash types */ #define M_HASHTYPE_NONE 0 @@ -401,15 +402,19 @@ struct mbuf { #define M_HASHTYPE_RSS_UDP_IPV6_EX M_HASHTYPE_HASH(10)/* IPv6 UDP 4-tuple + * ext hdrs */ -#define M_HASHTYPE_OPAQUE 63 /* ordering, not affinity */ +#define M_HASHTYPE_OPAQUE 0x3f /* ordering, not affinity */ #define M_HASHTYPE_OPAQUE_HASH M_HASHTYPE_HASH(M_HASHTYPE_OPAQUE) /* ordering+hash, not affinity*/ #define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0) -#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype) +#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype & ~M_HASHTYPE_INNER) #define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v)) #define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) -#define M_HASHTYPE_ISHASH(m) (M_HASHTYPE_GET(m) & M_HASHTYPE_HASHPROP) +#define M_HASHTYPE_ISHASH(m) \ + (((m)->m_pkthdr.rsstype & M_HASHTYPE_HASHPROP) != 0) +#define M_HASHTYPE_SETINNER(m) do { \ + (m)->m_pkthdr.rsstype |= M_HASHTYPE_INNER; \ + } while (0) /* * COS/QOS class and quality of service tags. @@ -659,6 +664,7 @@ extern uma_zone_t zone_jumbo16; void mb_dupcl(struct mbuf *, struct mbuf *); void mb_free_ext(struct mbuf *); void m_adj(struct mbuf *, int); +void m_adj_decap(struct mbuf *, int); int m_apply(struct mbuf *, int, int, int (*)(void *, void *, u_int), void *); int m_append(struct mbuf *, int, c_caddr_t); From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 05:08:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B351C5CB58C; Fri, 9 Apr 2021 05:08:46 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGmPV4cHXz3nvv; Fri, 9 Apr 2021 05:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F7B01810E; Fri, 9 Apr 2021 05:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13958k28015869; Fri, 9 Apr 2021 05:08:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13958kbp015868; Fri, 9 Apr 2021 05:08:46 GMT (envelope-from git) Date: Fri, 9 Apr 2021 05:08:46 GMT Message-Id: <202104090508.13958kbp015868@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e1fb4bc3e478 - stable/12 - Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e1fb4bc3e478b00cc4e89ef7609efafc0c87c3b4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 05:08:46 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e1fb4bc3e478b00cc4e89ef7609efafc0c87c3b4 commit e1fb4bc3e478b00cc4e89ef7609efafc0c87c3b4 Author: Konstantin Belousov AuthorDate: 2021-04-04 16:27:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-09 04:57:31 +0000 Style (cherry picked from commit 51a7be5f6036ebd47c8b3f704d52e7ec3f837114) --- sys/vm/vm_kern.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 5f79482a2d3f..83d58a194f62 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -848,7 +848,7 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) i = 0; error = sysctl_handle_int(oidp, &i, 0, req); - if (error) + if (error != 0) return (error); if ((i & ~(VM_LOW_KMEM | VM_LOW_PAGES)) != 0) return (EINVAL); @@ -857,5 +857,6 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) return (0); } -SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_RW, 0, 0, - debug_vm_lowmem, "I", "set to trigger vm_lowmem event with given flags"); +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"); From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 05:08:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 14C535CB783; Fri, 9 Apr 2021 05:08:48 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FGmPW6Rjcz3nr8; Fri, 9 Apr 2021 05:08:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4B0717CFC; Fri, 9 Apr 2021 05:08:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13958lTf015891; Fri, 9 Apr 2021 05:08:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13958lCl015890; Fri, 9 Apr 2021 05:08:47 GMT (envelope-from git) Date: Fri, 9 Apr 2021 05:08:47 GMT Message-Id: <202104090508.13958lCl015890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ecc571a85858 - stable/12 - nullfs: protect against user creating inconsistent state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ecc571a858586e7b62cae3794c0f6250a91a483b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 05:08:48 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ecc571a858586e7b62cae3794c0f6250a91a483b commit ecc571a858586e7b62cae3794c0f6250a91a483b Author: Konstantin Belousov AuthorDate: 2021-04-01 17:42:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-09 04:57:37 +0000 nullfs: protect against user creating inconsistent state PR: 253593 (cherry picked from commit 76b1b5ce6d81f66b09be8a20aecd064b65fd6b50) --- sys/fs/nullfs/null_vnops.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index b663d8d718d3..62351cd9d832 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -376,10 +376,21 @@ null_lookup(struct vop_lookup_args *ap) */ ldvp = NULLVPTOLOWERVP(dvp); vp = lvp = NULL; - KASSERT((ldvp->v_vflag & VV_ROOT) == 0 || - ((dvp->v_vflag & VV_ROOT) != 0 && (flags & ISDOTDOT) == 0), - ("ldvp %p fl %#x dvp %p fl %#x flags %#x", ldvp, ldvp->v_vflag, - dvp, dvp->v_vflag, flags)); + + /* + * Renames in the lower mounts might create an inconsistent + * configuration where lower vnode is moved out of the + * directory tree remounted by our null mount. Do not try to + * handle it fancy, just avoid VOP_LOOKUP() with DOTDOT name + * which cannot be handled by VOP, at least passing over lower + * root. + */ + if ((ldvp->v_vflag & VV_ROOT) != 0 && (flags & ISDOTDOT) != 0) { + KASSERT((dvp->v_vflag & VV_ROOT) == 0, + ("ldvp %p fl %#x dvp %p fl %#x flags %#x", + ldvp, ldvp->v_vflag, dvp, dvp->v_vflag, flags)); + return (ENOENT); + } /* * Hold ldvp. The reference on it, owned by dvp, is lost in From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 14:56:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7A6245BB582; Fri, 9 Apr 2021 14:56:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FH1RL33Cmz4njZ; Fri, 9 Apr 2021 14:56:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 577061FEA4; Fri, 9 Apr 2021 14:56:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 139EuEqf005745; Fri, 9 Apr 2021 14:56:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 139EuExL005744; Fri, 9 Apr 2021 14:56:14 GMT (envelope-from git) Date: Fri, 9 Apr 2021 14:56:14 GMT Message-Id: <202104091456.139EuExL005744@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: df23288bc0c6 - stable/12 - vfs: honor error code returned by mac_vnode_check_rename_from MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: df23288bc0c6d3c16287756c7f43c679fba6a0de Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 14:56:14 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=df23288bc0c6d3c16287756c7f43c679fba6a0de commit df23288bc0c6d3c16287756c7f43c679fba6a0de Author: Mateusz Guzik AuthorDate: 2020-07-29 17:04:33 +0000 Commit: Mark Johnston CommitDate: 2021-04-09 14:49:52 +0000 vfs: honor error code returned by mac_vnode_check_rename_from (cherry picked from commit fd8c6a48abe0ad2ba64b611fe044830f89b30138) --- sys/kern/vfs_syscalls.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 64b2f5d4a18a..f07ee87fce08 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3499,20 +3499,27 @@ again: NDINIT_ATRIGHTS(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART | AUDITVNODE1, pathseg, old, oldfd, &cap_renameat_source_rights, td); -#else - NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1, - pathseg, old, oldfd, - &cap_renameat_source_rights, td); -#endif - if ((error = namei(&fromnd)) != 0) return (error); -#ifdef MAC error = mac_vnode_check_rename_from(td->td_ucred, fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd); VOP_UNLOCK(fromnd.ni_dvp, 0); if (fromnd.ni_dvp != fromnd.ni_vp) VOP_UNLOCK(fromnd.ni_vp, 0); + if (error != 0) { + NDFREE(&fromnd, NDF_ONLY_PNBUF); + vrele(fromnd.ni_dvp); + vrele(fromnd.ni_vp); + if (fromnd.ni_startdir) + vrele(fromnd.ni_startdir); + return (error); + } +#else + NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1, + pathseg, old, oldfd, + &cap_renameat_source_rights, td); + if ((error = namei(&fromnd)) != 0) + return (error); #endif fvp = fromnd.ni_vp; NDINIT_ATRIGHTS(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 18:54:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 DE58D5C06F9; Fri, 9 Apr 2021 18:54:17 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FH6k14sLVz3Hgc; Fri, 9 Apr 2021 18:54:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 95B6323408; Fri, 9 Apr 2021 18:54:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 139IsH2Q024142; Fri, 9 Apr 2021 18:54:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 139IsHqA024141; Fri, 9 Apr 2021 18:54:17 GMT (envelope-from git) Date: Fri, 9 Apr 2021 18:54:17 GMT Message-Id: <202104091854.139IsHqA024141@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: fc1b4743b270 - Create tag release/13.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/tags/release/13.0.0 X-Git-Reftype: annotated tag X-Git-Commit: fc1b4743b2707bac402b7a20855964bc75e82685 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 18:54:18 -0000 The annotated tag release/13.0.0 has been created by gjb: URL: https://cgit.FreeBSD.org/src/tag/?h=release/13.0.0 tag release/13.0.0 Tagger: Glen Barber TaggerDate: 2021-04-09 18:52:16 +0000 13.0-RELEASE: tag release/13.0.0 Approved by: re (implicit) -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEjRJAPC5sqwhs9k2jAxRYpUeP4pMFAmBwooAACgkQAxRYpUeP 4pPzQA//T4/Lha3kSWoDwQOZGiP43Jhu0/x3V9OA2O7FYK6zgRfl2nFHwfKRA/3I xky711SpdYkM/dew1J6qUKLw8EwNBVPK2SyjfYN5r5d5T/CA6XhMUqDcM9f6jixn /8YBb7nc5oh80XLdSz05sNfhoxcJ04ytGx2Mes6wCu29Zniua+9aaLo6qax9LVHX cHwmK31tM5vScmlKFefSdehja3sE9aNS89y/q57EtO7vAk+Dm6yn3nH1zGKDNPtA hvCn0r7zehqL0Sb/Ujba3D1RCgnbGnLpGbqmhkd4oSbJerfvqg6EekWCMAHlXIAv Z4mCfht0hKDQpuOF3OQbSq7ojx6ktK2Ix8hlTDg8+E7azceFF9+q/S37E6U5rA1Y zHk26eQwywilUy1vHKC4w81kif5cYthZbUtOPsQmBPjqINYt1/0RV+QtJ90+C5NT tOOMipFOXcTEWAORxu4BJzxfLbYbpT6XC1Ld7VoBybL8puOS0UD0Xi7cdX9RoXXx Who/HvUXWbCJUOoL56mTzr7Sa+wpMI3/t2YndiFCTg+ximAE8vdmqd98qPgh+7r6 RJAvfhKQf/akQIymMfVeIIrdhKkDG5TdlVQ8WUTpap6ur56cfh7NTYFFWizRttzy 0d4Pc5ppFIlBMBBb5FMReOIBlUexmyM61LmiqeXeX1br1O6Qzf0= =kX6v -----END PGP SIGNATURE----- commit ea31abc261ffc01b6ff5671bffb15cf910a07f4b Author: Glen Barber AuthorDate: 2021-04-09 00:14:30 +0000 Commit: Glen Barber CommitDate: 2021-04-09 00:14:30 +0000 13.0: update to RELEASE Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") From owner-dev-commits-src-branches@freebsd.org Fri Apr 9 23:37:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 62A9B5C331A; Fri, 9 Apr 2021 23:37:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHF0K2HzXz4mfw; Fri, 9 Apr 2021 23:37:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 410BA26F88; Fri, 9 Apr 2021 23:37:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 139Nb5Ju098116; Fri, 9 Apr 2021 23:37:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 139Nb5Ik098115; Fri, 9 Apr 2021 23:37:05 GMT (envelope-from git) Date: Fri, 9 Apr 2021 23:37:05 GMT Message-Id: <202104092337.139Nb5Ik098115@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Peter Jeremy Subject: git: 292bcaa4ba28 - stable/13 - arm64: Add support for the RK805/RK808 RTC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: peterj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 292bcaa4ba2843da2757368094241c50c7cc0474 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2021 23:37:05 -0000 The branch stable/13 has been updated by peterj: URL: https://cgit.FreeBSD.org/src/commit/?id=292bcaa4ba2843da2757368094241c50c7cc0474 commit 292bcaa4ba2843da2757368094241c50c7cc0474 Author: Peter Jeremy AuthorDate: 2021-03-12 22:06:04 +0000 Commit: Peter Jeremy CommitDate: 2021-04-09 23:34:03 +0000 arm64: Add support for the RK805/RK808 RTC MFC 07564e1762010ba7e8ef5a7574bf9ceee811e95c Implement a driver for the RTC embedded in the RK805/RK808 power management system used for RK3328 and RK3399 SoCs. Based on experiments on my RK808, setting the time doesn't alter the internal/inaccessible sub-second counter, therefore there's no point in calling clock_schedule(). Based on an earlier revision by andrew. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D22692 Sponsored by: Google MFC after: 1 week (cherry picked from commit 07564e1762010ba7e8ef5a7574bf9ceee811e95c) --- sys/arm64/rockchip/rk805.c | 123 ++++++++++++++++++++++++++++++++++++++++-- sys/arm64/rockchip/rk805reg.h | 25 +++++++++ 2 files changed, 144 insertions(+), 4 deletions(-) diff --git a/sys/arm64/rockchip/rk805.c b/sys/arm64/rockchip/rk805.c index 19397627a8b0..d3e04081aeb2 100644 --- a/sys/arm64/rockchip/rk805.c +++ b/sys/arm64/rockchip/rk805.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -46,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include +#include "clock_if.h" #include "regdev_if.h" MALLOC_DEFINE(M_RK805_REG, "RK805 regulator", "RK805 power regulator"); @@ -356,10 +358,10 @@ rk805_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) } static int -rk805_write(device_t dev, uint8_t reg, uint8_t data) +rk805_write(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) { - return (iicdev_writeto(dev, reg, &data, 1, IIC_INTRWAIT)); + return (iicdev_writeto(dev, reg, data, size, IIC_INTRWAIT)); } static int @@ -415,7 +417,7 @@ rk805_regnode_enable(struct regnode *regnode, bool enable, int *udelay) val |= sc->def->enable_mask; else val &= ~sc->def->enable_mask; - rk805_write(sc->base_dev, sc->def->enable_reg, val); + rk805_write(sc->base_dev, sc->def->enable_reg, &val, 1); *udelay = 0; @@ -491,7 +493,7 @@ rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt, if (rk805_regnode_voltage_to_reg(sc, min_uvolt, max_uvolt, &val) != 0) return (ERANGE); - rk805_write(sc->base_dev, sc->def->voltage_reg, val); + rk805_write(sc->base_dev, sc->def->voltage_reg, &val, 1); rk805_read(sc->base_dev, sc->def->voltage_reg, &val, 1); @@ -624,9 +626,117 @@ rk805_start(void *pdev) device_printf(dev, "Chip Version: %x\n", data[1] & 0xf); } + /* Register this as a 1Hz clock */ + clock_register(dev, 1000000); + config_intrhook_disestablish(&sc->intr_hook); } +static int +rk805_gettime(device_t dev, struct timespec *ts) +{ + struct bcd_clocktime bct; + uint8_t data[7]; + uint8_t ctrl; + int error; + + /* Latch the RTC value into the shadow registers and set 24hr mode */ + error = rk805_read(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + + ctrl |= RK805_RTC_READSEL; + ctrl &= ~(RK805_RTC_AMPM_MODE | RK805_RTC_GET_TIME); + error = rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + ctrl |= RK805_RTC_GET_TIME; + error = rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + ctrl &= ~RK805_RTC_GET_TIME; + error = rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + + /* This works as long as RK805_RTC_SECS = 0 */ + error = rk805_read(dev, RK805_RTC_SECS, data, 7); + if (error != 0) + return (error); + + /* + * If the reported year is earlier than 2019, assume the clock is unset. + * This is both later than the reset value for the RK805 and RK808 as + * well as being prior to the current time. + */ + if (data[RK805_RTC_YEARS] < 0x19) + return (EINVAL); + + memset(&bct, 0, sizeof(bct)); + bct.year = data[RK805_RTC_YEARS]; + bct.mon = data[RK805_RTC_MONTHS] & RK805_RTC_MONTHS_MASK; + bct.day = data[RK805_RTC_DAYS] & RK805_RTC_DAYS_MASK; + bct.hour = data[RK805_RTC_HOURS] & RK805_RTC_HOURS_MASK; + bct.min = data[RK805_RTC_MINUTES] & RK805_RTC_MINUTES_MASK; + bct.sec = data[RK805_RTC_SECS] & RK805_RTC_SECS_MASK; + bct.dow = data[RK805_RTC_WEEKS] & RK805_RTC_WEEKS_MASK; + /* The day of week is reported as 1-7 with 1 = Monday */ + if (bct.dow == 7) + bct.dow = 0; + bct.ispm = 0; + + if (bootverbose) + device_printf(dev, "Read RTC: %02x-%02x-%02x %02x:%02x:%02x\n", + bct.year, bct.mon, bct.day, bct.hour, bct.min, bct.sec); + + return (clock_bcd_to_ts(&bct, ts, false)); +} + +static int +rk805_settime(device_t dev, struct timespec *ts) +{ + struct bcd_clocktime bct; + uint8_t data[7]; + int error; + uint8_t ctrl; + + clock_ts_to_bcd(ts, &bct, false); + + /* This works as long as RK805_RTC_SECS = 0 */ + data[RK805_RTC_YEARS] = bct.year; + data[RK805_RTC_MONTHS] = bct.mon; + data[RK805_RTC_DAYS] = bct.day; + data[RK805_RTC_HOURS] = bct.hour; + data[RK805_RTC_MINUTES] = bct.min; + data[RK805_RTC_SECS] = bct.sec; + data[RK805_RTC_WEEKS] = bct.dow; + /* The day of week is reported as 1-7 with 1 = Monday */ + if (data[RK805_RTC_WEEKS] == 0) + data[RK805_RTC_WEEKS] = 7; + + error = rk805_read(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + + ctrl |= RK805_RTC_CTRL_STOP; + ctrl &= ~RK805_RTC_AMPM_MODE; + error = rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); + if (error != 0) + return (error); + + error = rk805_write(dev, RK805_RTC_SECS, data, 7); + ctrl &= ~RK805_RTC_CTRL_STOP; + rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); + + if (bootverbose) + device_printf(dev, + "Set RTC at %04x-%02x-%02x %02x:%02x:%02x[.%09ld]\n", + bct.year, bct.mon, bct.day, bct.hour, bct.min, bct.sec, + bct.nsec); + + return (error); +} + static int rk805_attach(device_t dev) { @@ -724,6 +834,11 @@ static device_method_t rk805_methods[] = { /* regdev interface */ DEVMETHOD(regdev_map, rk805_map), + + /* Clock interface */ + DEVMETHOD(clock_gettime, rk805_gettime), + DEVMETHOD(clock_settime, rk805_settime), + DEVMETHOD_END }; diff --git a/sys/arm64/rockchip/rk805reg.h b/sys/arm64/rockchip/rk805reg.h index db489d77c26e..b1f4481a5b68 100644 --- a/sys/arm64/rockchip/rk805reg.h +++ b/sys/arm64/rockchip/rk805reg.h @@ -30,6 +30,31 @@ #ifndef _RK805REG_H_ #define _RK805REG_H_ +/* + * The RTC registers are the same in both RK805 and RK808. + * Note that the code assumes that RK805_RTC_SECS is 0 + */ +#define RK805_RTC_SECS 0x00 +#define RK805_RTC_SECS_MASK 0x7f +#define RK805_RTC_MINUTES 0x01 +#define RK805_RTC_MINUTES_MASK 0x7f +#define RK805_RTC_HOURS 0x02 +#define RK805_RTC_HOURS_MASK 0x3f +#define RK805_RTC_HOURS_PM 0x80 +#define RK805_RTC_DAYS 0x03 +#define RK805_RTC_DAYS_MASK 0x3f +#define RK805_RTC_MONTHS 0x04 +#define RK805_RTC_MONTHS_MASK 0x1f +#define RK805_RTC_YEARS 0x05 +#define RK805_RTC_WEEKS 0x06 /* day of week */ +#define RK805_RTC_WEEKS_MASK 0x07 + +#define RK805_RTC_CTRL 0x10 +#define RK805_RTC_CTRL_STOP (1 << 0) +#define RK805_RTC_AMPM_MODE (1 << 3) +#define RK805_RTC_GET_TIME (1 << 6) +#define RK805_RTC_READSEL (1 << 7) + #define RK805_CHIP_NAME 0x17 #define RK805_CHIP_VER 0x18 #define RK805_OTP_VER 0x19 From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 01:26:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 8C9695C6930; Sat, 10 Apr 2021 01:26:38 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHHQk3fMbz4rwJ; Sat, 10 Apr 2021 01:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7030246C; Sat, 10 Apr 2021 01:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A1QcSk043619; Sat, 10 Apr 2021 01:26:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A1QcuF043618; Sat, 10 Apr 2021 01:26:38 GMT (envelope-from git) Date: Sat, 10 Apr 2021 01:26:38 GMT Message-Id: <202104100126.13A1QcuF043618@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 484cec486ddc - stable/13 - ffsinfo: Update example to avoid to-be-deprecated vinum MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 484cec486ddcde8c4c009f786f57e3609c1c25db Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 01:26:38 -0000 The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=484cec486ddcde8c4c009f786f57e3609c1c25db commit 484cec486ddcde8c4c009f786f57e3609c1c25db Author: Ed Maste AuthorDate: 2021-03-29 00:04:29 +0000 Commit: Ed Maste CommitDate: 2021-04-10 01:26:23 +0000 ffsinfo: Update example to avoid to-be-deprecated vinum Reviewed by: mckusick Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29478 (cherry picked from commit a64096aa63ea1303ae8d20d4147b3b097071072f) --- sbin/ffsinfo/ffsinfo.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/ffsinfo/ffsinfo.8 b/sbin/ffsinfo/ffsinfo.8 index 4bf5cdd1cb18..90580f5767d5 100644 --- a/sbin/ffsinfo/ffsinfo.8 +++ b/sbin/ffsinfo/ffsinfo.8 @@ -113,10 +113,10 @@ If is provided, output will be sent to stdout. .El .Sh EXAMPLES -.Dl ffsinfo -o /var/tmp/ffsinfo -l 1023 /dev/vinum/testvol +.Dl ffsinfo -o /var/tmp/ffsinfo -l 1023 /dev/md0 .Pp will dump -.Pa /dev/vinum/testvol +.Pa /dev/md0 to .Pa /var/tmp/ffsinfo with all available information. From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 01:27:22 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 BAEBD5C6842; Sat, 10 Apr 2021 01:27:22 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHHRZ4xQhz4s02; Sat, 10 Apr 2021 01:27:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C61D3BF; Sat, 10 Apr 2021 01:27:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A1RMk4043779; Sat, 10 Apr 2021 01:27:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A1RM3c043778; Sat, 10 Apr 2021 01:27:22 GMT (envelope-from git) Date: Sat, 10 Apr 2021 01:27:22 GMT Message-Id: <202104100127.13A1RM3c043778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 3c00d2008f01 - stable/12 - ffsinfo: Update example to avoid to-be-deprecated vinum MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 3c00d2008f01ad15d6b1a2e93041030f46e65bcd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 01:27:22 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3c00d2008f01ad15d6b1a2e93041030f46e65bcd commit 3c00d2008f01ad15d6b1a2e93041030f46e65bcd Author: Ed Maste AuthorDate: 2021-03-29 00:04:29 +0000 Commit: Ed Maste CommitDate: 2021-04-10 01:27:13 +0000 ffsinfo: Update example to avoid to-be-deprecated vinum Reviewed by: mckusick Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29478 (cherry picked from commit a64096aa63ea1303ae8d20d4147b3b097071072f) --- sbin/ffsinfo/ffsinfo.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/ffsinfo/ffsinfo.8 b/sbin/ffsinfo/ffsinfo.8 index 4bf5cdd1cb18..90580f5767d5 100644 --- a/sbin/ffsinfo/ffsinfo.8 +++ b/sbin/ffsinfo/ffsinfo.8 @@ -113,10 +113,10 @@ If is provided, output will be sent to stdout. .El .Sh EXAMPLES -.Dl ffsinfo -o /var/tmp/ffsinfo -l 1023 /dev/vinum/testvol +.Dl ffsinfo -o /var/tmp/ffsinfo -l 1023 /dev/md0 .Pp will dump -.Pa /dev/vinum/testvol +.Pa /dev/md0 to .Pa /var/tmp/ffsinfo with all available information. From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:01:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C4AED5CF99C; Sat, 10 Apr 2021 06:01:59 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXR59wYz4RFK; Sat, 10 Apr 2021 06:01:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A269440A0; Sat, 10 Apr 2021 06:01:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A61xhA015073; Sat, 10 Apr 2021 06:01:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A61xb0015072; Sat, 10 Apr 2021 06:01:59 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:01:59 GMT Message-Id: <202104100601.13A61xb0015072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e201fa7c98db - stable/13 - cache: comment on FNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e201fa7c98db30b6a3c7c66387df68161b71c1ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:01:59 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e201fa7c98db30b6a3c7c66387df68161b71c1ef commit e201fa7c98db30b6a3c7c66387df68161b71c1ef Author: Mateusz Guzik AuthorDate: 2021-02-03 20:44:54 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:54 +0000 cache: comment on FNV (cherry picked from commit b54ed778fe45d482bd1e2009df802fda26f94495) --- sys/kern/vfs_cache.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index db482ea4eba3..47abe0feb152 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -704,9 +704,31 @@ out: SDT_PROBE1(vfs, namecache, purge, batch, i); } +/* + * Hashing. + * + * The code was made to use FNV in 2001 and this choice needs to be revisited. + * + * Short summary of the difficulty: + * The longest name which can be inserted is NAME_MAX characters in length (or + * 255 at the time of writing this comment), while majority of names used in + * practice are significantly shorter (mostly below 10). More importantly + * majority of lookups performed find names are even shorter than that. + * + * This poses a problem where hashes which do better than FNV past word size + * (or so) tend to come with additional overhead when finalizing the result, + * making them noticeably slower for the most commonly used range. + * + * Consider a path like: /usr/obj/usr/src/sys/amd64/GENERIC/vnode_if.c + * + * When looking it up the most time consuming part by a large margin (at least + * on amd64) is hashing. Replacing FNV with something which pessimizes short + * input would make the slowest part stand out even more. + */ + /* * TODO: With the value stored we can do better than computing the hash based - * on the address. The choice of FNV should also be revisited. + * on the address. */ static void cache_prehash(struct vnode *vp) From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 78EE65CF7F1; Sat, 10 Apr 2021 06:02:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXY2sJZz4R4c; Sat, 10 Apr 2021 06:02:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 492F8422A; Sat, 10 Apr 2021 06:02:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A625Zv015184; Sat, 10 Apr 2021 06:02:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A625Cj015183; Sat, 10 Apr 2021 06:02:05 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:05 GMT Message-Id: <202104100602.13A625Cj015183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: c3437848d868 - stable/13 - devfs: fix use count leak when using TIOCSCTTY MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c3437848d8683f6ad03a15bde201c4ead541378e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:05 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c3437848d8683f6ad03a15bde201c4ead541378e commit c3437848d8683f6ad03a15bde201c4ead541378e Author: Mateusz Guzik AuthorDate: 2021-02-08 22:10:57 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 devfs: fix use count leak when using TIOCSCTTY by matching devfs_ctty_ref Fixes: 3b44443626603f65 ("devfs: rework si_usecount to track opens") (cherry picked from commit 3bc17248d31794519ba95b2c6b9ff8a0d31dba81) --- sys/fs/devfs/devfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 983bfc803999..043cee74fde2 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -974,7 +974,7 @@ devfs_ioctl(struct vop_ioctl_args *ap) /* Get rid of reference to old control tty */ if (vpold) - vrele(vpold); + devfs_ctty_unref(vpold); } return (error); } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 28EA55CFB31; Sat, 10 Apr 2021 06:02:10 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXd6P0Nz4RLW; Sat, 10 Apr 2021 06:02:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC06840A2; Sat, 10 Apr 2021 06:02:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A629VO015268; Sat, 10 Apr 2021 06:02:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A629qt015267; Sat, 10 Apr 2021 06:02:09 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:09 GMT Message-Id: <202104100602.13A629qt015267@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 8ef8057ed5f1 - stable/13 - vfs: add vfs_smr_quiesce MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8ef8057ed5f16dde7a243e2cc557bc6cd4dfcdf9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:10 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8ef8057ed5f16dde7a243e2cc557bc6cd4dfcdf9 commit 8ef8057ed5f16dde7a243e2cc557bc6cd4dfcdf9 Author: Mateusz Guzik AuthorDate: 2021-03-30 14:44:10 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 vfs: add vfs_smr_quiesce This can be used to observe all CPUs not executing while within vfs_smr_enter. (cherry picked from commit 3f56bc79860ec20f0e53de42dab1c117ee68e37b) --- sys/sys/vnode.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index bb07cd80e42e..e37302aeb379 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1109,6 +1109,7 @@ int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp); #define VFS_SMR() vfs_smr #define vfs_smr_enter() smr_enter(VFS_SMR()) #define vfs_smr_exit() smr_exit(VFS_SMR()) +#define vfs_smr_quiesce() quiesce_all_critical() #define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR()) #define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR()) #define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR()) From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:02 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 56B585CF877; Sat, 10 Apr 2021 06:02:02 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXT6qzdz4R99; Sat, 10 Apr 2021 06:02:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DA5914130; Sat, 10 Apr 2021 06:02:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A621xE015115; Sat, 10 Apr 2021 06:02:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A621kH015114; Sat, 10 Apr 2021 06:02:01 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:01 GMT Message-Id: <202104100602.13A621kH015114@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 565872e3ed7c - stable/13 - cache: fix vfs:namecache:lookup:miss probe call sites MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 565872e3ed7c13a7412a055f9a6fab4453d2f460 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:02 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=565872e3ed7c13a7412a055f9a6fab4453d2f460 commit 565872e3ed7c13a7412a055f9a6fab4453d2f460 Author: Mateusz Guzik AuthorDate: 2021-02-05 22:58:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 cache: fix vfs:namecache:lookup:miss probe call sites (cherry picked from commit 0e1594e60e5e0b1fddc33225171f1d1c6a421ed4) --- sys/kern/vfs_cache.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 5cfc23779c42..50ec6face6ac 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1767,7 +1767,7 @@ retry: mtx_lock(dvlp); ncp = dvp->v_cache_dd; if (ncp == NULL) { - SDT_PROBE3(vfs, namecache, lookup, miss, dvp, "..", NULL); + SDT_PROBE2(vfs, namecache, lookup, miss, dvp, ".."); mtx_unlock(dvlp); return (0); } @@ -1894,8 +1894,7 @@ retry: if (__predict_false(ncp == NULL)) { mtx_unlock(blp); - SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr, - NULL); + SDT_PROBE2(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr); counter_u64_add(nummiss, 1); return (0); } @@ -1990,8 +1989,7 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, if (__predict_false(ncp == NULL)) { vfs_smr_exit(); - SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr, - NULL); + SDT_PROBE2(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr); counter_u64_add(nummiss, 1); return (0); } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:03 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 5E6D05CF65A; Sat, 10 Apr 2021 06:02:03 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXW1TNTz4RFR; Sat, 10 Apr 2021 06:02:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 137003A8B; Sat, 10 Apr 2021 06:02:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A62222015136; Sat, 10 Apr 2021 06:02:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A622HI015135; Sat, 10 Apr 2021 06:02:02 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:02 GMT Message-Id: <202104100602.13A622HI015135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 378d492b2ed4 - stable/13 - cache: remove the largely obsolete general description MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 378d492b2ed420d09344fb32f52ea75b1e35ac1e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:03 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=378d492b2ed420d09344fb32f52ea75b1e35ac1e commit 378d492b2ed420d09344fb32f52ea75b1e35ac1e Author: Mateusz Guzik AuthorDate: 2021-02-05 23:16:55 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 cache: remove the largely obsolete general description Examples of inconsistencies with the current state: - references LRU of all entries, removed years ago - references a non-existent lock (neglist) - claims negative entries have a NULL target It will be replaced with a more accurate and more informative description. In the meantime take it out so it stops misleading. (cherry picked from commit 2f8a844635312b0f25028a87459fdd2d2a1cbfd6) --- sys/kern/vfs_cache.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 50ec6face6ac..21eb436681fc 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -276,52 +276,6 @@ cache_ncp_invalidate(struct namecache *ncp) __predict_true((_nc_flag & (NCF_INVALID | NCF_WIP | NCF_WHITE)) == 0); \ }) -/* - * Name caching works as follows: - * - * Names found by directory scans are retained in a cache - * for future reference. It is managed LRU, so frequently - * used names will hang around. Cache is indexed by hash value - * obtained from (dvp, name) where dvp refers to the directory - * containing name. - * - * If it is a "negative" entry, (i.e. for a name that is known NOT to - * exist) the vnode pointer will be NULL. - * - * Upon reaching the last segment of a path, if the reference - * is for DELETE, or NOCACHE is set (rewrite), and the - * name is located in the cache, it will be dropped. - * - * These locks are used (in the order in which they can be taken): - * NAME TYPE ROLE - * vnodelock mtx vnode lists and v_cache_dd field protection - * bucketlock mtx for access to given set of hash buckets - * neglist mtx negative entry LRU management - * - * It is legal to take multiple vnodelock and bucketlock locks. The locking - * order is lower address first. Both are recursive. - * - * "." lookups are lockless. - * - * ".." and vnode -> name lookups require vnodelock. - * - * name -> vnode lookup requires the relevant bucketlock to be held for reading. - * - * Insertions and removals of entries require involved vnodes and bucketlocks - * to be locked to provide safe operation against other threads modifying the - * cache. - * - * Some lookups result in removal of the found entry (e.g. getting rid of a - * negative entry with the intent to create a positive one), which poses a - * problem when multiple threads reach the state. Similarly, two different - * threads can purge two different vnodes and try to remove the same name. - * - * If the already held vnode lock is lower than the second required lock, we - * can just take the other lock. However, in the opposite case, this could - * deadlock. As such, this is resolved by trylocking and if that fails unlocking - * the first node, locking everything in order and revalidating the state. - */ - VFS_SMR_DECLARE; static SYSCTL_NODE(_vfs_cache, OID_AUTO, param, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 013AC5CFAAE; Sat, 10 Apr 2021 06:02:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXh4wBgz4RCn; Sat, 10 Apr 2021 06:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2585E3FA0; Sat, 10 Apr 2021 06:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A62CB4015311; Sat, 10 Apr 2021 06:02:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A62Cjv015310; Sat, 10 Apr 2021 06:02:12 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:12 GMT Message-Id: <202104100602.13A62Cjv015310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: d8aa5ff4f606 - stable/13 - cache: add high level overview MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d8aa5ff4f606788fdbbfd032ebbe2966c1fb4399 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:13 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d8aa5ff4f606788fdbbfd032ebbe2966c1fb4399 commit d8aa5ff4f606788fdbbfd032ebbe2966c1fb4399 Author: Mateusz Guzik AuthorDate: 2021-02-11 15:39:28 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:56 +0000 cache: add high level overview Differential Revision: https://reviews.freebsd.org/D28675 (cherry picked from commit f79bd71def7a03b3a1b043cae7b908b36a05f41c) --- sys/kern/vfs_cache.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index ad91fb1686a4..a3af949597af 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -82,6 +82,131 @@ __FBSDID("$FreeBSD$"); #include +/* + * High level overview of name caching in the VFS layer. + * + * Originally caching was implemented as part of UFS, later extracted to allow + * use by other filesystems. A decision was made to make it optional and + * completely detached from the rest of the kernel, which comes with limitations + * outlined near the end of this comment block. + * + * This fundamental choice needs to be revisited. In the meantime, the current + * state is described below. Significance of all notable routines is explained + * in comments placed above their implementation. Scattered thoroughout the + * file are TODO comments indicating shortcomings which can be fixed without + * reworking everything (most of the fixes will likely be reusable). Various + * details are omitted from this explanation to not clutter the overview, they + * have to be checked by reading the code and associated commentary. + * + * Keep in mind that it's individual path components which are cached, not full + * paths. That is, for a fully cached path "foo/bar/baz" there are 3 entries, + * one for each name. + * + * I. Data organization + * + * Entries are described by "struct namecache" objects and stored in a hash + * table. See cache_get_hash for more information. + * + * "struct vnode" contains pointers to source entries (names which can be found + * when traversing through said vnode), destination entries (names of that + * vnode (see "Limitations" for a breakdown on the subject) and a pointer to + * the parent vnode. + * + * The (directory vnode; name) tuple reliably determines the target entry if + * it exists. + * + * Since there are no small locks at this time (all are 32 bytes in size on + * LP64), the code works around the problem by introducing lock arrays to + * protect hash buckets and vnode lists. + * + * II. Filesystem integration + * + * Filesystems participating in name caching do the following: + * - set vop_lookup routine to vfs_cache_lookup + * - set vop_cachedlookup to whatever can perform the lookup if the above fails + * - if they support lockless lookup (see below), vop_fplookup_vexec and + * vop_fplookup_symlink are set along with the MNTK_FPLOOKUP flag on the + * mount point + * - call cache_purge or cache_vop_* routines to eliminate stale entries as + * applicable + * - call cache_enter to add entries depending on the MAKEENTRY flag + * + * With the above in mind, there are 2 entry points when doing lookups: + * - ... -> namei -> cache_fplookup -- this is the default + * - ... -> VOP_LOOKUP -> vfs_cache_lookup -- normally only called by namei + * should the above fail + * + * Example code flow how an entry is added: + * ... -> namei -> cache_fplookup -> cache_fplookup_noentry -> VOP_LOOKUP -> + * vfs_cache_lookup -> VOP_CACHEDLOOKUP -> ufs_lookup_ino -> cache_enter + * + * III. Performance considerations + * + * For lockless case forward lookup avoids any writes to shared areas apart + * from the terminal path component. In other words non-modifying lookups of + * different files don't suffer any scalability problems in the namecache. + * Looking up the same file is limited by VFS and goes beyond the scope of this + * file. + * + * At least on amd64 the single-threaded bottleneck for long paths is hashing + * (see cache_get_hash). There are cases where the code issues acquire fence + * multiple times, they can be combined on architectures which suffer from it. + * + * For locked case each encountered vnode has to be referenced and locked in + * order to be handed out to the caller (normally that's namei). This + * introduces significant hit single-threaded and serialization multi-threaded. + * + * Reverse lookup (e.g., "getcwd") fully scales provided it is fully cached -- + * avoids any writes to shared areas to any components. + * + * Unrelated insertions are partially serialized on updating the global entry + * counter and possibly serialized on colliding bucket or vnode locks. + * + * IV. Observability + * + * Note not everything has an explicit dtrace probe nor it should have, thus + * some of the one-liners below depend on implementation details. + * + * Examples: + * + * # Check what lookups failed to be handled in a lockless manner. Column 1 is + * # line number, column 2 is status code (see cache_fpl_status) + * dtrace -n 'vfs:fplookup:lookup:done { @[arg1, arg2] = count(); }' + * + * # Lengths of names added by binary name + * dtrace -n 'fbt::cache_enter_time:entry { @[execname] = quantize(args[2]->cn_namelen); }' + * + * # Same as above but only those which exceed 64 characters + * dtrace -n 'fbt::cache_enter_time:entry /args[2]->cn_namelen > 64/ { @[execname] = quantize(args[2]->cn_namelen); }' + * + * # Who is performing lookups with spurious slashes (e.g., "foo//bar") and what + * # path is it + * dtrace -n 'fbt::cache_fplookup_skip_slashes:entry { @[execname, stringof(args[0]->cnp->cn_pnbuf)] = count(); }' + * + * V. Limitations and implementation defects + * + * - since it is possible there is no entry for an open file, tools like + * "procstat" may fail to resolve fd -> vnode -> path to anything + * - even if a filesystem adds an entry, it may get purged (e.g., due to memory + * shortage) in which case the above problem applies + * - hardlinks are not tracked, thus if a vnode is reachable in more than one + * way, resolving a name may return a different path than the one used to + * open it (even if said path is still valid) + * - by default entries are not added for newly created files + * - adding an entry may need to evict negative entry first, which happens in 2 + * distinct places (evicting on lookup, adding in a later VOP) making it + * impossible to simply reuse it + * - there is a simple scheme to evict negative entries as the cache is approaching + * its capacity, but it is very unclear if doing so is a good idea to begin with + * - vnodes are subject to being recycled even if target inode is left in memory, + * which loses the name cache entries when it perhaps should not. in case of tmpfs + * names get duplicated -- kept by filesystem itself and namecache separately + * - struct namecache has a fixed size and comes in 2 variants, often wasting space. + * now hard to replace with malloc due to dependence on SMR. + * - lack of better integration with the kernel also turns nullfs into a layered + * filesystem instead of something which can take advantage of caching + */ + static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Name cache"); From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0793E5CFB26; Sat, 10 Apr 2021 06:02:09 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXc5jmDz4R9k; Sat, 10 Apr 2021 06:02:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A82BB422F; Sat, 10 Apr 2021 06:02:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A628bW015247; Sat, 10 Apr 2021 06:02:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A6289I015246; Sat, 10 Apr 2021 06:02:08 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:08 GMT Message-Id: <202104100602.13A6289I015246@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 4606d441703d - stable/13 - vfs: employ vfs_ref_from_vp in statfs and fstatfs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4606d441703d695ab74d6e66fadc18703615e4dc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:09 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=4606d441703d695ab74d6e66fadc18703615e4dc commit 4606d441703d695ab74d6e66fadc18703615e4dc Author: Mateusz Guzik AuthorDate: 2021-02-15 22:08:20 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 vfs: employ vfs_ref_from_vp in statfs and fstatfs Avoids locking and unlocking the vnode. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D28695 (cherry picked from commit 81174cd8e24aa2bb27f6a8b41032abf59add479f) --- sys/kern/vfs_syscalls.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 40dd8c069bfb..3db34c3689de 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -331,15 +331,13 @@ kern_statfs(struct thread *td, const char *path, enum uio_seg pathseg, struct nameidata nd; int error; - NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, - pathseg, path, td); + NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, td); error = namei(&nd); if (error != 0) return (error); - mp = nd.ni_vp->v_mount; - vfs_ref(mp); + mp = vfs_ref_from_vp(nd.ni_vp); NDFREE_NOTHING(&nd); - vput(nd.ni_vp); + vrele(nd.ni_vp); return (kern_do_statfs(td, mp, buf)); } @@ -379,14 +377,14 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) if (error != 0) return (error); vp = fp->f_vnode; - vn_lock(vp, LK_SHARED | LK_RETRY); #ifdef AUDIT - AUDIT_ARG_VNODE1(vp); + if (AUDITING_TD(td)) { + vn_lock(vp, LK_SHARED | LK_RETRY); + AUDIT_ARG_VNODE1(vp); + VOP_UNLOCK(vp); + } #endif - mp = vp->v_mount; - if (mp != NULL) - vfs_ref(mp); - VOP_UNLOCK(vp); + mp = vfs_ref_from_vp(vp); fdrop(fp, td); return (kern_do_statfs(td, mp, buf)); } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 752045CFA2B; Sat, 10 Apr 2021 06:02:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXj2VHCz4RCs; Sat, 10 Apr 2021 06:02:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 474813C38; Sat, 10 Apr 2021 06:02:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A62DsK015332; Sat, 10 Apr 2021 06:02:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A62DiO015331; Sat, 10 Apr 2021 06:02:13 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:13 GMT Message-Id: <202104100602.13A62DiO015331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: f1727a66974f - stable/13 - cache: update an assert on CACHE_FPL_STATUS_ABORTED MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f1727a66974f07c44ab7f2770a7320c7d5a3800f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:13 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f1727a66974f07c44ab7f2770a7320c7d5a3800f commit f1727a66974f07c44ab7f2770a7320c7d5a3800f Author: Mateusz Guzik AuthorDate: 2021-04-06 20:31:48 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:56 +0000 cache: update an assert on CACHE_FPL_STATUS_ABORTED Since symlink support it can get upgraded to CACHE_FPL_STATUS_DESTROYED. Reported by: bdrewery (cherry picked from commit 13b3862ee874db0b5efae484934de9b20da864e4) --- sys/kern/vfs_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index a3af949597af..ddeb87e269d7 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -4655,7 +4655,8 @@ cache_fplookup_final_withparent(struct cache_fpl *fpl) error = cache_fplookup_final_child(fpl, tvs); if (__predict_false(error != 0)) { - MPASS(fpl->status == CACHE_FPL_STATUS_ABORTED); + MPASS(fpl->status == CACHE_FPL_STATUS_ABORTED || + fpl->status == CACHE_FPL_STATUS_DESTROYED); if ((cnp->cn_flags & LOCKPARENT) != 0) vput(dvp); else From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 2C2135CF669; Sat, 10 Apr 2021 06:02:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXg0g0Sz4RJ3; Sat, 10 Apr 2021 06:02:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0368B3F67; Sat, 10 Apr 2021 06:02:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A62AfB015290; Sat, 10 Apr 2021 06:02:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A62AB5015289; Sat, 10 Apr 2021 06:02:10 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:10 GMT Message-Id: <202104100602.13A62AB5015289@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 5dd2f40ab47c - stable/13 - cache: fix resizing in face of lockless lookup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5dd2f40ab47c02906a0fd86af45794b0e3869483 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:11 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=5dd2f40ab47c02906a0fd86af45794b0e3869483 commit 5dd2f40ab47c02906a0fd86af45794b0e3869483 Author: Mateusz Guzik AuthorDate: 2021-03-29 19:17:57 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:56 +0000 cache: fix resizing in face of lockless lookup Reported by: pho Tested by: pho (cherry picked from commit dc532884d582db6da833d598e4bb37ad1880947c) --- sys/kern/vfs_cache.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index fef1e31d197b..ad91fb1686a4 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -455,6 +455,9 @@ static long cache_lock_vnodes_cel_3_failures; DEBUGNODE_ULONG(vnodes_cel_3_failures, cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); +static void cache_fplookup_lockout(void); +static void cache_fplookup_restore(void); + static void cache_zap_locked(struct namecache *ncp); static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, size_t *buflen); @@ -2544,11 +2547,76 @@ cache_vnode_init(struct vnode *vp) cache_prehash(vp); } +/* + * Induce transient cache misses for lockless operation in cache_lookup() by + * using a temporary hash table. + * + * This will force a fs lookup. + * + * Synchronisation is done in 2 steps, calling vfs_smr_quiesce each time + * to observe all CPUs not performing the lookup. + */ +static void +cache_changesize_set_temp(struct nchashhead *temptbl, u_long temphash) +{ + + MPASS(temphash < nchash); + /* + * Change the size. The new size is smaller and can safely be used + * against the existing table. All lookups which now hash wrong will + * result in a cache miss, which all callers are supposed to know how + * to handle. + */ + atomic_store_long(&nchash, temphash); + atomic_thread_fence_rel(); + vfs_smr_quiesce(); + /* + * At this point everyone sees the updated hash value, but they still + * see the old table. + */ + atomic_store_ptr(&nchashtbl, temptbl); + atomic_thread_fence_rel(); + vfs_smr_quiesce(); + /* + * At this point everyone sees the updated table pointer and size pair. + */ +} + +/* + * Set the new hash table. + * + * Similarly to cache_changesize_set_temp(), this has to synchronize against + * lockless operation in cache_lookup(). + */ +static void +cache_changesize_set_new(struct nchashhead *new_tbl, u_long new_hash) +{ + + MPASS(nchash < new_hash); + /* + * Change the pointer first. This wont result in out of bounds access + * since the temporary table is guaranteed to be smaller. + */ + atomic_store_ptr(&nchashtbl, new_tbl); + atomic_thread_fence_rel(); + vfs_smr_quiesce(); + /* + * At this point everyone sees the updated pointer value, but they + * still see the old size. + */ + atomic_store_long(&nchash, new_hash); + atomic_thread_fence_rel(); + vfs_smr_quiesce(); + /* + * At this point everyone sees the updated table pointer and size pair. + */ +} + void cache_changesize(u_long newmaxvnodes) { - struct nchashhead *new_nchashtbl, *old_nchashtbl; - u_long new_nchash, old_nchash; + struct nchashhead *new_nchashtbl, *old_nchashtbl, *temptbl; + u_long new_nchash, old_nchash, temphash; struct namecache *ncp; uint32_t hash; u_long newncsize; @@ -2565,30 +2633,36 @@ cache_changesize(u_long newmaxvnodes) ncfreetbl(new_nchashtbl); return; } + + temptbl = nchinittbl(1, &temphash); + /* * Move everything from the old hash table to the new table. * None of the namecache entries in the table can be removed * because to do so, they have to be removed from the hash table. */ + cache_fplookup_lockout(); cache_lock_all_vnodes(); cache_lock_all_buckets(); old_nchashtbl = nchashtbl; old_nchash = nchash; - nchashtbl = new_nchashtbl; - nchash = new_nchash; + cache_changesize_set_temp(temptbl, temphash); for (i = 0; i <= old_nchash; i++) { while ((ncp = CK_SLIST_FIRST(&old_nchashtbl[i])) != NULL) { hash = cache_get_hash(ncp->nc_name, ncp->nc_nlen, ncp->nc_dvp); CK_SLIST_REMOVE(&old_nchashtbl[i], ncp, namecache, nc_hash); - CK_SLIST_INSERT_HEAD(NCHHASH(hash), ncp, nc_hash); + CK_SLIST_INSERT_HEAD(&new_nchashtbl[hash & new_nchash], ncp, nc_hash); } } ncsize = newncsize; cache_recalc_neg_min(ncnegminpct); + cache_changesize_set_new(new_nchashtbl, new_nchash); cache_unlock_all_buckets(); cache_unlock_all_vnodes(); + cache_fplookup_restore(); ncfreetbl(old_nchashtbl); + ncfreetbl(temptbl); } /* @@ -3661,6 +3735,33 @@ syscal_vfs_cache_fast_lookup(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_vfs, OID_AUTO, cache_fast_lookup, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, &cache_fast_lookup, 0, syscal_vfs_cache_fast_lookup, "IU", ""); +/* + * Disable lockless lookup and observe all CPUs not executing it. + * + * Used when resizing the hash table. + * + * TODO: no provisions are made to handle tweaking of the knob at the same time + */ +static void +cache_fplookup_lockout(void) +{ + bool on; + + on = atomic_load_char(&cache_fast_lookup_enabled); + if (on) { + atomic_store_char(&cache_fast_lookup_enabled, false); + atomic_thread_fence_rel(); + vfs_smr_quiesce(); + } +} + +static void +cache_fplookup_restore(void) +{ + + cache_fast_lookup_enabled_recalc(); +} + /* * Components of nameidata (or objects it can point to) which may * need restoring in case fast path lookup fails. From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 DC27A5CF9A0; Sat, 10 Apr 2021 06:02:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXS5mT8z4R4R; Sat, 10 Apr 2021 06:02:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6E59412F; Sat, 10 Apr 2021 06:02:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A620bQ015094; Sat, 10 Apr 2021 06:02:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A620oC015093; Sat, 10 Apr 2021 06:02:00 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:00 GMT Message-Id: <202104100602.13A620oC015093@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 7815eb006223 - stable/13 - cache: drop spurious arg from panic in cache_validate MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7815eb006223c7020c1322c0fdf949fb18d28a07 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:01 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7815eb006223c7020c1322c0fdf949fb18d28a07 commit 7815eb006223c7020c1322c0fdf949fb18d28a07 Author: Mateusz Guzik AuthorDate: 2021-02-05 22:49:59 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:54 +0000 cache: drop spurious arg from panic in cache_validate vp is already reported when noting mismatch (cherry picked from commit 2e96132a7d8bbb2347a3b4776806324f984aa49f) --- sys/kern/vfs_cache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 47abe0feb152..5cfc23779c42 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2824,9 +2824,8 @@ cache_validate(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen && !bcmp(ncp->nc_name, cnp->cn_nameptr, ncp->nc_nlen)) { if (ncp->nc_vp != vp) - panic("%s: mismatch (%p != %p); ncp %p [%s] dvp %p vp %p\n", - __func__, vp, ncp->nc_vp, ncp, ncp->nc_name, ncp->nc_dvp, - ncp->nc_vp); + panic("%s: mismatch (%p != %p); ncp %p [%s] dvp %p\n", + __func__, vp, ncp->nc_vp, ncp, ncp->nc_name, ncp->nc_dvp); } } mtx_unlock(blp); From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6F3325CF9A8; Sat, 10 Apr 2021 06:02:04 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXX2085z4QnY; Sat, 10 Apr 2021 06:02:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BA4E4229; Sat, 10 Apr 2021 06:02:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A624kN015157; Sat, 10 Apr 2021 06:02:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A624N0015156; Sat, 10 Apr 2021 06:02:04 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:04 GMT Message-Id: <202104100602.13A624N0015156@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: ca718f503168 - stable/13 - libkern: use compiler builtins for strcpy, strcmp and strlen MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ca718f503168291d3f764e32f7642501c5283efd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:04 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ca718f503168291d3f764e32f7642501c5283efd commit ca718f503168291d3f764e32f7642501c5283efd Author: Mateusz Guzik AuthorDate: 2021-02-07 19:50:25 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 libkern: use compiler builtins for strcpy, strcmp and strlen (cherry picked from commit 81e074d57dfcd86f152e2848dc44b77087ee7a2d) --- sys/sys/libkern.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 3874ef9ec4bd..3f8827de06c5 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -199,6 +199,10 @@ size_t kcsan_strlen(const char *); #define strcpy(d, s) kcsan_strcpy((d), (s)) #define strcmp(s1, s2) kcsan_strcmp((s1), (s2)) #define strlen(s) kcsan_strlen((s)) +#else +#define strcpy(d, s) __builtin_strcpy((d), (s)) +#define strcmp(s1, s2) __builtin_strcmp((s1), (s2)) +#define strlen(s) __builtin_strlen((s)) #endif static __inline char * From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 047B55CF9BB; Sat, 10 Apr 2021 06:02:07 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXZ4Bsgz4R4g; Sat, 10 Apr 2021 06:02:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5CCEE3F9E; Sat, 10 Apr 2021 06:02:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A6262K015205; Sat, 10 Apr 2021 06:02:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A6264L015204; Sat, 10 Apr 2021 06:02:06 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:06 GMT Message-Id: <202104100602.13A6264L015204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 4cb1b49b3c98 - stable/13 - cache: assorted comment fixups MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4cb1b49b3c985e97933a6194646bab47ece82400 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:07 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=4cb1b49b3c985e97933a6194646bab47ece82400 commit 4cb1b49b3c985e97933a6194646bab47ece82400 Author: Mateusz Guzik AuthorDate: 2021-02-09 16:06:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 cache: assorted comment fixups (cherry picked from commit 39e0c3f686387605591f8f646ceec53613619525) --- sys/kern/vfs_cache.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 21eb436681fc..fef1e31d197b 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -5268,6 +5268,10 @@ cache_fplookup_parse(struct cache_fpl *fpl) cache_fpl_pathlen_sub(fpl, cnp->cn_namelen); #ifdef INVARIANTS + /* + * cache_get_hash only accepts lengths up to NAME_MAX. This is fine since + * we are going to fail this lookup with ENAMETOOLONG (see below). + */ if (cnp->cn_namelen <= NAME_MAX) { if (fpl->hash != cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp)) { panic("%s: mismatched hash for [%s] len %ld", __func__, @@ -5359,7 +5363,7 @@ cache_fplookup_skip_slashes(struct cache_fpl *fpl) * manner relying on an invariant that a non-directory vnode will get a miss. * In this case cn_nameptr[0] == '\0' and cn_namelen == 0. * - * Thus for a path like "foo/bar/" the code unwinds the state back to 'bar/' + * Thus for a path like "foo/bar/" the code unwinds the state back to "bar/" * and denotes this is the last path component, which avoids looping back. * * Only plain lookups are supported for now to restrict corner cases to handle. @@ -5454,14 +5458,14 @@ cache_fplookup_trailingslash(struct cache_fpl *fpl) #endif /* - * The previous directory is this one. + * If this was a "./" lookup the parent directory is already correct. */ if (cnp->cn_nameptr[0] == '.' && cnp->cn_namelen == 1) { return (0); } /* - * The previous directory is something else. + * Otherwise we need to look it up. */ tvp = fpl->tvp; ncp = atomic_load_consume_ptr(&tvp->v_cache_dd); @@ -5495,10 +5499,11 @@ cache_fplookup_failed_vexec(struct cache_fpl *fpl, int error) dvp_seqc = fpl->dvp_seqc; /* - * TODO: Due to ignoring slashes lookup will perform a permission check - * on the last dir when it should not have. If it fails, we get here. - * It is possible possible to fix it up fully without resorting to - * regular lookup, but for now just abort. + * TODO: Due to ignoring trailing slashes lookup will perform a + * permission check on the last dir when it should not be doing it. It + * may fail, but said failure should be ignored. It is possible to fix + * it up fully without resorting to regular lookup, but for now just + * abort. */ if (cache_fpl_istrailingslash(fpl)) { return (cache_fpl_aborted(fpl)); From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:08 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6A94C5CFB24; Sat, 10 Apr 2021 06:02:08 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXc0TYsz4RHx; Sat, 10 Apr 2021 06:02:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8BFBE422D; Sat, 10 Apr 2021 06:02:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A627Yr015226; Sat, 10 Apr 2021 06:02:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A627Uh015225; Sat, 10 Apr 2021 06:02:07 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:07 GMT Message-Id: <202104100602.13A627Uh015225@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: fb16013129a1 - stable/13 - vfs: add vfs_ref_from_vp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fb16013129a10a10be46197a82b814e479ed0905 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:08 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=fb16013129a10a10be46197a82b814e479ed0905 commit fb16013129a10a10be46197a82b814e479ed0905 Author: Mateusz Guzik AuthorDate: 2021-02-15 22:08:40 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 vfs: add vfs_ref_from_vp This generalizes what vop_stdgetwritemount used to be doing. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D28695 (cherry picked from commit a15f787adb4429b83fa911dcb60f69121aaee1ba) --- sys/kern/vfs_default.c | 25 +------------------------ sys/kern/vfs_mount.c | 38 ++++++++++++++++++++++++++++++++++++++ sys/sys/mount.h | 1 + 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 3c428d7b7511..4b9b1b43f1ce 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -680,7 +680,6 @@ vop_stdgetwritemount(ap) } */ *ap; { struct mount *mp; - struct mount_pcpu *mpcpu; struct vnode *vp; /* @@ -693,29 +692,7 @@ vop_stdgetwritemount(ap) * with releasing it. */ vp = ap->a_vp; - mp = vp->v_mount; - if (mp == NULL) { - *(ap->a_mpp) = NULL; - return (0); - } - if (vfs_op_thread_enter(mp, mpcpu)) { - if (mp == vp->v_mount) { - vfs_mp_count_add_pcpu(mpcpu, ref, 1); - vfs_op_thread_exit(mp, mpcpu); - } else { - vfs_op_thread_exit(mp, mpcpu); - mp = NULL; - } - } else { - MNT_ILOCK(mp); - if (mp == vp->v_mount) { - MNT_REF(mp); - MNT_IUNLOCK(mp); - } else { - MNT_IUNLOCK(mp); - mp = NULL; - } - } + mp = vfs_ref_from_vp(vp); *(ap->a_mpp) = mp; return (0); } diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 59000728efcc..7dc6b795eefd 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -449,6 +449,44 @@ sys_nmount(struct thread *td, struct nmount_args *uap) * Various utility functions */ +/* + * Get a reference on a mount point from a vnode. + * + * The vnode is allowed to be passed unlocked and race against dooming. Note in + * such case there are no guarantees the referenced mount point will still be + * associated with it after the function returns. + */ +struct mount * +vfs_ref_from_vp(struct vnode *vp) +{ + struct mount *mp; + struct mount_pcpu *mpcpu; + + mp = atomic_load_ptr(&vp->v_mount); + if (__predict_false(mp == NULL)) { + return (mp); + } + if (vfs_op_thread_enter(mp, mpcpu)) { + if (__predict_true(mp == vp->v_mount)) { + vfs_mp_count_add_pcpu(mpcpu, ref, 1); + vfs_op_thread_exit(mp, mpcpu); + } else { + vfs_op_thread_exit(mp, mpcpu); + mp = NULL; + } + } else { + MNT_ILOCK(mp); + if (mp == vp->v_mount) { + MNT_REF(mp); + MNT_IUNLOCK(mp); + } else { + MNT_IUNLOCK(mp); + mp = NULL; + } + } + return (mp); +} + void vfs_ref(struct mount *mp) { diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 98d50161bed5..e6a74bf1fb60 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -997,6 +997,7 @@ void vfs_mount_error(struct mount *, const char *, ...); void vfs_mountroot(void); /* mount our root filesystem */ void vfs_mountedfrom(struct mount *, const char *from); void vfs_notify_upper(struct vnode *, int); +struct mount *vfs_ref_from_vp(struct vnode *); void vfs_ref(struct mount *); void vfs_rel(struct mount *); struct mount *vfs_mount_alloc(struct vnode *, struct vfsconf *, const char *, From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 06:02:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 E235E5CF9D2; Sat, 10 Apr 2021 06:02:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHPXk46gyz4R52; Sat, 10 Apr 2021 06:02:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B4F440A3; Sat, 10 Apr 2021 06:02:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A62Eia015353; Sat, 10 Apr 2021 06:02:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A62Ef3015352; Sat, 10 Apr 2021 06:02:14 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:14 GMT Message-Id: <202104100602.13A62Ef3015352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e9fc871b0dec - stable/13 - vfs: replace vfs_smr_quiesce with vfs_smr_synchronize MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e9fc871b0dec47b943dd2d09688aa9fe867bfc9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 06:02:15 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e9fc871b0dec47b943dd2d09688aa9fe867bfc9b commit e9fc871b0dec47b943dd2d09688aa9fe867bfc9b Author: Mateusz Guzik AuthorDate: 2021-04-08 07:08:41 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:56 +0000 vfs: replace vfs_smr_quiesce with vfs_smr_synchronize This ends up using a smr specific method. Suggested by: markj Tested by: pho (cherry picked from commit 72b3b5a941927f7a79611131f144eeb2dc9143c9) --- sys/kern/vfs_cache.c | 12 ++++++------ sys/sys/vnode.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index ddeb87e269d7..b5fa21eea887 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2678,7 +2678,7 @@ cache_vnode_init(struct vnode *vp) * * This will force a fs lookup. * - * Synchronisation is done in 2 steps, calling vfs_smr_quiesce each time + * Synchronisation is done in 2 steps, calling vfs_smr_synchronize each time * to observe all CPUs not performing the lookup. */ static void @@ -2694,14 +2694,14 @@ cache_changesize_set_temp(struct nchashhead *temptbl, u_long temphash) */ atomic_store_long(&nchash, temphash); atomic_thread_fence_rel(); - vfs_smr_quiesce(); + vfs_smr_synchronize(); /* * At this point everyone sees the updated hash value, but they still * see the old table. */ atomic_store_ptr(&nchashtbl, temptbl); atomic_thread_fence_rel(); - vfs_smr_quiesce(); + vfs_smr_synchronize(); /* * At this point everyone sees the updated table pointer and size pair. */ @@ -2724,14 +2724,14 @@ cache_changesize_set_new(struct nchashhead *new_tbl, u_long new_hash) */ atomic_store_ptr(&nchashtbl, new_tbl); atomic_thread_fence_rel(); - vfs_smr_quiesce(); + vfs_smr_synchronize(); /* * At this point everyone sees the updated pointer value, but they * still see the old size. */ atomic_store_long(&nchash, new_hash); atomic_thread_fence_rel(); - vfs_smr_quiesce(); + vfs_smr_synchronize(); /* * At this point everyone sees the updated table pointer and size pair. */ @@ -3876,7 +3876,7 @@ cache_fplookup_lockout(void) if (on) { atomic_store_char(&cache_fast_lookup_enabled, false); atomic_thread_fence_rel(); - vfs_smr_quiesce(); + vfs_smr_synchronize(); } } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index e37302aeb379..d26c8aa70d8e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1109,7 +1109,7 @@ int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp); #define VFS_SMR() vfs_smr #define vfs_smr_enter() smr_enter(VFS_SMR()) #define vfs_smr_exit() smr_exit(VFS_SMR()) -#define vfs_smr_quiesce() quiesce_all_critical() +#define vfs_smr_synchronize() smr_synchronize(VFS_SMR()) #define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR()) #define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR()) #define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR()) From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 08:38:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0EB425DEECC; Sat, 10 Apr 2021 08:38:09 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHT0c74TWz4m07; Sat, 10 Apr 2021 08:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E5ECD5D7E; Sat, 10 Apr 2021 08:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13A8c8qa015893; Sat, 10 Apr 2021 08:38:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A8c8Nb015892; Sat, 10 Apr 2021 08:38:08 GMT (envelope-from git) Date: Sat, 10 Apr 2021 08:38:08 GMT Message-Id: <202104100838.13A8c8Nb015892@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 3056bbfc2cb2 - stable/13 - loader: we should support pools without features MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3056bbfc2cb24ec80ebfd831bf5c2fb3d7596a2f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 08:38:09 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=3056bbfc2cb24ec80ebfd831bf5c2fb3d7596a2f commit 3056bbfc2cb24ec80ebfd831bf5c2fb3d7596a2f Author: Toomas Soome AuthorDate: 2021-04-02 23:40:51 +0000 Commit: Toomas Soome CommitDate: 2021-04-09 20:09:28 +0000 loader: we should support pools without features nvlist_check_features_for_read() does return error when there are no features for read. Reported by: yuripv (cherry picked from commit d36341f7b8ddc2457a1e9e4a721d27d2e66cb39a) --- stand/libsa/zfs/zfsimpl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index bc577f168459..7036b508fa3c 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -191,8 +191,16 @@ nvlist_check_features_for_read(nvlist_t *nvl) rc = nvlist_find(nvl, ZPOOL_CONFIG_FEATURES_FOR_READ, DATA_TYPE_NVLIST, NULL, &features, NULL); - if (rc != 0) - return (rc); + switch (rc) { + case 0: + break; /* Continue with checks */ + + case ENOENT: + return (0); /* All features are disabled */ + + default: + return (rc); /* Error while reading nvlist */ + } data = (nvs_data_t *)features->nv_data; nvp = &data->nvl_pair; /* first pair in nvlist */ From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:12:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6E9F55E6261; Sat, 10 Apr 2021 13:12:54 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHb5f2ZlWz3Hxc; Sat, 10 Apr 2021 13:12:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B04B11DD0; Sat, 10 Apr 2021 13:12:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADCs0T087317; Sat, 10 Apr 2021 13:12:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADCsP1087316; Sat, 10 Apr 2021 13:12:54 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:12:54 GMT Message-Id: <202104101312.13ADCsP1087316@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Tai-hwa Liang Subject: git: 50f1778f6e61 - stable/12 - net: fixing a memory leak in if_deregister_com_alloc() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avatar X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 50f1778f6e61dd5855f684bdc43c8f1977e11ff0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:12:54 -0000 The branch stable/12 has been updated by avatar: URL: https://cgit.FreeBSD.org/src/commit/?id=50f1778f6e61dd5855f684bdc43c8f1977e11ff0 commit 50f1778f6e61dd5855f684bdc43c8f1977e11ff0 Author: Tai-hwa Liang AuthorDate: 2021-03-06 14:36:35 +0000 Commit: Tai-hwa Liang CommitDate: 2021-04-10 13:11:01 +0000 net: fixing a memory leak in if_deregister_com_alloc() Drain the callbacks upon if_deregister_com_alloc() such that the if_com_free[type] won't be nullified before if_destroy(). Taking fwip(4) as an example, before this fix, kldunload if_fwip will go through the following: 1. fwip_detach() 2. if_free() -> schedule if_destroy() through NET_EPOCH_CALL 3. fwip_detach() returns 4. firewire_modevent(MOD_UNLOAD) -> if_deregister_com_alloc() 5. kernel complains about: Warning: memory type fw_com leaked memory on destroy (1 allocations, 64 bytes leaked). 6. EPOCH runs if_destroy() -> if_free_internal() By this time, if_com_free[if_alloctype] is NULL since it's already nullified by if_deregister_com_alloc(); hence, firewire_free() won't have a chance to release the allocated fw_com. Reviewed by: hselasky, glebius MFC after: 2 weeks (cherry picked from commit 092f3f081265c68cd8de0234ba8e46560ccc061e) --- sys/net/if.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/net/if.c b/sys/net/if.c index 2ae8121043b0..f2ef88d3f28e 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -4172,6 +4172,14 @@ if_deregister_com_alloc(u_char type) ("if_deregister_com_alloc: %d not registered", type)); KASSERT(if_com_free[type] != NULL, ("if_deregister_com_alloc: %d free not registered", type)); + + /* + * Ensure all pending EPOCH(9) callbacks have been executed. This + * fixes issues about late invocation of if_destroy(), which leads + * to memory leak from if_com_alloc[type] allocated if_l2com. + */ + epoch_drain_callbacks(net_epoch_preempt); + if_com_alloc[type] = NULL; if_com_free[type] = NULL; } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C81605E6745; Sat, 10 Apr 2021 13:29:53 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTF5L8kz3Jm6; Sat, 10 Apr 2021 13:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AA0A611FBE; Sat, 10 Apr 2021 13:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTrN8001849; Sat, 10 Apr 2021 13:29:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTrsI001848; Sat, 10 Apr 2021 13:29:53 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:53 GMT Message-Id: <202104101329.13ADTrsI001848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 7962978754d3 - stable/13 - Unbreak MSG_CMSG_CLOEXEC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7962978754d3372460c9f2bdcd6d8f27ad8f89e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:53 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=7962978754d3372460c9f2bdcd6d8f27ad8f89e8 commit 7962978754d3372460c9f2bdcd6d8f27ad8f89e8 Author: Alex Richardson AuthorDate: 2021-03-18 20:52:20 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:52:15 +0000 Unbreak MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC has not been working since 2015 (SVN r284380) because _finstall expects O_CLOEXEC and not UF_EXCLOSE as the flags argument. This was probably not noticed because we don't have a test for this flag so this commit adds one. I found this problem because one of the libwayland tests was failing. Fixes: ea31808c3b07 ("fd: move out actual fp installation to _finstall") MFC after: 3 days Reviewed By: mjg, kib Differential Revision: https://reviews.freebsd.org/D29328 (cherry picked from commit 6ceacebdf5221133943ab3b6b56751c8b51c3e2b) --- sys/kern/uipc_usrreq.c | 2 +- tests/sys/kern/unix_passfd_test.c | 45 ++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index ca23ccbdb05e..4466ae8822cd 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -2067,7 +2067,7 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp, int flags) } for (i = 0; i < newfds; i++, fdp++) { _finstall(fdesc, fdep[i]->fde_file, *fdp, - (flags & MSG_CMSG_CLOEXEC) != 0 ? UF_EXCLOSE : 0, + (flags & MSG_CMSG_CLOEXEC) != 0 ? O_CLOEXEC : 0, &fdep[i]->fde_caps); unp_externalize_fp(fdep[i]->fde_file); } diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c index 2fac0b3f1a0a..2b5cdde012c1 100644 --- a/tests/sys/kern/unix_passfd_test.c +++ b/tests/sys/kern/unix_passfd_test.c @@ -194,7 +194,7 @@ localcreds(int sockfd) static void recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen, - size_t cmsgsz) + size_t cmsgsz, int recvmsg_flags) { struct cmsghdr *cmsghdr; struct msghdr msghdr; @@ -216,7 +216,7 @@ recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen, msghdr.msg_iov = &iovec; msghdr.msg_iovlen = 1; - len = recvmsg(sockfd, &msghdr, 0); + len = recvmsg(sockfd, &msghdr, recvmsg_flags); ATF_REQUIRE_MSG(len != -1, "recvmsg failed: %s", strerror(errno)); ATF_REQUIRE_MSG((size_t)len == buflen, "recvmsg: %zd bytes received; expected %zd", len, buflen); @@ -243,12 +243,12 @@ recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen, } static void -recvfd(int sockfd, int *recv_fd) +recvfd(int sockfd, int *recv_fd, int flags) { char ch = 0; recvfd_payload(sockfd, recv_fd, &ch, sizeof(ch), - CMSG_SPACE(sizeof(int))); + CMSG_SPACE(sizeof(int)), flags); } /* @@ -266,9 +266,33 @@ ATF_TC_BODY(simple_send_fd, tc) tempfile(&putfd); dofstat(putfd, &putfd_stat); sendfd(fd[0], putfd); - recvfd(fd[1], &getfd); + recvfd(fd[1], &getfd, 0); + dofstat(getfd, &getfd_stat); + samefile(&putfd_stat, &getfd_stat); + close(putfd); + close(getfd); + closesocketpair(fd); +} + +/* + * Like simple_send_fd but also sets MSG_CMSG_CLOEXEC and checks that the + * received file descriptor has the FD_CLOEXEC flag set. + */ +ATF_TC_WITHOUT_HEAD(simple_send_fd_msg_cmsg_cloexec); +ATF_TC_BODY(simple_send_fd_msg_cmsg_cloexec, tc) +{ + struct stat getfd_stat, putfd_stat; + int fd[2], getfd, putfd; + + domainsocketpair(fd); + tempfile(&putfd); + dofstat(putfd, &putfd_stat); + sendfd(fd[0], putfd); + recvfd(fd[1], &getfd, MSG_CMSG_CLOEXEC); dofstat(getfd, &getfd_stat); samefile(&putfd_stat, &getfd_stat); + ATF_REQUIRE_EQ_MSG(fcntl(getfd, F_GETFD) & FD_CLOEXEC, FD_CLOEXEC, + "FD_CLOEXEC not set on the received file descriptor"); close(putfd); close(getfd); closesocketpair(fd); @@ -289,7 +313,7 @@ ATF_TC_BODY(send_and_close, tc) dofstat(putfd, &putfd_stat); sendfd(fd[0], putfd); close(putfd); - recvfd(fd[1], &getfd); + recvfd(fd[1], &getfd, 0); dofstat(getfd, &getfd_stat); samefile(&putfd_stat, &getfd_stat); close(getfd); @@ -331,8 +355,8 @@ ATF_TC_BODY(two_files, tc) sendfd(fd[0], putfd_2); close(putfd_1); close(putfd_2); - recvfd(fd[1], &getfd_1); - recvfd(fd[1], &getfd_2); + recvfd(fd[1], &getfd_1, 0); + recvfd(fd[1], &getfd_2, 0); dofstat(getfd_1, &getfd_1_stat); dofstat(getfd_2, &getfd_2_stat); samefile(&putfd_1_stat, &getfd_1_stat); @@ -355,7 +379,7 @@ ATF_TC_BODY(bundle, tc) sendfd(fd[0], fd[0]); close(fd[0]); - recvfd(fd[1], &getfd); + recvfd(fd[1], &getfd, 0); close(getfd); close(fd[1]); } @@ -430,7 +454,7 @@ ATF_TC_BODY(rights_creds_payload, tc) len = sendfd_payload(fd[0], putfd, buf, sendspace); ATF_REQUIRE_MSG(len < sendspace, "sendmsg: %zu bytes sent", len); recvfd_payload(fd[1], &getfd, buf, len, - CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int))); + CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)), 0); close(putfd); close(getfd); @@ -695,6 +719,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, simple_send_fd); + ATF_TP_ADD_TC(tp, simple_send_fd_msg_cmsg_cloexec); ATF_TP_ADD_TC(tp, send_and_close); ATF_TP_ADD_TC(tp, send_and_cancel); ATF_TP_ADD_TC(tp, two_files); From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 14EE85E6D00; Sat, 10 Apr 2021 13:29:55 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTG6tcmz3JZP; Sat, 10 Apr 2021 13:29:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D987911DF8; Sat, 10 Apr 2021 13:29:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTso1001872; Sat, 10 Apr 2021 13:29:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTsap001869; Sat, 10 Apr 2021 13:29:54 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:54 GMT Message-Id: <202104101329.13ADTsap001869@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 6462d714c766 - stable/13 - Silence unused parameter warnings in the RISC-V fenv.h MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6462d714c76639fc34edd8345f0bd814ad688db4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:55 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=6462d714c76639fc34edd8345f0bd814ad688db4 commit 6462d714c76639fc34edd8345f0bd814ad688db4 Author: Alex Richardson AuthorDate: 2021-03-22 17:47:50 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:52:40 +0000 Silence unused parameter warnings in the RISC-V fenv.h After increasing the lib/msun/tests WARNS to 6, this triggers a compilation error for RISC-V. Fixes: 87d65c747a43 ("lib/msun: Allow building tests with WARNS=6") Reported by: Jenkins (cherry picked from commit 15211f19509282d9c9a418d4e5b6ac75d9d1fc85) --- lib/msun/riscv/fenv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/msun/riscv/fenv.h b/lib/msun/riscv/fenv.h index f9d840d156fa..6c8c2861bc97 100644 --- a/lib/msun/riscv/fenv.h +++ b/lib/msun/riscv/fenv.h @@ -186,7 +186,7 @@ fegetenv(fenv_t *__envp) } __fenv_static inline int -feholdexcept(fenv_t *__envp) +feholdexcept(fenv_t *__envp __unused) { /* No exception traps. */ @@ -226,7 +226,7 @@ int fedisableexcept(int __mask); int fegetexcept(void); #else static inline int -feenableexcept(int __mask) +feenableexcept(int __mask __unused) { /* No exception traps. */ @@ -235,7 +235,7 @@ feenableexcept(int __mask) } static inline int -fedisableexcept(int __mask) +fedisableexcept(int __mask __unused) { /* No exception traps. */ From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 68FC35E674F; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTJ29Tjz3Jjs; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C8C91223A; Sat, 10 Apr 2021 13:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTtDa001898; Sat, 10 Apr 2021 13:29:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTtOa001897; Sat, 10 Apr 2021 13:29:55 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:55 GMT Message-Id: <202104101329.13ADTtOa001897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 502d647d75c8 - stable/13 - tests/sys/netgraph: Further CI fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 502d647d75c81ea63735b898b94ebad0de13c58d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:56 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=502d647d75c81ea63735b898b94ebad0de13c58d commit 502d647d75c81ea63735b898b94ebad0de13c58d Author: Alex Richardson AuthorDate: 2021-03-19 18:34:29 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:53:36 +0000 tests/sys/netgraph: Further CI fixes I was trying to debug why this test is working locally but failing in CI. While doing so I made some small changes to allow running it with set -e. It turns out the problem is that find_iface does not return anything in Jenkins, so all following tests fail with obscure error messages. To handle this case exit early if $eth is empty. Reviewed By: lwhsu Differential Revision: https://reviews.freebsd.org/D29340 (cherry picked from commit 7dd1f932c1f51bfe10da7bc8875879cdcdd40821) --- tests/sys/netgraph/ng_macfilter_test.sh | 57 +++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/tests/sys/netgraph/ng_macfilter_test.sh b/tests/sys/netgraph/ng_macfilter_test.sh index 269de3e130aa..482f32e5d335 100755 --- a/tests/sys/netgraph/ng_macfilter_test.sh +++ b/tests/sys/netgraph/ng_macfilter_test.sh @@ -29,6 +29,8 @@ # # $FreeBSD$ +set -e + progname="$(basename $0 .sh)" entries_lst="/tmp/$progname.entries.lst" entries2_lst="/tmp/$progname.entries2.lst" @@ -124,7 +126,7 @@ test_not_ok () { local msg="$1" _test_next - _test_fails + _test_fail echo "not ok $TSTNR - $msg" return 1 @@ -183,9 +185,24 @@ test_ge () { test_not_ok "$v1 <= $v2 $msg" fi } -test_rc () { test_eq $? $1 "$2"; } -test_failure () { test_ne $? 0 "$1"; } -test_success () { test_eq $? 0 "$1"; } +test_failure () { + msg=$1 + shift + if ! "$@"; then + test_ok "$msg - \"$@\" failed as expected" + else + test_not_ok "$msg - expected \"$@\" to fail but succeeded" + fi +} +test_success () { + msg=$1 + shift + if ! "$@"; then + test_not_ok "$msg - \"$@\" failed unexpectedly" + else + test_ok "$msg - \"$@\" succeeded" + fi +} gethooks () { ngctl msg MF: 'gethooks' \ @@ -217,6 +234,13 @@ genmac () { test_title "Setting up system..." load_modules netgraph ng_socket ng_ether ng_macfilter ng_one2many eth=$(find_iface) +if [ -z "$eth" ]; then + echo "1..1" + echo "not ok 1 - Could not find a valid interface" + echo "Available interfaces:" + ifconfig + exit 1 +fi test_comment "Using $eth..." @@ -239,31 +263,23 @@ test_cnt 46 ################################################################################ test_title "Test: Duplicate default hook" -ngctl connect MF: O2M: default many99 2>/dev/null -test_failure "duplicate connect of default hook" - +test_failure "duplicate connect of default hook" ngctl connect MF: O2M: default many99 ################################################################################ test_title "Test: Add and remove hooks" -ngctl connect MF: O2M: xxx1 many$((HOOKS + 1)) -test_success "connect MF:xxx1 to O2M:many$((HOOKS + 1))" -ngctl connect MF: O2M: xxx2 many$((HOOKS + 2)) -test_success "connect MF:xxx2 to O2M:many$((HOOKS + 2))" -ngctl connect MF: O2M: xxx3 many$((HOOKS + 3)) -test_success "connect MF:xxx3 to O2M:many$((HOOKS + 3))" +test_success "connect MF:xxx1 to O2M:many$((HOOKS + 1))" ngctl connect MF: O2M: xxx1 many$((HOOKS + 1)) +test_success "connect MF:xxx2 to O2M:many$((HOOKS + 2))" ngctl connect MF: O2M: xxx2 many$((HOOKS + 2)) +test_success "connect MF:xxx3 to O2M:many$((HOOKS + 3))" ngctl connect MF: O2M: xxx3 many$((HOOKS + 3)) hooks=$(gethooks) test_eq $created_hooks:xxx1:xxx2:xxx3 $hooks 'hooks after adding xxx1-3' -ngctl rmhook MF: xxx1 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx1 hooks=$(gethooks) test_eq $created_hooks:xxx2:xxx3 $hooks 'hooks after removing xxx1' -ngctl rmhook MF: xxx2 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx2 hooks=$(gethooks) test_eq $created_hooks:xxx3 $hooks 'hooks after removing xxx2' -ngctl rmhook MF: xxx3 -test_success "rmhook MF:xxx$i" +test_success "rmhook MF:xxx$i" ngctl rmhook MF: xxx3 hooks=$(gethooks) test_eq $created_hooks $hooks 'hooks after removing xxx3' @@ -418,8 +434,7 @@ done ################################################################################ test_title "Test: Resetting macfilter..." -ngctl msg MF: reset -test_success "**** reset failed" +test_success "**** reset failed" ngctl msg MF: reset test_eq $(countmacs) 0 'MACs in table' test_bail_on_fail From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 51B6E5E6C1A; Sat, 10 Apr 2021 13:29:57 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTK1fz5z3JgP; Sat, 10 Apr 2021 13:29:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29F05121A0; Sat, 10 Apr 2021 13:29:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTv98001921; Sat, 10 Apr 2021 13:29:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTvEV001920; Sat, 10 Apr 2021 13:29:57 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:57 GMT Message-Id: <202104101329.13ADTvEV001920@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 57971fe46793 - stable/13 - bsd.compiler.mk: Detect distribution-provided GCC when executed as cc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 57971fe46793911bcd976928fed8b19df4497a0b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:57 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=57971fe46793911bcd976928fed8b19df4497a0b commit 57971fe46793911bcd976928fed8b19df4497a0b Author: Jessica Clarke AuthorDate: 2021-02-09 21:40:24 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:55:29 +0000 bsd.compiler.mk: Detect distribution-provided GCC when executed as cc Clang always prints "clang $VERSION" regardless of the name used to execute it, whereas GCC prints "$progname $VERSION", meaning if CC is set to cc and cc is GCC it will print "cc $VERSION". We are able to detect some of those cases since it then prints "($PKGVERSION)", where the default is "GCC", but many distributions override that to print their name and the package version number (e.g. "Debian 10.2.1-6"), so nothing tells us it's GCC other than the fact that it's not Clang (and that there's an FSF copyright disclaimer). However, GCC's -v option will always print "gcc version $VERSION", so fall back on using that to detect GCC. Whilst Clang also supports this option, we should never get here, so Clang handling is not added. Reviewed by: brooks, emaste, arichardson Differential Revision: https://reviews.freebsd.org/D28315 (cherry picked from commit 9c6954329a9285547881ddd60e393b7c55ed30c4) --- share/mk/bsd.compiler.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index 8253669fe279..fa8e6c44a17e 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -187,7 +187,16 @@ ${X_}COMPILER_TYPE:= gcc . elif ${_v:Mclang} || ${_v:M(clang-*.*.*)} ${X_}COMPILER_TYPE:= clang . else +# With GCC, cc --version prints "cc $VERSION ($PKGVERSION)", so if a +# distribution overrides the default GCC PKGVERSION it is not identified. +# However, its -v output always says "gcc version" in it, so fall back on that. +_gcc_version!= ${${cc}:N${CCACHE_BIN}} -v 2>&1 | grep "gcc version" +. if !empty(_gcc_version) +${X_}COMPILER_TYPE:= gcc +. else .error Unable to determine compiler type for ${cc}=${${cc}}. Consider setting ${X_}COMPILER_TYPE. +. endif +.undef _gcc_version . endif .endif .if !defined(${X_}COMPILER_VERSION) From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:29:58 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 A06C05E6C86; Sat, 10 Apr 2021 13:29:58 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTL3w8lz3Jpk; Sat, 10 Apr 2021 13:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3F89B1223B; Sat, 10 Apr 2021 13:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTwGh001943; Sat, 10 Apr 2021 13:29:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTwf6001942; Sat, 10 Apr 2021 13:29:58 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:58 GMT Message-Id: <202104101329.13ADTwf6001942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 350123947584 - stable/13 - tools/build/make.py: drop workaround for cc --version not being parsed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 350123947584fb26062eb4b4d7c36185ed3b2830 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:29:58 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=350123947584fb26062eb4b4d7c36185ed3b2830 commit 350123947584fb26062eb4b4d7c36185ed3b2830 Author: Alex Richardson AuthorDate: 2021-02-13 13:54:20 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:55:54 +0000 tools/build/make.py: drop workaround for cc --version not being parsed Previously bsd.compiler.mk was not able to detect the compiler type for Ubuntu's /usr/bin/cc unless we were invoking the /usr/bin/gcc symlink. This problem has been fixed by 9c6954329a9285547881ddd60e393b7c55ed30c4 so we can drop the workaround from make.py. Reviewed By: jrtc27 Differential Revision: https://reviews.freebsd.org/D28323 (cherry picked from commit 88db1cc9f197a376817ce27ba269348666bbd4b7) --- tools/build/make.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/build/make.py b/tools/build/make.py index e692fef11e05..bc6d8fb449bb 100755 --- a/tools/build/make.py +++ b/tools/build/make.py @@ -182,13 +182,6 @@ if __name__ == "__main__": sys.exit("TARGET= and TARGET_ARCH= must be set explicitly " "when building on non-FreeBSD") # infer values for CC/CXX/CPP - - if sys.platform.startswith( - "linux") and parsed_args.host_compiler_type == "cc": - # FIXME: bsd.compiler.mk doesn't handle the output of GCC if it - # is /usr/bin/cc on Ubuntu since it doesn't contain the GCC string. - parsed_args.host_compiler_type = "gcc" - if parsed_args.host_compiler_type == "gcc": default_cc, default_cxx, default_cpp = ("gcc", "g++", "cpp") # FIXME: this should take values like `clang-9` and then look for @@ -225,8 +218,8 @@ if __name__ == "__main__": if not shutil.which("strip"): if sys.platform.startswith("darwin"): # On macOS systems we have to use /usr/bin/strip. - sys.exit("Cannot find required tool 'strip'. Please install the" - " host compiler and command line tools.") + sys.exit("Cannot find required tool 'strip'. Please install " + "the host compiler and command line tools.") if parsed_args.host_compiler_type == "clang": strip_binary = "llvm-strip" else: From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 F10BA5E6D1C; Sat, 10 Apr 2021 13:29:59 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTM39cbz3Jpt; Sat, 10 Apr 2021 13:29:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5D7B91223C; Sat, 10 Apr 2021 13:29:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADTxmq001966; Sat, 10 Apr 2021 13:29:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADTxwx001964; Sat, 10 Apr 2021 13:29:59 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:29:59 GMT Message-Id: <202104101329.13ADTxwx001964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 0a0e327fad67 - stable/13 - tools/build/make.py: Don't call brew --prefix if --cross-bindir is set MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0a0e327fad6745fa48091cbdaeb6fea36ac5dd69 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:00 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0a0e327fad6745fa48091cbdaeb6fea36ac5dd69 commit 0a0e327fad6745fa48091cbdaeb6fea36ac5dd69 Author: Alex Richardson AuthorDate: 2021-02-26 17:49:03 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:56:02 +0000 tools/build/make.py: Don't call brew --prefix if --cross-bindir is set Also updated the logic to use subprocess.run() instead of the old subprocess.getoutput() which also includes stderr and therefore can trigger an exception inside Path().exists(). Reported by: gnn (cherry picked from commit a26ace4db6d974215a4d882948da80eae2b3b0d4) --- tools/build/make.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/build/make.py b/tools/build/make.py index bc6d8fb449bb..c34147f6ac21 100755 --- a/tools/build/make.py +++ b/tools/build/make.py @@ -124,9 +124,14 @@ def default_cross_toolchain(): # default to homebrew-installed clang on MacOS if available if sys.platform.startswith("darwin"): if shutil.which("brew"): - llvm_dir = subprocess.getoutput("brew --prefix llvm") - if llvm_dir and Path(llvm_dir, "bin").exists(): - return str(Path(llvm_dir, "bin")) + llvm_dir = subprocess.run(["brew", "--prefix", "llvm"], + capture_output=True).stdout.strip() + debug("Inferred LLVM dir as", llvm_dir) + try: + if llvm_dir and Path(llvm_dir.decode("utf-8"), "bin").exists(): + return str(Path(llvm_dir.decode("utf-8"), "bin")) + except OSError: + return None return None @@ -137,7 +142,7 @@ if __name__ == "__main__": help="Directory to look for cc/c++/cpp/ld to build " "host (" + sys.platform + ") binaries", default="/usr/bin") - parser.add_argument("--cross-bindir", default=default_cross_toolchain(), + parser.add_argument("--cross-bindir", default=None, help="Directory to look for cc/c++/cpp/ld to build " "target binaries (only needed if XCC/XCPP/XLD " "are not set)") @@ -165,6 +170,8 @@ if __name__ == "__main__": except ImportError: pass parsed_args, bmake_args = parser.parse_known_args() + if parsed_args.cross_bindir is None: + parsed_args.cross_bindir = default_cross_toolchain() MAKEOBJDIRPREFIX = os.getenv("MAKEOBJDIRPREFIX") if not MAKEOBJDIRPREFIX: From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 CAA595E6760; Sat, 10 Apr 2021 13:30:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTN4PP6z3Jpy; Sat, 10 Apr 2021 13:30:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 749721223D; Sat, 10 Apr 2021 13:30:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU0qm002177; Sat, 10 Apr 2021 13:30:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU0dQ002164; Sat, 10 Apr 2021 13:30:00 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:00 GMT Message-Id: <202104101330.13ADU0dQ002164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 4eaec3eb5f9e - stable/13 - tools/build/make.py: Avoid calling brew --prefix on macOS unnecessarily MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4eaec3eb5f9e67eb20be00c20ff28537c3a51285 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:01 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=4eaec3eb5f9e67eb20be00c20ff28537c3a51285 commit 4eaec3eb5f9e67eb20be00c20ff28537c3a51285 Author: Alex Richardson AuthorDate: 2021-03-05 10:21:12 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 12:56:08 +0000 tools/build/make.py: Avoid calling brew --prefix on macOS unnecessarily If all the require variables (XCC/XCXX/XCPP/XLD) are already set in the environment, we don't have to infer a default value for the cross toolchain path. This avoids an additional `brew --prefix` call when building with cheribuild (since it already sets all these variables). (cherry picked from commit 2b181156c893843266c2825098360db2364dbd23) --- tools/build/make.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/build/make.py b/tools/build/make.py index c34147f6ac21..0cf831a3c966 100755 --- a/tools/build/make.py +++ b/tools/build/make.py @@ -119,6 +119,15 @@ def check_required_make_env_var(varname, binary_name, bindir): if parsed_args.debug: run([guess, "--version"]) +def check_xtool_make_env_var(varname, binary_name): + # Avoid calling brew --prefix on macOS if all variables are already set: + if os.getenv(varname): + return + global parsed_args + if parsed_args.cross_bindir is None: + parsed_args.cross_bindir = default_cross_toolchain() + return check_required_make_env_var(varname, binary_name, + parsed_args.cross_bindir) def default_cross_toolchain(): # default to homebrew-installed clang on MacOS if available @@ -170,8 +179,6 @@ if __name__ == "__main__": except ImportError: pass parsed_args, bmake_args = parser.parse_known_args() - if parsed_args.cross_bindir is None: - parsed_args.cross_bindir = default_cross_toolchain() MAKEOBJDIRPREFIX = os.getenv("MAKEOBJDIRPREFIX") if not MAKEOBJDIRPREFIX: @@ -209,16 +216,11 @@ if __name__ == "__main__": # On non-FreeBSD we need to explicitly pass XCC/XLD/X_COMPILER_TYPE use_cross_gcc = parsed_args.cross_compiler_type == "gcc" - check_required_make_env_var("XCC", "gcc" if use_cross_gcc else "clang", - parsed_args.cross_bindir) - check_required_make_env_var("XCXX", - "g++" if use_cross_gcc else "clang++", - parsed_args.cross_bindir) - check_required_make_env_var("XCPP", - "cpp" if use_cross_gcc else "clang-cpp", - parsed_args.cross_bindir) - check_required_make_env_var("XLD", "ld" if use_cross_gcc else "ld.lld", - parsed_args.cross_bindir) + check_xtool_make_env_var("XCC", "gcc" if use_cross_gcc else "clang") + check_xtool_make_env_var("XCXX", "g++" if use_cross_gcc else "clang++") + check_xtool_make_env_var("XCPP", + "cpp" if use_cross_gcc else "clang-cpp") + check_xtool_make_env_var("XLD", "ld" if use_cross_gcc else "ld.lld") # We also need to set STRIPBIN if there is no working strip binary # in $PATH. @@ -232,7 +234,7 @@ if __name__ == "__main__": else: strip_binary = "strip" check_required_make_env_var("STRIPBIN", strip_binary, - parsed_args.cross_bindir) + parsed_args.host_bindir) if os.getenv("STRIPBIN") or "STRIPBIN" in new_env_vars: # If we are setting STRIPBIN, we have to set XSTRIPBIN to the # default if it is not set otherwise already. From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:02 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 133CA5E6A3C; Sat, 10 Apr 2021 13:30:02 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTP4rknz3JZn; Sat, 10 Apr 2021 13:30:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93C00121A1; Sat, 10 Apr 2021 13:30:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU1pH003444; Sat, 10 Apr 2021 13:30:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU1qC003433; Sat, 10 Apr 2021 13:30:01 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:01 GMT Message-Id: <202104101330.13ADU1qC003433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 2cb6b07ca506 - stable/13 - Always build the sanitizer runtimes when compiling with clang MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2cb6b07ca506d2c1876279d477022022194e4cc9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:02 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=2cb6b07ca506d2c1876279d477022022194e4cc9 commit 2cb6b07ca506d2c1876279d477022022194e4cc9 Author: Alex Richardson AuthorDate: 2021-02-10 15:25:14 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:04 +0000 Always build the sanitizer runtimes when compiling with clang This allows instrumenting e.g. test binaries even when compiling with an external clang (e.g. CROSS_TOOLCHAIN=llvm11). I have some upcoming patches that allow building the entire base system with ASan/UBSan/etc. instrumentation and this is required in preparation for this. Reviewed By: dim, emaste Differential Revision: https://reviews.freebsd.org/D28532 (cherry picked from commit 7676b388adbc81a2ad46b43852cd9bc7ac7fad7e) --- lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index ddb627917215..90f1f7f3cd73 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -175,7 +175,7 @@ SUBDIR.${MK_STATS}+= libstats # The libraries under libclang_rt can only be built by clang, and only make # sense to build when clang is enabled at all. Furthermore, they can only be # built for certain architectures. -.if ${MK_CLANG} != "no" && ${COMPILER_TYPE} == "clang" && \ +.if ${COMPILER_TYPE} == "clang" && \ (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || \ ${MACHINE_CPUARCH} == "powerpc") From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:03 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 25B4A5E6763; Sat, 10 Apr 2021 13:30:03 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTQ6WYvz3Jgd; Sat, 10 Apr 2021 13:30:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1F151203B; Sat, 10 Apr 2021 13:30:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU2Nb003863; Sat, 10 Apr 2021 13:30:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU2Rk003860; Sat, 10 Apr 2021 13:30:02 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:02 GMT Message-Id: <202104101330.13ADU2Rk003860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 54d6cf9ec82b - stable/13 - Allow using sanitizers for ssp tests with out-of-tree compiler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 54d6cf9ec82b92c8d2dd2104139e1dc05e95c344 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:03 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=54d6cf9ec82b92c8d2dd2104139e1dc05e95c344 commit 54d6cf9ec82b92c8d2dd2104139e1dc05e95c344 Author: Alex Richardson AuthorDate: 2021-03-12 17:15:00 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:04 +0000 Allow using sanitizers for ssp tests with out-of-tree compiler With an out-of-tree Clang, we can use the -resource-dir flag when linking to point it at the runtime libraries from the current SYSROOT. This moves the path to the clang-internal library directory to a separate .mk file that can be used by Makefiles that want to find the sanitizer libraries. I intend to re-use this .mk file for my upcoming changes that allow building the entire base system with ASAN/UBSAN/MSAN. Reviewed By: dim Differential Revision: https://reviews.freebsd.org/D28852 (cherry picked from commit fe525d3f916602ddac3286641dab8f5e274daa44) --- lib/libc/tests/ssp/Makefile | 27 ++++++++++++--------------- lib/libclang_rt/Makefile.inc | 12 ++---------- lib/libclang_rt/compiler-rt-vars.mk | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index 655130ab309d..452c57246e39 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -6,9 +6,10 @@ MK_WERROR= no WARNS?= 2 CFLAGS.h_raw+= -fstack-protector-all -Wstack-protector -.if ${COMPILER_TYPE} == "clang" && ${CC} == "cc" -# Only use -fsanitize=bounds when using the in-tree compiler. Otherwise -# we may link to a sanitizer library targeted at a newer kernel/libc. +.if ${COMPILER_TYPE} == "clang" +# Only use -fsanitize=bounds when using clang. Otherwise we are not able to +# override the sanitizer runtime libraries to be the ones installed on the +# target system. CFLAGS.h_raw+= -fsanitize=bounds .elif ${COMPILER_TYPE} == "gcc" CFLAGS.h_raw+= --param ssp-buffer-size=1 @@ -25,24 +26,20 @@ PROGS+= h_getcwd PROGS+= h_memcpy PROGS+= h_memmove PROGS+= h_memset -# This testcase doesn't run properly when not compiled with -fsantize=bounds -# with clang, which is currently contingent on a compiler_rt update -# # XXX: the h_raw/h_read testcases don't cause a SIGABRT with in-tree gcc right # now on amd64 when it trips the stack bounds specified in t_ssp.sh . This # probably needs to be fixed as it's currently hardcoded. -# -# sanitizer is not tested or supported for ARM right now. sbruno -.if ${COMPILER_TYPE} == "clang" && ${CC} == "cc" && !defined(_SKIP_BUILD) && \ +.if ${COMPILER_TYPE} == "clang" && !defined(_SKIP_BUILD) && \ (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw") -.if !defined(_CLANG_RESOURCE_DIR) -_CLANG_RESOURCE_DIR!= ${CC:N${CCACHE_BIN}} -print-resource-dir -.export _CLANG_RESOURCE_DIR -.endif -_libclang_rt_arch= ${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/} -_libclang_rt_ubsan= ${_CLANG_RESOURCE_DIR}/lib/freebsd/libclang_rt.ubsan_standalone-${_libclang_rt_arch}.a +.include "${SRCTOP}/lib/libclang_rt/compiler-rt-vars.mk" +_libclang_rt_ubsan= ${SYSROOT}${SANITIZER_LIBDIR}/libclang_rt.ubsan_standalone-${CRTARCH}.a .if exists(${_libclang_rt_ubsan}) PROGS+= h_raw +LDADD.h_raw+= ${SANITIZER_LDFLAGS} +.else +.if make(all) +.info "Could not find runtime library ${_libclang_rt_ubsan}, skipping h_raw" +.endif .endif .endif PROGS+= h_read diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc index 01bfd72b5a7e..946d3f4c77a7 100644 --- a/lib/libclang_rt/Makefile.inc +++ b/lib/libclang_rt/Makefile.inc @@ -2,20 +2,12 @@ .include -# armv[67] is a bit special since we allow a soft-floating version via -# CPUTYPE matching *soft*. This variant may not actually work though. -.if ${MACHINE_ARCH:Marmv[67]*} != "" && \ - (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") -CRTARCH?= armhf -.else -CRTARCH?= ${MACHINE_ARCH:C/amd64/x86_64/} -.endif CRTSRC= ${SRCTOP}/contrib/llvm-project/compiler-rt +.include "compiler-rt-vars.mk" .PATH: ${CRTSRC}/lib -CLANGDIR= /usr/lib/clang/11.0.1 -LIBDIR= ${CLANGDIR}/lib/freebsd +LIBDIR= ${SANITIZER_LIBDIR} SHLIBDIR= ${LIBDIR} NO_PIC= diff --git a/lib/libclang_rt/compiler-rt-vars.mk b/lib/libclang_rt/compiler-rt-vars.mk new file mode 100644 index 000000000000..17424785c372 --- /dev/null +++ b/lib/libclang_rt/compiler-rt-vars.mk @@ -0,0 +1,24 @@ +CLANG_SUBDIR=clang/11.0.1 +CLANGDIR= /usr/lib/${CLANG_SUBDIR} +SANITIZER_LIBDIR= ${CLANGDIR}/lib/freebsd + +# armv[67] is a bit special since we allow a soft-floating version via +# CPUTYPE matching *soft*. This variant may not actually work though. +.if ${MACHINE_ARCH:Marmv[67]*} != "" && \ + (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +CRTARCH?= armhf +.else +CRTARCH?= ${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/} +.endif + +.if ${COMPILER_TYPE} == "clang" +# The only way to set the path to the sanitizer libraries with clang is to +# override the resource directory. +# Note: lib/freebsd is automatically appended to the -resource-dir value. +SANITIZER_LDFLAGS= -resource-dir=${SYSROOT}${CLANGDIR} +# Also set RPATH to ensure that the dynamically linked runtime libs are found. +SANITIZER_LDFLAGS+= -Wl,--enable-new-dtags +SANITIZER_LDFLAGS+= -Wl,-rpath,${SANITIZER_LIBDIR} +.else +.error "Unknown link flags for -fsanitize=... COMPILER_TYPE=${COMPILER_TYPE}" +.endif From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 299FB5E6BF0; Sat, 10 Apr 2021 13:30:04 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTR6lVCz3Jdt; Sat, 10 Apr 2021 13:30:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8E941223E; Sat, 10 Apr 2021 13:30:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU3HY004071; Sat, 10 Apr 2021 13:30:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU353004068; Sat, 10 Apr 2021 13:30:03 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:03 GMT Message-Id: <202104101330.13ADU353004068@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: d435574abffd - stable/13 - ng_macfilter_test: Skip rather than fail if there is no network MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d435574abffd58044f0184ebd857298ad637132f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:04 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=d435574abffd58044f0184ebd857298ad637132f commit d435574abffd58044f0184ebd857298ad637132f Author: Alex Richardson AuthorDate: 2021-03-25 11:14:46 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:04 +0000 ng_macfilter_test: Skip rather than fail if there is no network This should bring the number of Jenkins failures from 4 down to 3. Locally kyua now prints `skipped: could not find a valid interface [0.115s]` when I run it in QEMU without a network device. Reviewed By: lwhsu MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29414 (cherry picked from commit 6f30d1c851467d1f504f469a1b3a75a043ff070f) --- tests/sys/netgraph/ng_macfilter_test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/sys/netgraph/ng_macfilter_test.sh b/tests/sys/netgraph/ng_macfilter_test.sh index 482f32e5d335..85940e473951 100755 --- a/tests/sys/netgraph/ng_macfilter_test.sh +++ b/tests/sys/netgraph/ng_macfilter_test.sh @@ -235,8 +235,7 @@ test_title "Setting up system..." load_modules netgraph ng_socket ng_ether ng_macfilter ng_one2many eth=$(find_iface) if [ -z "$eth" ]; then - echo "1..1" - echo "not ok 1 - Could not find a valid interface" + echo "1..0 # SKIP could not find a valid interface" echo "Available interfaces:" ifconfig exit 1 From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 841B75E6D86; Sat, 10 Apr 2021 13:30:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTS71qNz3Jgq; Sat, 10 Apr 2021 13:30:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5C501223F; Sat, 10 Apr 2021 13:30:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU4Mq004284; Sat, 10 Apr 2021 13:30:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU4lc004282; Sat, 10 Apr 2021 13:30:04 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:04 GMT Message-Id: <202104101330.13ADU4lc004282@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 0eafcef4552c - stable/13 - RISC-V: Fix feenableexcept return value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0eafcef4552c8ce43a144eea724628a815c09700 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:05 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0eafcef4552c8ce43a144eea724628a815c09700 commit 0eafcef4552c8ce43a144eea724628a815c09700 Author: Alex Richardson AuthorDate: 2021-03-25 11:15:41 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 RISC-V: Fix feenableexcept return value The man page says "The feenableexcept(), fedisableexcept(), and fegetexcept() functions return a bitmap of the exceptions that were unmasked prior to the call.", so we should return zero not -1. Reviewed By: mhorne MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29386 (cherry picked from commit dd5ed53a2f93a5a54efe96bed6bbd0f18b6bdbe2) --- lib/msun/riscv/fenv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msun/riscv/fenv.h b/lib/msun/riscv/fenv.h index 6c8c2861bc97..f5c56f73b229 100644 --- a/lib/msun/riscv/fenv.h +++ b/lib/msun/riscv/fenv.h @@ -231,7 +231,7 @@ feenableexcept(int __mask __unused) /* No exception traps. */ - return (-1); + return (0); } static inline int From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 CFEFF5E6C38; Sat, 10 Apr 2021 13:30:06 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTV3jMKz3Jmv; Sat, 10 Apr 2021 13:30:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCCF112240; Sat, 10 Apr 2021 13:30:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU5g8004495; Sat, 10 Apr 2021 13:30:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU5Of004493; Sat, 10 Apr 2021 13:30:05 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:05 GMT Message-Id: <202104101330.13ADU5Of004493@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 3496971e61dc - stable/13 - lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3496971e61dc9f6e725e57fb7b5f0c57631bbfc2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:07 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=3496971e61dc9f6e725e57fb7b5f0c57631bbfc2 commit 3496971e61dc9f6e725e57fb7b5f0c57631bbfc2 Author: Alex Richardson AuthorDate: 2021-03-25 11:22:10 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations The error cases (goto fin) of _nsdispatch were missing the unlock. This change also drops the checks for __isthreaded since the pthread stubs are already no-ops if threads are not being used. Dropping those conditionals allows clang's thread safety analysis to deal with the file and also makes the code a bit more readable. While touching the file also add a few more assertions in debug mode that the right locks are held. Reviewed By: markj Differential Revision: https://reviews.freebsd.org/D29372 (cherry picked from commit 5245bf7b92b74e556527b4916a8deba386fe5772) --- lib/libc/net/nsdispatch.c | 201 +++++++++++++++++++++++++++++----------------- 1 file changed, 129 insertions(+), 72 deletions(-) diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c index b0f80d079b0b..d504a86d524b 100644 --- a/lib/libc/net/nsdispatch.c +++ b/lib/libc/net/nsdispatch.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -76,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -97,7 +99,52 @@ enum _nss_constants { * Global NSS data structures are mostly read-only, but we update * them when we read or re-read the nsswitch.conf. */ -static pthread_rwlock_t nss_lock = PTHREAD_RWLOCK_INITIALIZER; +static pthread_rwlock_t nss_lock = PTHREAD_RWLOCK_INITIALIZER; +#ifndef NDEBUG +static void *nss_wlock_owner __guarded_by(nss_lock); +#endif + +static inline /* __lock_annotate(locks_excluded(nss_lock)) */ +__locks_exclusive(nss_lock) int +nss_wlock(void) +{ + int err; + + err = _pthread_rwlock_wrlock(&nss_lock); +#ifndef NDEBUG + assert(nss_wlock_owner == NULL); + nss_wlock_owner = _pthread_self(); +#endif + assert(err == 0 && "Locking should not have failed!"); + return (err); +} + +/* + * XXX: The manpage says already held lock may result in EDEADLK, but + * actually libthr returns always EBUSY, so we need the extra owner + * variable for assertions. + */ +#define ASSERT_NSS_WLOCK_HELD() \ + do { \ + if (__isthreaded) { \ + assert(_pthread_rwlock_trywrlock(&nss_lock) == EBUSY); \ + assert(nss_wlock_owner == _pthread_self()); \ + } \ + } while (0) + +static inline __requires_exclusive(nss_lock) __unlocks(nss_lock) int +nss_wunlock(void) +{ + int err; + + ASSERT_NSS_WLOCK_HELD(); +#ifndef NDEBUG + nss_wlock_owner = NULL; +#endif + err = _pthread_rwlock_unlock(&nss_lock); + assert(err == 0 && "Unlocking should not have failed!"); + return (err); +} /* * Runtime determination of whether we are dynamically linked or not. @@ -114,12 +161,12 @@ const ns_src __nsdefaultsrc[] = { }; /* Database, source mappings. */ -static unsigned int _nsmapsize; -static ns_dbt *_nsmap = NULL; +static unsigned int _nsmapsize __guarded_by(nss_lock); +static ns_dbt *_nsmap __guarded_by(nss_lock); /* NSS modules. */ -static unsigned int _nsmodsize; -static ns_mod *_nsmod; +static unsigned int _nsmodsize __guarded_by(nss_lock); +static ns_mod *_nsmod __guarded_by(nss_lock); /* Placeholder for builtin modules' dlopen `handle'. */ static int __nss_builtin_handle; @@ -166,8 +213,7 @@ typedef int (*vector_comparison)(const void *, const void *); typedef void (*vector_free_elem)(void *); static void vector_sort(void *, unsigned int, size_t, vector_comparison); -static void vector_free(void *, unsigned int *, size_t, - vector_free_elem); +static void _vector_free(void *, unsigned int, size_t, vector_free_elem); static void *vector_ref(unsigned int, void *, unsigned int, size_t); static void *vector_search(const void *, void *, unsigned int, size_t, vector_comparison); @@ -238,22 +284,24 @@ vector_ref(unsigned int i, void *vec, unsigned int count, size_t esize) } -#define VECTOR_FREE(v, c, s, f) \ - do { vector_free(v, c, s, f); v = NULL; } while (0) +#define VECTOR_FREE(vec, count, es, fe) do { \ + _vector_free(vec, count, es, fe); \ + vec = NULL; \ + count = 0; \ +} while (0) static void -vector_free(void *vec, unsigned int *count, size_t esize, +_vector_free(void *vec, unsigned int count, size_t esize, vector_free_elem free_elem) { unsigned int i; void *elem; - for (i = 0; i < *count; i++) { - elem = vector_ref(i, vec, *count, esize); + for (i = 0; i < count; i++) { + elem = vector_ref(i, vec, count, esize); if (elem != NULL) free_elem(elem); } free(vec); - *count = 0; } /* @@ -282,13 +330,14 @@ mtab_compare(const void *a, const void *b) /* * NSS nsmap management. */ -void +__requires_exclusive(nss_lock) void _nsdbtaddsrc(ns_dbt *dbt, const ns_src *src) { const ns_mod *modp; - dbt->srclist = vector_append(src, dbt->srclist, &dbt->srclistsize, - sizeof(*src)); + ASSERT_NSS_WLOCK_HELD(); + dbt->srclist = vector_append(src, dbt->srclist, + (unsigned int *)&dbt->srclistsize, sizeof(*src)); modp = vector_search(&src->name, _nsmod, _nsmodsize, sizeof(*_nsmod), string_compare); if (modp == NULL) @@ -325,26 +374,28 @@ _nsdbtdump(const ns_dbt *dbt) } #endif +#ifndef NS_REREAD_CONF +static int __guarded_by(nss_lock) already_initialized = 0; +#endif /* * The first time nsdispatch is called (during a process's lifetime, * or after nsswitch.conf has been updated), nss_configure will * prepare global data needed by NSS. */ -static int -nss_configure(void) +static __requires_shared(nss_lock) int +__lock_annotate(no_thread_safety_analysis) /* RWLock upgrade not supported. */ +do_nss_configure(void) { - static time_t confmod; - static int already_initialized = 0; + static time_t __guarded_by(nss_lock) confmod = 0; struct stat statbuf; - int result, isthreaded; + int result; const char *path; #ifdef NS_CACHING void *handle; #endif result = 0; - isthreaded = __isthreaded; #if defined(_NSS_DEBUG) && defined(_NSS_SHOOT_FOOT) /* NOTE WELL: THIS IS A SECURITY HOLE. This must only be built * for debugging purposes and MUST NEVER be used in production. @@ -353,36 +404,33 @@ nss_configure(void) if (path == NULL) #endif path = _PATH_NS_CONF; + + result = _pthread_rwlock_unlock(&nss_lock); + if (result != 0) + return (result); + result = nss_wlock(); + if (result != 0) + return (result); #ifndef NS_REREAD_CONF /* - * Define NS_REREAD_CONF to have nsswitch notice changes - * to nsswitch.conf(5) during runtime. This involves calling - * stat(2) every time, which can result in performance hit. + * Another thread could have already run the initialization + * logic while we were waiting for the write lock. Check + * already_initialized to avoid re-initializing. */ if (already_initialized) - return (0); - already_initialized = 1; + goto fin; #endif /* NS_REREAD_CONF */ + ASSERT_NSS_WLOCK_HELD(); if (stat(path, &statbuf) != 0) - return (0); + goto fin; if (statbuf.st_mtime <= confmod) - return (0); - if (isthreaded) { - (void)_pthread_rwlock_unlock(&nss_lock); - result = _pthread_rwlock_wrlock(&nss_lock); - if (result != 0) - return (result); - if (stat(path, &statbuf) != 0) - goto fin; - if (statbuf.st_mtime <= confmod) - goto fin; - } + goto fin; _nsyyin = fopen(path, "re"); if (_nsyyin == NULL) goto fin; - VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), + VECTOR_FREE(_nsmap, _nsmapsize, sizeof(*_nsmap), (vector_free_elem)ns_dbt_free); - VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), + VECTOR_FREE(_nsmod, _nsmodsize, sizeof(*_nsmod), (vector_free_elem)ns_mod_free); if (confmod == 0) (void)atexit(nss_atexit); @@ -400,22 +448,42 @@ nss_configure(void) dlclose(handle); } #endif +#ifndef NS_REREAD_CONF + already_initialized = 1; +#endif fin: - if (isthreaded) { - (void)_pthread_rwlock_unlock(&nss_lock); - if (result == 0) - result = _pthread_rwlock_rdlock(&nss_lock); - } + result = nss_wunlock(); + if (result == 0) + result = _pthread_rwlock_rdlock(&nss_lock); + return (result); +} + +static __requires_shared(nss_lock) int +nss_configure(void) +{ + int result; +#ifndef NS_REREAD_CONF + /* + * Define NS_REREAD_CONF to have nsswitch notice changes + * to nsswitch.conf(5) during runtime. This involves calling + * stat(2) every time, which can result in performance hit. + */ + if (already_initialized) + return (0); +#endif /* NS_REREAD_CONF */ + result = do_nss_configure(); return (result); } -void +__requires_exclusive(nss_lock) void _nsdbtput(const ns_dbt *dbt) { unsigned int i; ns_dbt *p; + ASSERT_NSS_WLOCK_HELD(); + for (i = 0; i < _nsmapsize; i++) { p = vector_ref(i, _nsmap, _nsmapsize, sizeof(*_nsmap)); if (string_compare(&dbt->name, &p->name) == 0) { @@ -478,13 +546,15 @@ nss_load_builtin_modules(void) * argument is non-NULL, assume a built-in module and use reg_fn to * register it. Otherwise, search for a dynamic NSS module. */ -static void +static __requires_exclusive(nss_lock) void nss_load_module(const char *source, nss_module_register_fn reg_fn) { char buf[PATH_MAX]; ns_mod mod; nss_module_register_fn fn; + ASSERT_NSS_WLOCK_HELD(); + memset(&mod, 0, sizeof(mod)); mod.name = strdup(source); if (mod.name == NULL) { @@ -548,9 +618,9 @@ fin: vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare); } -static int exiting = 0; +static int exiting __guarded_by(nss_lock) = 0; -static void +static __requires_exclusive(nss_lock) void ns_mod_free(ns_mod *mod) { @@ -569,24 +639,19 @@ ns_mod_free(ns_mod *mod) static void nss_atexit(void) { - int isthreaded; - + (void)nss_wlock(); exiting = 1; - isthreaded = __isthreaded; - if (isthreaded) - (void)_pthread_rwlock_wrlock(&nss_lock); - VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), + VECTOR_FREE(_nsmap, _nsmapsize, sizeof(*_nsmap), (vector_free_elem)ns_dbt_free); - VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), + VECTOR_FREE(_nsmod, _nsmapsize, sizeof(*_nsmod), (vector_free_elem)ns_mod_free); - if (isthreaded) - (void)_pthread_rwlock_unlock(&nss_lock); + (void)nss_wunlock(); } /* * Finally, the actual implementation. */ -static nss_method +static __requires_shared(nss_lock) nss_method nss_method_lookup(const char *source, const char *database, const char *method, const ns_dtab disp_tab[], void **mdata) { @@ -625,7 +690,7 @@ fb_endstate(void *p) __weak_reference(_nsdispatch, nsdispatch); -int +__requires_unlocked(nss_lock) int _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, const char *method_name, const ns_src defaults[], ...) { @@ -634,7 +699,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, const ns_src *srclist; nss_method method, fb_method; void *mdata; - int isthreaded, serrno, i, result, srclistsize; + int serrno, i, result, srclistsize; struct fb_state *st; int saved_depth; @@ -647,15 +712,8 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, dbt = NULL; fb_method = NULL; - isthreaded = __isthreaded; serrno = errno; - if (isthreaded) { - result = _pthread_rwlock_rdlock(&nss_lock); - if (result != 0) { - result = NS_UNAVAIL; - goto fin; - } - } + (void)_pthread_rwlock_rdlock(&nss_lock); result = fb_getstate(&st); if (result != 0) { @@ -774,10 +832,9 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, } #endif /* NS_CACHING */ - if (isthreaded) - (void)_pthread_rwlock_unlock(&nss_lock); --st->dispatch_depth; fin: + (void)_pthread_rwlock_unlock(&nss_lock); errno = serrno; return (result); } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:08 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C7D015E6D94; Sat, 10 Apr 2021 13:30:08 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTX33xwz3Jh0; Sat, 10 Apr 2021 13:30:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DB1411DFB; Sat, 10 Apr 2021 13:30:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU7fN004922; Sat, 10 Apr 2021 13:30:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU7oI004920; Sat, 10 Apr 2021 13:30:07 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:07 GMT Message-Id: <202104101330.13ADU7oI004920@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 30626f9ad5ef - stable/13 - sys/dev/md: Drop unncessary __GLOBL(mfs_root) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 30626f9ad5effa12daa2f9f4b9c30c98e20b0200 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:09 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=30626f9ad5effa12daa2f9f4b9c30c98e20b0200 commit 30626f9ad5effa12daa2f9f4b9c30c98e20b0200 Author: Alex Richardson AuthorDate: 2021-03-30 13:53:41 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 sys/dev/md: Drop unncessary __GLOBL(mfs_root) LLVM12 complains if you change the symbol binding: error: mfs_root_end changed binding to STB_WEAK [-Werror,-Winline-asm] error: mfs_root changed binding to STB_WEAK [-Werror,-Winline-asm] (cherry picked from commit 69e18c9b7b12e7fd97a740d8748d8718021a1e34) --- sys/dev/md/md.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 5c2cb2f25d2e..c5c90d9173ad 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -187,8 +187,6 @@ int mfs_root_size; #else extern volatile u_char __weak_symbol mfs_root; extern volatile u_char __weak_symbol mfs_root_end; -__GLOBL(mfs_root); -__GLOBL(mfs_root_end); #define mfs_root_size ((uintptr_t)(&mfs_root_end - &mfs_root)) #endif #endif From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 81BC35E6CB5; Sat, 10 Apr 2021 13:30:09 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTY1sjwz3JbM; Sat, 10 Apr 2021 13:30:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 27176123EE; Sat, 10 Apr 2021 13:30:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU9Vu005130; Sat, 10 Apr 2021 13:30:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU9DR005127; Sat, 10 Apr 2021 13:30:09 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:09 GMT Message-Id: <202104101330.13ADU9DR005127@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: c5cde5af4b82 - stable/13 - resolv_test: Fix racy exit check, remove mutexes, and reduce output MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c5cde5af4b825ecb150e38c47fa60a0f1749a67a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:09 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=c5cde5af4b825ecb150e38c47fa60a0f1749a67a commit c5cde5af4b825ecb150e38c47fa60a0f1749a67a Author: Alex Richardson AuthorDate: 2021-03-30 14:00:16 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 resolv_test: Fix racy exit check, remove mutexes, and reduce output Instead of polling nleft[i] (without appropriate memory barriers!) and using sleep() to detect the exit just call pthread_join() on all threads. Also replace the use of a mutex that guarding the increments with atomic fetch_add. This should reduce the runtime of this test on SMP systems. Finally, remove all the debug printfs unless DEBUG_OUTPUT is set in the environment. Test Plan: still fails sometimes on qemu (but maybe less often?) Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D29390 (cherry picked from commit 85425bdc5a80c948f99aa046f9c48512466806dd) --- lib/libc/tests/resolv/resolv_test.c | 174 ++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/lib/libc/tests/resolv/resolv_test.c b/lib/libc/tests/resolv/resolv_test.c index 12f1dca76a56..4f17469fa0cb 100644 --- a/lib/libc/tests/resolv/resolv_test.c +++ b/lib/libc/tests/resolv/resolv_test.c @@ -38,6 +38,7 @@ __RCSID("$NetBSD: resolv.c,v 1.6 2004/05/23 16:59:11 christos Exp $"); #include #include #include +#include #include #include #include @@ -57,15 +58,19 @@ enum method { }; static StringList *hosts = NULL; -static int *ask = NULL; -static int *got = NULL; +static _Atomic(int) *ask = NULL; +static _Atomic(int) *got = NULL; +static bool debug_output = 0; static void load(const char *); -static void resolvone(int, enum method); +static void resolvone(long, int, enum method); static void *resolvloop(void *); -static void run(int *, enum method); +static pthread_t run(int, enum method, long); -static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; +#define DBG(...) do { \ + if (debug_output) \ + dprintf(STDOUT_FILENO, __VA_ARGS__); \ + } while (0) static void load(const char *fname) @@ -93,11 +98,11 @@ load(const char *fname) } static int -resolv_getaddrinfo(pthread_t self, char *host, int port) +resolv_getaddrinfo(long threadnum, char *host, int port, const char **errstr) { - char portstr[6], buf[1024], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; + char portstr[6], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; struct addrinfo hints, *res; - int error, len; + int error; snprintf(portstr, sizeof(portstr), "%d", port); memset(&hints, 0, sizeof(hints)); @@ -105,96 +110,85 @@ resolv_getaddrinfo(pthread_t self, char *host, int port) hints.ai_flags = AI_PASSIVE; hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(host, portstr, &hints, &res); - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, error ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); if (error == 0) { + DBG("T%ld: host %s ok\n", threadnum, host); memset(hbuf, 0, sizeof(hbuf)); memset(pbuf, 0, sizeof(pbuf)); getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf), - pbuf, sizeof(pbuf), 0); - len = snprintf(buf, sizeof(buf), - "%p: reverse %s %s\n", self, hbuf, pbuf); - (void)write(STDOUT_FILENO, buf, len); - } - if (error == 0) + pbuf, sizeof(pbuf), 0); + DBG("T%ld: reverse %s %s\n", threadnum, hbuf, pbuf); freeaddrinfo(res); + } else { + *errstr = gai_strerror(error); + DBG("T%ld: host %s not found: %s\n", threadnum, host, *errstr); + } return error; } static int -resolv_gethostby(pthread_t self, char *host) +resolv_gethostby(long threadnum, char *host, const char **errstr) { char buf[1024]; struct hostent *hp, *hp2; - int len; hp = gethostbyname(host); - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, (hp == NULL) ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); if (hp) { + DBG("T%ld: host %s ok\n", threadnum, host); memcpy(buf, hp->h_addr, hp->h_length); hp2 = gethostbyaddr(buf, hp->h_length, hp->h_addrtype); if (hp2) { - len = snprintf(buf, sizeof(buf), - "%p: reverse %s\n", self, hp2->h_name); - (void)write(STDOUT_FILENO, buf, len); + DBG("T%ld: reverse %s\n", threadnum, hp2->h_name); } + } else { + *errstr = hstrerror(h_errno); + DBG("T%ld: host %s not found: %s\n", threadnum, host, *errstr); } - return hp ? 0 : -1; + return hp ? 0 : h_errno; } static int -resolv_getipnodeby(pthread_t self, char *host) +resolv_getipnodeby(long threadnum, char *host, const char **errstr) { char buf[1024]; struct hostent *hp, *hp2; - int len, h_error; + int error = 0; - hp = getipnodebyname(host, AF_INET, 0, &h_error); - len = snprintf(buf, sizeof(buf), "%p: host %s %s\n", - self, host, (hp == NULL) ? "not found" : "ok"); - (void)write(STDOUT_FILENO, buf, len); + hp = getipnodebyname(host, AF_INET, 0, &error); if (hp) { + DBG("T%ld: host %s ok\n", threadnum, host); memcpy(buf, hp->h_addr, hp->h_length); hp2 = getipnodebyaddr(buf, hp->h_length, hp->h_addrtype, - &h_error); + &error); if (hp2) { - len = snprintf(buf, sizeof(buf), - "%p: reverse %s\n", self, hp2->h_name); - (void)write(STDOUT_FILENO, buf, len); - } - if (hp2) + DBG("T%ld: reverse %s\n", threadnum, hp2->h_name); freehostent(hp2); - } - if (hp) + } freehostent(hp); - return hp ? 0 : -1; + } else { + *errstr = hstrerror(error); + DBG("T%ld: host %s not found: %s\n", threadnum, host, *errstr); + } + return hp ? 0 : error; } static void -resolvone(int n, enum method method) +resolvone(long threadnum, int n, enum method method) { - char buf[1024]; - pthread_t self = pthread_self(); + const char* errstr = NULL; size_t i = (random() & 0x0fffffff) % hosts->sl_cur; char *host = hosts->sl_str[i]; - int error, len; + int error; - len = snprintf(buf, sizeof(buf), "%p: %d resolving %s %d\n", - self, n, host, (int)i); - (void)write(STDOUT_FILENO, buf, len); - error = 0; + DBG("T%ld: %d resolving %s %zd\n", threadnum, n, host, i); switch (method) { case METHOD_GETADDRINFO: - error = resolv_getaddrinfo(self, host, i); + error = resolv_getaddrinfo(threadnum, host, i, &errstr); break; case METHOD_GETHOSTBY: - error = resolv_gethostby(self, host); + error = resolv_gethostby(threadnum, host, &errstr); break; case METHOD_GETIPNODEBY: - error = resolv_getipnodeby(self, host); + error = resolv_getipnodeby(threadnum, host, &errstr); break; default: /* UNREACHABLE */ @@ -203,38 +197,43 @@ resolvone(int n, enum method method) abort(); break; } - pthread_mutex_lock(&stats); - ask[i]++; - got[i] += error == 0; - pthread_mutex_unlock(&stats); + atomic_fetch_add_explicit(&ask[i], 1, memory_order_relaxed); + if (error == 0) + atomic_fetch_add_explicit(&got[i], 1, memory_order_relaxed); + else if (got[i] != 0) + fprintf(stderr, + "T%ld ERROR after previous success for %s: %d (%s)\n", + threadnum, hosts->sl_str[i], error, errstr); } struct resolvloop_args { - int *nhosts; + int nhosts; enum method method; + long threadnum; }; static void * resolvloop(void *p) { struct resolvloop_args *args = p; + int nhosts = args->nhosts; - if (*args->nhosts == 0) { + if (nhosts == 0) { free(args); return NULL; } - do - resolvone(*args->nhosts, args->method); - while (--(*args->nhosts)); + do { + resolvone(args->threadnum, nhosts, args->method); + } while (--nhosts); free(args); - return NULL; + return (void *)(uintptr_t)nhosts; } -static void -run(int *nhosts, enum method method) +static pthread_t +run(int nhosts, enum method method, long i) { - pthread_t self; + pthread_t t; int rc; struct resolvloop_args *args; @@ -244,59 +243,60 @@ run(int *nhosts, enum method method) args->nhosts = nhosts; args->method = method; - self = pthread_self(); - rc = pthread_create(&self, NULL, resolvloop, args); + args->threadnum = i + 1; + rc = pthread_create(&t, NULL, resolvloop, args); ATF_REQUIRE_MSG(rc == 0, "pthread_create failed: %s", strerror(rc)); + return t; } static int run_tests(const char *hostlist_file, enum method method) { size_t nthreads = NTHREADS; + pthread_t *threads; size_t nhosts = NHOSTS; size_t i; - int c, done, *nleft; + int c; hosts = sl_init(); srandom(1234); + debug_output = getenv("DEBUG_OUTPUT") != NULL; load(hostlist_file); ATF_REQUIRE_MSG(0 < hosts->sl_cur, "0 hosts in %s", hostlist_file); - nleft = malloc(nthreads * sizeof(int)); - ATF_REQUIRE(nleft != NULL); - ask = calloc(hosts->sl_cur, sizeof(int)); ATF_REQUIRE(ask != NULL); got = calloc(hosts->sl_cur, sizeof(int)); ATF_REQUIRE(got != NULL); + threads = calloc(nthreads, sizeof(pthread_t)); + ATF_REQUIRE(threads != NULL); + for (i = 0; i < nthreads; i++) { - nleft[i] = nhosts; - run(&nleft[i], method); + threads[i] = run(nhosts, method, i); } + /* Wait for all threads to join and check that they checked all hosts */ + for (i = 0; i < nthreads; i++) { + size_t remaining; - for (done = 0; !done;) { - done = 1; - for (i = 0; i < nthreads; i++) { - if (nleft[i] != 0) { - done = 0; - break; - } - } - sleep(1); + remaining = (uintptr_t)pthread_join(threads[i], NULL); + ATF_CHECK_EQ_MSG(0, remaining, + "Thread %zd still had %zd hosts to check!", i, remaining); } + c = 0; for (i = 0; i < hosts->sl_cur; i++) { - if (ask[i] != got[i] && got[i] != 0) { - printf("Error: host %s ask %d got %d\n", - hosts->sl_str[i], ask[i], got[i]); - c++; + if (got[i] != 0) { + ATF_CHECK_EQ_MSG(ask[i], got[i], + "Error: host %s ask %d got %d", hosts->sl_str[i], + ask[i], got[i]); + c += ask[i] != got[i]; } } - free(nleft); + free(threads); free(ask); free(got); sl_free(hosts, 1); From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7051D5E6C3B; Sat, 10 Apr 2021 13:30:07 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTW1NJYz3JQ6; Sat, 10 Apr 2021 13:30:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EAB2A123ED; Sat, 10 Apr 2021 13:30:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADU62D004710; Sat, 10 Apr 2021 13:30:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADU6Na004708; Sat, 10 Apr 2021 13:30:06 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:06 GMT Message-Id: <202104101330.13ADU6Na004708@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 52b6501bd7de - stable/13 - libsa: Remove conflicting .global/.weak directive MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 52b6501bd7de28af8cfdfc62b8763dd580ba8ca3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:07 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=52b6501bd7de28af8cfdfc62b8763dd580ba8ca3 commit 52b6501bd7de28af8cfdfc62b8763dd580ba8ca3 Author: Alex Richardson AuthorDate: 2021-03-30 13:52:31 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 libsa: Remove conflicting .global/.weak directive LLVM12 complains if you change the symbol binding: `error: _longjmp changed binding to STB_GLOBAL` In this case LLVM actually ignored the weak directive and used the later .global, but GNU as would mark the symbol as weak. None of the other architectures mark the libsa _setjmp as weak so just drop this directive. (cherry picked from commit 59b2caef0537661397caf2ce1398cf802cb864b4) --- stand/libsa/amd64/_setjmp.S | 1 - 1 file changed, 1 deletion(-) diff --git a/stand/libsa/amd64/_setjmp.S b/stand/libsa/amd64/_setjmp.S index 6d9a5fa13f8d..53ea6e9b5d52 100644 --- a/stand/libsa/amd64/_setjmp.S +++ b/stand/libsa/amd64/_setjmp.S @@ -63,7 +63,6 @@ ENTRY(_setjmp) ret END(_setjmp) - .weak CNAME(_longjmp) ENTRY(_longjmp) movq %rdi,%rdx /* Restore the mxcsr, but leave exception flags intact. */ From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 2F7855E6CBD; Sat, 10 Apr 2021 13:30:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTZ2rxJz3Jn5; Sat, 10 Apr 2021 13:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C176123EF; Sat, 10 Apr 2021 13:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADUAvm005340; Sat, 10 Apr 2021 13:30:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADUACI005337; Sat, 10 Apr 2021 13:30:10 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:10 GMT Message-Id: <202104101330.13ADUACI005337@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 676010ab86f5 - stable/13 - tests/sys/net/routing: XFAIL the two failing tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 676010ab86f51643a2382cbd222102181c746d00 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:11 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=676010ab86f51643a2382cbd222102181c746d00 commit 676010ab86f51643a2382cbd222102181c746d00 Author: Alex Richardson AuthorDate: 2021-04-07 09:33:21 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 tests/sys/net/routing: XFAIL the two failing tests They have been failing for 1.5 months and the patch to fix them is stuck in review so mark them as XFAIL for now to get Jenkins back to green. To be reverted when https://reviews.freebsd.org/D28886 (or similar) is commited. Reviewed By: kp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29528 (cherry picked from commit 83532eb68cd06a3517bb7b5e5a34afcf798de914) --- tests/sys/net/routing/test_rtsock_l3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/sys/net/routing/test_rtsock_l3.c b/tests/sys/net/routing/test_rtsock_l3.c index 9486ac466965..91816679400f 100644 --- a/tests/sys/net/routing/test_rtsock_l3.c +++ b/tests/sys/net/routing/test_rtsock_l3.c @@ -383,6 +383,9 @@ ATF_TC_BODY(rtm_get_v4_hostbits_failure, tc) { DECLARE_TEST_VARS; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_expect_fail("Needs https://reviews.freebsd.org/D28886"); + c = presetup_ipv4(tc); /* Q the same prefix */ @@ -447,6 +450,9 @@ ATF_TC_BODY(rtm_add_v4_no_rtf_host_failure, tc) { DECLARE_TEST_VARS; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_expect_fail("Needs https://reviews.freebsd.org/D28886"); + c = presetup_ipv4(tc); /* Create IPv4 subnetwork with smaller prefix */ From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 B38405E6E12; Sat, 10 Apr 2021 13:30:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTb65p1z3Jks; Sat, 10 Apr 2021 13:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4EC3F123F0; Sat, 10 Apr 2021 13:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADUBLS005599; Sat, 10 Apr 2021 13:30:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADUBPh005593; Sat, 10 Apr 2021 13:30:11 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:11 GMT Message-Id: <202104101330.13ADUBPh005593@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: d612bd6d0d5d - stable/13 - libarchive: Make test_read_append_filter_wrong_program pass again MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d612bd6d0d5dc5bc8e6ac10aec845e2ae2fe933b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:12 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=d612bd6d0d5dc5bc8e6ac10aec845e2ae2fe933b commit d612bd6d0d5dc5bc8e6ac10aec845e2ae2fe933b Author: Alex Richardson AuthorDate: 2021-04-07 10:35:10 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:05 +0000 libarchive: Make test_read_append_filter_wrong_program pass again libarchive: Apply upstream commit a1b7bf8013fb7a11a486794247daae592db6f5ae This fixes the failing test_read_append_filter_wrong_program test in CI which has been failing since 01-Dec-2020. Commit message from https://github.com/libarchive/libarchive/commit/a1b7bf8013fb7a11a486794247daae592db6f5ae Silence stderr in test_read_append_filter_program When the FreeBSD testsuite runs the libarchive tests it checks that stderr is empty. Since #1382 this is no longer the case. This change restores the behaviour of silencing bunzip2 stderr but doesn't bring back the output text check. Partially reverts 2e7aa5d9 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29036 (cherry picked from commit 2bca8aa7a79ad2b6683e8f5a5c373de81c5baca2) --- .../libarchive/test/test_read_set_format.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contrib/libarchive/libarchive/test/test_read_set_format.c b/contrib/libarchive/libarchive/test/test_read_set_format.c index f357bada82c3..c760de0056d3 100644 --- a/contrib/libarchive/libarchive/test/test_read_set_format.c +++ b/contrib/libarchive/libarchive/test/test_read_set_format.c @@ -201,6 +201,11 @@ DEFINE_TEST(test_read_append_filter_wrong_program) { struct archive_entry *ae; struct archive *a; +#if !defined(_WIN32) || defined(__CYGWIN__) + FILE * fp; + int fd; + fpos_t pos; +#endif /* * If we have "bunzip2 -q", try using that. @@ -210,6 +215,14 @@ DEFINE_TEST(test_read_append_filter_wrong_program) return; } +#if !defined(_WIN32) || defined(__CYGWIN__) + /* bunzip2 will write to stderr, redirect it to a file */ + fflush(stderr); + fgetpos(stderr, &pos); + assert((fd = dup(fileno(stderr))) != -1); + fp = freopen("stderr1", "w", stderr); +#endif + assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR)); assertEqualIntA(a, ARCHIVE_OK, @@ -219,4 +232,15 @@ DEFINE_TEST(test_read_append_filter_wrong_program) assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN)); assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + +#if !defined(_WIN32) || defined(__CYGWIN__) + /* restore stderr */ + if (fp != NULL) { + fflush(stderr); + dup2(fd, fileno(stderr)); + clearerr(stderr); + (void)fsetpos(stderr, &pos); + } + close(fd); +#endif } From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:30:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 3AE615E6D55; Sat, 10 Apr 2021 13:30:13 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHbTc5K4Yz3JsV; Sat, 10 Apr 2021 13:30:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6BBF611D76; Sat, 10 Apr 2021 13:30:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADUCqq006075; Sat, 10 Apr 2021 13:30:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADUCHv006073; Sat, 10 Apr 2021 13:30:12 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:30:12 GMT Message-Id: <202104101330.13ADUCHv006073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 7755e8ae322b - stable/13 - ifconfig: fix UBSan signed shift error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7755e8ae322b63875d7f7f426e61ce0bcb9e0086 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:30:13 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=7755e8ae322b63875d7f7f426e61ce0bcb9e0086 commit 7755e8ae322b63875d7f7f426e61ce0bcb9e0086 Author: Alex Richardson AuthorDate: 2021-01-19 11:35:21 +0000 Commit: Alex Richardson CommitDate: 2021-04-10 13:01:56 +0000 ifconfig: fix UBSan signed shift error Use 1u since UBSan complains about 1 << 31. (cherry picked from commit 94ac312a71683a3a1a928c6adfe927d6bb45044f) --- sbin/ifconfig/ifconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 8b1a242db634..5e114b43c126 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1515,7 +1515,7 @@ printb(const char *s, unsigned v, const char *bits) bits++; putchar('<'); while ((i = *bits++) != '\0') { - if (v & (1 << (i-1))) { + if (v & (1u << (i-1))) { if (any) putchar(','); any = 1; From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:58:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7F61E5CC8A0; Sat, 10 Apr 2021 13:58:33 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHc6K3DhQz3MDC; Sat, 10 Apr 2021 13:58:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61B9112923; Sat, 10 Apr 2021 13:58:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADwXdn041181; Sat, 10 Apr 2021 13:58:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADwXro041180; Sat, 10 Apr 2021 13:58:33 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:58:33 GMT Message-Id: <202104101358.13ADwXro041180@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 9535440569ca - stable/13 - amd64: implement strlen in assembly, take 2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9535440569ca468b12030142d6631704b658ece6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:58:33 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9535440569ca468b12030142d6631704b658ece6 commit 9535440569ca468b12030142d6631704b658ece6 Author: Mateusz Guzik AuthorDate: 2021-04-10 13:52:49 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 13:53:46 +0000 amd64: implement strlen in assembly, take 2 Tested with glibc test suite. The C variant in libkern performs excessive branching to find the zero byte instead of using the bsfq instruction. The same code patched to use it is still slower than the routine implemented here as the compiler keeps neglecting to perform certain optimizations (like using leaq). On top of that the routine can be used as a starting point for copyinstr which operates on words intead of bytes. The previous attempt had an instance of swapped operands to andq when dealing with fully aligned case, which had a side effect of breaking the code for certain corner cases. Noted by jrtc27. Sample results: $(perl -e "print 'A' x 3"): stock: 211198039 patched:338626619 asm: 465609618 $(perl -e "print 'A' x 100"): stock: 83151997 patched: 98285919 asm: 120719888 Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D28779 (cherry picked from commit 5fa12fe0cd203efcbb2ac21e7c3e3fb9b2f801ae) --- sys/amd64/amd64/support.S | 66 +++++++++++++++++++++++++++++++++++++++++++++++ sys/conf/files | 1 - sys/conf/files.arm | 1 + sys/conf/files.i386 | 1 + sys/conf/files.mips | 1 + sys/conf/files.powerpc | 1 + sys/conf/files.riscv | 1 + 7 files changed, 71 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index b623fba277db..4c0f7da87ef8 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -697,6 +697,72 @@ ENTRY(fillw) ret END(fillw) +/* + * strlen(string) + * %rdi + * + * Uses the ((x - 0x01....01) & ~x & 0x80....80) trick. + * + * 0x01....01 is replaced with 0x0 - 0x01....01 so that it can be added + * with leaq. + * + * For a description see either: + * - "Hacker's Delight" by Henry S. Warren, Jr. + * - "Optimizing subroutines in assembly language: An optimization guide for x86 platforms" + * by Agner Fog + * + * The latter contains a 32-bit variant of the same algorithm coded in assembly for i386. + */ +ENTRY(strlen) + PUSH_FRAME_POINTER + movabsq $0xfefefefefefefeff,%r8 + movabsq $0x8080808080808080,%r9 + + movq %rdi,%r10 + movq %rdi,%rcx + testb $7,%dil + jz 2f + + /* + * Handle misaligned reads: align to 8 and fill + * the spurious bytes. + */ + andq $~7,%rdi + movq (%rdi),%r11 + shlq $3,%rcx + movq $-1,%rdx + shlq %cl,%rdx + notq %rdx + orq %rdx,%r11 + + leaq (%r11,%r8),%rcx + notq %r11 + andq %r11,%rcx + andq %r9,%rcx + jnz 3f + + /* + * Main loop. + */ + ALIGN_TEXT +1: + leaq 8(%rdi),%rdi +2: + movq (%rdi),%r11 + leaq (%r11,%r8),%rcx + notq %r11 + andq %r11,%rcx + andq %r9,%rcx + jz 1b +3: + bsfq %rcx,%rcx + shrq $3,%rcx + leaq (%rcx,%rdi),%rax + subq %r10,%rax + POP_FRAME_POINTER + ret +END(strlen) + /*****************************************************************************/ /* copyout and fubyte family */ /*****************************************************************************/ diff --git a/sys/conf/files b/sys/conf/files index e68aa2118791..9ec7292a741b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4086,7 +4086,6 @@ libkern/strdup.c standard libkern/strndup.c standard libkern/strlcat.c standard libkern/strlcpy.c standard -libkern/strlen.c standard libkern/strncat.c standard libkern/strncmp.c standard libkern/strncpy.c standard diff --git a/sys/conf/files.arm b/sys/conf/files.arm index eb3a23b5fc21..69986585bdf6 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -127,6 +127,7 @@ libkern/lshrdi3.c standard libkern/memcmp.c standard libkern/moddi3.c standard libkern/qdivrem.c standard +libkern/strlen.c standard libkern/ucmpdi2.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index b5192e47a738..de759a9f7c83 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -219,6 +219,7 @@ libkern/memcmp.c standard libkern/memset.c standard libkern/moddi3.c standard libkern/qdivrem.c standard +libkern/strlen.c standard libkern/ucmpdi2.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard diff --git a/sys/conf/files.mips b/sys/conf/files.mips index c18f0a5c69be..7ee5b0019bd7 100644 --- a/sys/conf/files.mips +++ b/sys/conf/files.mips @@ -66,6 +66,7 @@ libkern/ucmpdi2.c optional mips | mipshf | mipsel | mipselhf libkern/ashldi3.c standard libkern/ashrdi3.c standard libkern/memcmp.c standard +libkern/strlen.c standard # cfe support dev/cfe/cfe_api.c optional cfe diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index 3022fd6f6e39..347abee153d2 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -129,6 +129,7 @@ libkern/memcmp.c standard libkern/memset.c standard libkern/moddi3.c optional powerpc | powerpcspe libkern/qdivrem.c optional powerpc | powerpcspe +libkern/strlen.c standard libkern/ucmpdi2.c optional powerpc | powerpcspe libkern/udivdi3.c optional powerpc | powerpcspe libkern/umoddi3.c optional powerpc | powerpcspe diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index 3969528db07e..7ecea016b9a3 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -29,6 +29,7 @@ libkern/flsl.c standard libkern/flsll.c standard libkern/memcmp.c standard libkern/memset.c standard +libkern/strlen.c standard riscv/riscv/autoconf.c standard riscv/riscv/bus_machdep.c standard riscv/riscv/bus_space_asm.S standard From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 13:58:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 C35895CC549; Sat, 10 Apr 2021 13:58:34 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHc6L4npBz3MDF; Sat, 10 Apr 2021 13:58:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8785A12997; Sat, 10 Apr 2021 13:58:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13ADwYRe041202; Sat, 10 Apr 2021 13:58:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13ADwY3a041201; Sat, 10 Apr 2021 13:58:34 GMT (envelope-from git) Date: Sat, 10 Apr 2021 13:58:34 GMT Message-Id: <202104101358.13ADwY3a041201@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: c16fc9eae3ad - stable/13 - amd64: import asm strlen into libc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c16fc9eae3adca98f6d12ec4f54e043db1f8902b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 13:58:34 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c16fc9eae3adca98f6d12ec4f54e043db1f8902b commit c16fc9eae3adca98f6d12ec4f54e043db1f8902b Author: Mateusz Guzik AuthorDate: 2021-02-21 21:20:04 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 13:54:12 +0000 amd64: import asm strlen into libc Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D28845 (cherry picked from commit 7f06b217c53c3f5e4ac81eb11125adfb71359ac6) --- lib/libc/amd64/string/Makefile.inc | 1 + lib/libc/amd64/string/strlen.S | 81 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc index db88ac723539..cb370bc6be1c 100644 --- a/lib/libc/amd64/string/Makefile.inc +++ b/lib/libc/amd64/string/Makefile.inc @@ -8,4 +8,5 @@ MDSRCS+= \ memset.S \ strcat.S \ strcmp.S \ + strlen.S \ stpcpy.S diff --git a/lib/libc/amd64/string/strlen.S b/lib/libc/amd64/string/strlen.S new file mode 100644 index 000000000000..1d2428e3420e --- /dev/null +++ b/lib/libc/amd64/string/strlen.S @@ -0,0 +1,81 @@ +/* + * Written by Mateusz Guzik + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Note: this routine was written with kernel use in mind (read: no simd), + * it is only present in userspace as a temporary measure until something + * better gets imported. + */ + +#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ + +/* + * strlen(string) + * %rdi + * + * Uses the ((x - 0x01....01) & ~x & 0x80....80) trick. + * + * 0x01....01 is replaced with 0x0 - 0x01....01 so that it can be added + * with leaq. + * + * For a description see either: + * - "Hacker's Delight" by Henry S. Warren, Jr. + * - "Optimizing subroutines in assembly language: An optimization guide for x86 platforms" + * by Agner Fog + * + * The latter contains a 32-bit variant of the same algorithm coded in assembly for i386. + */ +ENTRY(strlen) + movabsq $0xfefefefefefefeff,%r8 + movabsq $0x8080808080808080,%r9 + + movq %rdi,%r10 + movq %rdi,%rcx + testb $7,%dil + jz 2f + + /* + * Handle misaligned reads: align to 8 and fill + * the spurious bytes. + */ + andq $~7,%rdi + movq (%rdi),%r11 + shlq $3,%rcx + movq $-1,%rdx + shlq %cl,%rdx + notq %rdx + orq %rdx,%r11 + + leaq (%r11,%r8),%rcx + notq %r11 + andq %r11,%rcx + andq %r9,%rcx + jnz 3f + + /* + * Main loop. + */ + ALIGN_TEXT +1: + leaq 8(%rdi),%rdi +2: + movq (%rdi),%r11 + leaq (%r11,%r8),%rcx + notq %r11 + andq %r11,%rcx + andq %r9,%rcx + jz 1b +3: + bsfq %rcx,%rcx + shrq $3,%rcx + leaq (%rcx,%rdi),%rax + subq %r10,%rax + ret +END(strlen) + + .section .note.GNU-stack,"",%progbits From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 14:01:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 44F6B5CC8DD; Sat, 10 Apr 2021 14:01:47 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHcB31XKwz3My6; Sat, 10 Apr 2021 14:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 27B4D12C26; Sat, 10 Apr 2021 14:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13AE1lXv055050; Sat, 10 Apr 2021 14:01:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13AE1l15055049; Sat, 10 Apr 2021 14:01:47 GMT (envelope-from git) Date: Sat, 10 Apr 2021 14:01:47 GMT Message-Id: <202104101401.13AE1l15055049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 8393e034dace - stable/13 - cache: temporarily drop the assert that dvp != vp when adding an entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8393e034dacec0bbafdd470c3cceaecc693357ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 14:01:47 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8393e034dacec0bbafdd470c3cceaecc693357ea commit 8393e034dacec0bbafdd470c3cceaecc693357ea Author: Mateusz Guzik AuthorDate: 2021-02-27 22:23:23 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 14:00:57 +0000 cache: temporarily drop the assert that dvp != vp when adding an entry Historically it was allowed for any names, but arguably should never be even attempted. Allow it again since there is a release pending and allowing it is bug-compatible with previous behavior. Reported by: otis (cherry picked from commit 1239a722214c245e642733fdea2b1348101598af) --- sys/kern/vfs_cache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index b5fa21eea887..8819ef483af5 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2394,7 +2394,12 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, KASSERT(cnp->cn_namelen <= NAME_MAX, ("%s: passed len %ld exceeds NAME_MAX (%d)", __func__, cnp->cn_namelen, NAME_MAX)); +#ifdef notyet + /* + * Not everything doing this is weeded out yet. + */ VNPASS(dvp != vp, dvp); +#endif VNPASS(!VN_IS_DOOMED(dvp), dvp); VNPASS(dvp->v_type != VNON, dvp); if (vp != NULL) { From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 14:20:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 DB6085CD720; Sat, 10 Apr 2021 14:20:47 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHcbz5lTcz3Nk4; Sat, 10 Apr 2021 14:20:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B859712D3E; Sat, 10 Apr 2021 14:20:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13AEKlbw077146; Sat, 10 Apr 2021 14:20:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13AEKlfK077140; Sat, 10 Apr 2021 14:20:47 GMT (envelope-from git) Date: Sat, 10 Apr 2021 14:20:47 GMT Message-Id: <202104101420.13AEKlfK077140@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: 0ca6ce5e976a - stable/13 - [bc] Update to version 4.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0ca6ce5e976a045ab1e81ec3469957a64f15ab12 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 14:20:47 -0000 The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=0ca6ce5e976a045ab1e81ec3469957a64f15ab12 commit 0ca6ce5e976a045ab1e81ec3469957a64f15ab12 Author: Stefan Eßer AuthorDate: 2021-04-06 08:44:52 +0000 Commit: Stefan Eßer CommitDate: 2021-04-10 14:18:50 +0000 [bc] Update to version 4.0.0 This version fixes an issue (missing pop of top-of-stack value in the "P" command of the dc program). This issue did not affect the bc program, since it does not use dc as an back-end to actually perform the calculations as was the case with the traditional bc and dc programs. The major number has been bumped due to Windows support that has been added to this version. It does not correspond to a major change that might affect FreeBSD. (cherry picked from commit b55a927bc884d7780d65a508572023b0dc2dede9) --- contrib/bc/Makefile.in | 11 +- contrib/bc/NEWS.md | 25 + contrib/bc/README.md | 107 +- contrib/bc/bc.sln | 31 + contrib/bc/bc.vcxproj | 278 +++++ contrib/bc/bc.vcxproj.filters | 182 ++++ contrib/bc/bcl.sln | 31 + contrib/bc/bcl.vcxproj | 161 +++ contrib/bc/bcl.vcxproj.filters | 96 ++ contrib/bc/configure | 1322 ++++++++++++++++++++++- contrib/bc/configure.sh | 2 + contrib/bc/gen/bc_help.txt | 19 +- contrib/bc/gen/dc_help.txt | 17 +- contrib/bc/gen/strgen.c | 56 +- contrib/bc/include/bcl.h | 102 ++ contrib/bc/include/file.h | 34 +- contrib/bc/include/history.h | 3 + contrib/bc/include/num.h | 3 +- contrib/bc/include/status.h | 59 - contrib/bc/include/version.h | 41 + contrib/bc/include/vm.h | 32 +- contrib/bc/karatsuba.py | 10 +- contrib/bc/manpage.sh | 2 +- contrib/bc/manuals/bc.1.md.in | 23 +- contrib/bc/manuals/bc/A.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/A.1.md | 18 +- contrib/bc/manuals/bc/E.1 | 905 +++++++++------- contrib/bc/manuals/bc/E.1.md | 18 +- contrib/bc/manuals/bc/EH.1 | 905 +++++++++------- contrib/bc/manuals/bc/EH.1.md | 18 +- contrib/bc/manuals/bc/EHN.1 | 905 +++++++++------- contrib/bc/manuals/bc/EHN.1.md | 18 +- contrib/bc/manuals/bc/EHNP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EHNP.1.md | 8 +- contrib/bc/manuals/bc/EHP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EHP.1.md | 8 +- contrib/bc/manuals/bc/EN.1 | 905 +++++++++------- contrib/bc/manuals/bc/EN.1.md | 18 +- contrib/bc/manuals/bc/ENP.1 | 894 +++++++++------- contrib/bc/manuals/bc/ENP.1.md | 8 +- contrib/bc/manuals/bc/EP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EP.1.md | 8 +- contrib/bc/manuals/bc/H.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/H.1.md | 18 +- contrib/bc/manuals/bc/HN.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/HN.1.md | 18 +- contrib/bc/manuals/bc/HNP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/HNP.1.md | 8 +- contrib/bc/manuals/bc/HP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/HP.1.md | 8 +- contrib/bc/manuals/bc/N.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/N.1.md | 18 +- contrib/bc/manuals/bc/NP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/NP.1.md | 8 +- contrib/bc/manuals/bc/P.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/P.1.md | 8 +- contrib/bc/manuals/bcl.3 | 1751 +++++++++++++++--------------- contrib/bc/manuals/build.md | 121 ++- contrib/bc/manuals/dc.1.md.in | 61 +- contrib/bc/manuals/dc/A.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/A.1.md | 56 +- contrib/bc/manuals/dc/E.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/E.1.md | 56 +- contrib/bc/manuals/dc/EH.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EH.1.md | 56 +- contrib/bc/manuals/dc/EHN.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EHN.1.md | 56 +- contrib/bc/manuals/dc/EHNP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EHNP.1.md | 46 +- contrib/bc/manuals/dc/EHP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EHP.1.md | 46 +- contrib/bc/manuals/dc/EN.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EN.1.md | 56 +- contrib/bc/manuals/dc/ENP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/ENP.1.md | 46 +- contrib/bc/manuals/dc/EP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EP.1.md | 46 +- contrib/bc/manuals/dc/H.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/H.1.md | 56 +- contrib/bc/manuals/dc/HN.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/HN.1.md | 56 +- contrib/bc/manuals/dc/HNP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/HNP.1.md | 46 +- contrib/bc/manuals/dc/HP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/HP.1.md | 46 +- contrib/bc/manuals/dc/N.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/N.1.md | 56 +- contrib/bc/manuals/dc/NP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/NP.1.md | 46 +- contrib/bc/manuals/dc/P.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/P.1.md | 46 +- contrib/bc/manuals/header_bc.txt | 2 +- contrib/bc/manuals/header_bcl.txt | 2 +- contrib/bc/manuals/header_dc.txt | 2 +- contrib/bc/release.sh | 33 +- contrib/bc/src/args.c | 9 + contrib/bc/src/data.c | 6 + contrib/bc/src/file.c | 71 +- contrib/bc/src/history.c | 63 +- contrib/bc/src/main.c | 6 +- contrib/bc/src/num.c | 29 +- contrib/bc/src/program.c | 36 +- contrib/bc/src/rand.c | 36 +- contrib/bc/src/read.c | 29 +- contrib/bc/src/vm.c | 132 ++- contrib/bc/tests/dc/scripts/easter.sh | 47 + contrib/bc/tests/other.sh | 37 +- usr.bin/gh-bc/Makefile | 2 - 108 files changed, 28963 insertions(+), 20119 deletions(-) diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index aab7f9b569e5..2b50476a79fe 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -29,8 +29,6 @@ # .POSIX: -VERSION = 3.3.4 - SRC = %%SRC%% OBJ = %%OBJ%% GCDA = %%GCDA%% @@ -128,6 +126,8 @@ MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX) EXEC = $(%%EXEC%%) NLSPATH = %%NLSPATH%% +BC_BUILD_TYPE = %%BUILD_TYPE%% + BC_ENABLE_LIBRARY = %%LIBRARY%% BC_ENABLE_HISTORY = %%HISTORY%% @@ -158,7 +158,7 @@ TEST_STARS = "****************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) -CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DVERSION=$(VERSION) %%LONG_BIT_DEFINE%% +CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%% CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC) CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) @@ -322,9 +322,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -version: - @printf '%s' "$(VERSION)" - libcname: @printf '%s' "$(BC_LIB_C)" @@ -341,6 +338,7 @@ clean_gen: clean:%%CLEAN_PREREQS%% @printf 'Cleaning files...\n' + @$(RM) -f src/*.tmp gen/*.tmp @$(RM) -f $(OBJ) @$(RM) -f $(BC_EXEC) @$(RM) -f $(DC_EXEC) @@ -352,6 +350,7 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(DC_HELP_C) $(DC_HELP_O) @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) + @$(RM) -fr Debug/ Release/ clean_config: clean @printf 'Cleaning config...\n' diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index 3374ab57bc41..011cb9138912 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,30 @@ # News +## 4.0.0 + +This is a production release with many fixes, a new command-line option, and a +big surprise: + +* A bug was fixed in `dc`'s `P` command where the item on the stack was *not* + popped. +* Various bugs in the manuals have been fixed. +* A known bug was fixed where history did not interact well with prompts printed + by user code without newlines. +* A new command-line option, `-R` and `--no-read-prompt` was added to disable + just the prompt when using `read()` (`bc`) or `?` (`dc`). +* And finally, **official support for Windows was added**. + +The last item is why this is a major version bump. + +Currently, only one set of build options (extra math and prompt enabled, history +and NLS/locale support disabled, both calculators enabled) is supported on +Windows. However, both debug and release builds are supported. + +In addition, Windows builds are supported for the the library (`bcl`). + +For more details about how to build on Windows, see the [README][5] or the +[build manual][13]. + ## 3.3.4 This is a production release that fixes a small bug. diff --git a/contrib/bc/README.md b/contrib/bc/README.md index 6a37a8bfb8da..852c8956a73d 100644 --- a/contrib/bc/README.md +++ b/contrib/bc/README.md @@ -24,13 +24,16 @@ This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD ## Prerequisites -This `bc` only requires a C99-compatible compiler and a (mostly) POSIX -2008-compatible system with the XSI (X/Open System Interfaces) option group. +This `bc` only requires either: + +1. Windows 10 or later, or +2. A C99-compatible compiler and a (mostly) POSIX 2008-compatible system with + the XSI (X/Open System Interfaces) option group. Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any POSIX and XSI-compatible system will have everything needed. -Systems that are known to work: +POSIX-compatible systems that are known to work: * Linux * FreeBSD @@ -41,17 +44,68 @@ Systems that are known to work: * AIX * HP-UX* (except for history) +In addition, there is compatibility code to make this `bc` work on Windows. + Please submit bug reports if this `bc` does not build out of the box on any -system besides Windows. +system. ## Build -This `bc` should build unmodified on any POSIX-compliant system. +### Windows + +There is no guarantee that this `bc` will work on any version of Windows earlier +than Windows 10 (I cannot test on earlier versions), but it is guaranteed to +work on Windows 10 at least. + +Also, if building with MSBuild, the MSBuild bundled with Visual Studio is +required. + +**Note**: Unlike the POSIX-compatible platforms, only one build configuration is +supported on Windows: extra math and prompt enabled, history and NLS (locale +support) disabled, with both calculators built. + +#### `bc` + +To build `bc`, you can open the `bc.sln` file in Visual Studio, select the +configuration, and build. + +You can also build using MSBuild with the following from the root directory: + +``` +msbuild -property:Configuration= bc.sln +``` + +where `` is either one of `Debug` or `Release`. + +#### `bcl` (Library) + +To build the library, you can open the `bcl.sln` file in Visual Studio, select +the configuration, and build. + +You can also build using MSBuild with the following from the root directory: + +``` +msbuild -property:Configuration= bcl.sln +``` + +where `` is either one of `Debug` or `Release`. + +### POSIX-Compatible Systems + +This `bc` should build unmodified on any POSIX-compliant system or on Windows +starting with Windows 10 (though earlier versions may work). For more complex build requirements than the ones below, see the [build manual][5]. -### Default +On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as +`bin/dc` by default. On Windows, they are built as `Release/bc/bc.exe` and +`Release/bc/dc.exe`. + +**Note**: On Windows, `dc.exe` is just copied from `bc.exe`; it is not linked. +Patches are welcome for a way to do that. + +#### Default For the default build with optimization, use the following commands in the root directory: @@ -61,7 +115,7 @@ directory: make ``` -### One Calculator +#### One Calculator To only build `bc`, use the following commands: @@ -77,7 +131,7 @@ To only build `dc`, use the following commands: make ``` -### Debug +#### Debug For debug builds, use the following commands in the root directory: @@ -86,7 +140,7 @@ For debug builds, use the following commands in the root directory: make ``` -### Install +#### Install To install, use the following command: @@ -99,7 +153,7 @@ other locations, use the `PREFIX` environment variable when running `configure.sh` or pass the `--prefix=` option to `configure.sh`. See the [build manual][5], or run `./configure.sh --help`, for more details. -### Library +#### Library This `bc` does provide a way to build a math library with C bindings. This is done by the `-a` or `--library` options to `configure.sh`: @@ -114,11 +168,12 @@ see the [build manual][5]. The library API can be found in [`manuals/bcl.3.md`][26] or `man bcl` once the library is installed. -The library is built as `bin/libbcl.a`. +The library is built as `bin/libbcl.a` on POSIX-compatible systems or as +`Release/bcl/bcl.lib` on Windows. -### Package and Distro Maintainers +#### Package and Distro Maintainers -#### Recommended Compiler +##### Recommended Compiler When I ran benchmarks with my `bc` compiled under `clang`, it performed much better than when compiled under `gcc`. I recommend compiling this `bc` with @@ -127,7 +182,7 @@ better than when compiled under `gcc`. I recommend compiling this `bc` with I also recommend building this `bc` with C11 if you can because `bc` will detect a C11 compiler and add `_Noreturn` to any relevant function(s). -#### Recommended Optimizations +##### Recommended Optimizations I wrote this `bc` with Separation of Concerns, which means that there are many small functions that could be inlined. However, they are often called across @@ -154,12 +209,12 @@ However, I recommend ***NOT*** using `-march=native`. Doing so will reduce this `bc`'s performance, at least when building with link-time optimization. See the [benchmarks][19] for more details. -#### Stripping Binaries +##### Stripping Binaries By default, non-debug binaries are stripped, but stripping can be disabled with the `-T` option to `configure.sh`. -#### Using This `bc` as an Alternative +##### Using This `bc` as an Alternative If this `bc` is packaged as an alternative to an already existing `bc` package, it is possible to rename it in the build to prevent name collision. To prepend @@ -181,7 +236,7 @@ allowed. **Note**: The suggested name (and package name) when `bc` is not available is `bc-gh`. -#### Karatsuba Number +##### Karatsuba Number Package and distro maintainers have one tool at their disposal to build this `bc` in the optimal configuration: `karatsuba.py`. @@ -217,6 +272,7 @@ translations will also be added as they are provided. This `bc` compares favorably to GNU `bc`. +* This `bc` builds natively on Windows. * It has more extensions, which make this `bc` more useful for scripting. * This `bc` is a bit more POSIX compliant. * It has a much less buggy parser. The GNU `bc` will give parse errors for what @@ -246,7 +302,9 @@ To see what algorithms this `bc` uses, see the [algorithms manual][7]. ## Locales -Currently, this `bc` only has support for English (and US English), French, +Currently, there is no locale support on Windows. + +Additionally, this `bc` only has support for English (and US English), French, German, Portuguese, Dutch, Polish, Russian, Japanese, and Chinese locales. Patches are welcome for translations; use the existing `*.msg` files in `locales/` as a starting point. @@ -276,7 +334,8 @@ Other projects based on this bc are: ## Language -This `bc` is written in pure ISO C99, using POSIX 2008 APIs. +This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows +compatibility code. ## Commit Messages @@ -294,6 +353,13 @@ tarballs. Files: .gitignore The git ignore file (maintainer use only). + .gitattributes The git attributes file (maintainer use only). + bc.sln The Visual Studio solution file for bc. + bc.vcxproj The Visual Studio project file for bc. + bc.vcxproj.filters The Visual Studio filters file for bc. + bcl.sln The Visual Studio solution file for bcl. + bcl.vcxproj The Visual Studio project file for bcl. + bcl.vcxproj.filters The Visual Studio filters file for bcl. configure A symlink to configure.sh to make packaging easier. configure.sh The configure script. functions.sh A script with functions used by other scripts. @@ -304,7 +370,8 @@ Files: locale_install.sh A script to install locales, if desired. locale_uninstall.sh A script to uninstall locales. Makefile.in The Makefile template. - manpage.sh Script to generate man pages from markdown files. + manpage.sh Script to generate man pages from markdown files + (maintainer use only). NOTICE.md List of contributors and copyright owners. RELEASE.md A checklist for making a release (maintainer use only). release.sh A script to test for release (maintainer use only). diff --git a/contrib/bc/bc.sln b/contrib/bc/bc.sln new file mode 100644 index 000000000000..584b28d13bf6 --- /dev/null +++ b/contrib/bc/bc.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc", "bc.vcxproj", "{D5086CFE-052C-4742-B005-E05DB983BBA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.ActiveCfg = Debug|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.Build.0 = Debug|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.ActiveCfg = Debug|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.Build.0 = Debug|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.ActiveCfg = Release|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.Build.0 = Release|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.ActiveCfg = Release|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7869B1FB-A7C4-4FCF-8B99-F696DB2765EC} + EndGlobalSection +EndGlobal diff --git a/contrib/bc/bc.vcxproj b/contrib/bc/bc.vcxproj new file mode 100644 index 000000000000..ba0a7f6f1dd6 --- /dev/null +++ b/contrib/bc/bc.vcxproj @@ -0,0 +1,278 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {D5086CFE-052C-4742-B005-E05DB983BBA2} + Win32Proj + + + + Application + true + v142 + + + Application + false + v142 + + + Application + true + v142 + + + Application + false + v142 + + + + + + + + + + + + + + + + + + + + + Building strgen + CL /Fo:$(Configuration)\$(ProjectName)\ /Fe:$(Configuration)\$(ProjectName)\strgen.exe gen\strgen.c + gen\strgen.c + $(Configuration)\$(ProjectName)\strgen.exe + + + Generating $(Configuration)\$(ProjectName)/lib.c + START $(Configuration)\$(ProjectName)/strgen gen\lib.bc $(Configuration)\$(ProjectName)/lib.c bc_lib bc_lib_name BC_ENABLED 1 + $(Configuration)\$(ProjectName)\strgen.exe;gen\lib.bc + $(Configuration)\$(ProjectName)\lib.c + + + Generating $(Configuration)\$(ProjectName)/lib2.c + START $(Configuration)\$(ProjectName)/strgen gen\lib2.bc $(Configuration)\$(ProjectName)/lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1 + $(Configuration)\$(ProjectName)\strgen.exe;gen\lib2.bc + $(Configuration)\$(ProjectName)\lib2.c + + + Generating $(Configuration)\$(ProjectName)/bc_help.c + START $(Configuration)\$(ProjectName)/strgen gen\bc_help.txt $(Configuration)\$(ProjectName)\bc_help.c bc_help "" BC_ENABLED + $(Configuration)\$(ProjectName)\strgen.exe;gen\bc_help.txt + $(Configuration)\$(ProjectName)\bc_help.c + + + Generating $(Configuration)\$(ProjectName)/dc_help.c + START $(Configuration)\$(ProjectName)/strgen gen\dc_help.txt $(Configuration)\$(ProjectName)\dc_help.c dc_help "" DC_ENABLED + $(Configuration)\$(ProjectName)\strgen.exe;gen\dc_help.txt + $(Configuration)\$(ProjectName)\dc_help.c + + + + ClCompile + + + + true + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + true + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + false + /W3 %(AdditionalOptions) + + + MachineX86 + true + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + MaxSpeed + false + /W3 %(AdditionalOptions) + + + MachineX86 + false + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + true + true + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + false + /W3 %(AdditionalOptions) + + + MachineX64 + true + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + MaxSpeed + false + /W3 %(AdditionalOptions) + Default + + + MachineX64 + false + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contrib/bc/bc.vcxproj.filters b/contrib/bc/bc.vcxproj.filters new file mode 100644 index 000000000000..bc72b60519e9 --- /dev/null +++ b/contrib/bc/bc.vcxproj.filters @@ -0,0 +1,182 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + + + + + + + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/contrib/bc/bcl.sln b/contrib/bc/bcl.sln new file mode 100644 index 000000000000..77009a439db3 --- /dev/null +++ b/contrib/bc/bcl.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcl", "bcl.vcxproj", "{D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution *** 66043 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Sat Apr 10 14:43:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0EA985CE700; Sat, 10 Apr 2021 14:43:34 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHd6F70wqz3Pyn; Sat, 10 Apr 2021 14:43:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E31F913511; Sat, 10 Apr 2021 14:43:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13AEhXaQ008184; Sat, 10 Apr 2021 14:43:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13AEhXNE008183; Sat, 10 Apr 2021 14:43:33 GMT (envelope-from git) Date: Sat, 10 Apr 2021 14:43:33 GMT Message-Id: <202104101443.13AEhXNE008183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: 19f2e30f4224 - stable/12 - [bc] Update to version 4.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 19f2e30f422458bce4ee3d6dfeb9aeeff4e37786 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 14:43:34 -0000 The branch stable/12 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=19f2e30f422458bce4ee3d6dfeb9aeeff4e37786 commit 19f2e30f422458bce4ee3d6dfeb9aeeff4e37786 Author: Stefan Eßer AuthorDate: 2021-04-06 08:44:52 +0000 Commit: Stefan Eßer CommitDate: 2021-04-10 14:43:21 +0000 [bc] Update to version 4.0.0 This version fixes an issue (missing pop of top-of-stack value in the "P" command of the dc program). This issue did not affect the bc program, since it does not use dc as an back-end to actually perform the calculations as was the case with the traditional bc and dc programs. The major number has been bumped due to Windows support that has been added to this version. It does not correspond to a major change that might affect FreeBSD. (cherry picked from commit b55a927bc884d7780d65a508572023b0dc2dede9) --- contrib/bc/Makefile.in | 11 +- contrib/bc/NEWS.md | 25 + contrib/bc/README.md | 107 +- contrib/bc/bc.sln | 31 + contrib/bc/bc.vcxproj | 278 +++++ contrib/bc/bc.vcxproj.filters | 182 ++++ contrib/bc/bcl.sln | 31 + contrib/bc/bcl.vcxproj | 161 +++ contrib/bc/bcl.vcxproj.filters | 96 ++ contrib/bc/configure | 1322 ++++++++++++++++++++++- contrib/bc/configure.sh | 2 + contrib/bc/gen/bc_help.txt | 19 +- contrib/bc/gen/dc_help.txt | 17 +- contrib/bc/gen/strgen.c | 56 +- contrib/bc/include/bcl.h | 102 ++ contrib/bc/include/file.h | 34 +- contrib/bc/include/history.h | 3 + contrib/bc/include/num.h | 3 +- contrib/bc/include/status.h | 59 - contrib/bc/include/version.h | 41 + contrib/bc/include/vm.h | 32 +- contrib/bc/karatsuba.py | 10 +- contrib/bc/manpage.sh | 2 +- contrib/bc/manuals/bc.1.md.in | 23 +- contrib/bc/manuals/bc/A.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/A.1.md | 18 +- contrib/bc/manuals/bc/E.1 | 905 +++++++++------- contrib/bc/manuals/bc/E.1.md | 18 +- contrib/bc/manuals/bc/EH.1 | 905 +++++++++------- contrib/bc/manuals/bc/EH.1.md | 18 +- contrib/bc/manuals/bc/EHN.1 | 905 +++++++++------- contrib/bc/manuals/bc/EHN.1.md | 18 +- contrib/bc/manuals/bc/EHNP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EHNP.1.md | 8 +- contrib/bc/manuals/bc/EHP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EHP.1.md | 8 +- contrib/bc/manuals/bc/EN.1 | 905 +++++++++------- contrib/bc/manuals/bc/EN.1.md | 18 +- contrib/bc/manuals/bc/ENP.1 | 894 +++++++++------- contrib/bc/manuals/bc/ENP.1.md | 8 +- contrib/bc/manuals/bc/EP.1 | 894 +++++++++------- contrib/bc/manuals/bc/EP.1.md | 8 +- contrib/bc/manuals/bc/H.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/H.1.md | 18 +- contrib/bc/manuals/bc/HN.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/HN.1.md | 18 +- contrib/bc/manuals/bc/HNP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/HNP.1.md | 8 +- contrib/bc/manuals/bc/HP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/HP.1.md | 8 +- contrib/bc/manuals/bc/N.1 | 1901 ++++++++++++++++++--------------- contrib/bc/manuals/bc/N.1.md | 18 +- contrib/bc/manuals/bc/NP.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/NP.1.md | 8 +- contrib/bc/manuals/bc/P.1 | 1892 +++++++++++++++++--------------- contrib/bc/manuals/bc/P.1.md | 8 +- contrib/bc/manuals/bcl.3 | 1751 +++++++++++++++--------------- contrib/bc/manuals/build.md | 121 ++- contrib/bc/manuals/dc.1.md.in | 61 +- contrib/bc/manuals/dc/A.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/A.1.md | 56 +- contrib/bc/manuals/dc/E.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/E.1.md | 56 +- contrib/bc/manuals/dc/EH.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EH.1.md | 56 +- contrib/bc/manuals/dc/EHN.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EHN.1.md | 56 +- contrib/bc/manuals/dc/EHNP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EHNP.1.md | 46 +- contrib/bc/manuals/dc/EHP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EHP.1.md | 46 +- contrib/bc/manuals/dc/EN.1 | 1197 ++++++++++++--------- contrib/bc/manuals/dc/EN.1.md | 56 +- contrib/bc/manuals/dc/ENP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/ENP.1.md | 46 +- contrib/bc/manuals/dc/EP.1 | 1185 +++++++++++--------- contrib/bc/manuals/dc/EP.1.md | 46 +- contrib/bc/manuals/dc/H.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/H.1.md | 56 +- contrib/bc/manuals/dc/HN.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/HN.1.md | 56 +- contrib/bc/manuals/dc/HNP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/HNP.1.md | 46 +- contrib/bc/manuals/dc/HP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/HP.1.md | 46 +- contrib/bc/manuals/dc/N.1 | 1386 ++++++++++++++---------- contrib/bc/manuals/dc/N.1.md | 56 +- contrib/bc/manuals/dc/NP.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/NP.1.md | 46 +- contrib/bc/manuals/dc/P.1 | 1374 ++++++++++++++---------- contrib/bc/manuals/dc/P.1.md | 46 +- contrib/bc/manuals/header_bc.txt | 2 +- contrib/bc/manuals/header_bcl.txt | 2 +- contrib/bc/manuals/header_dc.txt | 2 +- contrib/bc/release.sh | 33 +- contrib/bc/src/args.c | 9 + contrib/bc/src/data.c | 6 + contrib/bc/src/file.c | 71 +- contrib/bc/src/history.c | 63 +- contrib/bc/src/main.c | 6 +- contrib/bc/src/num.c | 29 +- contrib/bc/src/program.c | 36 +- contrib/bc/src/rand.c | 36 +- contrib/bc/src/read.c | 29 +- contrib/bc/src/vm.c | 132 ++- contrib/bc/tests/dc/scripts/easter.sh | 47 + contrib/bc/tests/other.sh | 37 +- usr.bin/gh-bc/Makefile | 2 - 108 files changed, 28963 insertions(+), 20119 deletions(-) diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index aab7f9b569e5..2b50476a79fe 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -29,8 +29,6 @@ # .POSIX: -VERSION = 3.3.4 - SRC = %%SRC%% OBJ = %%OBJ%% GCDA = %%GCDA%% @@ -128,6 +126,8 @@ MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX) EXEC = $(%%EXEC%%) NLSPATH = %%NLSPATH%% +BC_BUILD_TYPE = %%BUILD_TYPE%% + BC_ENABLE_LIBRARY = %%LIBRARY%% BC_ENABLE_HISTORY = %%HISTORY%% @@ -158,7 +158,7 @@ TEST_STARS = "****************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) -CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DVERSION=$(VERSION) %%LONG_BIT_DEFINE%% +CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%% CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC) CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) @@ -322,9 +322,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -version: - @printf '%s' "$(VERSION)" - libcname: @printf '%s' "$(BC_LIB_C)" @@ -341,6 +338,7 @@ clean_gen: clean:%%CLEAN_PREREQS%% @printf 'Cleaning files...\n' + @$(RM) -f src/*.tmp gen/*.tmp @$(RM) -f $(OBJ) @$(RM) -f $(BC_EXEC) @$(RM) -f $(DC_EXEC) @@ -352,6 +350,7 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(DC_HELP_C) $(DC_HELP_O) @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) + @$(RM) -fr Debug/ Release/ clean_config: clean @printf 'Cleaning config...\n' diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index 3374ab57bc41..011cb9138912 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,30 @@ # News +## 4.0.0 + +This is a production release with many fixes, a new command-line option, and a +big surprise: + +* A bug was fixed in `dc`'s `P` command where the item on the stack was *not* + popped. +* Various bugs in the manuals have been fixed. +* A known bug was fixed where history did not interact well with prompts printed + by user code without newlines. +* A new command-line option, `-R` and `--no-read-prompt` was added to disable + just the prompt when using `read()` (`bc`) or `?` (`dc`). +* And finally, **official support for Windows was added**. + +The last item is why this is a major version bump. + +Currently, only one set of build options (extra math and prompt enabled, history +and NLS/locale support disabled, both calculators enabled) is supported on +Windows. However, both debug and release builds are supported. + +In addition, Windows builds are supported for the the library (`bcl`). + +For more details about how to build on Windows, see the [README][5] or the +[build manual][13]. + ## 3.3.4 This is a production release that fixes a small bug. diff --git a/contrib/bc/README.md b/contrib/bc/README.md index 6a37a8bfb8da..852c8956a73d 100644 --- a/contrib/bc/README.md +++ b/contrib/bc/README.md @@ -24,13 +24,16 @@ This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD ## Prerequisites -This `bc` only requires a C99-compatible compiler and a (mostly) POSIX -2008-compatible system with the XSI (X/Open System Interfaces) option group. +This `bc` only requires either: + +1. Windows 10 or later, or +2. A C99-compatible compiler and a (mostly) POSIX 2008-compatible system with + the XSI (X/Open System Interfaces) option group. Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any POSIX and XSI-compatible system will have everything needed. -Systems that are known to work: +POSIX-compatible systems that are known to work: * Linux * FreeBSD @@ -41,17 +44,68 @@ Systems that are known to work: * AIX * HP-UX* (except for history) +In addition, there is compatibility code to make this `bc` work on Windows. + Please submit bug reports if this `bc` does not build out of the box on any -system besides Windows. +system. ## Build -This `bc` should build unmodified on any POSIX-compliant system. +### Windows + +There is no guarantee that this `bc` will work on any version of Windows earlier +than Windows 10 (I cannot test on earlier versions), but it is guaranteed to +work on Windows 10 at least. + +Also, if building with MSBuild, the MSBuild bundled with Visual Studio is +required. + +**Note**: Unlike the POSIX-compatible platforms, only one build configuration is +supported on Windows: extra math and prompt enabled, history and NLS (locale +support) disabled, with both calculators built. + +#### `bc` + +To build `bc`, you can open the `bc.sln` file in Visual Studio, select the +configuration, and build. + +You can also build using MSBuild with the following from the root directory: + +``` +msbuild -property:Configuration= bc.sln +``` + +where `` is either one of `Debug` or `Release`. + +#### `bcl` (Library) + +To build the library, you can open the `bcl.sln` file in Visual Studio, select +the configuration, and build. + +You can also build using MSBuild with the following from the root directory: + +``` +msbuild -property:Configuration= bcl.sln +``` + +where `` is either one of `Debug` or `Release`. + +### POSIX-Compatible Systems + +This `bc` should build unmodified on any POSIX-compliant system or on Windows +starting with Windows 10 (though earlier versions may work). For more complex build requirements than the ones below, see the [build manual][5]. -### Default +On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as +`bin/dc` by default. On Windows, they are built as `Release/bc/bc.exe` and +`Release/bc/dc.exe`. + +**Note**: On Windows, `dc.exe` is just copied from `bc.exe`; it is not linked. +Patches are welcome for a way to do that. + +#### Default For the default build with optimization, use the following commands in the root directory: @@ -61,7 +115,7 @@ directory: make ``` -### One Calculator +#### One Calculator To only build `bc`, use the following commands: @@ -77,7 +131,7 @@ To only build `dc`, use the following commands: make ``` -### Debug +#### Debug For debug builds, use the following commands in the root directory: @@ -86,7 +140,7 @@ For debug builds, use the following commands in the root directory: make ``` -### Install +#### Install To install, use the following command: @@ -99,7 +153,7 @@ other locations, use the `PREFIX` environment variable when running `configure.sh` or pass the `--prefix=` option to `configure.sh`. See the [build manual][5], or run `./configure.sh --help`, for more details. -### Library +#### Library This `bc` does provide a way to build a math library with C bindings. This is done by the `-a` or `--library` options to `configure.sh`: @@ -114,11 +168,12 @@ see the [build manual][5]. The library API can be found in [`manuals/bcl.3.md`][26] or `man bcl` once the library is installed. -The library is built as `bin/libbcl.a`. +The library is built as `bin/libbcl.a` on POSIX-compatible systems or as +`Release/bcl/bcl.lib` on Windows. -### Package and Distro Maintainers +#### Package and Distro Maintainers -#### Recommended Compiler +##### Recommended Compiler When I ran benchmarks with my `bc` compiled under `clang`, it performed much better than when compiled under `gcc`. I recommend compiling this `bc` with @@ -127,7 +182,7 @@ better than when compiled under `gcc`. I recommend compiling this `bc` with I also recommend building this `bc` with C11 if you can because `bc` will detect a C11 compiler and add `_Noreturn` to any relevant function(s). -#### Recommended Optimizations +##### Recommended Optimizations I wrote this `bc` with Separation of Concerns, which means that there are many small functions that could be inlined. However, they are often called across @@ -154,12 +209,12 @@ However, I recommend ***NOT*** using `-march=native`. Doing so will reduce this `bc`'s performance, at least when building with link-time optimization. See the [benchmarks][19] for more details. -#### Stripping Binaries +##### Stripping Binaries By default, non-debug binaries are stripped, but stripping can be disabled with the `-T` option to `configure.sh`. -#### Using This `bc` as an Alternative +##### Using This `bc` as an Alternative If this `bc` is packaged as an alternative to an already existing `bc` package, it is possible to rename it in the build to prevent name collision. To prepend @@ -181,7 +236,7 @@ allowed. **Note**: The suggested name (and package name) when `bc` is not available is `bc-gh`. -#### Karatsuba Number +##### Karatsuba Number Package and distro maintainers have one tool at their disposal to build this `bc` in the optimal configuration: `karatsuba.py`. @@ -217,6 +272,7 @@ translations will also be added as they are provided. This `bc` compares favorably to GNU `bc`. +* This `bc` builds natively on Windows. * It has more extensions, which make this `bc` more useful for scripting. * This `bc` is a bit more POSIX compliant. * It has a much less buggy parser. The GNU `bc` will give parse errors for what @@ -246,7 +302,9 @@ To see what algorithms this `bc` uses, see the [algorithms manual][7]. ## Locales -Currently, this `bc` only has support for English (and US English), French, +Currently, there is no locale support on Windows. + +Additionally, this `bc` only has support for English (and US English), French, German, Portuguese, Dutch, Polish, Russian, Japanese, and Chinese locales. Patches are welcome for translations; use the existing `*.msg` files in `locales/` as a starting point. @@ -276,7 +334,8 @@ Other projects based on this bc are: ## Language -This `bc` is written in pure ISO C99, using POSIX 2008 APIs. +This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows +compatibility code. ## Commit Messages @@ -294,6 +353,13 @@ tarballs. Files: .gitignore The git ignore file (maintainer use only). + .gitattributes The git attributes file (maintainer use only). + bc.sln The Visual Studio solution file for bc. + bc.vcxproj The Visual Studio project file for bc. + bc.vcxproj.filters The Visual Studio filters file for bc. + bcl.sln The Visual Studio solution file for bcl. + bcl.vcxproj The Visual Studio project file for bcl. + bcl.vcxproj.filters The Visual Studio filters file for bcl. configure A symlink to configure.sh to make packaging easier. configure.sh The configure script. functions.sh A script with functions used by other scripts. @@ -304,7 +370,8 @@ Files: locale_install.sh A script to install locales, if desired. locale_uninstall.sh A script to uninstall locales. Makefile.in The Makefile template. - manpage.sh Script to generate man pages from markdown files. + manpage.sh Script to generate man pages from markdown files + (maintainer use only). NOTICE.md List of contributors and copyright owners. RELEASE.md A checklist for making a release (maintainer use only). release.sh A script to test for release (maintainer use only). diff --git a/contrib/bc/bc.sln b/contrib/bc/bc.sln new file mode 100644 index 000000000000..584b28d13bf6 --- /dev/null +++ b/contrib/bc/bc.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc", "bc.vcxproj", "{D5086CFE-052C-4742-B005-E05DB983BBA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.ActiveCfg = Debug|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.Build.0 = Debug|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.ActiveCfg = Debug|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.Build.0 = Debug|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.ActiveCfg = Release|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.Build.0 = Release|x64 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.ActiveCfg = Release|Win32 + {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7869B1FB-A7C4-4FCF-8B99-F696DB2765EC} + EndGlobalSection +EndGlobal diff --git a/contrib/bc/bc.vcxproj b/contrib/bc/bc.vcxproj new file mode 100644 index 000000000000..ba0a7f6f1dd6 --- /dev/null +++ b/contrib/bc/bc.vcxproj @@ -0,0 +1,278 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {D5086CFE-052C-4742-B005-E05DB983BBA2} + Win32Proj + + + + Application + true + v142 + + + Application + false + v142 + + + Application + true + v142 + + + Application + false + v142 + + + + + + + + + + + + + + + + + + + + + Building strgen + CL /Fo:$(Configuration)\$(ProjectName)\ /Fe:$(Configuration)\$(ProjectName)\strgen.exe gen\strgen.c + gen\strgen.c + $(Configuration)\$(ProjectName)\strgen.exe + + + Generating $(Configuration)\$(ProjectName)/lib.c + START $(Configuration)\$(ProjectName)/strgen gen\lib.bc $(Configuration)\$(ProjectName)/lib.c bc_lib bc_lib_name BC_ENABLED 1 + $(Configuration)\$(ProjectName)\strgen.exe;gen\lib.bc + $(Configuration)\$(ProjectName)\lib.c + + + Generating $(Configuration)\$(ProjectName)/lib2.c + START $(Configuration)\$(ProjectName)/strgen gen\lib2.bc $(Configuration)\$(ProjectName)/lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1 + $(Configuration)\$(ProjectName)\strgen.exe;gen\lib2.bc + $(Configuration)\$(ProjectName)\lib2.c + + + Generating $(Configuration)\$(ProjectName)/bc_help.c + START $(Configuration)\$(ProjectName)/strgen gen\bc_help.txt $(Configuration)\$(ProjectName)\bc_help.c bc_help "" BC_ENABLED + $(Configuration)\$(ProjectName)\strgen.exe;gen\bc_help.txt + $(Configuration)\$(ProjectName)\bc_help.c + + + Generating $(Configuration)\$(ProjectName)/dc_help.c + START $(Configuration)\$(ProjectName)/strgen gen\dc_help.txt $(Configuration)\$(ProjectName)\dc_help.c dc_help "" DC_ENABLED + $(Configuration)\$(ProjectName)\strgen.exe;gen\dc_help.txt + $(Configuration)\$(ProjectName)\dc_help.c + + + + ClCompile + + + + true + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + true + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(ProjectName)\ + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + false + /W3 %(AdditionalOptions) + + + MachineX86 + true + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + MaxSpeed + false + /W3 %(AdditionalOptions) + + + MachineX86 + false + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + true + true + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + false + /W3 %(AdditionalOptions) + + + MachineX64 + true + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + $(SolutionDir)\include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + MaxSpeed + false + /W3 %(AdditionalOptions) + Default + + + MachineX64 + false + Console + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) + + + copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + + + Copying bc to dc... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contrib/bc/bc.vcxproj.filters b/contrib/bc/bc.vcxproj.filters new file mode 100644 index 000000000000..bc72b60519e9 --- /dev/null +++ b/contrib/bc/bc.vcxproj.filters @@ -0,0 +1,182 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + + + + + + + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/contrib/bc/bcl.sln b/contrib/bc/bcl.sln new file mode 100644 index 000000000000..77009a439db3 --- /dev/null +++ b/contrib/bc/bcl.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcl", "bcl.vcxproj", "{D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution *** 66043 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 00:56:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 F157E5DCFDC; Sun, 11 Apr 2021 00:56:25 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHtjP6b7Wz4c7r; Sun, 11 Apr 2021 00:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D544B1B125; Sun, 11 Apr 2021 00:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13B0uPmf014311; Sun, 11 Apr 2021 00:56:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13B0uPXT014310; Sun, 11 Apr 2021 00:56:25 GMT (envelope-from git) Date: Sun, 11 Apr 2021 00:56:25 GMT Message-Id: <202104110056.13B0uPXT014310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c28f5f9b3e99 - stable/13 - Add sysctl debug.uma_reclaim MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c28f5f9b3e99e3785228e05907a00f36b249c37a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 00:56:26 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c28f5f9b3e99e3785228e05907a00f36b249c37a commit c28f5f9b3e99e3785228e05907a00f36b249c37a Author: Konstantin Belousov AuthorDate: 2021-04-04 16:28:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-11 00:35:16 +0000 Add sysctl debug.uma_reclaim (cherry picked from commit 89619b747bcff379dca98e975a98865a45366417) --- sys/vm/vm_kern.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 8d6e4f678970..93c9e8c638bc 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -898,3 +898,23 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) 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"); + +static int +debug_uma_reclaim(SYSCTL_HANDLER_ARGS) +{ + int error, i; + + i = 0; + error = sysctl_handle_int(oidp, &i, 0, req); + if (error != 0) + return (error); + if (i != UMA_RECLAIM_TRIM && i != UMA_RECLAIM_DRAIN && + i != UMA_RECLAIM_DRAIN_CPU) + return (EINVAL); + uma_reclaim(i); + return (0); +} + +SYSCTL_PROC(_debug, OID_AUTO, uma_reclaim, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, 0, debug_uma_reclaim, "I", + "set to generate request to reclaim uma caches"); From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 00:56:27 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 904E15DD0D3; Sun, 11 Apr 2021 00:56:27 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FHtjR05xjz4cJj; Sun, 11 Apr 2021 00:56:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9BF31B31A; Sun, 11 Apr 2021 00:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13B0uQdp014332; Sun, 11 Apr 2021 00:56:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13B0uQpm014331; Sun, 11 Apr 2021 00:56:26 GMT (envelope-from git) Date: Sun, 11 Apr 2021 00:56:26 GMT Message-Id: <202104110056.13B0uQpm014331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: de87ea5a43a8 - stable/13 - struct mount uppers: correct locking annotations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: de87ea5a43a850079b5f8901795f3769c85c6f89 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 00:56:27 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=de87ea5a43a850079b5f8901795f3769c85c6f89 commit de87ea5a43a850079b5f8901795f3769c85c6f89 Author: Konstantin Belousov AuthorDate: 2021-04-08 22:03:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-11 00:35:23 +0000 struct mount uppers: correct locking annotations (cherry picked from commit 5af1131de7fc18c795ed28e69d9393f78875d3e5) --- sys/sys/mount.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/sys/mount.h b/sys/sys/mount.h index e6a74bf1fb60..8b5712d19215 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -196,6 +196,7 @@ _Static_assert(sizeof(struct mount_pcpu) == 16, * l - mnt_listmtx * m - mountlist_mtx * i - interlock + * i* - interlock of uppers' list head * v - vnode freelist mutex * * Unmarked fields are considered stable as long as a ref is held. @@ -240,8 +241,8 @@ struct mount { struct vnodelst mnt_lazyvnodelist; /* (l) list of lazy vnodes */ int mnt_lazyvnodelistsize; /* (l) # of lazy vnodes */ struct lock mnt_explock; /* vfs_export walkers lock */ - TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */ - TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/ + TAILQ_ENTRY(mount) mnt_upper_link; /* (i*) we in the all uppers */ + TAILQ_HEAD(, mount) mnt_uppers; /* (i) upper mounts over us */ }; /* From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 07:49:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D58BF5E35F0; Sun, 11 Apr 2021 07:49:14 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJ3sk5d3Wz4tQg; Sun, 11 Apr 2021 07:49:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B48082026E; Sun, 11 Apr 2021 07:49:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13B7nE4D056024; Sun, 11 Apr 2021 07:49:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13B7nEDd056023; Sun, 11 Apr 2021 07:49:14 GMT (envelope-from git) Date: Sun, 11 Apr 2021 07:49:14 GMT Message-Id: <202104110749.13B7nEDd056023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2670d879f366 - stable/12 - struct mount uppers: correct locking annotations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2670d879f366435ec3072b46d5a4818915b13132 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 07:49:14 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2670d879f366435ec3072b46d5a4818915b13132 commit 2670d879f366435ec3072b46d5a4818915b13132 Author: Konstantin Belousov AuthorDate: 2021-04-08 22:03:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-11 07:38:08 +0000 struct mount uppers: correct locking annotations (cherry picked from commit 5af1131de7fc18c795ed28e69d9393f78875d3e5) --- sys/sys/mount.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/sys/mount.h b/sys/sys/mount.h index d099e453ec1a..f1a42cb3d29b 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -186,6 +186,7 @@ struct vfsopt { * l - mnt_listmtx * m - mountlist_mtx * i - interlock + * i* - interlock of uppers' list head * v - vnode freelist mutex * * Unmarked fields are considered stable as long as a ref is held. @@ -229,8 +230,8 @@ struct mount { struct vnodelst mnt_tmpfreevnodelist; /* (l) list of free vnodes */ int mnt_tmpfreevnodelistsize;/* (l) # of free vnodes */ struct lock mnt_explock; /* vfs_export walkers lock */ - TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */ - TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/ + TAILQ_ENTRY(mount) mnt_upper_link; /* (i*) we in the all uppers */ + TAILQ_HEAD(, mount) mnt_uppers; /* (i) upper mounts over us */ }; /* From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 07:49:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 0EE9D5E3BE3; Sun, 11 Apr 2021 07:49:16 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJ3sl6DNSz4swD; Sun, 11 Apr 2021 07:49:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C7CD12026F; Sun, 11 Apr 2021 07:49:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13B7nFOM056051; Sun, 11 Apr 2021 07:49:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13B7nFvb056050; Sun, 11 Apr 2021 07:49:15 GMT (envelope-from git) Date: Sun, 11 Apr 2021 07:49:15 GMT Message-Id: <202104110749.13B7nFvb056050@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 7f676ba9c69c - stable/12 - Add sysctl debug.uma_reclaim MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7f676ba9c69c577255faf63b3dce711f1959b495 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 07:49:16 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7f676ba9c69c577255faf63b3dce711f1959b495 commit 7f676ba9c69c577255faf63b3dce711f1959b495 Author: Konstantin Belousov AuthorDate: 2021-04-04 16:28:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-04-11 07:48:51 +0000 Add sysctl debug.uma_reclaim (cherry picked from commit 89619b747bcff379dca98e975a98865a45366417) --- sys/vm/vm_kern.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 83d58a194f62..80e7dd3c823b 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -860,3 +860,21 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) 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"); + +static int +debug_uma_reclaim(SYSCTL_HANDLER_ARGS) +{ + int error, i; + + i = 0; + error = sysctl_handle_int(oidp, &i, 0, req); + if (error != 0) + return (error); + if (i != 0) + uma_reclaim(); + return (0); +} + +SYSCTL_PROC(_debug, OID_AUTO, uma_reclaim, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, 0, debug_uma_reclaim, "I", + "set to generate request to reclaim uma caches"); From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 10:08:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 29EB75E78E5; Sun, 11 Apr 2021 10:08:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJ6y40mhCz3GqG; Sun, 11 Apr 2021 10:08:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D9F921C69; Sun, 11 Apr 2021 10:08:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BA8Bmm040991; Sun, 11 Apr 2021 10:08:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BA8Bqq040990; Sun, 11 Apr 2021 10:08:11 GMT (envelope-from git) Date: Sun, 11 Apr 2021 10:08:11 GMT Message-Id: <202104111008.13BA8Bqq040990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: 236d1f8c1773 - stable/13 - [tcp] Fix ECN on finalizing sessions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 236d1f8c1773a647891a9f37cc305dabde22f7f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 10:08:12 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=236d1f8c1773a647891a9f37cc305dabde22f7f7 commit 236d1f8c1773a647891a9f37cc305dabde22f7f7 Author: Richard Scheffenegger AuthorDate: 2021-04-08 12:50:34 +0000 Commit: Richard Scheffenegger CommitDate: 2021-04-11 09:18:35 +0000 [tcp] Fix ECN on finalizing sessions. A subtle oversight would subtly change new data packets sent after a shutdown() or close() call, while the send buffer is still draining. MFC after: 3 days Reviewed By: #transport, tuexen Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29616 (cherry picked from commit 9f2eeb02623d6a847a90da68a5892c25b14ce2d4) --- sys/netinet/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index d4b5a328e2a6..e23cdc749e98 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1181,7 +1181,7 @@ send: tp->t_flags2 &= ~TF2_ECN_SND_ECE; } - if (tp->t_state == TCPS_ESTABLISHED && + if (TCPS_HAVEESTABLISHED(tp->t_state) && (tp->t_flags2 & TF2_ECN_PERMIT)) { /* * If the peer has ECN, mark data packets with From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 10:41:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 EE1545C86E8; Sun, 11 Apr 2021 10:41:30 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJ7hV6Txgz3J9X; Sun, 11 Apr 2021 10:41:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D1920228C2; Sun, 11 Apr 2021 10:41:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BAfUG7091838; Sun, 11 Apr 2021 10:41:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BAfUe3091837; Sun, 11 Apr 2021 10:41:30 GMT (envelope-from git) Date: Sun, 11 Apr 2021 10:41:30 GMT Message-Id: <202104111041.13BAfUe3091837@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: 130abbf80364 - stable/12 - [tcp] Fix ECN on finalizing sessions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 130abbf803644dd12ea97dd55cbd19b7cf416738 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 10:41:31 -0000 The branch stable/12 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=130abbf803644dd12ea97dd55cbd19b7cf416738 commit 130abbf803644dd12ea97dd55cbd19b7cf416738 Author: Richard Scheffenegger AuthorDate: 2021-04-08 12:50:34 +0000 Commit: Richard Scheffenegger CommitDate: 2021-04-11 10:12:18 +0000 [tcp] Fix ECN on finalizing sessions. A subtle oversight would subtly change new data packets sent after a shutdown() or close() call, while the send buffer is still draining. MFC after: 3 days Reviewed By: #transport, tuexen Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29616 (cherry picked from commit 9f2eeb02623d6a847a90da68a5892c25b14ce2d4) --- sys/netinet/tcp_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index eeb9ca20a2b8..323d61c3e39a 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1137,8 +1137,8 @@ send: } else flags |= TH_ECE|TH_CWR; } - - if (tp->t_state == TCPS_ESTABLISHED && + + if (TCPS_HAVEESTABLISHED(tp->t_state) && (tp->t_flags & TF_ECN_PERMIT)) { /* * If the peer has ECN, mark data packets with From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 11:10:22 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 366A65C96FE; Sun, 11 Apr 2021 11:10:22 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJ8Kp0qq0z3L10; Sun, 11 Apr 2021 11:10:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0AD5E22C65; Sun, 11 Apr 2021 11:10:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BBALOg028990; Sun, 11 Apr 2021 11:10:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BBALTV028989; Sun, 11 Apr 2021 11:10:21 GMT (envelope-from git) Date: Sun, 11 Apr 2021 11:10:21 GMT Message-Id: <202104111110.13BBALTV028989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: 8d589e0cf979 - stable/11 - [tcp] Fix ECN on finalizing sessions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 8d589e0cf9793996f24f0d6fa9fddbf8b2ce0cdd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 11:10:22 -0000 The branch stable/11 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=8d589e0cf9793996f24f0d6fa9fddbf8b2ce0cdd commit 8d589e0cf9793996f24f0d6fa9fddbf8b2ce0cdd Author: Richard Scheffenegger AuthorDate: 2021-04-08 12:50:34 +0000 Commit: Richard Scheffenegger CommitDate: 2021-04-11 10:45:11 +0000 [tcp] Fix ECN on finalizing sessions. A subtle oversight would subtly change new data packets sent after a shutdown() or close() call, while the send buffer is still draining. MFC after: 3 days Reviewed By: #transport, tuexen Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29616 (cherry picked from commit 9f2eeb02623d6a847a90da68a5892c25b14ce2d4) --- sys/netinet/tcp_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index d7fcd626d9cd..53e3623e7616 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1152,8 +1152,8 @@ send: } else flags |= TH_ECE|TH_CWR; } - - if (tp->t_state == TCPS_ESTABLISHED && + + if (TCPS_HAVEESTABLISHED(tp->t_state) && (tp->t_flags & TF_ECN_PERMIT)) { /* * If the peer has ECN, mark data packets with From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 15:58:28 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 1324F5D2C60; Sun, 11 Apr 2021 15:58:28 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJGkD05L1z3pwP; Sun, 11 Apr 2021 15:58:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA58526C52; Sun, 11 Apr 2021 15:58:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BFwRo6004338; Sun, 11 Apr 2021 15:58:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BFwRZS004337; Sun, 11 Apr 2021 15:58:27 GMT (envelope-from git) Date: Sun, 11 Apr 2021 15:58:27 GMT Message-Id: <202104111558.13BFwRZS004337@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brandon Bergren Subject: git: 908d607bd100 - stable/13 - [PowerPC] Fix NUMA checking for powernv MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bdragon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 908d607bd100a96b416483975e8abfec636e85d1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 15:58:28 -0000 The branch stable/13 has been updated by bdragon: URL: https://cgit.FreeBSD.org/src/commit/?id=908d607bd100a96b416483975e8abfec636e85d1 commit 908d607bd100a96b416483975e8abfec636e85d1 Author: Brandon Bergren AuthorDate: 2021-03-28 01:41:45 +0000 Commit: Brandon Bergren CommitDate: 2021-04-11 15:52:23 +0000 [PowerPC] Fix NUMA checking for powernv At this point in startup, vm_ndomains has not been initialized. Switch to checking kenv instead. Fixes incorrect NUMA information being set on multi-domain systems like Talos II. Submitted by: jhibbits (cherry picked from commit bd94c8ab29c3162bbb43973ee77ce245fe157fef) --- sys/powerpc/powernv/platform_powernv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/powerpc/powernv/platform_powernv.c b/sys/powerpc/powernv/platform_powernv.c index 434b642a66a8..d7acc544c2ed 100644 --- a/sys/powerpc/powernv/platform_powernv.c +++ b/sys/powerpc/powernv/platform_powernv.c @@ -532,7 +532,9 @@ powernv_node_numa_domain(platform_t platform, phandle_t node) #ifndef NUMA return (0); #endif - if (vm_ndomains == 1) + i = 0; + TUNABLE_INT_FETCH("vm.numa.disabled", &i); + if (i) return (0); res = OF_getencprop(node, "ibm,associativity", From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 19:32:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D28975D97BC; Sun, 11 Apr 2021 19:32:53 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJMTd5cPxz4Vtb; Sun, 11 Apr 2021 19:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B382B1A91; Sun, 11 Apr 2021 19:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BJWre3094814; Sun, 11 Apr 2021 19:32:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BJWrFt094813; Sun, 11 Apr 2021 19:32:53 GMT (envelope-from git) Date: Sun, 11 Apr 2021 19:32:53 GMT Message-Id: <202104111932.13BJWrFt094813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 9f7ff9fe8450 - stable/13 - Remove tmpfs size and properly format generated fstab for arm MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9f7ff9fe8450497fa3ca6049a56a667dfd878899 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 19:32:53 -0000 The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=9f7ff9fe8450497fa3ca6049a56a667dfd878899 commit 9f7ff9fe8450497fa3ca6049a56a667dfd878899 Author: Daniel Engerg AuthorDate: 2021-03-17 14:00:57 +0000 Commit: Emmanuel Vadot CommitDate: 2021-04-11 19:32:13 +0000 Remove tmpfs size and properly format generated fstab for arm Remove tmpfs size limitation, this breaks make installworld and installation of some packages Format generated fstab using tabs to make it consistent and readable MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29283 (cherry picked from commit 5bffdafd6c5f2a8279a57172ab760ea66ed3d7d5) --- release/tools/arm.subr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release/tools/arm.subr b/release/tools/arm.subr index 2f91490c0859..811d6ddb402d 100644 --- a/release/tools/arm.subr +++ b/release/tools/arm.subr @@ -197,18 +197,18 @@ arm_install_base() { echo '# Custom /etc/fstab for FreeBSD embedded images' \ > ${CHROOTDIR}/${DESTDIR}/etc/fstab if [ "${PART_SCHEME}" == "GPT" ]; then - echo "/dev/ufs/rootfs / ufs rw 1 1" \ + echo "/dev/ufs/rootfs / ufs rw 1 1" \ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab - echo "/dev/msdosfs/EFI /boot/efi msdosfs rw,noatime 0 0" \ + echo "/dev/msdosfs/EFI /boot/efi msdosfs rw,noatime 0 0" \ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab fi if [ "${PART_SCHEME}" == "MBR" ]; then - echo "/dev/ufs/rootfs / ufs rw 1 1" \ + echo "/dev/ufs/rootfs / ufs rw 1 1" \ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab - echo "/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0" \ + echo "/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0" \ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab fi - echo "tmpfs /tmp tmpfs rw,mode=1777,size=50m 0 0" \ + echo "tmpfs /tmp tmpfs rw,mode=1777 0 0" \ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab local hostname From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 21:49:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 F0E365DFD77; Sun, 11 Apr 2021 21:49:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJQWm6YWWz4fTX; Sun, 11 Apr 2021 21:49:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3E1D3443; Sun, 11 Apr 2021 21:49:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BLnu3O067429; Sun, 11 Apr 2021 21:49:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BLnuiI067428; Sun, 11 Apr 2021 21:49:56 GMT (envelope-from git) Date: Sun, 11 Apr 2021 21:49:56 GMT Message-Id: <202104112149.13BLnuiI067428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: fd140c52160a - stable/13 - epoll: Store epoll_event udata member in ext member of kevent. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fd140c52160a8cc21d665d5bc6fa91d9d6ab8efe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 21:49:57 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fd140c52160a8cc21d665d5bc6fa91d9d6ab8efe commit fd140c52160a8cc21d665d5bc6fa91d9d6ab8efe Author: Vladimir Kondratyev AuthorDate: 2021-02-07 23:46:14 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-04-11 21:47:39 +0000 epoll: Store epoll_event udata member in ext member of kevent. Current epoll implementation stores udata fields of epoll_event structure in special dynamically-sized table rather than in udata field of backing kevent structure because of 2 reasons: 1. Kevent's udata size is smaller than epoll's on 32-bit archs. 2. Kevent's udata can be clobbered on execution EPOLL_CTL_ADD as kqueue modifies existing event while epoll returns error in this case. After r320043 has introduced four new 64bit user data members (ext[]), we can store epoll udata in one of them and drop aforementioned table. According to kqueue_register() source code ext members are not updated when existing kevent is modified that fixes p.2. As a side effect the patch fixes PR/252582. Reviewed by: trasz MFC after: 1 month Differential revision: https://reviews.freebsd.org/D28169 (cherry picked from commit b3c6fe663bb90240f8bda6b5ba9c6a761f09f078) --- sys/compat/linux/linux_emul.c | 21 ---------- sys/compat/linux/linux_emul.h | 1 - sys/compat/linux/linux_event.c | 88 ++++++------------------------------------ 3 files changed, 11 insertions(+), 99 deletions(-) diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c index 1dfbe239ccc4..499bebe8926a 100644 --- a/sys/compat/linux/linux_emul.c +++ b/sys/compat/linux/linux_emul.c @@ -143,7 +143,6 @@ linux_proc_init(struct thread *td, struct thread *newtd, int flags) { struct linux_emuldata *em; struct linux_pemuldata *pem; - struct epoll_emuldata *emd; struct proc *p; if (newtd != NULL) { @@ -185,15 +184,9 @@ linux_proc_init(struct thread *td, struct thread *newtd, int flags) em->child_clear_tid = NULL; em->child_set_tid = NULL; - /* epoll should be destroyed in a case of exec. */ pem = pem_find(p); KASSERT(pem != NULL, ("proc_exit: proc emuldata not found.\n")); pem->persona = 0; - if (pem->epoll != NULL) { - emd = pem->epoll; - pem->epoll = NULL; - free(emd, M_EPOLL); - } } } @@ -202,7 +195,6 @@ void linux_on_exit(struct proc *p) { struct linux_pemuldata *pem; - struct epoll_emuldata *emd; struct thread *td = curthread; MPASS(SV_CURPROC_ABI() == SV_ABI_LINUX); @@ -217,12 +209,6 @@ linux_on_exit(struct proc *p) p->p_emuldata = NULL; - if (pem->epoll != NULL) { - emd = pem->epoll; - pem->epoll = NULL; - free(emd, M_EPOLL); - } - sx_destroy(&pem->pem_sx); free(pem, M_LINUX); } @@ -267,7 +253,6 @@ int linux_common_execve(struct thread *td, struct image_args *eargs) { struct linux_pemuldata *pem; - struct epoll_emuldata *emd; struct vmspace *oldvmspace; struct linux_emuldata *em; struct proc *p; @@ -299,12 +284,6 @@ linux_common_execve(struct thread *td, struct image_args *eargs) p->p_emuldata = NULL; PROC_UNLOCK(p); - if (pem->epoll != NULL) { - emd = pem->epoll; - pem->epoll = NULL; - free(emd, M_EPOLL); - } - free(em, M_TEMP); free(pem, M_LINUX); } diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h index 1bbc69ad98be..de66a7a4c82a 100644 --- a/sys/compat/linux/linux_emul.h +++ b/sys/compat/linux/linux_emul.h @@ -68,7 +68,6 @@ int linux_common_execve(struct thread *, struct image_args *); struct linux_pemuldata { uint32_t flags; /* process emuldata flags */ struct sx pem_sx; /* lock for this struct */ - void *epoll; /* epoll data */ uint32_t persona; /* process execution domain */ uint32_t ptrace_flags; /* used by ptrace(2) */ }; diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 54f6b083adf3..370bf4d6485f 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -71,25 +71,8 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * epoll defines 'struct epoll_event' with the field 'data' as 64 bits - * on all architectures. But on 32 bit architectures BSD 'struct kevent' only - * has 32 bit opaque pointer as 'udata' field. So we can't pass epoll supplied - * data verbatuim. Therefore we allocate 64-bit memory block to pass - * user supplied data for every file descriptor. - */ - typedef uint64_t epoll_udata_t; -struct epoll_emuldata { - uint32_t fdc; /* epoll udata max index */ - epoll_udata_t udata[1]; /* epoll user data vector */ -}; - -#define EPOLL_DEF_SZ 16 -#define EPOLL_SIZE(fdn) \ - (sizeof(struct epoll_emuldata)+(fdn) * sizeof(epoll_udata_t)) - struct epoll_event { uint32_t events; epoll_udata_t data; @@ -101,7 +84,6 @@ __attribute__((packed)) #define LINUX_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event)) -static void epoll_fd_install(struct thread *td, int fd, epoll_udata_t udata); static int epoll_to_kevent(struct thread *td, int fd, struct epoll_event *l_event, struct kevent *kevent, int *nkevents); @@ -175,47 +157,11 @@ struct timerfd { static void linux_timerfd_expire(void *); static void linux_timerfd_curval(struct timerfd *, struct itimerspec *); -static void -epoll_fd_install(struct thread *td, int fd, epoll_udata_t udata) -{ - struct linux_pemuldata *pem; - struct epoll_emuldata *emd; - struct proc *p; - - p = td->td_proc; - - pem = pem_find(p); - KASSERT(pem != NULL, ("epoll proc emuldata not found.\n")); - - LINUX_PEM_XLOCK(pem); - if (pem->epoll == NULL) { - emd = malloc(EPOLL_SIZE(fd), M_EPOLL, M_WAITOK); - emd->fdc = fd; - pem->epoll = emd; - } else { - emd = pem->epoll; - if (fd > emd->fdc) { - emd = realloc(emd, EPOLL_SIZE(fd), M_EPOLL, M_WAITOK); - emd->fdc = fd; - pem->epoll = emd; - } - } - emd->udata[fd] = udata; - LINUX_PEM_XUNLOCK(pem); -} - static int epoll_create_common(struct thread *td, int flags) { - int error; - - error = kern_kqueue(td, flags, NULL); - if (error != 0) - return (error); - - epoll_fd_install(td, EPOLL_DEF_SZ, 0); - return (0); + return (kern_kqueue(td, flags, NULL)); } #ifdef LINUX_LEGACY_SYSCALLS @@ -271,11 +217,15 @@ epoll_to_kevent(struct thread *td, int fd, struct epoll_event *l_event, /* flags related to what event is registered */ if ((levents & LINUX_EPOLL_EVRD) != 0) { - EV_SET(kevent++, fd, EVFILT_READ, kev_flags, 0, 0, 0); + EV_SET(kevent, fd, EVFILT_READ, kev_flags, 0, 0, 0); + kevent->ext[0] = l_event->data; + ++kevent; ++(*nkevents); } if ((levents & LINUX_EPOLL_EVWR) != 0) { - EV_SET(kevent++, fd, EVFILT_WRITE, kev_flags, 0, 0, 0); + EV_SET(kevent, fd, EVFILT_WRITE, kev_flags, 0, 0, 0); + kevent->ext[0] = l_event->data; + ++kevent; ++(*nkevents); } /* zero event mask is legal */ @@ -289,7 +239,6 @@ epoll_to_kevent(struct thread *td, int fd, struct epoll_event *l_event, pem = pem_find(p); KASSERT(pem != NULL, ("epoll proc emuldata not found.\n")); - KASSERT(pem->epoll != NULL, ("epoll proc epolldata not found.\n")); LINUX_PEM_XLOCK(pem); if ((pem->flags & LINUX_XUNSUP_EPOLL) == 0) { @@ -314,6 +263,8 @@ static void kevent_to_epoll(struct kevent *kevent, struct epoll_event *l_event) { + l_event->data = kevent->ext[0]; + if ((kevent->flags & EV_ERROR) != 0) { l_event->events = LINUX_EPOLLERR; return; @@ -342,30 +293,15 @@ static int epoll_kev_copyout(void *arg, struct kevent *kevp, int count) { struct epoll_copyout_args *args; - struct linux_pemuldata *pem; - struct epoll_emuldata *emd; struct epoll_event *eep; - int error, fd, i; + int error, i; args = (struct epoll_copyout_args*) arg; eep = malloc(sizeof(*eep) * count, M_EPOLL, M_WAITOK | M_ZERO); - pem = pem_find(args->p); - KASSERT(pem != NULL, ("epoll proc emuldata not found.\n")); - LINUX_PEM_SLOCK(pem); - emd = pem->epoll; - KASSERT(emd != NULL, ("epoll proc epolldata not found.\n")); - - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) kevent_to_epoll(&kevp[i], &eep[i]); - fd = kevp[i].ident; - KASSERT(fd <= emd->fdc, ("epoll user data vector" - " is too small.\n")); - eep[i].data = emd->udata[fd]; - } - LINUX_PEM_SUNLOCK(pem); - error = copyout(eep, args->leventlist, count * sizeof(*eep)); if (error == 0) { args->leventlist += count; @@ -473,8 +409,6 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ctl_args *args) goto leave0; } - epoll_fd_install(td, args->fd, le.data); - error = kern_kevent_fp(td, epfp, nchanges, 0, &k_ops, NULL); leave0: From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 21:49:58 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 3B0C35DFD7E; Sun, 11 Apr 2021 21:49:58 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJQWp17JWz4f9H; Sun, 11 Apr 2021 21:49:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 090E933F1; Sun, 11 Apr 2021 21:49:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BLnvIn067450; Sun, 11 Apr 2021 21:49:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BLnvUH067449; Sun, 11 Apr 2021 21:49:57 GMT (envelope-from git) Date: Sun, 11 Apr 2021 21:49:57 GMT Message-Id: <202104112149.13BLnvUH067449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 09d2a7a67b54 - stable/13 - ig4: Add PCI IDs for Intel Gemini Lake I2C controller. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 09d2a7a67b54eccccdc9ec97bbb7c918f0166ab8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 21:49:58 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=09d2a7a67b54eccccdc9ec97bbb7c918f0166ab8 commit 09d2a7a67b54eccccdc9ec97bbb7c918f0166ab8 Author: Vladimir Kondratyev AuthorDate: 2021-02-23 22:20:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-04-11 21:48:08 +0000 ig4: Add PCI IDs for Intel Gemini Lake I2C controller. Submitted by: Dmitry Luhtionov MFC after: 2 weeks (cherry picked from commit bbacb7ce72956a41c0daeefe875e5209d87c11ba) --- sys/dev/ichiic/ig4_iic.c | 6 ++++++ sys/dev/ichiic/ig4_pci.c | 16 ++++++++++++++++ sys/dev/ichiic/ig4_var.h | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ichiic/ig4_iic.c b/sys/dev/ichiic/ig4_iic.c index b684dc7d87cd..f24b26f53366 100644 --- a/sys/dev/ichiic/ig4_iic.c +++ b/sys/dev/ichiic/ig4_iic.c @@ -125,6 +125,12 @@ static const struct ig4_hw ig4iic_hw[] = { .scl_fall_time = 208, .sda_hold_time = 42, }, + [IG4_GEMINILAKE] = { + .ic_clock_rate = 133, + .sda_fall_time = 171, + .scl_fall_time = 290, + .sda_hold_time = 313, + }, }; static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); diff --git a/sys/dev/ichiic/ig4_pci.c b/sys/dev/ichiic/ig4_pci.c index 4667709e2fa2..2d80a8b1800a 100644 --- a/sys/dev/ichiic/ig4_pci.c +++ b/sys/dev/ichiic/ig4_pci.c @@ -136,6 +136,14 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_TIGERLAKE_LP_I2C_5 0xa0e98086 #define PCI_CHIP_TIGERLAKE_LP_I2C_6 0xa0ea8086 #define PCI_CHIP_TIGERLAKE_LP_I2C_7 0xa0eb8086 +#define PCI_CHIP_GEMINILAKE_I2C_0 0x31ac8086 +#define PCI_CHIP_GEMINILAKE_I2C_1 0x31ae8086 +#define PCI_CHIP_GEMINILAKE_I2C_2 0x31b08086 +#define PCI_CHIP_GEMINILAKE_I2C_3 0x31b28086 +#define PCI_CHIP_GEMINILAKE_I2C_4 0x31b48086 +#define PCI_CHIP_GEMINILAKE_I2C_5 0x31b68086 +#define PCI_CHIP_GEMINILAKE_I2C_6 0x31b88086 +#define PCI_CHIP_GEMINILAKE_I2C_7 0x31ba8086 struct ig4iic_pci_device { uint32_t devid; @@ -214,6 +222,14 @@ static struct ig4iic_pci_device ig4iic_pci_devices[] = { { PCI_CHIP_TIGERLAKE_LP_I2C_5, "Intel Tiger Lake-LP I2C Controller-5", IG4_SKYLAKE}, { PCI_CHIP_TIGERLAKE_LP_I2C_6, "Intel Tiger Lake-LP I2C Controller-6", IG4_SKYLAKE}, { PCI_CHIP_TIGERLAKE_LP_I2C_7, "Intel Tiger Lake-LP I2C Controller-7", IG4_SKYLAKE}, + { PCI_CHIP_GEMINILAKE_I2C_0, "Intel Gemini Lake I2C Controller-0", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_1, "Intel Gemini Lake I2C Controller-1", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_2, "Intel Gemini Lake I2C Controller-2", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_3, "Intel Gemini Lake I2C Controller-3", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_4, "Intel Gemini Lake I2C Controller-4", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_5, "Intel Gemini Lake I2C Controller-5", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_6, "Intel Gemini Lake I2C Controller-6", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_7, "Intel Gemini Lake I2C Controller-7", IG4_GEMINILAKE}, }; static int diff --git a/sys/dev/ichiic/ig4_var.h b/sys/dev/ichiic/ig4_var.h index 7a94e4f5cffd..da81980039f1 100644 --- a/sys/dev/ichiic/ig4_var.h +++ b/sys/dev/ichiic/ig4_var.h @@ -49,7 +49,8 @@ enum ig4_vers { IG4_SKYLAKE, IG4_APL, IG4_CANNONLAKE, - IG4_TIGERLAKE + IG4_TIGERLAKE, + IG4_GEMINILAKE }; /* Controller has additional registers */ From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 21:49:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 6E3BA5E003E; Sun, 11 Apr 2021 21:49:59 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJQWq283Yz4fcC; Sun, 11 Apr 2021 21:49:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B2833894; Sun, 11 Apr 2021 21:49:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BLnx60067471; Sun, 11 Apr 2021 21:49:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BLnxi9067470; Sun, 11 Apr 2021 21:49:59 GMT (envelope-from git) Date: Sun, 11 Apr 2021 21:49:59 GMT Message-Id: <202104112149.13BLnxi9067470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 99bc385243e8 - stable/13 - hid: add opt_hid.h to modules that use HID_DEBUG MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 99bc385243e80406ccb504384132738023be182a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 21:49:59 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=99bc385243e80406ccb504384132738023be182a commit 99bc385243e80406ccb504384132738023be182a Author: Vladimir Kondratyev AuthorDate: 2021-03-03 22:21:15 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-04-11 21:48:51 +0000 hid: add opt_hid.h to modules that use HID_DEBUG Submitted by: Greg V Reviewed by: imp, wulf MFC after: 1 week Differential revision: https://reviews.freebsd.org/D28995 (cherry picked from commit 6241b57131a60bc2bd0eda41c145aa9659c2886b) --- sys/dev/hid/hconf.c | 2 ++ sys/dev/hid/hkbd.c | 1 + sys/modules/hid/hconf/Makefile | 1 + sys/modules/hid/hkbd/Makefile | 2 +- sys/modules/hid/ps4dshock/Makefile | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/hid/hconf.c b/sys/dev/hid/hconf.c index cb0465e71b3e..90cd52d3116c 100644 --- a/sys/dev/hid/hconf.c +++ b/sys/dev/hid/hconf.c @@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$"); * https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-precision-touchpad-required-hid-top-level-collections */ +#include "opt_hid.h" + #include #include #include diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index 89325f9b2499..775ad677f4de 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf */ +#include "opt_hid.h" #include "opt_kbd.h" #include "opt_hkbd.h" #include "opt_evdev.h" diff --git a/sys/modules/hid/hconf/Makefile b/sys/modules/hid/hconf/Makefile index 1e5c68fe1848..0ac8d969cd71 100644 --- a/sys/modules/hid/hconf/Makefile +++ b/sys/modules/hid/hconf/Makefile @@ -4,6 +4,7 @@ KMOD= hconf SRCS= hconf.c +SRCS+= opt_hid.h SRCS+= bus_if.h device_if.h .include diff --git a/sys/modules/hid/hkbd/Makefile b/sys/modules/hid/hkbd/Makefile index 38221227d1cd..8bb1c339ac6c 100644 --- a/sys/modules/hid/hkbd/Makefile +++ b/sys/modules/hid/hkbd/Makefile @@ -4,7 +4,7 @@ KMOD= hkbd SRCS= hkbd.c -SRCS+= opt_evdev.h opt_kbd.h opt_hkbd.h +SRCS+= opt_hid.h opt_evdev.h opt_kbd.h opt_hkbd.h SRCS+= bus_if.h device_if.h .include diff --git a/sys/modules/hid/ps4dshock/Makefile b/sys/modules/hid/ps4dshock/Makefile index 688494f33ac6..ab46ba3f2363 100644 --- a/sys/modules/hid/ps4dshock/Makefile +++ b/sys/modules/hid/ps4dshock/Makefile @@ -4,6 +4,7 @@ KMOD= ps4dshock SRCS= ps4dshock.c +SRCS+= opt_hid.h SRCS+= bus_if.h device_if.h usbdevs.h .include From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 21:54:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7E1FD5E0152; Sun, 11 Apr 2021 21:54:52 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJQdS38XNz4g8r; Sun, 11 Apr 2021 21:54:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5F08238C2; Sun, 11 Apr 2021 21:54:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BLsqkt080102; Sun, 11 Apr 2021 21:54:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BLsqTv080101; Sun, 11 Apr 2021 21:54:52 GMT (envelope-from git) Date: Sun, 11 Apr 2021 21:54:52 GMT Message-Id: <202104112154.13BLsqTv080101@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 30b132ffe699 - stable/12 - ig4: Add PCI IDs for Intel Gemini Lake I2C controller. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 30b132ffe6999013e8b1cf5d85ed645495ac36d0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 21:54:52 -0000 The branch stable/12 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=30b132ffe6999013e8b1cf5d85ed645495ac36d0 commit 30b132ffe6999013e8b1cf5d85ed645495ac36d0 Author: Vladimir Kondratyev AuthorDate: 2021-02-23 22:20:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-04-11 21:52:04 +0000 ig4: Add PCI IDs for Intel Gemini Lake I2C controller. Submitted by: Dmitry Luhtionov MFC after: 2 weeks --- sys/dev/ichiic/ig4_iic.c | 6 ++++++ sys/dev/ichiic/ig4_pci.c | 16 ++++++++++++++++ sys/dev/ichiic/ig4_var.h | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ichiic/ig4_iic.c b/sys/dev/ichiic/ig4_iic.c index b684dc7d87cd..f24b26f53366 100644 --- a/sys/dev/ichiic/ig4_iic.c +++ b/sys/dev/ichiic/ig4_iic.c @@ -125,6 +125,12 @@ static const struct ig4_hw ig4iic_hw[] = { .scl_fall_time = 208, .sda_hold_time = 42, }, + [IG4_GEMINILAKE] = { + .ic_clock_rate = 133, + .sda_fall_time = 171, + .scl_fall_time = 290, + .sda_hold_time = 313, + }, }; static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); diff --git a/sys/dev/ichiic/ig4_pci.c b/sys/dev/ichiic/ig4_pci.c index 4667709e2fa2..2d80a8b1800a 100644 --- a/sys/dev/ichiic/ig4_pci.c +++ b/sys/dev/ichiic/ig4_pci.c @@ -136,6 +136,14 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_TIGERLAKE_LP_I2C_5 0xa0e98086 #define PCI_CHIP_TIGERLAKE_LP_I2C_6 0xa0ea8086 #define PCI_CHIP_TIGERLAKE_LP_I2C_7 0xa0eb8086 +#define PCI_CHIP_GEMINILAKE_I2C_0 0x31ac8086 +#define PCI_CHIP_GEMINILAKE_I2C_1 0x31ae8086 +#define PCI_CHIP_GEMINILAKE_I2C_2 0x31b08086 +#define PCI_CHIP_GEMINILAKE_I2C_3 0x31b28086 +#define PCI_CHIP_GEMINILAKE_I2C_4 0x31b48086 +#define PCI_CHIP_GEMINILAKE_I2C_5 0x31b68086 +#define PCI_CHIP_GEMINILAKE_I2C_6 0x31b88086 +#define PCI_CHIP_GEMINILAKE_I2C_7 0x31ba8086 struct ig4iic_pci_device { uint32_t devid; @@ -214,6 +222,14 @@ static struct ig4iic_pci_device ig4iic_pci_devices[] = { { PCI_CHIP_TIGERLAKE_LP_I2C_5, "Intel Tiger Lake-LP I2C Controller-5", IG4_SKYLAKE}, { PCI_CHIP_TIGERLAKE_LP_I2C_6, "Intel Tiger Lake-LP I2C Controller-6", IG4_SKYLAKE}, { PCI_CHIP_TIGERLAKE_LP_I2C_7, "Intel Tiger Lake-LP I2C Controller-7", IG4_SKYLAKE}, + { PCI_CHIP_GEMINILAKE_I2C_0, "Intel Gemini Lake I2C Controller-0", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_1, "Intel Gemini Lake I2C Controller-1", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_2, "Intel Gemini Lake I2C Controller-2", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_3, "Intel Gemini Lake I2C Controller-3", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_4, "Intel Gemini Lake I2C Controller-4", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_5, "Intel Gemini Lake I2C Controller-5", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_6, "Intel Gemini Lake I2C Controller-6", IG4_GEMINILAKE}, + { PCI_CHIP_GEMINILAKE_I2C_7, "Intel Gemini Lake I2C Controller-7", IG4_GEMINILAKE}, }; static int diff --git a/sys/dev/ichiic/ig4_var.h b/sys/dev/ichiic/ig4_var.h index 7a94e4f5cffd..da81980039f1 100644 --- a/sys/dev/ichiic/ig4_var.h +++ b/sys/dev/ichiic/ig4_var.h @@ -49,7 +49,8 @@ enum ig4_vers { IG4_SKYLAKE, IG4_APL, IG4_CANNONLAKE, - IG4_TIGERLAKE + IG4_TIGERLAKE, + IG4_GEMINILAKE }; /* Controller has additional registers */ From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 22:26:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 061A95E1115; Sun, 11 Apr 2021 22:26:52 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJRLM6mBVz4hQL; Sun, 11 Apr 2021 22:26:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DAC523ACA; Sun, 11 Apr 2021 22:26:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BMQpOP020822; Sun, 11 Apr 2021 22:26:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BMQpkb020821; Sun, 11 Apr 2021 22:26:51 GMT (envelope-from git) Date: Sun, 11 Apr 2021 22:26:51 GMT Message-Id: <202104112226.13BMQpkb020821@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 431a136f423b - stable/13 - nfsv4 client: fix forced dismount when sleeping in the renew thread MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 431a136f423b7487fab33ea8d431af4f67b7e226 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 22:26:52 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=431a136f423b7487fab33ea8d431af4f67b7e226 commit 431a136f423b7487fab33ea8d431af4f67b7e226 Author: Rick Macklem AuthorDate: 2021-03-23 20:04:37 +0000 Commit: Rick Macklem CommitDate: 2021-04-11 22:23:23 +0000 nfsv4 client: fix forced dismount when sleeping in the renew thread During a recent NFSv4 testing event a test server caused a hang where "umount -N" failed. The renew thread was sleeping on "nfsv4lck" and the "umount" was sleeping, waiting for the renew thread to terminate. This is the second of two patches that is hoped to fix the renew thread so that it will terminate when "umount -N" is done on the mount. This patch adds a 5second timeout on the msleep()s and checks for the forced dismount flag so that the renew thread will wake up and see the forced dismount flag. Normally a wakeup() will occur in less than 5seconds, but if a premature return from msleep() does occur, it will simply loop around and msleep() again. The patch also adds the "mp" argument to nfsv4_lock() so that it will return when the forced dismount flag is set. While here, replace the nfsmsleep() wrapper that was used for portability with the actual msleep() call. (cherry picked from commit 82ee386c2afb42388804c1189751b83048953433) --- sys/fs/nfsclient/nfs_clstate.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 227d82a5f7f3..4e3abf82c96a 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -2550,10 +2550,12 @@ nfscl_renewthread(struct nfsclclient *clp, NFSPROC_T *p) struct nfsclrecalllayout *recallp; struct nfsclds *dsp; bool retok; + struct mount *mp; cred = newnfs_getcred(); NFSLOCKCLSTATE(); clp->nfsc_flags |= NFSCLFLAGS_HASTHREAD; + mp = clp->nfsc_nmp->nm_mountp; NFSUNLOCKCLSTATE(); for(;;) { newnfs_setroot(cred); @@ -2652,14 +2654,18 @@ tryagain: } dp->nfsdl_rwlock.nfslock_lock |= NFSV4LOCK_WANTED; - (void) nfsmsleep(&dp->nfsdl_rwlock, - NFSCLSTATEMUTEXPTR, PZERO, "nfscld", - NULL); + msleep(&dp->nfsdl_rwlock, + NFSCLSTATEMUTEXPTR, PVFS, "nfscld", + 5 * hz); + if (NFSCL_FORCEDISM(mp)) + goto terminate; goto tryagain; } while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, - &islept, NFSCLSTATEMUTEXPTR, NULL); + &islept, NFSCLSTATEMUTEXPTR, mp); + if (igotlock == 0 && NFSCL_FORCEDISM(mp)) + goto terminate; if (islept) goto tryagain; } @@ -2739,9 +2745,11 @@ tryagain2: NFSV4LOCK_LOCK) != 0) { lyp->nfsly_lock.nfslock_lock |= NFSV4LOCK_WANTED; - nfsmsleep(&lyp->nfsly_lock.nfslock_lock, - NFSCLSTATEMUTEXPTR, PZERO, "nfslyp", - NULL); + msleep(&lyp->nfsly_lock.nfslock_lock, + NFSCLSTATEMUTEXPTR, PVFS, "nfslyp", + 5 * hz); + if (NFSCL_FORCEDISM(mp)) + goto terminate; goto tryagain2; } /* Move the layout to the recall list. */ @@ -2850,6 +2858,7 @@ tryagain2: if ((clp->nfsc_flags & NFSCLFLAGS_RECOVER) == 0) (void)mtx_sleep(clp, NFSCLSTATEMUTEXPTR, PWAIT, "nfscl", hz); +terminate: if (clp->nfsc_flags & NFSCLFLAGS_UMOUNT) { clp->nfsc_flags &= ~NFSCLFLAGS_HASTHREAD; NFSUNLOCKCLSTATE(); From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 22:29:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 276325E0AFC; Sun, 11 Apr 2021 22:29:31 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJRPQ6Dvbz4hk4; Sun, 11 Apr 2021 22:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C4DC3412B; Sun, 11 Apr 2021 22:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BMTUtr021107; Sun, 11 Apr 2021 22:29:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BMTUDa021106; Sun, 11 Apr 2021 22:29:30 GMT (envelope-from git) Date: Sun, 11 Apr 2021 22:29:30 GMT Message-Id: <202104112229.13BMTUDa021106@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 09d112c8a015 - stable/13 - nfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 09d112c8a015e41e728864b967c1666cc1c40c93 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 22:29:31 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=09d112c8a015e41e728864b967c1666cc1c40c93 commit 09d112c8a015e41e728864b967c1666cc1c40c93 Author: Rick Macklem AuthorDate: 2021-03-30 21:31:05 +0000 Commit: Rick Macklem CommitDate: 2021-04-11 22:26:14 +0000 nfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts The NFSv4.1 (and 4.2 on 13) server incorrectly binds a new TCP connection to the back channel when first used by an RPC with a Sequence op in it (almost all of them). RFC5661 specifies that only the fore channel should be bound. This was done because early clients (including FreeBSD) did not do the required BindConnectionToSession RPC. Unfortunately, this breaks the Linux client when the "nconnects" mount option is used, since the server may do a callback on the incorrect TCP connection. This patch converts the server behaviour to that required by the RFC. It also makes the server test/indicate failure of the back channel more aggressively. Until this patch is applied to the server, the "nconnects" mount option is not recommended for a Linux NFSv4.1/4.2 client mount to the FreeBSD server. (cherry picked from commit 01ae8969a9eed652fbd894faa5b31b1593079ed8) --- sys/fs/nfsserver/nfs_nfsdstate.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 1f6e8b7ef526..5ac37ed07cae 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -6209,7 +6209,6 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_t sequenceid, struct nfsdsession *sep; struct nfssessionhash *shp; int error; - SVCXPRT *savxprt; shp = NFSSESSIONHASH(nd->nd_sessionid); NFSLOCKSESSION(shp); @@ -6235,36 +6234,11 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_t sequenceid, nd->nd_maxreq = sep->sess_maxreq; nd->nd_maxresp = sep->sess_maxresp; - /* - * If this session handles the backchannel, save the nd_xprt for this - * RPC, since this is the one being used. - * RFC-5661 specifies that the fore channel will be implicitly - * bound by a Sequence operation. However, since some NFSv4.1 clients - * erroneously assumed that the back channel would be implicitly - * bound as well, do the implicit binding unless a - * BindConnectiontoSession has already been done on the session. - */ - savxprt = NULL; - if (sep->sess_clp->lc_req.nr_client != NULL && - sep->sess_cbsess.nfsess_xprt != nd->nd_xprt && - (sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0 && - (sep->sess_clp->lc_flags & LCL_DONEBINDCONN) == 0) { - NFSD_DEBUG(2, - "nfsrv_checksequence: implicit back channel bind\n"); - savxprt = sep->sess_cbsess.nfsess_xprt; - SVC_ACQUIRE(nd->nd_xprt); - nd->nd_xprt->xp_p2 = - sep->sess_clp->lc_req.nr_client->cl_private; - nd->nd_xprt->xp_idletimeout = 0; /* Disable timeout. */ - sep->sess_cbsess.nfsess_xprt = nd->nd_xprt; - } - *sflagsp = 0; - if (sep->sess_clp->lc_req.nr_client == NULL) + if (sep->sess_clp->lc_req.nr_client == NULL || + (sep->sess_clp->lc_flags & LCL_CBDOWN) != 0) *sflagsp |= NFSV4SEQ_CBPATHDOWN; NFSUNLOCKSESSION(shp); - if (savxprt != NULL) - SVC_RELEASE(savxprt); if (error == NFSERR_EXPIRED) { *sflagsp |= NFSV4SEQ_EXPIREDALLSTATEREVOKED; error = 0; @@ -6464,7 +6438,8 @@ nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t *sessionid, int *foreaftp) nd->nd_xprt->xp_idletimeout = 0; sep->sess_cbsess.nfsess_xprt = nd->nd_xprt; sep->sess_crflags |= NFSV4CRSESS_CONNBACKCHAN; - clp->lc_flags |= LCL_DONEBINDCONN; + clp->lc_flags |= LCL_DONEBINDCONN | + LCL_NEEDSCBNULL; if (*foreaftp == NFSCDFS4_BACK) *foreaftp = NFSCDFS4_BACK; else From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 22:38:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 684B15E1811; Sun, 11 Apr 2021 22:38:47 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJRc72YVQz4hpr; Sun, 11 Apr 2021 22:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A86D4158; Sun, 11 Apr 2021 22:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BMclm2034089; Sun, 11 Apr 2021 22:38:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BMclhQ034088; Sun, 11 Apr 2021 22:38:47 GMT (envelope-from git) Date: Sun, 11 Apr 2021 22:38:47 GMT Message-Id: <202104112238.13BMclhQ034088@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: e18f9de06121 - stable/12 - nfsv4 client: fix forced dismount when sleeping in the renew thread MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e18f9de0612137924951a0ec709eb36286bb3894 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 22:38:47 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=e18f9de0612137924951a0ec709eb36286bb3894 commit e18f9de0612137924951a0ec709eb36286bb3894 Author: Rick Macklem AuthorDate: 2021-03-23 20:04:37 +0000 Commit: Rick Macklem CommitDate: 2021-04-11 22:34:52 +0000 nfsv4 client: fix forced dismount when sleeping in the renew thread During a recent NFSv4 testing event a test server caused a hang where "umount -N" failed. The renew thread was sleeping on "nfsv4lck" and the "umount" was sleeping, waiting for the renew thread to terminate. This is the second of two patches that is hoped to fix the renew thread so that it will terminate when "umount -N" is done on the mount. This patch adds a 5second timeout on the msleep()s and checks for the forced dismount flag so that the renew thread will wake up and see the forced dismount flag. Normally a wakeup() will occur in less than 5seconds, but if a premature return from msleep() does occur, it will simply loop around and msleep() again. The patch also adds the "mp" argument to nfsv4_lock() so that it will return when the forced dismount flag is set. While here, replace the nfsmsleep() wrapper that was used for portability with the actual msleep() call. (cherry picked from commit 82ee386c2afb42388804c1189751b83048953433) --- sys/fs/nfsclient/nfs_clstate.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 79a18a12f91f..0cade3e4178a 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -2531,10 +2531,12 @@ nfscl_renewthread(struct nfsclclient *clp, NFSPROC_T *p) struct nfscllayouthead rlh; struct nfsclrecalllayout *recallp; struct nfsclds *dsp; + struct mount *mp; cred = newnfs_getcred(); NFSLOCKCLSTATE(); clp->nfsc_flags |= NFSCLFLAGS_HASTHREAD; + mp = clp->nfsc_nmp->nm_mountp; NFSUNLOCKCLSTATE(); for(;;) { newnfs_setroot(cred); @@ -2631,14 +2633,18 @@ tryagain: } dp->nfsdl_rwlock.nfslock_lock |= NFSV4LOCK_WANTED; - (void) nfsmsleep(&dp->nfsdl_rwlock, - NFSCLSTATEMUTEXPTR, PZERO, "nfscld", - NULL); + msleep(&dp->nfsdl_rwlock, + NFSCLSTATEMUTEXPTR, PVFS, "nfscld", + 5 * hz); + if (NFSCL_FORCEDISM(mp)) + goto terminate; goto tryagain; } while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, - &islept, NFSCLSTATEMUTEXPTR, NULL); + &islept, NFSCLSTATEMUTEXPTR, mp); + if (igotlock == 0 && NFSCL_FORCEDISM(mp)) + goto terminate; if (islept) goto tryagain; } @@ -2718,9 +2724,11 @@ tryagain2: NFSV4LOCK_LOCK) != 0) { lyp->nfsly_lock.nfslock_lock |= NFSV4LOCK_WANTED; - nfsmsleep(&lyp->nfsly_lock.nfslock_lock, - NFSCLSTATEMUTEXPTR, PZERO, "nfslyp", - NULL); + msleep(&lyp->nfsly_lock.nfslock_lock, + NFSCLSTATEMUTEXPTR, PVFS, "nfslyp", + 5 * hz); + if (NFSCL_FORCEDISM(mp)) + goto terminate; goto tryagain2; } /* Move the layout to the recall list. */ @@ -2829,6 +2837,7 @@ tryagain2: if ((clp->nfsc_flags & NFSCLFLAGS_RECOVER) == 0) (void)mtx_sleep(clp, NFSCLSTATEMUTEXPTR, PWAIT, "nfscl", hz); +terminate: if (clp->nfsc_flags & NFSCLFLAGS_UMOUNT) { clp->nfsc_flags &= ~NFSCLFLAGS_HASTHREAD; NFSUNLOCKCLSTATE(); From owner-dev-commits-src-branches@freebsd.org Sun Apr 11 22:46:41 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 DE33F5E17E3; Sun, 11 Apr 2021 22:46:41 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJRnF5z3Hz4jFr; Sun, 11 Apr 2021 22:46:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF71C3BB2; Sun, 11 Apr 2021 22:46:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13BMkfb4047157; Sun, 11 Apr 2021 22:46:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13BMkfFA047156; Sun, 11 Apr 2021 22:46:41 GMT (envelope-from git) Date: Sun, 11 Apr 2021 22:46:41 GMT Message-Id: <202104112246.13BMkfFA047156@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 5fb6cfadcd9d - stable/12 - nfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5fb6cfadcd9dbc850a018a3690a2b775c01fff8f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 22:46:41 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=5fb6cfadcd9dbc850a018a3690a2b775c01fff8f commit 5fb6cfadcd9dbc850a018a3690a2b775c01fff8f Author: Rick Macklem AuthorDate: 2021-03-30 21:31:05 +0000 Commit: Rick Macklem CommitDate: 2021-04-11 22:43:20 +0000 nfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts The NFSv4.1 (and 4.2 on 13) server incorrectly binds a new TCP connection to the back channel when first used by an RPC with a Sequence op in it (almost all of them). RFC5661 specifies that only the fore channel should be bound. This was done because early clients (including FreeBSD) did not do the required BindConnectionToSession RPC. Unfortunately, this breaks the Linux client when the "nconnects" mount option is used, since the server may do a callback on the incorrect TCP connection. This patch converts the server behaviour to that required by the RFC. It also makes the server test/indicate failure of the back channel more aggressively. Until this patch is applied to the server, the "nconnects" mount option is not recommended for a Linux NFSv4.1/4.2 client mount to the FreeBSD server. PR: 254560 (cherry picked from commit 01ae8969a9eed652fbd894faa5b31b1593079ed8) --- sys/fs/nfsserver/nfs_nfsdstate.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 5b92e7c297fa..d9fd1bbb588d 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -6189,7 +6189,6 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_t sequenceid, struct nfsdsession *sep; struct nfssessionhash *shp; int error; - SVCXPRT *savxprt; shp = NFSSESSIONHASH(nd->nd_sessionid); NFSLOCKSESSION(shp); @@ -6211,36 +6210,11 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_t sequenceid, nd->nd_clientid.qval = sep->sess_clp->lc_clientid.qval; nd->nd_flag |= ND_IMPLIEDCLID; - /* - * If this session handles the backchannel, save the nd_xprt for this - * RPC, since this is the one being used. - * RFC-5661 specifies that the fore channel will be implicitly - * bound by a Sequence operation. However, since some NFSv4.1 clients - * erroneously assumed that the back channel would be implicitly - * bound as well, do the implicit binding unless a - * BindConnectiontoSession has already been done on the session. - */ - savxprt = NULL; - if (sep->sess_clp->lc_req.nr_client != NULL && - sep->sess_cbsess.nfsess_xprt != nd->nd_xprt && - (sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0 && - (sep->sess_clp->lc_flags & LCL_DONEBINDCONN) == 0) { - NFSD_DEBUG(2, - "nfsrv_checksequence: implicit back channel bind\n"); - savxprt = sep->sess_cbsess.nfsess_xprt; - SVC_ACQUIRE(nd->nd_xprt); - nd->nd_xprt->xp_p2 = - sep->sess_clp->lc_req.nr_client->cl_private; - nd->nd_xprt->xp_idletimeout = 0; /* Disable timeout. */ - sep->sess_cbsess.nfsess_xprt = nd->nd_xprt; - } - *sflagsp = 0; - if (sep->sess_clp->lc_req.nr_client == NULL) + if (sep->sess_clp->lc_req.nr_client == NULL || + (sep->sess_clp->lc_flags & LCL_CBDOWN) != 0) *sflagsp |= NFSV4SEQ_CBPATHDOWN; NFSUNLOCKSESSION(shp); - if (savxprt != NULL) - SVC_RELEASE(savxprt); if (error == NFSERR_EXPIRED) { *sflagsp |= NFSV4SEQ_EXPIREDALLSTATEREVOKED; error = 0; @@ -6440,7 +6414,8 @@ nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t *sessionid, int *foreaftp) nd->nd_xprt->xp_idletimeout = 0; sep->sess_cbsess.nfsess_xprt = nd->nd_xprt; sep->sess_crflags |= NFSV4CRSESS_CONNBACKCHAN; - clp->lc_flags |= LCL_DONEBINDCONN; + clp->lc_flags |= LCL_DONEBINDCONN | + LCL_NEEDSCBNULL; if (*foreaftp == NFSCDFS4_BACK) *foreaftp = NFSCDFS4_BACK; else